@sps-woodland/tokens 7.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 (110) hide show
  1. package/README.md +128 -0
  2. package/config/config.js +89 -0
  3. package/config/config.js.map +1 -0
  4. package/config/formats/fontFace.js +73 -0
  5. package/config/formats/fontFace.js.map +1 -0
  6. package/config/formats/jsSimpleObject.js +59 -0
  7. package/config/formats/jsSimpleObject.js.map +1 -0
  8. package/config/formats/utility-class-builders/color.js +25 -0
  9. package/config/formats/utility-class-builders/color.js.map +1 -0
  10. package/config/formats/utility-class-builders/grid.js +31 -0
  11. package/config/formats/utility-class-builders/grid.js.map +1 -0
  12. package/config/formats/utility-class-builders/icon.js +26 -0
  13. package/config/formats/utility-class-builders/icon.js.map +1 -0
  14. package/config/formats/utility-class-builders/iconSize.js +15 -0
  15. package/config/formats/utility-class-builders/iconSize.js.map +1 -0
  16. package/config/formats/utility-class-builders/spacing.js +44 -0
  17. package/config/formats/utility-class-builders/spacing.js.map +1 -0
  18. package/config/formats/utility-class-builders/typeSize.js +30 -0
  19. package/config/formats/utility-class-builders/typeSize.js.map +1 -0
  20. package/config/formats/utility-class-builders/typeWeight.js +15 -0
  21. package/config/formats/utility-class-builders/typeWeight.js.map +1 -0
  22. package/config/formats/utilityClasses.js +91 -0
  23. package/config/formats/utilityClasses.js.map +1 -0
  24. package/config/formats/utils.js +19 -0
  25. package/config/formats/utils.js.map +1 -0
  26. package/config/formats/vanillaExtractSprinkleValues.js +86 -0
  27. package/config/formats/vanillaExtractSprinkleValues.js.map +1 -0
  28. package/config/transforms/attrFont.js +23 -0
  29. package/config/transforms/attrFont.js.map +1 -0
  30. package/config/transforms/attrGridColumns.js +20 -0
  31. package/config/transforms/attrGridColumns.js.map +1 -0
  32. package/config-src/config.js.map +1 -0
  33. package/config-src/config.ts +89 -0
  34. package/config-src/formats/fontFace.js.map +1 -0
  35. package/config-src/formats/fontFace.ts +68 -0
  36. package/config-src/formats/jsSimpleObject.js.map +1 -0
  37. package/config-src/formats/jsSimpleObject.ts +32 -0
  38. package/config-src/formats/utility-class-builders/UtilityClassBuilder.d.ts +7 -0
  39. package/config-src/formats/utility-class-builders/color.js.map +1 -0
  40. package/config-src/formats/utility-class-builders/color.ts +24 -0
  41. package/config-src/formats/utility-class-builders/grid.js.map +1 -0
  42. package/config-src/formats/utility-class-builders/grid.ts +30 -0
  43. package/config-src/formats/utility-class-builders/icon.js.map +1 -0
  44. package/config-src/formats/utility-class-builders/icon.ts +26 -0
  45. package/config-src/formats/utility-class-builders/iconSize.js.map +1 -0
  46. package/config-src/formats/utility-class-builders/iconSize.ts +13 -0
  47. package/config-src/formats/utility-class-builders/spacing.js.map +1 -0
  48. package/config-src/formats/utility-class-builders/spacing.ts +44 -0
  49. package/config-src/formats/utility-class-builders/typeSize.js.map +1 -0
  50. package/config-src/formats/utility-class-builders/typeSize.ts +30 -0
  51. package/config-src/formats/utility-class-builders/typeWeight.js.map +1 -0
  52. package/config-src/formats/utility-class-builders/typeWeight.ts +13 -0
  53. package/config-src/formats/utilityClasses.js.map +1 -0
  54. package/config-src/formats/utilityClasses.ts +77 -0
  55. package/config-src/formats/utils.js.map +1 -0
  56. package/config-src/formats/utils.ts +14 -0
  57. package/config-src/formats/vanillaExtractSprinkleValues.js.map +1 -0
  58. package/config-src/formats/vanillaExtractSprinkleValues.ts +73 -0
  59. package/config-src/transforms/attrFont.js.map +1 -0
  60. package/config-src/transforms/attrFont.ts +24 -0
  61. package/config-src/transforms/attrGridColumns.js.map +1 -0
  62. package/config-src/transforms/attrGridColumns.ts +15 -0
  63. package/config-src/tsconfig.json +22 -0
  64. package/lib/css/tokens.css +668 -0
  65. package/lib/css/utils.css +1318 -0
  66. package/lib/dictionary.d.ts +33847 -0
  67. package/lib/font.css +102 -0
  68. package/lib/index.cjs.js +1 -0
  69. package/lib/index.d.ts +8 -0
  70. package/lib/index.es.js +1611 -0
  71. package/lib/scss/tokens.scss +665 -0
  72. package/lib/scss/utils.scss +1318 -0
  73. package/lib/tokens.d.ts +1389 -0
  74. package/lib/types.d.ts +5 -0
  75. package/lib/utils/pxToRem.d.ts +5 -0
  76. package/lib/utils/rem.d.ts +7 -0
  77. package/lib/utils/transparentEquivalentColor.d.ts +29 -0
  78. package/lib/vanilla-extract/border.css.d.ts +37 -0
  79. package/lib/vanilla-extract/grid.css.d.ts +15 -0
  80. package/lib/vanilla-extract/properties/border.css.d.ts +1397 -0
  81. package/lib/vanilla-extract/properties/color.css.d.ts +464 -0
  82. package/lib/vanilla-extract/properties/conditions.d.ts +27 -0
  83. package/lib/vanilla-extract/properties/grid.css.d.ts +55 -0
  84. package/lib/vanilla-extract/properties/margin.css.d.ts +321 -0
  85. package/lib/vanilla-extract/properties/padding.css.d.ts +321 -0
  86. package/lib/vanilla-extract/properties/type.css.d.ts +80 -0
  87. package/lib/vanilla-extract/sprinkleValues.d.ts +1114 -0
  88. package/lib/vanilla-extract/sprinkles.css.d.ts +5267 -0
  89. package/lib/vanilla-extract/style.css +1 -0
  90. package/package.json +37 -0
  91. package/src/dictionary.ts +46007 -0
  92. package/src/index.ts +8 -0
  93. package/src/tokens.ts +785 -0
  94. package/src/types.ts +6 -0
  95. package/src/utils/pxToRem.ts +7 -0
  96. package/src/utils/rem.ts +27 -0
  97. package/src/utils/transparentEquivalentColor.ts +42 -0
  98. package/src/vanilla-extract/border.css.ts +46 -0
  99. package/src/vanilla-extract/grid.css.ts +49 -0
  100. package/src/vanilla-extract/properties/border.css.ts +33 -0
  101. package/src/vanilla-extract/properties/color.css.ts +16 -0
  102. package/src/vanilla-extract/properties/conditions.ts +14 -0
  103. package/src/vanilla-extract/properties/grid.css.ts +13 -0
  104. package/src/vanilla-extract/properties/margin.css.ts +40 -0
  105. package/src/vanilla-extract/properties/padding.css.ts +40 -0
  106. package/src/vanilla-extract/properties/type.css.ts +17 -0
  107. package/src/vanilla-extract/sprinkleValues.ts +605 -0
  108. package/src/vanilla-extract/sprinkles.css.ts +19 -0
  109. package/tsconfig.json +13 -0
  110. package/vite.config.js +21 -0
