@equinor/eds-tokens 2.3.0 → 2.3.2
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 +24 -6
- package/build/css/spacing/comfortable.css +26 -0
- package/build/css/spacing/spacious.css +26 -0
- package/build/css/variables.css +52 -0
- package/build/css/variables.min.css +1 -1
- package/build/ts/spacing/comfortable.ts +22 -0
- package/build/ts/spacing/spacious.ts +22 -0
- package/dist/esm/base/index.mjs +7 -0
- package/dist/tokens.cjs +7 -0
- package/dist/types/base/index.d.ts +7 -0
- package/dist/types/tokens/ts/color-scheme/dark.d.ts +117 -0
- package/dist/types/tokens/ts/color-scheme/light.d.ts +117 -0
- package/dist/types/tokens/ts/colors/default.d.ts +249 -0
- package/dist/types/tokens/ts/density/comfortable.d.ts +100 -0
- package/dist/types/tokens/ts/density/compact.d.ts +100 -0
- package/dist/types/tokens/ts/density/relaxed.d.ts +100 -0
- package/dist/types/tokens/ts/font/default.d.ts +16 -0
- package/dist/types/tokens/ts/primitives/default.d.ts +169 -0
- package/dist/types/tokens/ts/semantic/dark.d.ts +212 -0
- package/dist/types/tokens/ts/semantic/light.d.ts +212 -0
- package/instructions/typography.md +37 -5
- package/package.json +12 -10
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly — generated by scripts/generate-ts-tokens.mjs
|
|
3
|
+
* from the Tokens Studio DTCG + CSS exports.
|
|
4
|
+
*/
|
|
5
|
+
export declare const semantic: {
|
|
6
|
+
readonly background: {
|
|
7
|
+
readonly container: {
|
|
8
|
+
readonly canvas: {
|
|
9
|
+
readonly default: "#f8f8f8";
|
|
10
|
+
};
|
|
11
|
+
readonly card: {
|
|
12
|
+
readonly default: "#ffffff";
|
|
13
|
+
};
|
|
14
|
+
readonly popover: {
|
|
15
|
+
readonly default: "#ffffff";
|
|
16
|
+
readonly inverted: "#404040";
|
|
17
|
+
};
|
|
18
|
+
readonly sheet: {
|
|
19
|
+
readonly dialog: {
|
|
20
|
+
readonly default: "#ffffff";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly surface: {
|
|
25
|
+
readonly accent: {
|
|
26
|
+
readonly default: {
|
|
27
|
+
readonly default: "#cae4e7";
|
|
28
|
+
readonly hover: "#20565c";
|
|
29
|
+
readonly pressed: "#ffffff";
|
|
30
|
+
};
|
|
31
|
+
readonly selected: {
|
|
32
|
+
readonly default: "#a2cdd2";
|
|
33
|
+
readonly hover: "#87c0c6";
|
|
34
|
+
readonly pressed: "#6cb2b9";
|
|
35
|
+
};
|
|
36
|
+
readonly subtle: {
|
|
37
|
+
readonly default: "#ddeff1";
|
|
38
|
+
readonly hover: "#bbdbdf";
|
|
39
|
+
readonly pressed: "#87c0c6";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly default: {
|
|
43
|
+
readonly active: "#ebebeb";
|
|
44
|
+
readonly default: "#f8f8f8";
|
|
45
|
+
readonly disabled: "#f8f8f8";
|
|
46
|
+
readonly hover: "#ebebeb";
|
|
47
|
+
readonly muted: "#f8f8f8";
|
|
48
|
+
readonly pressed: "#e1e1e1";
|
|
49
|
+
readonly readOnly: "#f8f8f8";
|
|
50
|
+
readonly selected: {
|
|
51
|
+
readonly default: "#ddeff1";
|
|
52
|
+
readonly hover: "#cfe7e9";
|
|
53
|
+
readonly pressed: "#bbdbdf";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
readonly border: {
|
|
59
|
+
readonly default: "#d4d4d4";
|
|
60
|
+
readonly disabled: "#a4a4a4";
|
|
61
|
+
readonly emphasized: "#b4b4b4";
|
|
62
|
+
readonly focus: "#5cade5";
|
|
63
|
+
readonly hover: "#a4a4a4";
|
|
64
|
+
readonly selected: "#1e383a";
|
|
65
|
+
readonly subtle: "#ebebeb";
|
|
66
|
+
};
|
|
67
|
+
readonly cornerRadius: {
|
|
68
|
+
readonly none: 0;
|
|
69
|
+
readonly pill: 9999;
|
|
70
|
+
readonly rounded: 4;
|
|
71
|
+
readonly roundedOuter: 6;
|
|
72
|
+
};
|
|
73
|
+
readonly fontFamily: {
|
|
74
|
+
readonly header: "Equinor";
|
|
75
|
+
readonly ui: "Inter";
|
|
76
|
+
};
|
|
77
|
+
readonly fontWeight: {
|
|
78
|
+
readonly bolder: 500;
|
|
79
|
+
readonly lighter: 300;
|
|
80
|
+
readonly normal: 400;
|
|
81
|
+
};
|
|
82
|
+
readonly icon: {
|
|
83
|
+
readonly accent: "#1e383a";
|
|
84
|
+
readonly accentHover: "#cae4e7";
|
|
85
|
+
readonly accentPressed: "#ffffff";
|
|
86
|
+
readonly colorOnDark: "#dedede";
|
|
87
|
+
readonly colorOnLight: "#404040";
|
|
88
|
+
readonly disabled: "#c4c4c4";
|
|
89
|
+
readonly muted: "#a4a4a4";
|
|
90
|
+
readonly onAccent: "#dedede";
|
|
91
|
+
readonly primary: "#5b5b5b";
|
|
92
|
+
readonly secondary: "#868686";
|
|
93
|
+
};
|
|
94
|
+
readonly overlay: {
|
|
95
|
+
readonly scrim: "#1d1d1d1a";
|
|
96
|
+
};
|
|
97
|
+
readonly spacing: {
|
|
98
|
+
readonly twoXl: 28;
|
|
99
|
+
readonly twoXs: 6;
|
|
100
|
+
readonly threeXl: 32;
|
|
101
|
+
readonly threeXs: 4;
|
|
102
|
+
readonly fourXs: 2;
|
|
103
|
+
readonly lg: 20;
|
|
104
|
+
readonly md: 16;
|
|
105
|
+
readonly none: 0;
|
|
106
|
+
readonly sm: 12;
|
|
107
|
+
readonly xl: 24;
|
|
108
|
+
readonly xs: 8;
|
|
109
|
+
};
|
|
110
|
+
readonly status: {
|
|
111
|
+
readonly warning: {
|
|
112
|
+
readonly default: "#fff6f0";
|
|
113
|
+
readonly emphased: {
|
|
114
|
+
readonly default: "#c86a00";
|
|
115
|
+
readonly hover: "#753c00";
|
|
116
|
+
readonly selected: "#603204";
|
|
117
|
+
};
|
|
118
|
+
readonly hover: "#fbdac1";
|
|
119
|
+
readonly selected: "#f0b689";
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
readonly text: {
|
|
123
|
+
readonly accent: "#1d8fcf";
|
|
124
|
+
readonly colorOnDark: "#dedede";
|
|
125
|
+
readonly colorOnLight: "#404040";
|
|
126
|
+
readonly disabled: "#a4a4a4";
|
|
127
|
+
readonly muted: "#a4a4a4";
|
|
128
|
+
readonly onAccent: "#dedede";
|
|
129
|
+
readonly pressed: "#006192";
|
|
130
|
+
readonly primary: "#404040";
|
|
131
|
+
readonly secondary: "#868686";
|
|
132
|
+
readonly status: {
|
|
133
|
+
readonly onDark: "#ffffff";
|
|
134
|
+
readonly onLight: "#753c00";
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
readonly typography: {
|
|
138
|
+
readonly header: {
|
|
139
|
+
readonly twoXl: {
|
|
140
|
+
readonly fontSize: 24;
|
|
141
|
+
readonly lineHeight: 28;
|
|
142
|
+
};
|
|
143
|
+
readonly threeXl: {
|
|
144
|
+
readonly fontSize: 24;
|
|
145
|
+
readonly lineHeight: 32;
|
|
146
|
+
};
|
|
147
|
+
readonly fourXl: {
|
|
148
|
+
readonly fontSize: 32;
|
|
149
|
+
readonly lineHeight: 32;
|
|
150
|
+
};
|
|
151
|
+
readonly lg: {
|
|
152
|
+
readonly fontSize: 18;
|
|
153
|
+
readonly lineHeight: 24;
|
|
154
|
+
};
|
|
155
|
+
readonly md: {
|
|
156
|
+
readonly fontSize: 16;
|
|
157
|
+
readonly lineHeight: 20;
|
|
158
|
+
};
|
|
159
|
+
readonly sm: {
|
|
160
|
+
readonly fontSize: 14;
|
|
161
|
+
readonly lineHeight: 16;
|
|
162
|
+
};
|
|
163
|
+
readonly xl: {
|
|
164
|
+
readonly fontSize: 21;
|
|
165
|
+
readonly lineHeight: 24;
|
|
166
|
+
};
|
|
167
|
+
readonly xs: {
|
|
168
|
+
readonly fontSize: 12;
|
|
169
|
+
readonly lineHeight: 16;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
readonly ui: {
|
|
173
|
+
readonly twoXl: {
|
|
174
|
+
readonly fontSize: 21;
|
|
175
|
+
readonly lineHeight: 28;
|
|
176
|
+
};
|
|
177
|
+
readonly threeXl: {
|
|
178
|
+
readonly fontSize: 24;
|
|
179
|
+
readonly lineHeight: 32;
|
|
180
|
+
};
|
|
181
|
+
readonly fourXl: {
|
|
182
|
+
readonly fontSize: 28;
|
|
183
|
+
readonly lineHeight: 32;
|
|
184
|
+
};
|
|
185
|
+
readonly fiveXl: {
|
|
186
|
+
readonly fontSize: 32;
|
|
187
|
+
readonly lineHeight: 36;
|
|
188
|
+
};
|
|
189
|
+
readonly lg: {
|
|
190
|
+
readonly fontSize: 16;
|
|
191
|
+
readonly lineHeight: 24;
|
|
192
|
+
};
|
|
193
|
+
readonly md: {
|
|
194
|
+
readonly fontSize: 14;
|
|
195
|
+
readonly lineHeight: 20;
|
|
196
|
+
};
|
|
197
|
+
readonly sm: {
|
|
198
|
+
readonly fontSize: 12;
|
|
199
|
+
readonly lineHeight: 16;
|
|
200
|
+
};
|
|
201
|
+
readonly xl: {
|
|
202
|
+
readonly fontSize: 18;
|
|
203
|
+
readonly lineHeight: 24;
|
|
204
|
+
};
|
|
205
|
+
readonly xs: {
|
|
206
|
+
readonly fontSize: 10;
|
|
207
|
+
readonly lineHeight: 16;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
export type Semantic = typeof semantic;
|
|
@@ -4,11 +4,43 @@ applyTo: '**'
|
|
|
4
4
|
|
|
5
5
|
# Typography System
|
|
6
6
|
|
|
7
|
-
This guide introduces the EDS typography system -- how typographic properties are tokenised
|
|
7
|
+
This guide introduces the EDS typography system -- how typographic properties are tokenised and consumed in CSS and TypeScript.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
There are two ways to apply typography:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
1. **Static, per-element tokens (preferred for EDS 2.0 components in `/next`)** -- set `font-family`, `font-size`, and `line-height` directly in the component CSS using semantic tokens such as `--eds-typography-ui-body-md-font-size`. The size and family are part of the component's design; consumers do not switch them at runtime. See [Semantic typography tokens for component CSS](#semantic-typography-tokens-for-component-css).
|
|
12
|
+
|
|
13
|
+
2. **Runtime data-attribute switching** -- set `data-font-family` / `data-font-size` / `data-line-height` etc. on an element to flip the active typography axis at runtime. Useful for `elements.css` (semantic HTML defaults) and ad-hoc consumer markup, but not the default choice inside a component's own CSS. See [Runtime data-attribute switching](#runtime-data-attribute-switching).
|
|
14
|
+
|
|
15
|
+
If you are building a new component in `packages/eds-core-react/src/components/next/`, use approach 1. Approach 2 is documented for completeness and for cases where it is the right tool.
|
|
16
|
+
|
|
17
|
+
## Semantic typography tokens for component CSS
|
|
18
|
+
|
|
19
|
+
Components in `/next` use the per-size, per-role semantic tokens directly in their CSS:
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
.eds-button {
|
|
23
|
+
font-family: var(--eds-typography-ui-body-font-family);
|
|
24
|
+
font-size: var(--eds-typography-ui-body-md-font-size);
|
|
25
|
+
line-height: var(--eds-typography-ui-body-md-line-height-squished);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The token shape is `--eds-typography-{role}-{size}-{property}` where:
|
|
30
|
+
|
|
31
|
+
- **role**: `ui-body` (UI / body copy, Inter) or `header` (headings, Equinor typeface)
|
|
32
|
+
- **size**: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`
|
|
33
|
+
- **property**: `font-size`, `line-height-default`, `line-height-squished`, `font-weight-{lighter,normal,bolder}`
|
|
34
|
+
|
|
35
|
+
`font-family` is set once per role (`--eds-typography-{ui-body,header}-font-family`); it does not have a size segment.
|
|
36
|
+
|
|
37
|
+
Reach for these tokens whenever the component's typography is fixed by design -- which is the common case. Do not add `data-font-*` attributes to the component's own elements for this; the tokens above already encode the size + role combination.
|
|
38
|
+
|
|
39
|
+
For the underlying decision, including font-weight handling with `--_font-weight-{bolder,lighter}` for inline `strong`/`em` inheritance, see [ADR-0005: Typography approach for EDS 2.0](../../../documentation/adr/0005-typography-approach-for-eds-2.md).
|
|
40
|
+
|
|
41
|
+
## Runtime data-attribute switching
|
|
42
|
+
|
|
43
|
+
Typography in EDS is also broken into five independent axes. Each axis has its own set of generic CSS variables and can be switched at runtime using a `data-*` attribute. This is the mechanism that `elements.css` and other foundation-level styles use, and it is available for ad-hoc consumer markup.
|
|
12
44
|
|
|
13
45
|
| Axis | Data attribute | Modes |
|
|
14
46
|
|------|---------------|-------|
|
|
@@ -166,12 +198,12 @@ The other axis files (`font-weight-*`, `line-height-*`, `tracking-*`) and the pe
|
|
|
166
198
|
|
|
167
199
|
| Format | Import path | Use case |
|
|
168
200
|
|--------|-------------|----------|
|
|
169
|
-
| **CSS variables** | `@equinor/eds-tokens/css/variables` |
|
|
201
|
+
| **CSS variables** | `@equinor/eds-tokens/css/variables` | Component styling via per-role semantic tokens and runtime data-attribute switching |
|
|
170
202
|
| **TypeScript matrix** | `@equinor/eds-tokens/ts/typography/font-family-{ui,header}` | Direct matrix access for non-CSS consumers (RN, SSR, design tooling) |
|
|
171
203
|
|
|
172
204
|
## Best Practices
|
|
173
205
|
|
|
174
|
-
- **
|
|
206
|
+
- **Prefer per-role semantic tokens in component CSS** -- inside `/next` components, set `font-family`, `font-size`, and `line-height` directly with `--eds-typography-{role}-{size}-{property}` tokens; reach for `data-font-*` only for `elements.css` defaults and ad-hoc consumer markup
|
|
175
207
|
- **Scale together** -- Font size, icon size, and gap are designed to work as a unit
|
|
176
208
|
- **Combine axes freely** -- Each axis is independent; mix and match as needed
|
|
177
209
|
- **Test across sizes** -- Verify layouts work at all font size modes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/eds-tokens",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Design tokens for the Equinor Design System",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -52,24 +52,25 @@
|
|
|
52
52
|
"design tokens"
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@rollup/plugin-babel": "^7.
|
|
56
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
55
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
56
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
57
57
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
58
|
+
"@tokens-studio/studio-cli": "^0.1.7",
|
|
58
59
|
"@types/node": "^25.5.2",
|
|
59
60
|
"copyfiles": "^2.4.1",
|
|
60
61
|
"lightningcss-cli": "^1.32.0",
|
|
61
|
-
"prettier": "3.
|
|
62
|
+
"prettier": "3.9.5",
|
|
62
63
|
"rimraf": "^6.1.3",
|
|
63
|
-
"rollup": "^4.
|
|
64
|
+
"rollup": "^4.62.2",
|
|
64
65
|
"rollup-plugin-delete": "^3.0.2",
|
|
65
|
-
"style-dictionary": "^5.
|
|
66
|
+
"style-dictionary": "^5.5.0",
|
|
66
67
|
"style-dictionary-utils": "^6.0.1",
|
|
67
68
|
"typescript": "^5.9.3",
|
|
68
|
-
"vite": "^8.
|
|
69
|
-
"vitest": "^4.1.
|
|
70
|
-
"@equinor/eds-color-palette-generator": "^0.1.0",
|
|
69
|
+
"vite": "^8.1.4",
|
|
70
|
+
"vitest": "^4.1.10",
|
|
71
71
|
"@equinor/eds-tokens-build": "^1.1.0",
|
|
72
|
-
"@equinor/eds-tokens-sync": "^1.0.0"
|
|
72
|
+
"@equinor/eds-tokens-sync": "^1.0.0",
|
|
73
|
+
"@equinor/eds-color-palette-generator": "^0.1.0"
|
|
73
74
|
},
|
|
74
75
|
"scripts": {
|
|
75
76
|
"build": "rollup -c && pnpm run types",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"types": "tsc",
|
|
78
79
|
"test": "vitest run",
|
|
79
80
|
"test:watch": "vitest",
|
|
81
|
+
"generate:ts-tokens": "node scripts/generate-ts-tokens.mjs",
|
|
80
82
|
"prettier:check": "prettier --check src/",
|
|
81
83
|
"build:variables:color-scheme": "build-color-scheme-variables",
|
|
82
84
|
"build:variables:semantic:static": "build-semantic-static-variables",
|