@equinor/eds-tokens 2.3.0-beta.2 → 2.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.
@@ -51,10 +51,10 @@ Apply data attributes to set the typographic context, then use the CSS variables
51
51
  ```css
52
52
  .text {
53
53
  font-family: var(--eds-typography-font-family);
54
- font-size: calc(var(--eds-typography-font-size) * 1px);
54
+ font-size: var(--eds-typography-font-size);
55
55
  font-weight: var(--eds-typography-font-weight);
56
- line-height: calc(var(--eds-typography-line-height) * 1px);
57
- letter-spacing: calc(var(--eds-typography-tracking) * 1px);
56
+ line-height: var(--eds-typography-line-height);
57
+ letter-spacing: var(--eds-typography-tracking);
58
58
  }
59
59
  ```
60
60
 
@@ -65,8 +65,8 @@ When `data-font-size` is set, additional variables are resolved automatically:
65
65
  ```css
66
66
  .icon-next-to-text {
67
67
  /* Icon size and gap scale with font size */
68
- width: calc(var(--eds-typography-icon-size) * 1px);
69
- gap: calc(var(--eds-typography-gap-horizontal) * 1px);
68
+ width: var(--eds-typography-icon-size);
69
+ gap: var(--eds-typography-gap-horizontal);
70
70
  }
71
71
  ```
72
72
 
@@ -91,67 +91,83 @@ Change typographic properties by updating data attributes -- no CSS changes need
91
91
  </small>
92
92
  ```
93
93
 
94
- ## TypeScript Tokens
94
+ ## Using Typography in TypeScript / JavaScript
95
95
 
96
- Typography tokens are available as nested TypeScript objects with `as const` for type safety.
96
+ The CSS cascade is what composes the five axes into a final style. Targets without a cascade -- React Native, server-side rendering, design tooling, plain JS -- read the family matrix directly and pick the variant they want.
97
97
 
98
- ### Import
98
+ ### Direct token import
99
+
100
+ Two files are emitted, one per font family. Each is a fully resolved matrix keyed by size, with nested axes inside each size cell:
99
101
 
100
102
  ```typescript
101
- import { typography } from '@equinor/eds-tokens/ts/typography/font-size-md'
102
- import { typography } from '@equinor/eds-tokens/ts/typography/font-family-header'
103
- import { typography } from '@equinor/eds-tokens/ts/typography/font-weight-normal'
104
- import { typography } from '@equinor/eds-tokens/ts/typography/line-height-default'
105
- import { typography } from '@equinor/eds-tokens/ts/typography/tracking-tight'
103
+ import { typography as ui } from '@equinor/eds-tokens/ts/typography/font-family-ui'
104
+ import { typography as header } from '@equinor/eds-tokens/ts/typography/font-family-header'
105
+
106
+ const md = ui.fontFamilySize.md
107
+
108
+ const style = {
109
+ fontFamily: ui.typography.fontFamily,
110
+ fontSize: md.fontSize,
111
+ fontWeight: md.fontWeight.normal, // 300 | 400 | 500
112
+ lineHeight: md.lineHeight.default, // pixels
113
+ letterSpacing: md.tracking.normal,
114
+ }
115
+ // { fontFamily: 'Inter', fontSize: 14, fontWeight: 400,
116
+ // lineHeight: 20, letterSpacing: 0 }
106
117
  ```
107
118
 
108
- ### Available Files
119
+ The size cell also exposes family-independent extras for chip- and button-like layouts:
109
120
 
110
- Each mode of each axis has its own file:
121
+ ```typescript
122
+ const md = ui.fontFamilySize.md
123
+ md.iconSize // matches the size axis
124
+ md.gapHorizontal // matches the size axis
125
+ md.gapVertical
126
+ ```
111
127
 
112
- | Axis | Files |
113
- |------|-------|
114
- | Font family | `font-family-header`, `font-family-ui` |
115
- | Font size | `font-size-xs`, `font-size-sm`, `font-size-md`, `font-size-lg`, `font-size-xl`, `font-size-2xl`, `font-size-3xl`, `font-size-4xl`, `font-size-5xl`, `font-size-6xl` |
116
- | Font weight | `font-weight-lighter`, `font-weight-normal`, `font-weight-bolder` |
117
- | Line height | `line-height-default`, `line-height-squished` |
118
- | Tracking | `tracking-tight`, `tracking-normal`, `tracking-wide`, `tracking-loose` |
128
+ ### Deriving variant types
119
129
 
120
- ### Usage
130
+ Variant names are encoded in the data, so consumers don't have to hand-roll axis-name lookups:
121
131
 
122
132
  ```typescript