package/src/types.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { sprinkleValues } from "./vanilla-extract/sprinkleValues";
2
+ import type { Tokens } from "./tokens";
3
+
4
+ export type Color = keyof typeof sprinkleValues.colors;
5
+ export type IconName = keyof typeof Tokens.icon;
6
+ export type IconSize = keyof typeof Tokens.size.icon;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Takes in a CSS pixel value (e.g. "25px")
3
+ * and returns its rem value ("1.5625rem")
4
+ */
5
+ export function pxToRem(px: string): string {
6
+ return `${Number(px.replace("px", "")) / 16}rem`;
7
+ }
@@ -0,0 +1,27 @@
1
+ import type { StyleRule } from "@vanilla-extract/css";
2
+
3
+ import { pxToRem } from "./pxToRem";
4
+
5
+ /**
6
+ * Recursively navigates a vanilla-extract StyleRule and applies
7
+ * pxToRem on every pixel value in every string property value
8
+ * it can find.
9
+ */
10
+ export function rem<T extends StyleRule>(styleRule: T): T {
11
+ return Object.keys(styleRule)
12
+ .reduce((acc, key) => {
13
+ switch (typeof styleRule[key]) {
14
+ case "object":
15
+ acc[key] = rem(styleRule[key]);
16
+ break;
17
+
18
+ case "string":
19
+ acc[key] = styleRule[key].replace(/[\d.]+px/g, pxToRem);
20
+ break;
21
+
22
+ default:
23
+ acc[key] = styleRule[key];
24
+ }
25
+ return acc;
26
+ }, {} as T);
27
+ }
@@ -0,0 +1,42 @@
1
+ import tinycolor from "tinycolor2";
2
+
3
+ interface RGBColor {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ a?: number;
8
+ }
9
+
10
+ interface HSLColor {
11
+ h: number;
12
+ s: number;
13
+ l: number;
14
+ }
15
+
16
+ interface HSVColor {
17
+ h: number;
18
+ s: number;
19
+ v: number;
20
+ }
21
+
22
+ /**
23
+ * Takes in a color value (see https://www.npmjs.com/package/tinycolor2
24
+ * for accepted input formats) and returns a new color in rgb format
25
+ * that is 30% transparent, but results in the same perceived color
26
+ * as the input when layered on a white background. This is used so that
27
+ * when you place an element in a container that uses linear-gradient
28
+ * background images to create shadows indicating that the container
29
+ * can be scrolled to reveal more content, those elements can appear
30
+ * as though they are under the shadows even though they are, in fact,
31
+ * on top of them.
32
+ */
33
+ export function transparentEquivalentColor(color: string | RGBColor | HSLColor | HSVColor): string {
34
+ const { r, g, b } = tinycolor(color).toRgb();
35
+ const newRGB = [
36
+ r,
37
+ g,
38
+ b,
39
+ ].map((c: number): number => Math.round((c - 255 + (255 * 0.3)) / 0.3))
40
+ .join(", ");
41
+ return `rgb(${newRGB}, 0.3)`;
42
+ }
@@ -0,0 +1,46 @@
1
+ import { recipe } from "@vanilla-extract/recipes";
2
+
3
+ import { sprinkleValues } from "./sprinkleValues";
4
+ import type { Sprinkles } from "./sprinkles.css";
5
+ import { sprinkles } from "./sprinkles.css";
6
+
7
+ type Colors = typeof sprinkleValues.colors;
8
+
9
+ const color: Colors = Object.keys(sprinkleValues.colors)
10
+ .reduce((acc, key) => {
11
+ acc[key] = sprinkles({
12
+ borderColor: key as Sprinkles["borderColor"],
13
+ });
14
+ return acc;
15
+ }, {} as Colors);
16
+
17
+ type Radii = typeof sprinkleValues.border.radius;
18
+
19
+ const radius: Radii = Object.keys(sprinkleValues.border.radius)
20
+ .reduce((acc, key) => {
21
+ acc[key] = sprinkles({
22
+ borderRadius: key as Sprinkles["borderRadius"],
23
+ });
24
+ return acc;
25
+ }, {} as Radii);
26
+
27
+ export const border = recipe({
28
+ base: [
29
+ sprinkles({
30
+ borderWidth: "standard",
31
+ }),
32
+ {
33
+ borderStyle: "solid",
34
+ },
35
+ ],
36
+
37
+ variants: {
38
+ color,
39
+ radius,
40
+ },
41
+
42
+ defaultVariants: {
43
+ color: "grey-medium-light",
44
+ radius: "none",
45
+ },
46
+ });
@@ -0,0 +1,49 @@
1
+ import { style } from "@vanilla-extract/css";
2
+
3
+ import { dictionary } from "../dictionary";
4
+
5
+ /*
6
+ * usage:
7
+ * <div className={grid.root}>
8
+ * <div className={grid[12]}></div>
9
+ * <div className={grid[3]}</div>
10
+ * <div className={grid[9]}</div>
11
+ * </div>
12
+ *
13
+ * this example will result in two "rows"
14
+ * the grid is 12 wide, so the first child will
15
+ * obviously span all the way across, then
16
+ * the 3 and 9 will go on one "row" together
17
+ *
18
+ * but when we add responsive conditions to the
19
+ * grid code, we could have the elements in these
20
+ * examples flow/wrap differently since they're
21
+ * siblings. CSS grid will give us flexibility we
22
+ * don't currently have
23
+ */
24
+ export const grid = {
25
+ root: style({
26
+ display: "grid",
27
+ gap: dictionary.tokens.size.grid.gutter.value,
28
+ gridTemplateColumns: dictionary.tokens.grid.columns.standard.attributes.cssValue,
29
+ }),
30
+
31
+ /*
32
+ * manually enumerating these rather than using a loop of some kind
33
+ * allows for the TypeScript typing to be inferred; otherwise the
34
+ * type would have to be written out separately and manually enumerate
35
+ * these properties anyway
36
+ */
37
+ 1: style({ gridColumn: "span 1" }),
38
+ 2: style({ gridColumn: "span 2" }),
39
+ 3: style({ gridColumn: "span 3" }),
40
+ 4: style({ gridColumn: "span 4" }),
41
+ 5: style({ gridColumn: "span 5" }),
42
+ 6: style({ gridColumn: "span 6" }),
43
+ 7: style({ gridColumn: "span 7" }),
44
+ 8: style({ gridColumn: "span 8" }),
45
+ 9: style({ gridColumn: "span 9" }),
46
+ 10: style({ gridColumn: "span 10" }),
47
+ 11: style({ gridColumn: "span 11" }),
48
+ 12: style({ gridColumn: "span 12" }),
49
+ };
@@ -0,0 +1,33 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+ import { conditions } from "./conditions";
5
+
6
+ export const borderProperties = defineProperties({
7
+ conditions: {
8
+ default: {},
9
+ ...conditions.interaction,
10
+ },
11
+ defaultCondition: "default",
12
+ properties: {
13
+ borderColor: sprinkleValues.colors,
14
+ borderBottomColor: sprinkleValues.colors,
15
+ borderLeftColor: sprinkleValues.colors,
16
+ borderRightColor: sprinkleValues.colors,
17
+ borderTopColor: sprinkleValues.colors,
18
+ borderRadius: sprinkleValues.border.radius,
19
+ borderWidth: sprinkleValues.border.width,
20
+ borderTopWidth: sprinkleValues.border.width,
21
+ borderRightWidth: sprinkleValues.border.width,
22
+ borderBottomWidth: sprinkleValues.border.width,
23
+ borderLeftWidth: sprinkleValues.border.width,
24
+ borderTopLeftRadius: sprinkleValues.border.radius,
25
+ borderTopRightRadius: sprinkleValues.border.radius,
26
+ borderBottomRightRadius: sprinkleValues.border.radius,
27
+ borderBottomLeftRadius: sprinkleValues.border.radius,
28
+ },
29
+ shorthands: {
30
+ borderTopRadius: ["borderTopLeftRadius", "borderTopRightRadius"],
31
+ borderBottomRadius: ["borderBottomLeftRadius", "borderBottomRightRadius"],
32
+ },
33
+ });
@@ -0,0 +1,16 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+ import { conditions } from "./conditions";
5
+
6
+ export const colorProperties = defineProperties({
7
+ conditions: {
8
+ default: {},
9
+ ...conditions.interaction,
10
+ },
11
+ defaultCondition: "default",
12
+ properties: {
13
+ backgroundColor: sprinkleValues.colors,
14
+ color: sprinkleValues.colors,
15
+ },
16
+ });
@@ -0,0 +1,14 @@
1
+ export const conditions = {
2
+ childPosition: {
3
+ firstChild: { selector: "&:first-child" },
4
+ notFirstChild: { selector: "&:not(:first-child)" },
5
+ lastChild: { selector: "&:last-child" },
6
+ notLastChild: { selector: "&:not(:last-child)" },
7
+ middleChild: { selector: "&:not(:first-child):not(:last-child)" },
8
+ },
9
+
10
+ interaction: {
11
+ hover: { selector: "&:hover" },
12
+ focus: { selector: "&:focus" },
13
+ },
14
+ };
@@ -0,0 +1,13 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+
5
+ export const gridProperties = defineProperties({
6
+ properties: {
7
+ columnGap: sprinkleValues.spacing,
8
+ rowGap: sprinkleValues.spacing,
9
+ },
10
+ shorthands: {
11
+ gap: ["rowGap", "columnGap"],
12
+ },
13
+ });
@@ -0,0 +1,40 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+ import { conditions } from "./conditions";
5
+
6
+ export const marginProperties = defineProperties({
7
+ conditions: {
8
+ default: {},
9
+ ...conditions.childPosition,
10
+ },
11
+ defaultCondition: "default",
12
+ properties: {
13
+ marginBottom: sprinkleValues.spacing,
14
+ marginLeft: sprinkleValues.spacing,
15
+ marginRight: sprinkleValues.spacing,
16
+ marginTop: sprinkleValues.spacing,
17
+ },
18
+ shorthands: {
19
+ margin: [
20
+ "marginTop",
21
+ "marginBottom",
22
+ "marginLeft",
23
+ "marginRight",
24
+ ],
25
+ marginX: ["marginLeft", "marginRight"],
26
+ marginY: ["marginTop", "marginBottom"],
27
+ m: [
28
+ "marginTop",
29
+ "marginBottom",
30
+ "marginLeft",
31
+ "marginRight",
32
+ ],
33
+ mx: ["marginLeft", "marginRight"],
34
+ my: ["marginTop", "marginBottom"],
35
+ mt: ["marginTop"],
36
+ mr: ["marginRight"],
37
+ mb: ["marginBottom"],
38
+ ml: ["marginLeft"],
39
+ },
40
+ });
@@ -0,0 +1,40 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+ import { conditions } from "./conditions";
5
+
6
+ export const paddingProperties = defineProperties({
7
+ conditions: {
8
+ default: {},
9
+ ...conditions.childPosition,
10
+ },
11
+ defaultCondition: "default",
12
+ properties: {
13
+ paddingBottom: sprinkleValues.spacing,
14
+ paddingLeft: sprinkleValues.spacing,
15
+ paddingRight: sprinkleValues.spacing,
16
+ paddingTop: sprinkleValues.spacing,
17
+ },
18
+ shorthands: {
19
+ padding: [
20
+ "paddingTop",
21
+ "paddingBottom",
22
+ "paddingLeft",
23
+ "paddingRight",
24
+ ],
25
+ paddingX: ["paddingLeft", "paddingRight"],
26
+ paddingY: ["paddingTop", "paddingBottom"],
27
+ p: [
28
+ "paddingTop",
29
+ "paddingBottom",
30
+ "paddingLeft",
31
+ "paddingRight",
32
+ ],
33
+ px: ["paddingLeft", "paddingRight"],
34
+ py: ["paddingTop", "paddingBottom"],
35
+ pt: ["paddingTop"],
36
+ pr: ["paddingRight"],
37
+ pb: ["paddingBottom"],
38
+ pl: ["paddingLeft"],
39
+ },
40
+ });
@@ -0,0 +1,17 @@
1
+ import { defineProperties } from "@vanilla-extract/sprinkles";
2
+
3
+ import { sprinkleValues } from "../sprinkleValues";
4
+
5
+ export const typeProperties = defineProperties({
6
+ properties: {
7
+ fontSize: sprinkleValues.fontSizes,
8
+ fontWeight: sprinkleValues.type.weight,
9
+ lineHeight: sprinkleValues.lineHeights,
10
+ },
11
+ shorthands: {
12
+ fs: ["fontSize"],
13
+ fw: ["fontWeight"],
14
+ lh: ["lineHeight"],
15
+ type: ["fontSize", "lineHeight"],
16
+ },
17
+ });