@gyldendal/kobber-tokens 1.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/LICENSE +1 -0
- package/README.md +219 -0
- package/dist/CHANGELOG.txt +1549 -0
- package/dist/k-tokens.css +1552 -0
- package/dist/tokens.css +1552 -0
- package/dist/tokens.d.ts +3361 -0
- package/dist/tokens.js +3360 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
UNLICENSED
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# @gyldendal/kobber-tokens
|
|
2
|
+
|
|
3
|
+
Gyldendal Kobber design tokens - CSS variables, JavaScript, and TypeScript definitions.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package provides design tokens in multiple formats (CSS, JavaScript, TypeScript) for use in Gyldendal applications.
|
|
8
|
+
|
|
9
|
+
**Key features:**
|
|
10
|
+
- **Design tokens** - CSS variables and JavaScript/TypeScript exports for colors, spacing, typography, etc.
|
|
11
|
+
- **Changelog** - Detailed changelog tracking all token changes (added, removed, changed values)
|
|
12
|
+
- **AI-friendly** - The changelog is designed to be read by AI assistants to help developers update their components when tokens change
|
|
13
|
+
|
|
14
|
+
When you upgrade to a new version, you can share the changelog with your AI assistant to get help updating your components to use the new token values or migrate away from removed tokens.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @gyldendal/kobber-tokens
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### CSS
|
|
25
|
+
|
|
26
|
+
Two CSS files are available with different prefixes:
|
|
27
|
+
|
|
28
|
+
#### Kobber tokens (for external consumers):
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@import "@gyldendal/kobber-tokens/tokens.css";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or in JavaScript/TypeScript:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
import "@gyldendal/kobber-tokens/tokens.css";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Then use the CSS custom properties with `--kobber-` prefix:
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
.my-component {
|
|
44
|
+
background-color: var(--kobber-component-button-background-color-brand-primary-tone-a);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### K tokens (for content templates use with short prefix):
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
@import "@gyldendal/kobber-tokens/k-tokens.css";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or in JavaScript/TypeScript:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import "@gyldendal/kobber-tokens/k-tokens.css";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then use the CSS custom properties with `--k-` prefix:
|
|
61
|
+
|
|
62
|
+
```css
|
|
63
|
+
.my-component {
|
|
64
|
+
background-color: var(--k-component-button-background-color-brand-primary-tone-a);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### JavaScript/TypeScript
|
|
69
|
+
|
|
70
|
+
Import tokens as JavaScript objects with full TypeScript support:
|
|
71
|
+
|
|
72
|
+
#### Named imports (recommended)
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { primitives, component, spacing } from "@gyldendal/kobber-tokens";
|
|
76
|
+
|
|
77
|
+
// Access tokens with autocomplete
|
|
78
|
+
const buttonColor = component.button.backgroundColor.brand.primary.toneA;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Namespace import (all tokens)
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import * as tokens from "@gyldendal/kobber-tokens";
|
|
85
|
+
|
|
86
|
+
// Access via namespace
|
|
87
|
+
const buttonColor = tokens.component.button.backgroundColor.brand.primary.toneA;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Changelog
|
|
91
|
+
|
|
92
|
+
Each version includes a `CHANGELOG.txt` file documenting all token changes:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import changelog from "@gyldendal/kobber-tokens/CHANGELOG.txt";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The changelog format:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
=== 17.12.2025, 14:30:45 [a1b2c3d4] - MINOR - npm: vX.Y.Z ===
|
|
102
|
+
|
|
103
|
+
ADDED
|
|
104
|
+
--kobber-component-new-token
|
|
105
|
+
|
|
106
|
+
REMOVED
|
|
107
|
+
--kobber-component-old-token
|
|
108
|
+
|
|
109
|
+
CHANGED
|
|
110
|
+
--kobber-component-changed-token|oldValue|newValue
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Header format:**
|
|
114
|
+
- Timestamp in Norwegian format
|
|
115
|
+
- `[hash]` - Short hash of the changes (for duplicate detection)
|
|
116
|
+
- `MAJOR/MINOR/PATCH` - Recommended version bump type
|
|
117
|
+
- `npm: vX.Y.Z` - Placeholder for npm version (replace manually before publishing)
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
### Prerequisites
|
|
122
|
+
|
|
123
|
+
- Node.js >= 22.20.0 < 23
|
|
124
|
+
- npm
|
|
125
|
+
|
|
126
|
+
### Node.js Version Management
|
|
127
|
+
|
|
128
|
+
The `.nvmrc` file specifies the required Node.js version.
|
|
129
|
+
|
|
130
|
+
If you use [NVM (Node Version Manager)](https://github.com/nvm-sh/nvm), you can ensure you're using the correct version by running:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
nvm use
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
If you don't have the required version installed, install it with:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
nvm install
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Setup
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm install
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Build
|
|
149
|
+
|
|
150
|
+
Build tokens from Figma JSON:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm run build
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This will:
|
|
157
|
+
1. Generate `dist/tokens.css` (CSS custom properties with `--kobber-` prefix)
|
|
158
|
+
2. Generate `dist/k-tokens.css` (CSS custom properties with `--k-` prefix)
|
|
159
|
+
3. Generate `dist/tokens.js` (JavaScript/ESM)
|
|
160
|
+
4. Generate `dist/tokens.d.ts` (TypeScript definitions)
|
|
161
|
+
5. Generate `dist/CHANGELOG.txt` (changelog)
|
|
162
|
+
|
|
163
|
+
### Scripts
|
|
164
|
+
|
|
165
|
+
- `npm run build` - Build tokens and changelog
|
|
166
|
+
- `npm run build:tokens` - Build tokens only
|
|
167
|
+
- `npm run build:changelog` - Generate changelog only
|
|
168
|
+
- `npm run quality-check` - Run TypeScript type checking and Biome check (lint + format)
|
|
169
|
+
|
|
170
|
+
## Changelog
|
|
171
|
+
|
|
172
|
+
The `dist/CHANGELOG.txt` file automatically tracks **token changes only** (added, removed, or changed token values). It does not track other changes like build script updates, documentation, or bug fixes.
|
|
173
|
+
|
|
174
|
+
**Why?**
|
|
175
|
+
- Developers consuming this package care about token changes that might affect their UI
|
|
176
|
+
- Other changes (scripts, docs, etc.) are tracked in Git history and don't need to be in the changelog
|
|
177
|
+
- This keeps the changelog focused and useful for version upgrade decisions
|
|
178
|
+
|
|
179
|
+
If you publish a new version without token changes (e.g., fixing a build script bug), you don't need to update the changelog.
|
|
180
|
+
|
|
181
|
+
### Workflow
|
|
182
|
+
|
|
183
|
+
#### For UX Team (updating tokens)
|
|
184
|
+
|
|
185
|
+
1. Create a new branch: `git checkout -b tokens-update`
|
|
186
|
+
2. Export `design-tokens.tokens.json` from Figma
|
|
187
|
+
3. Replace the file in project root
|
|
188
|
+
4. Commit and push: `git add . && git commit -m "feat: update tokens" && git push`
|
|
189
|
+
5. Create a Pull Request on GitHub
|
|
190
|
+
|
|
191
|
+
#### For Developers (publishing new version)
|
|
192
|
+
|
|
193
|
+
1. Merge the UX team's PR to `main`
|
|
194
|
+
2. Pull latest changes: `git checkout main && git pull`
|
|
195
|
+
3. Build tokens: `npm run build`
|
|
196
|
+
4. Check `dist/CHANGELOG.txt` for changes:
|
|
197
|
+
- If changelog was updated, note the change type (MAJOR/MINOR/PATCH)
|
|
198
|
+
- If no changes, you're done!
|
|
199
|
+
5. Update package version:
|
|
200
|
+
```bash
|
|
201
|
+
npm version patch --no-git-tag-version # or minor/major
|
|
202
|
+
```
|
|
203
|
+
6. Edit `dist/CHANGELOG.txt` and replace `vX.Y.Z` with actual new version:
|
|
204
|
+
```
|
|
205
|
+
=== 18.12.2025, 14:45:07 [abc12345] - MINOR - npm: v1.2.0 ===
|
|
206
|
+
```
|
|
207
|
+
7. Commit: `git add . && git commit -m "chore: release v1.2.0"`
|
|
208
|
+
8. Publish to npm: `npm publish`
|
|
209
|
+
9. Push to GitHub: `git push origin main`
|
|
210
|
+
|
|
211
|
+
#### Version Bump Guidelines
|
|
212
|
+
|
|
213
|
+
- **MAJOR**: Breaking changes (tokens removed - breaks existing code)
|
|
214
|
+
- **MINOR**: New features (tokens added - safe to upgrade)
|
|
215
|
+
- **PATCH**: Updates (token values changed - visual updates only)
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
UNLICENSED - Internal Gyldendal use only
|