123
- import { typography } from '@equinor/eds-tokens/ts/typography/font-size-md'
124
-
125
- // Font size files contain resolved values for that size
126
- typography.typography['font-size'] // '16'
127
- typography.typography['line-height-default'] // '20'
128
- typography.typography['font-weight-normal'] // '400'
133
+ type FontFamily = 'ui' | 'header'
134
+ type FontSize = keyof typeof ui.fontFamilySize // 'xs' | 'sm' | ... | 'sixXl'
135
+ type FontWeight = keyof typeof ui.fontFamilySize.md.fontWeight // 'lighter' | 'normal' | 'bolder'
136
+ type LineHeight = keyof typeof ui.fontFamilySize.md.lineHeight // 'default' | 'squished'
137
+ type Tracking = keyof typeof ui.fontFamilySize.md.tracking // 'tight' | 'normal' | 'wide'
129
138
  ```
130
139
 
131
- ```typescript
132
- import { typography } from '@equinor/eds-tokens/ts/typography/font-family-header'
140
+ ### React Native
133
141
 
134
- // Font family files contain the family and all size-specific values
135
- typography.typography['font-family'] // 'Equinor'
136
- typography['font-family-size'].md['font-size'] // '16'
137
- ```
142
+ Pass `String(...)` over the weight when handing it to `<Text style>` (RN expects string fontWeight):
138
143
 
139
- ### Naming Conversion
144
+ ```typescript
145
+ import { Text, StyleSheet } from 'react-native'
146
+ import { typography as ui } from '@equinor/eds-tokens/ts/typography/font-family-ui'
147
+
148
+ const md = ui.fontFamilySize.md
149
+
150
+ const styles = StyleSheet.create({
151
+ body: {
152
+ fontFamily: ui.typography.fontFamily,
153
+ fontSize: md.fontSize,
154
+ fontWeight: String(md.fontWeight.normal) as '400',
155
+ lineHeight: md.lineHeight.default,
156
+ letterSpacing: md.tracking.normal,
157
+ },
158
+ })
159
+ ```
140
160
 
141
- CSS variable segments map to TypeScript object keys:
161
+ ### What's not exported
142
162
 
143
- | CSS variable | TypeScript path |
144
- |---|---|
145
- | `--eds-typography-font-size` | `typography.typography['font-size']` |
146
- | `--eds-typography-font-weight` | `typography.typography['font-weight']` |
147
- | `--eds-typography-tracking` | `typography.typography.tracking` |
163
+ The other axis files (`font-weight-*`, `line-height-*`, `tracking-*`) and the per-size files (`font-size-{xs..6xl}`) intentionally do **not** ship as TypeScript. Their values depend on the active mode of another axis at runtime, so a static TypeScript export cannot represent them without silently picking one cell of the matrix. The two family files are the only TS surface — everything you need to compose a style lives on a single size cell within them.
148
164
 
149
165
  ## Output Formats
150
166
 
151
167
  | Format | Import path | Use case |
152
168
  |--------|-------------|----------|
153
169
  | **CSS variables** | `@equinor/eds-tokens/css/variables` | Standard web styling via data attributes |
154
- | **TypeScript (nested)** | `@equinor/eds-tokens/ts/typography/*` | Type-safe access with autocomplete |
170
+ | **TypeScript matrix** | `@equinor/eds-tokens/ts/typography/font-family-{ui,header}` | Direct matrix access for non-CSS consumers (RN, SSR, design tooling) |
155
171
 
156
172
  ## Best Practices
157
173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-tokens",
3
- "version": "2.3.0-beta.2",
3
+ "version": "2.3.0",
4
4
  "description": "Design tokens for the Equinor Design System",
5
5
  "type": "module",
6
6
  "exports": {
@@ -45,15 +45,44 @@
45
45
  "tokens.css",
46
46
  "elements.css"
47
47
  ],
48
+ "keywords": [
49
+ "eds",
50
+ "design system",
51
+ "equinor",
52
+ "design tokens"
53
+ ],
54
+ "devDependencies": {
55
+ "@rollup/plugin-babel": "^7.0.0",
56
+ "@rollup/plugin-commonjs": "^29.0.2",
57
+ "@rollup/plugin-node-resolve": "^16.0.3",
58
+ "@types/node": "^25.5.2",
59
+ "copyfiles": "^2.4.1",
60
+ "lightningcss-cli": "^1.32.0",
61
+ "prettier": "3.8.3",
62
+ "rimraf": "^6.1.3",
63
+ "rollup": "^4.60.3",
64
+ "rollup-plugin-delete": "^3.0.2",
65
+ "style-dictionary": "^5.4.0",
66
+ "style-dictionary-utils": "^6.0.1",
67
+ "typescript": "^5.9.3",
68
+ "vite": "^8.0.10",
69
+ "vitest": "^4.1.5",
70
+ "@equinor/eds-color-palette-generator": "^0.1.0",
71
+ "@equinor/eds-tokens-build": "^1.1.0",
72
+ "@equinor/eds-tokens-sync": "^1.0.0"
73
+ },
48
74
  "scripts": {
49
75
  "build": "rollup -c && pnpm run types",
50
76
  "dev": "rollup -c -w",
51
77
  "types": "tsc",
78
+ "test": "vitest run",
79
+ "test:watch": "vitest",
52
80
  "prettier:check": "prettier --check src/",
53
81
  "build:variables:color-scheme": "build-color-scheme-variables",
54
82
  "build:variables:semantic:static": "build-semantic-static-variables",
55
83
  "build:variables:semantic:dynamic": "build-semantic-dynamic-variables",
56
84
  "build:variables:elevation": "build-elevation-variables",
85
+ "_build:css:dark-scope": "build-dark-scope",
57
86
  "build:variables:color": "pnpm run build:variables:color-scheme && pnpm run build:variables:semantic:static && pnpm run build:variables:semantic:dynamic",
58
87
  "generate:tokens:color-core": "generate-colors palette-config.json tokens/GnovDpL3UV6X51Ot7Kv6Im",
59
88
  "generate:tokens:color-scheme": "generate-color-scheme-tokens",
@@ -66,7 +95,8 @@
66
95
  "_prebuild:css-copy-index": "copyfiles ./src/css/*.css ./build/css --flat",
67
96
  "_build:css:variables": "lightningcss --bundle ./build/css/index-variables.css -o ./build/css/variables.css",
68
97
  "_build:css-min-variables": "lightningcss --minify ./build/css/variables.css -o ./build/css/variables.min.css",
69
- "_build:css": "pnpm run _prebuild:css-copy-index && pnpm run _build:css:variables && pnpm run build:variables:elevation && pnpm run _build:css-min-variables",
98
+ "_build:css:assert-no-light-dark": "node scripts/assert-no-light-dark.mjs",
99
+ "_build:css": "pnpm run _prebuild:css-copy-index && pnpm run _build:css:variables && pnpm run build:variables:elevation && pnpm run _build:css:dark-scope && pnpm run _build:css-min-variables && pnpm run _build:css:assert-no-light-dark",
70
100
  "clean": "rimraf build",
71
101
  "build:variables": "pnpm run clean && pnpm run build:variables:typography-and-spacing && pnpm run build:variables:color && pnpm run _build:css",
72
102
  "update-tokens:spacing-primitives": "sync-figma-to-tokens --file-key cpNchKjiIM19dPqTxE0fqg",
@@ -81,30 +111,5 @@
81
111
  "update-figma:color-dynamic": "sync-tokens-to-figma --file-key nyPaQ3QnI1UAcxKW4a0d2c",
82
112
  "update-tokens": "pnpm run update-tokens:foundations && pnpm run update-tokens:color-static && pnpm run update-tokens:color-dynamic && pnpm run update-tokens:spacing-primitives && pnpm run update-tokens:spacing-modes",
83
113
  "update-figma": "pnpm run update-figma:foundations && pnpm run update-figma:color-static && pnpm run update-figma:color-dynamic && pnpm run update-figma:spacing-primitives && pnpm run update-figma:spacing-modes"
84
- },
85
- "keywords": [
86
- "eds",
87
- "design system",
88
- "equinor",
89
- "design tokens"
90
- ],
91
- "devDependencies": {
92
- "@equinor/eds-color-palette-generator": "workspace:^",
93
- "@equinor/eds-tokens-build": "workspace:^",
94
- "@equinor/eds-tokens-sync": "workspace:^",
95
- "@rollup/plugin-babel": "^7.0.0",
96
- "@rollup/plugin-commonjs": "^29.0.2",
97
- "@rollup/plugin-node-resolve": "^16.0.3",
98
- "@types/node": "^25.5.2",
99
- "copyfiles": "^2.4.1",
100
- "lightningcss-cli": "^1.32.0",
101
- "prettier": "3.8.3",
102
- "rimraf": "^6.1.3",
103
- "rollup": "^4.60.1",
104
- "rollup-plugin-delete": "^3.0.2",
105
- "style-dictionary": "^5.4.0",
106
- "style-dictionary-utils": "^6.0.1",
107
- "typescript": "^5.9.3",
108
- "vite": "^8.0.8"
109
114
  }
110
- }
115
+ }
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: '2xl',
7
- typography: {
8
- fontSize: 21,
9
- lineHeightDefault: 28,
10
- lineHeightSquished: 24,
11
- iconSize: 32,
12
- gapHorizontal: 13,
13
- gapVertical: 13,
14
- trackingTight: -2.309999942779541,
15
- trackingNormal: 0,
16
- trackingWide: 2.309999942779541,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: '3xl',
7
- typography: {
8
- fontSize: 24.5,
9
- lineHeightDefault: 32,
10
- lineHeightSquished: 28,
11
- iconSize: 37,
12
- gapHorizontal: 15,
13
- gapVertical: 15,
14
- trackingTight: -2.694999933242798,
15
- trackingNormal: 0,
16
- trackingWide: 2.694999933242798,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: '4xl',
7
- typography: {
8
- fontSize: 28,
9
- lineHeightDefault: 32,
10
- lineHeightSquished: 28,
11
- iconSize: 42,
12
- gapHorizontal: 17.5,
13
- gapVertical: 17.5,
14
- trackingTight: -3.0799999237060547,
15
- trackingNormal: 0,
16
- trackingWide: 3.0799999237060547,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: '5xl',
7
- typography: {
8
- fontSize: 32,
9
- lineHeightDefault: 36,
10
- lineHeightSquished: 32,
11
- iconSize: 48,
12
- gapHorizontal: 20,
13
- gapVertical: 20,
14
- trackingTight: -3.5199999809265137,
15
- trackingNormal: 0,
16
- trackingWide: 300,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: '6xl',
7
- typography: {
8
- fontSize: 37,
9
- lineHeightDefault: 40,
10
- lineHeightSquished: 36,
11
- iconSize: 56,
12
- gapHorizontal: 23,
13
- gapVertical: 23,
14
- trackingTight: -4.070000171661377,
15
- trackingNormal: 0,
16
- trackingWide: 4.070000171661377,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: 'lg',
7
- typography: {
8
- fontSize: 16,
9
- lineHeightDefault: 24,
10
- lineHeightSquished: 20,
11
- iconSize: 24,
12
- gapHorizontal: 10,
13
- gapVertical: 10,
14
- trackingTight: -1.7599999904632568,
15
- trackingNormal: 0,
16
- trackingWide: 1.7599999904632568,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: 'md',
7
- typography: {
8
- fontSize: 14,
9
- lineHeightDefault: 20,
10
- lineHeightSquished: 16,
11
- iconSize: 20,
12
- gapHorizontal: 8.5,
13
- gapVertical: 8.5,
14
- trackingTight: -1.5399999618530273,
15
- trackingNormal: 0,
16
- trackingWide: 1.5399999618530273,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: 'sm',
7
- typography: {
8
- fontSize: 12,
9
- lineHeightDefault: 16,
10
- lineHeightSquished: 12,
11
- iconSize: 18,
12
- gapHorizontal: 7.5,
13
- gapVertical: 7.5,
14
- trackingTight: -1.3200000524520874,
15
- trackingNormal: 0,
16
- trackingWide: 1.3200000524520874,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: 'xl',
7
- typography: {
8
- fontSize: 18.5,
9
- lineHeightDefault: 24,
10
- lineHeightSquished: 20,
11
- iconSize: 28,
12
- gapHorizontal: 11.5,
13
- gapVertical: 11.5,
14
- trackingTight: -1.7599999904632568,
15
- trackingNormal: 0,
16
- trackingWide: 2.0350000858306885,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,21 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- documentation: 'xs',
7
- typography: {
8
- fontSize: 10.5,
9
- lineHeightDefault: 16,
10
- lineHeightSquished: 12,
11
- iconSize: 16,
12
- gapHorizontal: 6.5,
13
- gapVertical: 6.5,
14
- trackingTight: -1.149999976158142,
15
- trackingNormal: 0,
16
- trackingWide: 1.149999976158142,
17
- fontWeightLighter: 300,
18
- fontWeightNormal: 400,
19
- fontWeightBolder: 500,
20
- },
21
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- fontWeight: 500,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- fontWeight: 300,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- fontWeight: 400,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- lineHeight: 16,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- lineHeight: 12,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- tracking: 1.149999976158142,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- tracking: 0,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- tracking: -1.149999976158142,
8
- },
9
- } as const
@@ -1,9 +0,0 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
- export const typography = {
6
- typography: {
7
- tracking: 1.149999976158142,
8
- },
9
- } as const