@thatch-health/slab-tokens 0.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/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Slab Tokens
2
+
3
+ This package is the pipeline for importing Figma tokens defined in [Token Foundations](https://www.figma.com/design/AMVtHovyyMCo78skFvePV4/Token-Foundations?node-id=32-93&p=f&t=fLz0IYz5irefoKsl-11) and then outputing in appropriate formats for web, the marketing website, and slab design system itself. This package uses [Terrazzo](https://terrazzo.app/) to manage the conversion from the [Design Token Community Group](https://www.designtokens.org/) specification which is a universal token specification. The package itself exports a few endpoints for consumers to use:
4
+
5
+ - `@thatch-health/slab-tokens/tokens-raw` - The raw JSON values of the DTCG specification downloaded from Figma
6
+ - `@thatch-health/slab-tokens/css` - The output from terrazzo using the css plugin
7
+ - `@thatch-health/slab-tokens/tailwind-v3-plugin` - A plugin for tailwind v3 that maps css variables
8
+
9
+ ## Development
10
+
11
+ - Install dependencies:
12
+
13
+ ```bash
14
+ vp install
15
+ ```
16
+
17
+ - Build the library:
18
+
19
+ ```bash
20
+ vp pack
21
+ ```
22
+
23
+ ## Figma Conversion
24
+
25
+ While Figma does export tokens in a DTCG format it does not do appropriate unit conversions for tokens like using rem and px for certain spacing tokens. The way the conversion works is looking at the tokens `$.extensions.['com.figma.scopes']` value in order to see what the usages are. Rather than always using rem units, we map tokens to [the appropriate unit based on the use case](https://www.joshwcomeau.com/css/surprising-truth-about-pixels-and-accessibility/). Token mappings are as follows:
26
+
27
+ | Figma Scope | Unit type |
28
+ | ------------- | --------- |
29
+ | CORNER_RADIUS | px |
30
+ | GAP | px |
31
+ | STROKE_FLOAT | px |
32
+ | WIDTH_HEIGHT | rem |
33
+
34
+ All color tokens use the srgb color space
35
+
36
+ Typography tokens need to be merged into [a typography DTCG $type](https://www.designtokens.org/tr/drafts/format/#typography). This can be done by collapsing typography types from `type.tokens.json` where the structure is `Display.Large.Size` to `display.large` with the following mapping of units:
37
+
38
+ | Figma Scope | Unit type | DTCG type |
39
+ | -------------- | --------- | ------------- |
40
+ | FONT_SIZE | rem | fontSize |
41
+ | FONT_FAMILY | string | fontFamily |
42
+ | FONT_STYLE | number | fontWeight |
43
+ | LINE_HEIGHT | number | lineHeight |
44
+ | LETTER_SPACING | rem | letterSpacing |
45
+
46
+ **Note**: In Figma, variable line height is represented in figma as a pixel unit, therefore, line height is converted to a percentage value of the typeography style's font size.
47
+
48
+ ### Importing tokens from Figma
49
+
50
+ Importing tokens from Figma is currently a manual process. In order to import tokens, you need to right click each collection and press export. Tokens are then placed into this file structure:
51
+
52
+ ```
53
+ tokens-raw-import/
54
+ ├── color/
55
+ │ └── [mode].tokens.json
56
+ ├── color-core.tokens.json
57
+ ├── color-primitives.tokens.json
58
+ ├── spacing.tokens.json
59
+ ├── spacing-primitives.tokens.json
60
+ ├── type.tokens.json
61
+ └── type-primitives/
62
+ └── [mode].tokens.json
63
+ ```
64
+
65
+ When extracting tokens, you will have to format the tokens as they're exported which means that files will be downloaded as the collection name and then you'll need to rename the extracted json file to match the token name.
66
+
67
+ #### Collection with only one mode
68
+
69
+ 1. Download file from figma by right clicking and selecting "Export modes"
70
+ 2. Unzip directory
71
+ 3. Rename the extracted file, `default.tokens.json`, to `[collection name in kebab case].tokens.json`
72
+
73
+ #### Collection with many modes
74
+
75
+ 1. Download file from figma by right clicking and selecting "Export modes"
76
+ 2. Unzip directory
77
+ 3. Rename the directory file to kebab case, all files nested should already be in the correct format.
78
+
79
+ ## Further reading
80
+
81
+ ### Our docs
82
+
83
+ - [About this package](https://www.notion.so/thatchhealth/DS-Code-Structure-Proposal-342114874bc280c1bba6c2c184b8e83b?source=copy_link#343114874bc280f4b87cc67208911bf1)
84
+ - [About our color tokens](https://www.notion.so/thatchhealth/Color-Tokens-33e114874bc280e88ecbee9c28cb60af)
85
+ - [The strategy in our tokens](https://www.notion.so/thatchhealth/Proposed-Token-Changes-32d114874bc280e08f6feb3b32326a29)
86
+
87
+ ### External docs
88
+
89
+ - [Mode.place](https://mode.place/)
90
+ - [What are design tokens](https://www.youtube.com/watch?v=q5qIowMyVt8)
91
+ - [DTCG](https://www.designtokens.org/)