Skip to content

Migrate postcss-double-position-gradients #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions plugins/postcss-double-position-gradients/.editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion plugins/postcss-double-position-gradients/.gitattributes

This file was deleted.

This file was deleted.

8 changes: 5 additions & 3 deletions plugins/postcss-double-position-gradients/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
node_modules
dist
package-lock.json
yarn-lock.json
yarn.lock
*.log*
*.result.css
.*
*.result.css.map
!.editorconfig
!.gitattributes
!.gitignore
!.rollup.js
!.tape.js
!.travis.yml
!.github
65 changes: 0 additions & 65 deletions plugins/postcss-double-position-gradients/CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/postcss-double-position-gradients/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,6 @@ grunt.initConfig({
[PostCSS]: https://github.com/postcss/postcss
[PostCSS CLI]: https://github.com/postcss/postcss-cli
[PostCSS Loader]: https://github.com/postcss/postcss-loader
[PostCSS Double Position Gradients]: https://github.com/csstools/postcss-double-position-gradients
[PostCSS Double Position Gradients]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
[React App Rewired]: https://github.com/timarney/react-app-rewired
4 changes: 1 addition & 3 deletions plugins/postcss-double-position-gradients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[<img alt="NPM Version" src="https://img.shields.io/npm/v/postcss-double-position-gradients.svg" height="20">][npm-url]
[<img alt="CSS Standard Status" src="https://cssdb.org/badge/double-position-gradients.svg" height="20">][css-url]
[<img alt="Build Status" src="https://img.shields.io/travis/csstools/postcss-double-position-gradients/master.svg" height="20">][cli-url]
[<img alt="Support Chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]

[PostCSS Double Position Gradients] lets you use double-position gradients in
Expand Down Expand Up @@ -94,10 +93,9 @@ postcssDoublePositionGradients({ preserve: false })
```

[css-url]: https://cssdb.org/#double-position-gradients
[cli-url]: https://travis-ci.org/csstools/postcss-double-position-gradients
[git-url]: https://gitter.im/postcss/postcss
[npm-url]: https://www.npmjs.com/package/postcss-double-position-gradients

[CSS Image Values and Replaced Content]: https://www.w3.org/TR/css-images-4/#color-stop-syntax
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Double Position Gradients]: https://github.com/csstools/postcss-double-position-gradients
[PostCSS Double Position Gradients]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients
53 changes: 30 additions & 23 deletions plugins/postcss-double-position-gradients/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,39 @@
"description": "Use double-position gradients in CSS",
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
"license": "CC0-1.0",
"repository": "csstools/postcss-double-position-gradients",
"homepage": "https://github.com/csstools/postcss-double-position-gradients#readme",
"bugs": "https://github.com/csstools/postcss-double-position-gradients/issues",
"main": "index.js",
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme",
"bugs": "https://github.com/csstools/postcss-plugins/issues",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"files": [
"CHANGELOG.md",
"INSTALL.md",
"LICENSE.md",
"README.md",
"dist"
],
"bin": {
"postcss-double-position-gradients": "dist/cli.mjs"
},
"scripts": {
"prepublishOnly": "npm test",
"lint": "eslint *.js --cache",
"lint:fix": "eslint *.js --cache --fix",
"test": "npm run lint && npm run tape",
"tape": "postcss-tape"
"prepublishOnly": "npm run build && npm run test",
"lint": "eslint src/**/*.js",
"test": "postcss-tape",
"build": "rollup -c ../../rollup/default.js",
"stryker": "stryker run --logLevel error"
},
"engines": {
"node": ">=12"
"node": "^12 || ^14 || >=16"
},
"dependencies": {
"postcss-values-parser": "6.0.1"
},
"peerDependencies": {
"postcss": "^8.3"
"postcss-values-parser": "^6.0.1"
},
"devDependencies": {
"eslint": "8.2.0",
"postcss": "8.3.11",
"postcss": "8.3.6",
"postcss-tape": "6.0.1"
},
"eslintConfig": {
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended"
"peerDependencies": {
"postcss": "^8.3"
},
"keywords": [
"postcss",
Expand All @@ -50,5 +52,10 @@
"stop",
"syntax",
"repeating"
]
],
"repository": {
"type": "git",
"url": "https://github.com/csstools/postcss-plugins.git",
"directory": "plugins/postcss-double-position-gradients"
}
}
17 changes: 17 additions & 0 deletions plugins/postcss-double-position-gradients/src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import plugin from './index';
import { cli, helpTextLogger } from '@csstools/base-cli';

cli(
plugin,
['preserve'],
helpTextLogger(
'postcss-double-position-gradients',
'PostCSS Double Position Gradients',
'Lets you use double-position gradients in CSS, following the [CSS Image Values and Replaced Content] specification',
{
dir: 'ltr',
preserve: true,
shadow: true,
},
),
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Punctuation = require('postcss-values-parser/lib/nodes/Punctuation');
const gradientRegExp = /(repeating-)?(conic|linear|radial)-gradient\([\W\w]*\)/i;
const gradientPartsRegExp = /^(repeating-)?(conic|linear|radial)-gradient$/i;

const isPunctuationCommaNode = node => node.type === 'punctuation' && node.value === ','
const isPunctuationCommaNode = node => node.type === 'punctuation' && node.value === ',';

/**
* Transform double-position gradients in CSS.
Expand All @@ -29,7 +29,7 @@ module.exports = function creator(opts) {
} catch (error) {
decl.warn(
result,
`Failed to parse value '${decl.value}' as a CSS gradient. Leaving the original value intact.`
`Failed to parse value '${decl.value}' as a CSS gradient. Leaving the original value intact.`,
);
}

Expand Down Expand Up @@ -60,22 +60,22 @@ module.exports = function creator(opts) {
value: ',',
raws: isPunctuationCommaNode(node1next)
? Object.assign({}, node1next.clone().raws)
: { before: '', after: '' }
: { before: '', after: '' },
});

func.insertBefore(node, [comma, color]);
}
})
})
});
});

const modifiedValue = String(valueAST);

if (modifiedValue !== decl.value) {
if (preserve) decl.cloneBefore({ value: modifiedValue });
else decl.value = modifiedValue;
}
}
}
}
},
};
};

module.exports.postcss = true;