@equinor/eds-tokens 2.2.0 → 2.3.0-beta.1
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 +11 -1
- package/build/css/color/color-scheme/dark-semantic-trimmed.css +8 -0
- package/build/css/color/color-scheme/light-semantic-trimmed.css +8 -0
- package/build/css/color/static/semantic-verbose.css +8 -0
- package/build/css/color/static/variables.css +8 -0
- package/build/js/color/color-scheme/dark-semantic.d.ts +8 -0
- package/build/js/color/color-scheme/dark-semantic.js +8 -0
- package/build/js/color/color-scheme/light-semantic.d.ts +8 -0
- package/build/js/color/color-scheme/light-semantic.js +8 -0
- package/build/js/color/static/semantic.d.ts +8 -0
- package/build/js/color/static/semantic.js +8 -0
- package/build/js/spacing/comfortable.d.ts +0 -1
- package/build/js/spacing/comfortable.js +0 -1
- package/build/js/spacing/spacious.d.ts +0 -1
- package/build/js/spacing/spacious.js +0 -1
- package/build/json/color/color-scheme/flat/dark-semantic.json +9 -1
- package/build/json/color/color-scheme/flat/light-semantic.json +9 -1
- package/build/json/color/color-scheme/nested/dark-semantic.json +11 -3
- package/build/json/color/color-scheme/nested/light-semantic.json +11 -3
- package/build/json/color/static/flat/semantic.json +9 -1
- package/build/json/color/static/nested/semantic.json +11 -3
- package/build/ts/color/color-scheme/dark-color-scheme.ts +116 -0
- package/build/ts/color/color-scheme/dark-semantic.ts +170 -0
- package/build/ts/color/color-scheme/light-color-scheme.ts +116 -0
- package/build/ts/color/color-scheme/light-semantic.ts +170 -0
- package/build/ts/color/static/semantic.ts +170 -0
- package/build/ts/spacing/comfortable.ts +558 -0
- package/build/ts/spacing/index.ts +6 -0
- package/build/ts/spacing/spacious.ts +558 -0
- package/build/ts/typography/font-family-header.ts +122 -0
- package/build/ts/typography/font-family-ui.ts +122 -0
- package/build/ts/typography/font-size-2xl.ts +21 -0
- package/build/ts/typography/font-size-3xl.ts +21 -0
- package/build/ts/typography/font-size-4xl.ts +21 -0
- package/build/ts/typography/font-size-5xl.ts +21 -0
- package/build/ts/typography/font-size-6xl.ts +21 -0
- package/build/ts/typography/font-size-lg.ts +21 -0
- package/build/ts/typography/font-size-md.ts +21 -0
- package/build/ts/typography/font-size-sm.ts +21 -0
- package/build/ts/typography/font-size-xl.ts +21 -0
- package/build/ts/typography/font-size-xs.ts +21 -0
- package/build/ts/typography/font-weight-bolder.ts +9 -0
- package/build/ts/typography/font-weight-lighter.ts +9 -0
- package/build/ts/typography/font-weight-normal.ts +9 -0
- package/build/ts/typography/line-height-default.ts +9 -0
- package/build/ts/typography/line-height-squished.ts +9 -0
- package/build/ts/typography/tracking-loose.ts +9 -0
- package/build/ts/typography/tracking-normal.ts +9 -0
- package/build/ts/typography/tracking-tight.ts +9 -0
- package/build/ts/typography/tracking-wide.ts +9 -0
- package/instructions/colors-dynamic.md +29 -0
- package/instructions/colors-static.md +78 -0
- package/instructions/colors.md +13 -0
- package/instructions/typography.md +161 -0
- package/package.json +12 -9
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Typography System
|
|
6
|
+
|
|
7
|
+
This guide introduces the EDS typography system -- how typographic properties are tokenised, controlled via data attributes, and consumed in CSS and TypeScript.
|
|
8
|
+
|
|
9
|
+
## Core Concepts
|
|
10
|
+
|
|
11
|
+
Typography in EDS is broken into five independent axes. Each axis has its own set of CSS variables and can be switched at runtime using a `data-*` attribute.
|
|
12
|
+
|
|
13
|
+
| Axis | Data attribute | Modes |
|
|
14
|
+
|------|---------------|-------|
|
|
15
|
+
| **Font family** | `data-font-family` | `header`, `ui` |
|
|
16
|
+
| **Font size** | `data-font-size` | `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl` |
|
|
17
|
+
| **Font weight** | `data-font-weight` | `lighter`, `normal`, `bolder` |
|
|
18
|
+
| **Line height** | `data-line-height` | `default`, `squished` |
|
|
19
|
+
| **Tracking** | `data-tracking` | `tight`, `normal`, `wide`, `loose` |
|
|
20
|
+
|
|
21
|
+
### How It Works
|
|
22
|
+
|
|
23
|
+
Each axis resolves to a single active CSS variable:
|
|
24
|
+
|
|
25
|
+
- `--eds-typography-font-family`
|
|
26
|
+
- `--eds-typography-font-size`
|
|
27
|
+
- `--eds-typography-font-weight`
|
|
28
|
+
- `--eds-typography-line-height`
|
|
29
|
+
- `--eds-typography-tracking`
|
|
30
|
+
|
|
31
|
+
The data attributes switch which underlying mode is mapped to these variables. Font size also sets companion variables for icon sizing and gap spacing that scale with the text.
|
|
32
|
+
|
|
33
|
+
## CSS Variables
|
|
34
|
+
|
|
35
|
+
### Import
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
@import '@equinor/eds-tokens/css/variables';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Usage
|
|
42
|
+
|
|
43
|
+
Apply data attributes to set the typographic context, then use the CSS variables in your styles:
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<div data-font-family="ui" data-font-size="md" data-font-weight="normal">
|
|
47
|
+
<p>Body text using UI font at medium size</p>
|
|
48
|
+
</div>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```css
|
|
52
|
+
.text {
|
|
53
|
+
font-family: var(--eds-typography-font-family);
|
|
54
|
+
font-size: calc(var(--eds-typography-font-size) * 1px);
|
|
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);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Companion Variables
|
|
62
|
+
|
|
63
|
+
When `data-font-size` is set, additional variables are resolved automatically:
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
.icon-next-to-text {
|
|
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);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Switching Modes
|
|
74
|
+
|
|
75
|
+
Change typographic properties by updating data attributes -- no CSS changes needed:
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- Heading context -->
|
|
79
|
+
<h2 data-font-family="header" data-font-size="2xl" data-font-weight="bolder">
|
|
80
|
+
Section Title
|
|
81
|
+
</h2>
|
|
82
|
+
|
|
83
|
+
<!-- Body context -->
|
|
84
|
+
<p data-font-family="ui" data-font-size="md" data-font-weight="normal">
|
|
85
|
+
Paragraph text
|
|
86
|
+
</p>
|
|
87
|
+
|
|
88
|
+
<!-- Caption context -->
|
|
89
|
+
<small data-font-family="ui" data-font-size="xs" data-tracking="wide">
|
|
90
|
+
Caption
|
|
91
|
+
</small>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## TypeScript Tokens
|
|
95
|
+
|
|
96
|
+
Typography tokens are available as nested TypeScript objects with `as const` for type safety.
|
|
97
|
+
|
|
98
|
+
### Import
|
|
99
|
+
|
|
100
|
+
```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'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Available Files
|
|
109
|
+
|
|
110
|
+
Each mode of each axis has its own file:
|
|
111
|
+
|
|
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` |
|
|
119
|
+
|
|
120
|
+
### Usage
|
|
121
|
+
|
|
122
|
+
```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'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { typography } from '@equinor/eds-tokens/ts/typography/font-family-header'
|
|
133
|
+
|
|
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
|
+
```
|
|
138
|
+
|
|
139
|
+
### Naming Conversion
|
|
140
|
+
|
|
141
|
+
CSS variable segments map to TypeScript object keys:
|
|
142
|
+
|
|
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` |
|
|
148
|
+
|
|
149
|
+
## Output Formats
|
|
150
|
+
|
|
151
|
+
| Format | Import path | Use case |
|
|
152
|
+
|--------|-------------|----------|
|
|
153
|
+
| **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 |
|
|
155
|
+
|
|
156
|
+
## Best Practices
|
|
157
|
+
|
|
158
|
+
- **Use data attributes** -- Let the token system resolve the right values rather than hardcoding
|
|
159
|
+
- **Scale together** -- Font size, icon size, and gap are designed to work as a unit
|
|
160
|
+
- **Combine axes freely** -- Each axis is independent; mix and match as needed
|
|
161
|
+
- **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
|
+
"version": "2.3.0-beta.1",
|
|
4
4
|
"description": "Design tokens for the Equinor Design System",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
"./css/variables.css": "./build/css/variables.min.css",
|
|
17
17
|
"./json/*/*": "./build/json/*/*.json",
|
|
18
18
|
"./js/color/*": "./build/js/color/*.js",
|
|
19
|
-
"./js/spacing/*": "./build/js/spacing/*.js"
|
|
19
|
+
"./js/spacing/*": "./build/js/spacing/*.js",
|
|
20
|
+
"./ts/color/*": "./build/ts/color/*.ts",
|
|
21
|
+
"./ts/spacing/*": "./build/ts/spacing/*.ts",
|
|
22
|
+
"./ts/typography/*": "./build/ts/typography/*.ts"
|
|
20
23
|
},
|
|
21
24
|
"types": "./dist/types/index.d.ts",
|
|
22
25
|
"main": "./dist/tokens.cjs",
|
|
@@ -50,22 +53,22 @@
|
|
|
50
53
|
],
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@rollup/plugin-babel": "^6.1.0",
|
|
53
|
-
"@rollup/plugin-commonjs": "^
|
|
56
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
54
57
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
55
|
-
"@types/node": "^25.
|
|
58
|
+
"@types/node": "^25.3.3",
|
|
56
59
|
"copyfiles": "^2.4.1",
|
|
57
60
|
"lightningcss-cli": "^1.31.1",
|
|
58
61
|
"prettier": "3.8.1",
|
|
59
|
-
"rimraf": "^6.1.
|
|
60
|
-
"rollup": "^4.
|
|
62
|
+
"rimraf": "^6.1.3",
|
|
63
|
+
"rollup": "^4.59.0",
|
|
61
64
|
"rollup-plugin-delete": "^3.0.2",
|
|
62
|
-
"style-dictionary": "^5.3.
|
|
65
|
+
"style-dictionary": "^5.3.2",
|
|
63
66
|
"style-dictionary-utils": "^4.1.0",
|
|
64
67
|
"typescript": "^5.9.3",
|
|
65
68
|
"vite": "^7.3.1",
|
|
69
|
+
"@equinor/eds-tokens-sync": "^1.0.0",
|
|
66
70
|
"@equinor/eds-color-palette-generator": "^0.1.0",
|
|
67
|
-
"@equinor/eds-tokens-build": "^1.1.0"
|
|
68
|
-
"@equinor/eds-tokens-sync": "^1.0.0"
|
|
71
|
+
"@equinor/eds-tokens-build": "^1.1.0"
|
|
69
72
|
},
|
|
70
73
|
"scripts": {
|
|
71
74
|
"build": "rollup -c && pnpm run types",
|