@abgov/design-tokens 1.9.0 → 2.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/data/component-design-tokens/accordion-design-tokens.json +92 -11
- package/data/component-design-tokens/badge-design-tokens.json +115 -26
- package/data/component-design-tokens/button-design-tokens.json +151 -66
- package/data/component-design-tokens/callout-design-tokens.json +158 -74
- package/data/component-design-tokens/checkbox-design-tokens.json +33 -14
- package/data/component-design-tokens/container-design-tokens.json +15 -11
- package/data/component-design-tokens/date-picker-design-tokens.json +26 -10
- package/data/component-design-tokens/details-design-tokens.json +28 -5
- package/data/component-design-tokens/drawer-design-tokens.json +42 -35
- package/data/component-design-tokens/dropdown-design-tokens.json +81 -17
- package/data/component-design-tokens/filter-chip-design-tokens.json +92 -0
- package/data/component-design-tokens/footer-design-tokens.json +16 -20
- package/data/component-design-tokens/form-item-design-tokens.json +99 -20
- package/data/component-design-tokens/header-design-tokens.json +189 -235
- package/data/component-design-tokens/icon-button-design-tokens.json +40 -24
- package/data/component-design-tokens/input-design-tokens.json +52 -28
- package/data/component-design-tokens/link-design-tokens.json +115 -0
- package/data/component-design-tokens/modal-design-tokens.json +202 -17
- package/data/component-design-tokens/notification-banner-design-tokens.json +152 -0
- package/data/component-design-tokens/pagination-design-tokens.json +17 -0
- package/data/component-design-tokens/popover-design-tokens.json +23 -9
- package/data/component-design-tokens/push-drawer-design-tokens.json +1 -1
- package/data/component-design-tokens/radio-design-tokens.json +79 -17
- package/data/component-design-tokens/side-menu-design-tokens.json +101 -94
- package/data/component-design-tokens/table-design-tokens.json +159 -9
- package/data/component-design-tokens/tabs-design-tokens.json +74 -16
- package/data/component-design-tokens/temporary-notification-design-tokens.json +112 -0
- package/data/component-design-tokens/text-area-design-tokens.json +29 -15
- package/data/component-design-tokens/tooltip-design-tokens.json +3 -3
- package/data/component-design-tokens/work-side-menu-design-tokens.json +34 -0
- package/data/component-design-tokens/work-side-menu-group-design-tokens.json +26 -0
- package/data/component-design-tokens/work-side-menu-item-design-tokens.json +58 -0
- package/data/goa-global-design-tokens.json +571 -145
- package/dist/tokens.css +840 -430
- package/dist/tokens.scss +974 -564
- package/index.spec.js +12 -0
- package/lib/design-tokens.js +43 -9
- package/package.json +1 -1
package/index.spec.js
CHANGED
|
@@ -27,4 +27,16 @@ describe("GoA Design Tokens", () => {
|
|
|
27
27
|
const raw = fs.readFileSync("./tmp/dist/tokens.scss", { encoding: "utf8" });
|
|
28
28
|
expect(raw).not.toContain("[object Object]");
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
it("should not contain double goa prefixes", async () => {
|
|
32
|
+
SC.generate("./tmp");
|
|
33
|
+
const raw = fs.readFileSync("./tmp/dist/tokens.css", { encoding: "utf8" });
|
|
34
|
+
expect(raw).not.toContain("--goa-goa");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should not contain undefined values", async () => {
|
|
38
|
+
SC.generate("./tmp");
|
|
39
|
+
const raw = fs.readFileSync("./tmp/dist/tokens.css", { encoding: "utf8" });
|
|
40
|
+
expect(raw.toLowerCase()).not.toContain("undefined");
|
|
41
|
+
});
|
|
30
42
|
});
|
package/lib/design-tokens.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
const StyleDictionary = require("style-dictionary");
|
|
2
2
|
|
|
3
3
|
function generate(outputPath) {
|
|
4
|
-
|
|
5
4
|
// Typography
|
|
6
5
|
StyleDictionary.registerTransform({
|
|
7
6
|
name: "typography/shorthand",
|
|
8
7
|
type: "value",
|
|
9
8
|
transitive: true,
|
|
10
|
-
matcher: function(token) {
|
|
9
|
+
matcher: function (token) {
|
|
11
10
|
return token.type === "typography";
|
|
12
11
|
},
|
|
13
|
-
transformer: function(token) {
|
|
12
|
+
transformer: function (token) {
|
|
14
13
|
const { fontWeight, fontSize, lineHeight, fontFamily } =
|
|
15
14
|
token.original.value;
|
|
16
15
|
return `${fontWeight} ${fontSize}/${lineHeight} ${fontFamily}`;
|
|
@@ -22,12 +21,29 @@ function generate(outputPath) {
|
|
|
22
21
|
name: "box-shadow",
|
|
23
22
|
type: "value",
|
|
24
23
|
transitive: true,
|
|
25
|
-
matcher: function(token) {
|
|
24
|
+
matcher: function (token) {
|
|
26
25
|
return token.type === "boxShadow";
|
|
27
26
|
},
|
|
28
|
-
transformer: function(token) {
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
transformer: function (token) {
|
|
28
|
+
const toPx = (value) => {
|
|
29
|
+
if (value === 0 || value === "0") return "0px";
|
|
30
|
+
if (typeof value === "number") return `${value}px`;
|
|
31
|
+
if (typeof value !== "string") return value;
|
|
32
|
+
if (/^-?\d+(\.\d+)?$/.test(value)) return `${value}px`;
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const formatLayer = (layer) => {
|
|
37
|
+
const { x, y, blur, spread, color } = layer;
|
|
38
|
+
return `${toPx(x)} ${toPx(y)} ${toPx(blur)} ${toPx(spread)} ${color}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const value = token.original.value;
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return value.map(formatLayer).join(", ");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return formatLayer(value);
|
|
31
47
|
},
|
|
32
48
|
});
|
|
33
49
|
|
|
@@ -36,15 +52,31 @@ function generate(outputPath) {
|
|
|
36
52
|
name: "border",
|
|
37
53
|
type: "value",
|
|
38
54
|
transitive: true,
|
|
39
|
-
matcher: function(token) {
|
|
55
|
+
matcher: function (token) {
|
|
40
56
|
return token.type === "border";
|
|
41
57
|
},
|
|
42
|
-
transformer: function(token) {
|
|
58
|
+
transformer: function (token) {
|
|
43
59
|
const { color, width, style } = token.original.value;
|
|
44
60
|
return `${width} ${style} ${color}`;
|
|
45
61
|
},
|
|
46
62
|
});
|
|
47
63
|
|
|
64
|
+
// Font Variation Settings
|
|
65
|
+
StyleDictionary.registerTransform({
|
|
66
|
+
name: "fontVariationSettings",
|
|
67
|
+
type: "value",
|
|
68
|
+
transitive: true,
|
|
69
|
+
matcher: function (token) {
|
|
70
|
+
return token.type === "fontVariationSettings";
|
|
71
|
+
},
|
|
72
|
+
transformer: function (token) {
|
|
73
|
+
const settings = token.original.value;
|
|
74
|
+
return Object.entries(settings)
|
|
75
|
+
.map(([key, value]) => `${key} ${value}`)
|
|
76
|
+
.join(", ");
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
48
80
|
try {
|
|
49
81
|
StyleDictionary.extend({
|
|
50
82
|
source: [`./data/**/*.json`],
|
|
@@ -56,6 +88,7 @@ function generate(outputPath) {
|
|
|
56
88
|
"typography/shorthand",
|
|
57
89
|
"box-shadow",
|
|
58
90
|
"border",
|
|
91
|
+
"fontVariationSettings",
|
|
59
92
|
],
|
|
60
93
|
buildPath: `${outputPath}/dist/`,
|
|
61
94
|
files: [
|
|
@@ -72,6 +105,7 @@ function generate(outputPath) {
|
|
|
72
105
|
"typography/shorthand",
|
|
73
106
|
"box-shadow",
|
|
74
107
|
"border",
|
|
108
|
+
"fontVariationSettings",
|
|
75
109
|
],
|
|
76
110
|
buildPath: `${outputPath}/dist/`,
|
|
77
111
|
files: [
|