@atom-learning/theme 1.2.0 → 1.3.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/README.md CHANGED
@@ -1 +1,69 @@
1
- # theme
1
+ # theme
2
+
3
+ These repository contains the Atom Learning Design System tokens, like colours, sizes, spaces, font families and so on.
4
+
5
+ ## How to add new tokens that are not part of the theme specification
6
+
7
+ If you need to add tokens that are not part of the [theme specification](https://github.com/system-ui/theme-specification#key-reference), follow the instruction below. You can also have a look at [this PR](https://github.com/Atom-Learning/theme/pull/25) where we did it for aspect ratios.
8
+
9
+ * In `system-ui-theme.js`, in `schema` add a new field as an empty object, like `ratios: {}`
10
+ * Also in `system-ui-theme.js`, in `matchSchema`, add a new field named `[category].[type]`, which value references the field you added to `schema` in the previous step. For example if the category is ratios, and the type is ratio, it would look like `'ratios.ratio': 'ratios`
11
+ * Depending on what you are adding you might have to add it to an existing .json file or create a new one. In our example, we created a new one `src/properties/ratios.json`, and added all our tokens there. The json structure is as follow
12
+ - first level: the `category` mentioned in the step above
13
+ - second level: the `type` mentioned in the step above
14
+ - third level: the token name, as you would use it with `$`, e.g.: `$16-9`
15
+ - fourth level: `value`, the value the token will be replaced by.
16
+
17
+ e.g.:
18
+ ```json
19
+ {
20
+ "ratios": {
21
+ "ratio": {
22
+ "16-9": {
23
+ "value": "16/9"
24
+ },
25
+ "3-2": {
26
+ "value": "3/2"
27
+ },
28
+ "4-3": {
29
+ "value": "4/3"
30
+ },
31
+ "1-1": {
32
+ "value": "1/1"
33
+ },
34
+ "3-4": {
35
+ "value": "3/4"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ * In `style.config.js` add your new category (if you added a new category) to the filter of the formatter `'custom/format/scss-map-flat'`. So it's treated the same way than `'size'` and `'effects'`
43
+
44
+ * In `theme-map.js` add the (css property -> category) relation to `themeMap`, in this example, we added `aspectRatio: 'ratios'`. This `themeMap` config is exported and used by projects using our `theme` repo. It's used by `createStitches()` from `@stitches/react` so that we don't have to reference the `type`, so we can call the token like `'$16-9'` instead of `'$ratios$16-9'`
45
+
46
+ ### How is `themeMap` used?
47
+
48
+ For example, in `components` repo we use it like this:
49
+
50
+ ```
51
+ ...
52
+ import { createStitches, defaultThemeMap } from '@stitches/react'
53
+ import { themeMap } from '@atom-learning/theme/theme-map'
54
+
55
+ ...
56
+
57
+ const stitchesConfig = createStitches({
58
+ theme: atomTheme as Theme,
59
+ themeMap: {
60
+ ...defaultThemeMap,
61
+ ...themeMap
62
+ },
63
+ utils,
64
+ media
65
+ })
66
+ ```
67
+
68
+ ### Why/When do we need `themeMap`?
69
+ Some CSS properties are not included in the [defaultThemeMap](https://stitches.dev/docs/api#defaultthememap). If they are missing (e.g.: aspectRatio) you need to add them to our custom `themeMap` which we pass to stitches [themeMap](https://stitches.dev/docs/api#thememap) config
package/lib/index.d.ts CHANGED
@@ -139,5 +139,12 @@ export type Theme = {
139
139
  "1": string
140
140
  "2": string
141
141
  "3": string
142
+ },
143
+ "ratios": {
144
+ "16-9": string
145
+ "3-2": string
146
+ "4-3": string
147
+ "1-1": string
148
+ "3-4": string
142
149
  }
143
150
  }
package/lib/index.js CHANGED
@@ -139,5 +139,12 @@ module.exports = {
139
139
  "1": "0 3px 6px hsla(0, 0%, 20%, 0.1), 0 3px 6px hsla(0, 0%, 20%, 0.1)",
140
140
  "2": "0 10px 20px hsla(0, 0%, 20%, 0.1), 0 6px 6px hsla(0, 0%, 20%, 0.1)",
141
141
  "3": "0 14px 28px hsla(0, 0%, 20%, 0.15), 0 10px 10px hsla(0, 0%, 20%, 0.1)"
142
+ },
143
+ "ratios": {
144
+ "16-9": "16/9",
145
+ "3-2": "3/2",
146
+ "4-3": "4/3",
147
+ "1-1": "1/1",
148
+ "3-4": "3/4"
142
149
  }
143
150
  }
package/lib/index.scss CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Wed, 22 Feb 2023 12:09:52 GMT
3
+ // Generated on Tue, 02 May 2023 09:29:20 GMT
4
4
 
5
5
  $color-text-foreground: #1f1f1f;
6
6
  $color-text-subtle: #545454;
@@ -99,6 +99,13 @@ $effects-shadows: (
99
99
  2: (0 10px 20px rgba(51, 51, 51, 0.1), 0 6px 6px rgba(51, 51, 51, 0.1)),
100
100
  3: (0 14px 28px rgba(51, 51, 51, 0.15), 0 10px 10px rgba(51, 51, 51, 0.1))
101
101
  );
102
+ $ratios-ratio: (
103
+ 16-9: 16/9,
104
+ 3-2: 3/2,
105
+ 4-3: 4/3,
106
+ 1-1: 1/1,
107
+ 3-4: 3/4
108
+ );
102
109
  $size-font: (
103
110
  xs: 12px,
104
111
  sm: 14px,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atom-learning/theme",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Design tokens and assets for Atom Learning",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,7 +11,8 @@
11
11
  "clean": "del ./lib"
12
12
  },
13
13
  "files": [
14
- "lib"
14
+ "lib",
15
+ "theme-map.js"
15
16
  ],
16
17
  "author": "",
17
18
  "license": "ISC",
package/theme-map.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ themeMap: {
3
+ aspectRatio: 'ratios'
4
+ }
5
+ }