@nswds/tokens 2.25.5 → 2.26.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/README.md CHANGED
@@ -0,0 +1,177 @@
1
+ # nswds-tokens
2
+
3
+ Design tokens for the NSW Design System – a single source of truth for colour, typography, spacing, radii, breakpoints and more.
4
+
5
+ These tokens are used to keep NSW digital products visually consistent, accessible and easy to maintain.
6
+
7
+ > ℹ️ **Note:** Update package names, file paths and script names below to match this repo’s actual setup.
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - 🎨 Centralised colour system (including Aboriginal and NSW palettes)
14
+ - ✏️ Typography scales and font stacks
15
+ - 📏 Spacing, sizing and layout tokens
16
+ - 🧱 Border radius, shadows and other UI primitives
17
+ - 🌗 Theme-aware tokens for different NSW themes
18
+ - 🧩 Ready to consume from CSS, Sass, JavaScript/TypeScript or build tools
19
+
20
+ ---
21
+
22
+ ## Installation
23
+
24
+ Install via your package manager (replace the package name if different):
25
+
26
+ ```bash
27
+ npm install @digitalnsw/nswds-tokens
28
+ # or
29
+ yarn add @digitalnsw/nswds-tokens
30
+ # or
31
+ pnpm add @digitalnsw/nswds-tokens
32
+ ```
33
+
34
+ If you are using this repo locally (e.g. via workspace):
35
+
36
+ ```bash
37
+ npm install
38
+ # or yarn / pnpm install
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Using the tokens
44
+
45
+ There are a few common ways to consume the tokens. Adjust paths to match your `dist/` structure.
46
+
47
+ ### 1. CSS custom properties
48
+
49
+ ```css
50
+ @import '@digitalnsw/nswds-tokens/dist/tokens.css';
51
+
52
+ .my-button {
53
+ background-color: var(--nsw-color-primary);
54
+ color: var(--nsw-color-text-on-primary);
55
+ padding: var(--nsw-space-3);
56
+ border-radius: var(--nsw-radius-md);
57
+ }
58
+ ```
59
+
60
+ ### 1a. Prism CSS (standalone)
61
+
62
+ ```css
63
+ @import '@nswds/tokens/prism.css';
64
+ ```
65
+
66
+ Or via JS/TS (for bundlers that support CSS imports):
67
+
68
+ ```ts
69
+ import '@nswds/tokens/prism.css';
70
+ ```
71
+
72
+ The full path is also available:
73
+
74
+ ```css
75
+ @import '@nswds/tokens/css/prism/prism.css';
76
+ ```
77
+
78
+ ### 2. Sass / SCSS variables or maps
79
+
80
+ ```scss
81
+ @use '@digitalnsw/nswds-tokens/dist/tokens' as nsw;
82
+
83
+ .page-heading {
84
+ font-family: nsw.$font-family-sans;
85
+ font-size: nsw.$font-size-xxl;
86
+ margin-bottom: nsw.$space-4;
87
+ }
88
+ ```
89
+
90
+ ### 3. JavaScript / TypeScript
91
+
92
+ ```ts
93
+ import tokens from '@digitalnsw/nswds-tokens/dist/tokens.json'
94
+
95
+ console.log(tokens.color['nsw-blue-500'])
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Token structure
101
+
102
+ Tokens are organised into logical groups such as:
103
+
104
+ - `color`
105
+ - `font`
106
+ - `fontSize`, `fontWeight`, `lineHeight`
107
+ - `space`
108
+ - `radius`
109
+ - `shadow`
110
+ - `border`
111
+ - `breakpoint`
112
+ - `motion`
113
+ - `theme`
114
+
115
+ ---
116
+
117
+ ## Theming
118
+
119
+ Token sets support multiple NSW themes via **alias tokens** mapping to base tokens.
120
+
121
+ Example:
122
+
123
+ ```json
124
+ {
125
+ "theme": {
126
+ "light": {
127
+ "background": { "value": "{color.nsw-grey-050}" },
128
+ "text": { "value": "{color.nsw-grey-900}" }
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Local development
137
+
138
+ ```bash
139
+ git clone https://github.com/digitalnsw/nswds-tokens.git
140
+ cd nswds-tokens
141
+ npm install
142
+ ```
143
+
144
+ Build:
145
+
146
+ ```bash
147
+ npm run build
148
+ npm run dev
149
+ npm test
150
+ npm run lint
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Versioning & releases
156
+
157
+ Semantic versioning:
158
+
159
+ - **Major** for breaking changes.
160
+ - **Minor** for additive changes.
161
+ - **Patch** for fixes.
162
+
163
+ ---
164
+
165
+ ## Contributing
166
+
167
+ 1. Create a feature branch
168
+ 2. Make changes
169
+ 3. Update tests
170
+ 4. Run build
171
+ 5. Open a PR
172
+
173
+ ---
174
+
175
+ ## License
176
+
177
+ MIT License. See [`LICENSE`](./LICENSE).