@csstools/postcss-image-function 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE.md +18 -0
- package/README.md +93 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.mjs +1 -0
- package/package.json +66 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changes to PostCSS Image Function
|
|
2
|
+
|
|
3
|
+
### 1.0.0
|
|
4
|
+
|
|
5
|
+
_May 13, 2026_
|
|
6
|
+
|
|
7
|
+
- Initial version
|
|
8
|
+
- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`5.1.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#510) (minor)
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT No Attribution (MIT-0)
|
|
2
|
+
|
|
3
|
+
Copyright © CSSTools Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# PostCSS Image Function [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
|
|
2
|
+
|
|
3
|
+
`npm install @csstools/postcss-image-function --save-dev`
|
|
4
|
+
|
|
5
|
+
[PostCSS Image Function] lets you easily generate a solid-color image from any color following the [CSS Images 4 Specification].
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
.foo {
|
|
9
|
+
background-image: image(transparent);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.foo {
|
|
13
|
+
--bg-image: image(transparent);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* becomes */
|
|
17
|
+
|
|
18
|
+
.foo {
|
|
19
|
+
background-image: linear-gradient(transparent,transparent);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.foo {
|
|
23
|
+
--bg-image: linear-gradient(transparent,transparent);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Add [PostCSS Image Function] to your project:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install postcss @csstools/postcss-image-function --save-dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use it as a [PostCSS] plugin:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const postcss = require('postcss');
|
|
39
|
+
const postcssImageFunction = require('@csstools/postcss-image-function');
|
|
40
|
+
|
|
41
|
+
postcss([
|
|
42
|
+
postcssImageFunction(/* pluginOptions */)
|
|
43
|
+
]).process(YOUR_CSS /*, processOptions */);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Options
|
|
49
|
+
|
|
50
|
+
### preserve
|
|
51
|
+
|
|
52
|
+
The `preserve` option determines whether the original notation
|
|
53
|
+
is preserved. By default, it is not preserved.
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
postcssImageFunction({ preserve: true })
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
.foo {
|
|
61
|
+
background-image: image(transparent);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.foo {
|
|
65
|
+
--bg-image: image(transparent);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* becomes */
|
|
69
|
+
|
|
70
|
+
.foo {
|
|
71
|
+
background-image: linear-gradient(transparent,transparent);
|
|
72
|
+
background-image: image(transparent);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.foo {
|
|
76
|
+
--bg-image: linear-gradient(transparent,transparent);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@supports (background-image: image(red)) {
|
|
80
|
+
.foo {
|
|
81
|
+
--bg-image: image(transparent);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|
87
|
+
[css-url]: https://cssdb.org/#image-function
|
|
88
|
+
[discord]: https://discord.gg/bUadyRwkJS
|
|
89
|
+
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-image-function
|
|
90
|
+
|
|
91
|
+
[PostCSS]: https://github.com/postcss/postcss
|
|
92
|
+
[PostCSS Image Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-function
|
|
93
|
+
[CSS Images 4 Specification]: https://drafts.csswg.org/css-images-4/#funcdef-image
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
/** postcss-image-function plugin options */
|
|
4
|
+
export declare type basePluginOptions = {
|
|
5
|
+
/** Preserve the original notation. default: false */
|
|
6
|
+
preserve?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** postcss-image-function plugin options */
|
|
10
|
+
export declare type pluginOptions = {
|
|
11
|
+
/** Preserve the original notation. default: false */
|
|
12
|
+
preserve?: boolean;
|
|
13
|
+
/** Enable "@csstools/postcss-progressive-custom-properties". default: true */
|
|
14
|
+
enableProgressiveCustomProperties?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Transform image() functions in CSS. */
|
|
18
|
+
declare const postcssPlugin: PluginCreator<pluginOptions>;
|
|
19
|
+
export default postcssPlugin;
|
|
20
|
+
export { postcssPlugin as 'module.exports' }
|
|
21
|
+
|
|
22
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@csstools/postcss-progressive-custom-properties";import{hasFallback as s,hasSupportsAtRuleAncestor as o}from"@csstools/utilities";import{replaceComponentValues as t,parseCommaSeparatedListOfComponentValues as r,isFunctionNode as i,isWhiteSpaceOrCommentNode as n,FunctionNode as a,TokenNode as c,stringify as l}from"@csstools/css-parser-algorithms";import{tokenize as m,TokenType as p}from"@csstools/css-tokenizer";const u=/\bimage\(/i,g=/^image$/i,basePlugin=e=>({postcssPlugin:"postcss-image-function",Declaration(v){const f=v.value;if(!u.test(f))return;if(s(v))return;if(o(v,u))return;const d=t(r(m({css:f})),e=>{if(i(e)&&g.test(e.getName())&&1===e.value.filter(e=>!n(e)).length)return new a([p.Function,"linear-gradient(",e.name[2],e.name[3],{value:"linear-gradient"}],e.endToken,[...e.value,new c([p.Comma,",",e.name[2],e.name[3],void 0]),...e.value])}),P=l(d);P!==f&&(v.cloneBefore({value:P}),e?.preserve||v.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const o=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-image-function",plugins:[e(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"};
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@csstools/postcss-image-function",
|
|
3
|
+
"description": "Generate a solid-color image from any color",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Antonio Laguna",
|
|
8
|
+
"email": "antonio@laguna.es",
|
|
9
|
+
"url": "https://antonio.laguna.es"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Romain Menke",
|
|
13
|
+
"email": "romainmenke@gmail.com"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT-0",
|
|
17
|
+
"funding": [
|
|
18
|
+
{
|
|
19
|
+
"type": "github",
|
|
20
|
+
"url": "https://github.com/sponsors/csstools"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "opencollective",
|
|
24
|
+
"url": "https://opencollective.com/csstools"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20.19.0"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"CHANGELOG.md",
|
|
39
|
+
"LICENSE.md",
|
|
40
|
+
"README.md",
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@csstools/css-parser-algorithms": "^4.0.0",
|
|
45
|
+
"@csstools/css-tokenizer": "^4.0.0",
|
|
46
|
+
"@csstools/postcss-progressive-custom-properties": "^5.1.0",
|
|
47
|
+
"@csstools/utilities": "^3.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"postcss": "^8.4"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {},
|
|
53
|
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-image-function#readme",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
|
57
|
+
"directory": "plugins/postcss-image-function"
|
|
58
|
+
},
|
|
59
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
60
|
+
"keywords": [
|
|
61
|
+
"csswg",
|
|
62
|
+
"fallback",
|
|
63
|
+
"image function",
|
|
64
|
+
"postcss-plugin"
|
|
65
|
+
]
|
|
66
|
+
}
|