@openkfw/design-tokens 0.6.0 → 0.6.1
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/demo/dist/css/style.min.css +1 -1
- package/demo/scripts/build-icons.js +37 -0
- package/demo/scripts/postcss.svg-load-plugin.js +1 -1
- package/demo/src/style.css +234 -114
- package/demo/src/vendor/gen-icons.css +105 -0
- package/output/css/kfw-design-tokens.light.css +5 -3
- package/output/figma/kfw-design-tokens.light.json +8 -0
- package/output/js/kfw-design-tokens.d.ts +15 -3
- package/output/js/kfw-design-tokens.light.js +13 -3
- package/output/json/kfw-design-tokens.json +74 -4
- package/output/penpot/kfw-design-tokens.light.json +8 -0
- package/output/scss/kfw-design-tokens.light.scss +5 -3
- package/output/web_thirdparty_16px/css/kfw-design-tokens.light.css +5 -3
- package/output/web_thirdparty_16px/js/kfw-design-tokens.light.js +13 -3
- package/output/web_thirdparty_16px/scss/kfw-design-tokens.light.scss +5 -3
- package/package.json +3 -4
- package/tokens/gen-tokens.dark.json5 +10 -2
- package/tokens/tokens.json +4 -2
- package/demo/scripts/postcss.color-to-filter.js +0 -66
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* KfW Design Tokens v0.6.
|
|
2
|
+
* KfW Design Tokens v0.6.1 | MPL-2.0 | https://github.com/openkfw/design-tokens
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export const KfwBaseColorBlue100 = {
|
|
@@ -280,7 +280,7 @@ export const KfwColorFnActive = {
|
|
|
280
280
|
colorSpace: "srgb",
|
|
281
281
|
components: [0, 0.2667, 0.4314],
|
|
282
282
|
hex: "#00446e",
|
|
283
|
-
}; //
|
|
283
|
+
}; // Main interaction color when active (e.g., hover, Blue 700)
|
|
284
284
|
export const KfwColorFnInactive = {
|
|
285
285
|
colorSpace: "srgb",
|
|
286
286
|
components: [0.6314, 0.6784, 0.7098],
|
|
@@ -306,11 +306,21 @@ export const KfwColorTextOnDarkBg = {
|
|
|
306
306
|
components: [1, 1, 1],
|
|
307
307
|
hex: "#ffffff",
|
|
308
308
|
}; // Main text color on dark background (White)
|
|
309
|
+
export const KfwColorTextOnWhiteBg = {
|
|
310
|
+
colorSpace: "srgb",
|
|
311
|
+
components: [0.7176, 0.9765, 0.6667],
|
|
312
|
+
hex: "#b7f9aa",
|
|
313
|
+
}; // Text color on white background (Green 300)
|
|
314
|
+
export const KfwColorTextOnColoredBg = {
|
|
315
|
+
colorSpace: "srgb",
|
|
316
|
+
components: [0, 0.2157, 0.3588],
|
|
317
|
+
hex: "#00375b",
|
|
318
|
+
}; // Text color on colored background (Blue 800)
|
|
309
319
|
export const KfwColorTextOnDisabled = {
|
|
310
320
|
colorSpace: "srgb",
|
|
311
321
|
components: [1, 1, 1],
|
|
312
322
|
hex: "#ffffff",
|
|
313
|
-
}; //
|
|
323
|
+
}; // Text color on disabled (White)
|
|
314
324
|
export const KfwColorTextHeadlineOnDarkBg = {
|
|
315
325
|
colorSpace: "srgb",
|
|
316
326
|
components: [0.7176, 0.9765, 0.6667],
|
|
@@ -4547,13 +4547,13 @@
|
|
|
4547
4547
|
],
|
|
4548
4548
|
"hex": "#00446e"
|
|
4549
4549
|
},
|
|
4550
|
-
"$description": "
|
|
4550
|
+
"$description": "Main interaction color when active (e.g., hover, Blue 700)",
|
|
4551
4551
|
"filePath": "tokens/tokens.json",
|
|
4552
4552
|
"isSource": true,
|
|
4553
4553
|
"$type": "color",
|
|
4554
4554
|
"original": {
|
|
4555
4555
|
"$value": "{base.color.blue.700}",
|
|
4556
|
-
"$description": "
|
|
4556
|
+
"$description": "Main interaction color when active (e.g., hover, Blue 700)",
|
|
4557
4557
|
"$type": "color",
|
|
4558
4558
|
"key": "{semantic.color.fn.active}"
|
|
4559
4559
|
},
|
|
@@ -4748,6 +4748,76 @@
|
|
|
4748
4748
|
"on-dark-bg"
|
|
4749
4749
|
]
|
|
4750
4750
|
},
|
|
4751
|
+
"on-white-bg": {
|
|
4752
|
+
"key": "{semantic.color.text.on-white-bg}",
|
|
4753
|
+
"$value": {
|
|
4754
|
+
"colorSpace": "srgb",
|
|
4755
|
+
"components": [
|
|
4756
|
+
0.7176,
|
|
4757
|
+
0.9765,
|
|
4758
|
+
0.6667
|
|
4759
|
+
],
|
|
4760
|
+
"hex": "#b7f9aa"
|
|
4761
|
+
},
|
|
4762
|
+
"$description": "Text color on white background (Green 300)",
|
|
4763
|
+
"filePath": "tokens/tokens.json",
|
|
4764
|
+
"isSource": true,
|
|
4765
|
+
"$type": "color",
|
|
4766
|
+
"original": {
|
|
4767
|
+
"$value": "{base.color.green.300}",
|
|
4768
|
+
"$description": "Text color on white background (Green 300)",
|
|
4769
|
+
"$type": "color",
|
|
4770
|
+
"key": "{semantic.color.text.on-white-bg}"
|
|
4771
|
+
},
|
|
4772
|
+
"name": "kfw-color-text-on-white-bg",
|
|
4773
|
+
"attributes": {
|
|
4774
|
+
"category": "semantic",
|
|
4775
|
+
"type": "color",
|
|
4776
|
+
"item": "text",
|
|
4777
|
+
"subitem": "on-white-bg"
|
|
4778
|
+
},
|
|
4779
|
+
"path": [
|
|
4780
|
+
"semantic",
|
|
4781
|
+
"color",
|
|
4782
|
+
"text",
|
|
4783
|
+
"on-white-bg"
|
|
4784
|
+
]
|
|
4785
|
+
},
|
|
4786
|
+
"on-colored-bg": {
|
|
4787
|
+
"key": "{semantic.color.text.on-colored-bg}",
|
|
4788
|
+
"$value": {
|
|
4789
|
+
"colorSpace": "srgb",
|
|
4790
|
+
"components": [
|
|
4791
|
+
0,
|
|
4792
|
+
0.2157,
|
|
4793
|
+
0.3588
|
|
4794
|
+
],
|
|
4795
|
+
"hex": "#00375b"
|
|
4796
|
+
},
|
|
4797
|
+
"$description": "Text color on colored background (Blue 800)",
|
|
4798
|
+
"filePath": "tokens/tokens.json",
|
|
4799
|
+
"isSource": true,
|
|
4800
|
+
"$type": "color",
|
|
4801
|
+
"original": {
|
|
4802
|
+
"$value": "{base.color.blue.800}",
|
|
4803
|
+
"$description": "Text color on colored background (Blue 800)",
|
|
4804
|
+
"$type": "color",
|
|
4805
|
+
"key": "{semantic.color.text.on-colored-bg}"
|
|
4806
|
+
},
|
|
4807
|
+
"name": "kfw-color-text-on-colored-bg",
|
|
4808
|
+
"attributes": {
|
|
4809
|
+
"category": "semantic",
|
|
4810
|
+
"type": "color",
|
|
4811
|
+
"item": "text",
|
|
4812
|
+
"subitem": "on-colored-bg"
|
|
4813
|
+
},
|
|
4814
|
+
"path": [
|
|
4815
|
+
"semantic",
|
|
4816
|
+
"color",
|
|
4817
|
+
"text",
|
|
4818
|
+
"on-colored-bg"
|
|
4819
|
+
]
|
|
4820
|
+
},
|
|
4751
4821
|
"on-disabled": {
|
|
4752
4822
|
"key": "{semantic.color.text.on-disabled}",
|
|
4753
4823
|
"$value": {
|
|
@@ -4759,13 +4829,13 @@
|
|
|
4759
4829
|
],
|
|
4760
4830
|
"hex": "#ffffff"
|
|
4761
4831
|
},
|
|
4762
|
-
"$description": "
|
|
4832
|
+
"$description": "Text color on disabled (White)",
|
|
4763
4833
|
"filePath": "tokens/tokens.json",
|
|
4764
4834
|
"isSource": true,
|
|
4765
4835
|
"$type": "color",
|
|
4766
4836
|
"original": {
|
|
4767
4837
|
"$value": "{base.color.white.default}",
|
|
4768
|
-
"$description": "
|
|
4838
|
+
"$description": "Text color on disabled (White)",
|
|
4769
4839
|
"$type": "color",
|
|
4770
4840
|
"key": "{semantic.color.text.on-disabled}"
|
|
4771
4841
|
},
|
|
@@ -340,6 +340,14 @@
|
|
|
340
340
|
"$value": "#fff",
|
|
341
341
|
"$type": "color"
|
|
342
342
|
},
|
|
343
|
+
"On-white-bg": {
|
|
344
|
+
"$value": "#b7f9aa",
|
|
345
|
+
"$type": "color"
|
|
346
|
+
},
|
|
347
|
+
"On-colored-bg": {
|
|
348
|
+
"$value": "#00375b",
|
|
349
|
+
"$type": "color"
|
|
350
|
+
},
|
|
343
351
|
"On-disabled": {
|
|
344
352
|
"$value": "#fff",
|
|
345
353
|
"$type": "color"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
// KfW Design Tokens v0.6.
|
|
2
|
+
// KfW Design Tokens v0.6.1 | MPL-2.0 | https://github.com/openkfw/design-tokens
|
|
3
3
|
|
|
4
4
|
$kfw-base-color-blue-100: #e9f5fb;
|
|
5
5
|
$kfw-base-color-blue-400: #54b3e2;
|
|
@@ -152,13 +152,15 @@ $kfw-base-layout-gridgap-fluid-min: 1.2rem;
|
|
|
152
152
|
$kfw-base-layout-gridgap-fluid-max: 3.6rem;
|
|
153
153
|
$kfw-base-layout-gridgap-fluid-val: 3.529vi - 0.9176rem;
|
|
154
154
|
$kfw-color-fn: #005a8c; // Main interaction color for buttons and links (Blue 600)
|
|
155
|
-
$kfw-color-fn-active: #00446e; //
|
|
155
|
+
$kfw-color-fn-active: #00446e; // Main interaction color when active (e.g., hover, Blue 700)
|
|
156
156
|
$kfw-color-fn-inactive: #a1adb5; // Interaction color when inactive (Gray 300)
|
|
157
157
|
$kfw-color-fn-border: #2d3134; // Interaction border color (Gray 600)
|
|
158
158
|
$kfw-color-fn-label: #2d3134; // Interaction label color (Gray 600)
|
|
159
159
|
$kfw-color-text: #2d3134; // Main text color for body (Gray 600)
|
|
160
160
|
$kfw-color-text-on-dark-bg: #fff; // Main text color on dark background (White)
|
|
161
|
-
$kfw-color-text-on-
|
|
161
|
+
$kfw-color-text-on-white-bg: #b7f9aa; // Text color on white background (Green 300)
|
|
162
|
+
$kfw-color-text-on-colored-bg: #00375b; // Text color on colored background (Blue 800)
|
|
163
|
+
$kfw-color-text-on-disabled: #fff; // Text color on disabled (White)
|
|
162
164
|
$kfw-color-text-headline-on-dark-bg: #b7f9aa; // Headline text color on dark background (Green 300)
|
|
163
165
|
$kfw-color-background: #fff; // Main background color for body (White)
|
|
164
166
|
$kfw-color-background-subtle: #f6f7f8; // Neutral (Gray 50)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* KfW Design Tokens v0.6.
|
|
2
|
+
* KfW Design Tokens v0.6.1 | MPL-2.0 | https://github.com/openkfw/design-tokens
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
:root, :host { color-scheme: light; }
|
|
@@ -156,13 +156,15 @@
|
|
|
156
156
|
--kfw-base-layout-gridgap-fluid-max: 2.25rem;
|
|
157
157
|
--kfw-base-layout-gridgap-fluid-val: 3.529vi - 0.5735rem;
|
|
158
158
|
--kfw-color-fn: #005a8c; /** Main interaction color for buttons and links (Blue 600) */
|
|
159
|
-
--kfw-color-fn-active: #00446e; /**
|
|
159
|
+
--kfw-color-fn-active: #00446e; /** Main interaction color when active (e.g., hover, Blue 700) */
|
|
160
160
|
--kfw-color-fn-inactive: #a1adb5; /** Interaction color when inactive (Gray 300) */
|
|
161
161
|
--kfw-color-fn-border: #2d3134; /** Interaction border color (Gray 600) */
|
|
162
162
|
--kfw-color-fn-label: #2d3134; /** Interaction label color (Gray 600) */
|
|
163
163
|
--kfw-color-text: #2d3134; /** Main text color for body (Gray 600) */
|
|
164
164
|
--kfw-color-text-on-dark-bg: #fff; /** Main text color on dark background (White) */
|
|
165
|
-
--kfw-color-text-on-
|
|
165
|
+
--kfw-color-text-on-white-bg: #b7f9aa; /** Text color on white background (Green 300) */
|
|
166
|
+
--kfw-color-text-on-colored-bg: #00375b; /** Text color on colored background (Blue 800) */
|
|
167
|
+
--kfw-color-text-on-disabled: #fff; /** Text color on disabled (White) */
|
|
166
168
|
--kfw-color-text-headline-on-dark-bg: #b7f9aa; /** Headline text color on dark background (Green 300) */
|
|
167
169
|
--kfw-color-background: #fff; /** Main background color for body (White) */
|
|
168
170
|
--kfw-color-background-subtle: #f6f7f8; /** Neutral (Gray 50) */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* KfW Design Tokens v0.6.
|
|
2
|
+
* KfW Design Tokens v0.6.1 | MPL-2.0 | https://github.com/openkfw/design-tokens
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export const KfwBaseColorBlue100 = {
|
|
@@ -280,7 +280,7 @@ export const KfwColorFnActive = {
|
|
|
280
280
|
colorSpace: "srgb",
|
|
281
281
|
components: [0, 0.2667, 0.4314],
|
|
282
282
|
hex: "#00446e",
|
|
283
|
-
}; //
|
|
283
|
+
}; // Main interaction color when active (e.g., hover, Blue 700)
|
|
284
284
|
export const KfwColorFnInactive = {
|
|
285
285
|
colorSpace: "srgb",
|
|
286
286
|
components: [0.6314, 0.6784, 0.7098],
|
|
@@ -306,11 +306,21 @@ export const KfwColorTextOnDarkBg = {
|
|
|
306
306
|
components: [1, 1, 1],
|
|
307
307
|
hex: "#ffffff",
|
|
308
308
|
}; // Main text color on dark background (White)
|
|
309
|
+
export const KfwColorTextOnWhiteBg = {
|
|
310
|
+
colorSpace: "srgb",
|
|
311
|
+
components: [0.7176, 0.9765, 0.6667],
|
|
312
|
+
hex: "#b7f9aa",
|
|
313
|
+
}; // Text color on white background (Green 300)
|
|
314
|
+
export const KfwColorTextOnColoredBg = {
|
|
315
|
+
colorSpace: "srgb",
|
|
316
|
+
components: [0, 0.2157, 0.3588],
|
|
317
|
+
hex: "#00375b",
|
|
318
|
+
}; // Text color on colored background (Blue 800)
|
|
309
319
|
export const KfwColorTextOnDisabled = {
|
|
310
320
|
colorSpace: "srgb",
|
|
311
321
|
components: [1, 1, 1],
|
|
312
322
|
hex: "#ffffff",
|
|
313
|
-
}; //
|
|
323
|
+
}; // Text color on disabled (White)
|
|
314
324
|
export const KfwColorTextHeadlineOnDarkBg = {
|
|
315
325
|
colorSpace: "srgb",
|
|
316
326
|
components: [0.7176, 0.9765, 0.6667],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
// KfW Design Tokens v0.6.
|
|
2
|
+
// KfW Design Tokens v0.6.1 | MPL-2.0 | https://github.com/openkfw/design-tokens
|
|
3
3
|
|
|
4
4
|
$kfw-base-color-blue-100: #e9f5fb;
|
|
5
5
|
$kfw-base-color-blue-400: #54b3e2;
|
|
@@ -152,13 +152,15 @@ $kfw-base-layout-gridgap-fluid-min: 0.75rem;
|
|
|
152
152
|
$kfw-base-layout-gridgap-fluid-max: 2.25rem;
|
|
153
153
|
$kfw-base-layout-gridgap-fluid-val: 3.529vi - 0.5735rem;
|
|
154
154
|
$kfw-color-fn: #005a8c; // Main interaction color for buttons and links (Blue 600)
|
|
155
|
-
$kfw-color-fn-active: #00446e; //
|
|
155
|
+
$kfw-color-fn-active: #00446e; // Main interaction color when active (e.g., hover, Blue 700)
|
|
156
156
|
$kfw-color-fn-inactive: #a1adb5; // Interaction color when inactive (Gray 300)
|
|
157
157
|
$kfw-color-fn-border: #2d3134; // Interaction border color (Gray 600)
|
|
158
158
|
$kfw-color-fn-label: #2d3134; // Interaction label color (Gray 600)
|
|
159
159
|
$kfw-color-text: #2d3134; // Main text color for body (Gray 600)
|
|
160
160
|
$kfw-color-text-on-dark-bg: #fff; // Main text color on dark background (White)
|
|
161
|
-
$kfw-color-text-on-
|
|
161
|
+
$kfw-color-text-on-white-bg: #b7f9aa; // Text color on white background (Green 300)
|
|
162
|
+
$kfw-color-text-on-colored-bg: #00375b; // Text color on colored background (Blue 800)
|
|
163
|
+
$kfw-color-text-on-disabled: #fff; // Text color on disabled (White)
|
|
162
164
|
$kfw-color-text-headline-on-dark-bg: #b7f9aa; // Headline text color on dark background (Green 300)
|
|
163
165
|
$kfw-color-background: #fff; // Main background color for body (White)
|
|
164
166
|
$kfw-color-background-subtle: #f6f7f8; // Neutral (Gray 50)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openkfw/design-tokens",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The source of truth for KfW-branded digital products.",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -44,19 +44,18 @@
|
|
|
44
44
|
"@eslint/js": "^9.39.2",
|
|
45
45
|
"@tsconfig/node24": "^24.0.3",
|
|
46
46
|
"@types/lodash": "^4.17.21",
|
|
47
|
-
"@types/node": "^24
|
|
47
|
+
"@types/node": "^24",
|
|
48
48
|
"concurrently": "^9.2.1",
|
|
49
49
|
"deep-get-set-ts": "^1.1.2",
|
|
50
50
|
"eslint": "^9.39.2",
|
|
51
51
|
"json5": "^2.2.3",
|
|
52
52
|
"jsoneditor-cli": "^1.1.0",
|
|
53
53
|
"lodash": "4.17.21",
|
|
54
|
-
"npm-check-updates": "^19.2.0",
|
|
55
54
|
"prettier": "^3.7.4",
|
|
56
55
|
"style-dictionary": "^5.1.1",
|
|
57
56
|
"style-dictionary-utils": "^6.0.1",
|
|
58
57
|
"tsx": "^4.21.0",
|
|
59
58
|
"typescript": "^5.9.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
59
|
+
"typescript-eslint": "^8.52.0"
|
|
61
60
|
}
|
|
62
61
|
}
|
|
@@ -1089,7 +1089,7 @@
|
|
|
1089
1089
|
},
|
|
1090
1090
|
active: {
|
|
1091
1091
|
$value: "{base.color.white.default}",
|
|
1092
|
-
$description: "
|
|
1092
|
+
$description: "Main interaction color when active (e.g., hover, Blue 700)",
|
|
1093
1093
|
},
|
|
1094
1094
|
inactive: {
|
|
1095
1095
|
$value: "{base.color.gray.300}",
|
|
@@ -1113,9 +1113,17 @@
|
|
|
1113
1113
|
$value: "{base.color.white.default}",
|
|
1114
1114
|
$description: "Main text color on dark background (White)",
|
|
1115
1115
|
},
|
|
1116
|
+
"on-white-bg": {
|
|
1117
|
+
$value: "{base.color.green.300}",
|
|
1118
|
+
$description: "Text color on white background (Green 300)",
|
|
1119
|
+
},
|
|
1120
|
+
"on-colored-bg": {
|
|
1121
|
+
$value: "{base.color.blue.800}",
|
|
1122
|
+
$description: "Text color on colored background (Blue 800)",
|
|
1123
|
+
},
|
|
1116
1124
|
"on-disabled": {
|
|
1117
1125
|
$value: "{base.color.white.default}",
|
|
1118
|
-
$description: "
|
|
1126
|
+
$description: "Text color on disabled (White)",
|
|
1119
1127
|
},
|
|
1120
1128
|
"headline-on-dark-bg": {
|
|
1121
1129
|
$value: "{base.color.green.300}",
|
package/tokens/tokens.json
CHANGED
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
"$type": "color",
|
|
272
272
|
"fn": {
|
|
273
273
|
"default": { "$value": "{base.color.blue.600}", "$description": "Main interaction color for buttons and links (Blue 600)" },
|
|
274
|
-
"active": { "$value": "{base.color.blue.700}", "$description": "
|
|
274
|
+
"active": { "$value": "{base.color.blue.700}", "$description": "Main interaction color when active (e.g., hover, Blue 700)" },
|
|
275
275
|
"inactive": { "$value": "{base.color.gray.300}", "$description": "Interaction color when inactive (Gray 300)" },
|
|
276
276
|
"border": { "$value": "{base.color.gray.600}", "$description": "Interaction border color (Gray 600)" },
|
|
277
277
|
"label": { "$value": "{base.color.gray.600}", "$description": "Interaction label color (Gray 600)" }
|
|
@@ -279,7 +279,9 @@
|
|
|
279
279
|
"text": {
|
|
280
280
|
"default": { "$value": "{base.color.gray.600}", "$description": "Main text color for body (Gray 600)" },
|
|
281
281
|
"on-dark-bg": { "$value": "{base.color.white.default}", "$description": "Main text color on dark background (White)" },
|
|
282
|
-
"on-
|
|
282
|
+
"on-white-bg": { "$value": "{base.color.green.300}", "$description": "Text color on white background (Green 300)" },
|
|
283
|
+
"on-colored-bg": { "$value": "{base.color.blue.800}", "$description": "Text color on colored background (Blue 800)" },
|
|
284
|
+
"on-disabled": { "$value": "{base.color.white.default}", "$description": "Text color on disabled (White)" },
|
|
283
285
|
"headline-on-dark-bg": { "$value": "{base.color.green.300}", "$description": "Headline text color on dark background (Green 300)" }
|
|
284
286
|
},
|
|
285
287
|
"background": {
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import CssFilterConverter from "css-filter-converter"
|
|
2
|
-
|
|
3
|
-
export default function postcssColorToFilterPlugin() {
|
|
4
|
-
return {
|
|
5
|
-
postcssPlugin: "postcss-color-to-filter",
|
|
6
|
-
async Once(root, { result }) {
|
|
7
|
-
const cssVariables = {}
|
|
8
|
-
|
|
9
|
-
// CSS-Variablen aus :root sammeln
|
|
10
|
-
root.walkRules((rule) => {
|
|
11
|
-
if (rule.selector === ":root" || rule.selector.startsWith(":root,")) {
|
|
12
|
-
rule.walkDecls((decl) => {
|
|
13
|
-
if (decl.prop.startsWith("--")) {
|
|
14
|
-
cssVariables[decl.prop] = decl.value.trim()
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const colorToFilterRegex = /color-to-filter\(\s*(var\(\s*--[\w-]+\s*\))\s*\)/g
|
|
21
|
-
|
|
22
|
-
root.walkDecls(async (decl) => {
|
|
23
|
-
let match
|
|
24
|
-
const matches = []
|
|
25
|
-
|
|
26
|
-
while ((match = colorToFilterRegex.exec(decl.value)) !== null) {
|
|
27
|
-
matches.push(match)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let newValue = decl.value
|
|
31
|
-
let hasReplacements = false
|
|
32
|
-
|
|
33
|
-
for (const match of matches) {
|
|
34
|
-
const [fullMatch, paramRaw] = match
|
|
35
|
-
let param = paramRaw.trim()
|
|
36
|
-
const varMatch = param.match(/^var\((--[^)]+)\)$/)
|
|
37
|
-
|
|
38
|
-
if (varMatch) {
|
|
39
|
-
const varName = varMatch[1]
|
|
40
|
-
if (cssVariables[varName]) {
|
|
41
|
-
param = cssVariables[varName]
|
|
42
|
-
} else {
|
|
43
|
-
result.warn(`CSS variable ${varName} not found`, { node: decl })
|
|
44
|
-
continue
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const result = await CssFilterConverter.hexToFilter(param)
|
|
50
|
-
const filterString = result.color || param
|
|
51
|
-
newValue = newValue.replace(fullMatch, filterString)
|
|
52
|
-
hasReplacements = true
|
|
53
|
-
} catch (e) {
|
|
54
|
-
result.warn(`Error generating filter for color "${param}": ${e.message}`, { node: decl })
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (hasReplacements) {
|
|
59
|
-
decl.value = newValue
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
postcssColorToFilterPlugin.postcss = true
|