@equinor/eds-tokens 2.2.0 → 2.3.0-beta.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.
Files changed (39) hide show
  1. package/README.md +11 -1
  2. package/build/js/spacing/comfortable.d.ts +0 -1
  3. package/build/js/spacing/comfortable.js +0 -1
  4. package/build/js/spacing/spacious.d.ts +0 -1
  5. package/build/js/spacing/spacious.js +0 -1
  6. package/build/ts/color/color-scheme/dark-color-scheme.ts +116 -0
  7. package/build/ts/color/color-scheme/dark-semantic.ts +162 -0
  8. package/build/ts/color/color-scheme/light-color-scheme.ts +116 -0
  9. package/build/ts/color/color-scheme/light-semantic.ts +162 -0
  10. package/build/ts/spacing/comfortable.ts +558 -0
  11. package/build/ts/spacing/index.ts +6 -0
  12. package/build/ts/spacing/spacious.ts +558 -0
  13. package/build/ts/typography/font-family-header.ts +122 -0
  14. package/build/ts/typography/font-family-ui.ts +122 -0
  15. package/build/ts/typography/font-size-2xl.ts +21 -0
  16. package/build/ts/typography/font-size-3xl.ts +21 -0
  17. package/build/ts/typography/font-size-4xl.ts +21 -0
  18. package/build/ts/typography/font-size-5xl.ts +21 -0
  19. package/build/ts/typography/font-size-6xl.ts +21 -0
  20. package/build/ts/typography/font-size-lg.ts +21 -0
  21. package/build/ts/typography/font-size-md.ts +21 -0
  22. package/build/ts/typography/font-size-sm.ts +21 -0
  23. package/build/ts/typography/font-size-xl.ts +21 -0
  24. package/build/ts/typography/font-size-xs.ts +21 -0
  25. package/build/ts/typography/font-weight-bolder.ts +9 -0
  26. package/build/ts/typography/font-weight-lighter.ts +9 -0
  27. package/build/ts/typography/font-weight-normal.ts +9 -0
  28. package/build/ts/typography/line-height-default.ts +9 -0
  29. package/build/ts/typography/line-height-squished.ts +9 -0
  30. package/build/ts/typography/tracking-loose.ts +9 -0
  31. package/build/ts/typography/tracking-normal.ts +9 -0
  32. package/build/ts/typography/tracking-tight.ts +9 -0
  33. package/build/ts/typography/tracking-wide.ts +9 -0
  34. package/instructions/colors-dynamic.md +29 -0
  35. package/instructions/colors-static.md +78 -0
  36. package/instructions/colors.md +13 -0
  37. package/instructions/typography.md +161 -0
  38. package/package.json +31 -28
  39. package/LICENSE +0 -21
@@ -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.2.0",
3
+ "version": "2.3.0-beta.0",
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",
@@ -42,31 +45,6 @@
42
45
  "tokens.css",
43
46
  "elements.css"
44
47
  ],
45
- "keywords": [
46
- "eds",
47
- "design system",
48
- "equinor",
49
- "design tokens"
50
- ],
51
- "devDependencies": {
52
- "@rollup/plugin-babel": "^6.1.0",
53
- "@rollup/plugin-commonjs": "^28.0.8",
54
- "@rollup/plugin-node-resolve": "^16.0.3",
55
- "@types/node": "^25.2.3",
56
- "copyfiles": "^2.4.1",
57
- "lightningcss-cli": "^1.31.1",
58
- "prettier": "3.8.1",
59
- "rimraf": "^6.1.2",
60
- "rollup": "^4.57.1",
61
- "rollup-plugin-delete": "^3.0.2",
62
- "style-dictionary": "^5.3.0",
63
- "style-dictionary-utils": "^4.1.0",
64
- "typescript": "^5.9.3",
65
- "vite": "^7.3.1",
66
- "@equinor/eds-color-palette-generator": "^0.1.0",
67
- "@equinor/eds-tokens-build": "^1.1.0",
68
- "@equinor/eds-tokens-sync": "^1.0.0"
69
- },
70
48
  "scripts": {
71
49
  "build": "rollup -c && pnpm run types",
72
50
  "dev": "rollup -c -w",
@@ -102,5 +80,30 @@
102
80
  "update-figma:color-dynamic": "sync-tokens-to-figma --file-key nyPaQ3QnI1UAcxKW4a0d2c",
103
81
  "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",
104
82
  "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"
83
+ },
84
+ "keywords": [
85
+ "eds",
86
+ "design system",
87
+ "equinor",
88
+ "design tokens"
89
+ ],
90
+ "devDependencies": {
91
+ "@equinor/eds-color-palette-generator": "workspace:^",
92
+ "@equinor/eds-tokens-build": "workspace:^",
93
+ "@equinor/eds-tokens-sync": "workspace:^",
94
+ "@rollup/plugin-babel": "^6.1.0",
95
+ "@rollup/plugin-commonjs": "^29.0.0",
96
+ "@rollup/plugin-node-resolve": "^16.0.3",
97
+ "@types/node": "^25.3.0",
98
+ "copyfiles": "^2.4.1",
99
+ "lightningcss-cli": "^1.31.1",
100
+ "prettier": "3.8.1",
101
+ "rimraf": "^6.1.3",
102
+ "rollup": "^4.59.0",
103
+ "rollup-plugin-delete": "^3.0.2",
104
+ "style-dictionary": "^5.3.2",
105
+ "style-dictionary-utils": "^4.1.0",
106
+ "typescript": "^5.9.3",
107
+ "vite": "^7.3.1"
105
108
  }
106
- }
109
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Equinor ASA
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.