@abgov/design-tokens 1.10.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.
Files changed (34) hide show
  1. package/data/component-design-tokens/accordion-design-tokens.json +92 -11
  2. package/data/component-design-tokens/badge-design-tokens.json +115 -26
  3. package/data/component-design-tokens/button-design-tokens.json +151 -66
  4. package/data/component-design-tokens/callout-design-tokens.json +158 -74
  5. package/data/component-design-tokens/checkbox-design-tokens.json +33 -14
  6. package/data/component-design-tokens/container-design-tokens.json +15 -11
  7. package/data/component-design-tokens/date-picker-design-tokens.json +26 -10
  8. package/data/component-design-tokens/details-design-tokens.json +28 -5
  9. package/data/component-design-tokens/drawer-design-tokens.json +42 -35
  10. package/data/component-design-tokens/dropdown-design-tokens.json +81 -17
  11. package/data/component-design-tokens/filter-chip-design-tokens.json +92 -0
  12. package/data/component-design-tokens/footer-design-tokens.json +16 -20
  13. package/data/component-design-tokens/form-item-design-tokens.json +99 -20
  14. package/data/component-design-tokens/header-design-tokens.json +189 -235
  15. package/data/component-design-tokens/icon-button-design-tokens.json +40 -24
  16. package/data/component-design-tokens/input-design-tokens.json +52 -28
  17. package/data/component-design-tokens/link-design-tokens.json +115 -0
  18. package/data/component-design-tokens/modal-design-tokens.json +202 -17
  19. package/data/component-design-tokens/notification-banner-design-tokens.json +152 -0
  20. package/data/component-design-tokens/pagination-design-tokens.json +17 -0
  21. package/data/component-design-tokens/popover-design-tokens.json +23 -9
  22. package/data/component-design-tokens/push-drawer-design-tokens.json +1 -1
  23. package/data/component-design-tokens/radio-design-tokens.json +79 -17
  24. package/data/component-design-tokens/side-menu-design-tokens.json +101 -94
  25. package/data/component-design-tokens/table-design-tokens.json +159 -9
  26. package/data/component-design-tokens/tabs-design-tokens.json +74 -16
  27. package/data/component-design-tokens/temporary-notification-design-tokens.json +112 -0
  28. package/data/component-design-tokens/text-area-design-tokens.json +29 -15
  29. package/data/component-design-tokens/tooltip-design-tokens.json +3 -3
  30. package/data/goa-global-design-tokens.json +571 -145
  31. package/dist/tokens.css +812 -430
  32. package/dist/tokens.scss +958 -576
  33. package/lib/design-tokens.js +43 -9
  34. package/package.json +1 -1
@@ -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 { x, y, blur, spread, color } = token.original.value;
30
- return `${x}px ${y}px ${blur}px ${spread}px ${color}`;
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: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/design-tokens",
3
- "version": "1.10.0",
3
+ "version": "2.0.0",
4
4
  "main": "./index.js",
5
5
  "repository": {
6
6
  "type": "git",