@aziontech/theme 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +454 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1 +1,455 @@
1
1
  # @aziontech/theme
2
+
3
+ A comprehensive design token system and theming solution for Azion's web applications. This package provides primitive colors, semantic tokens, brand colors, and seamless integration with Tailwind CSS.
4
+
5
+ ## Features
6
+
7
+ - **Design Tokens**: Primitive and semantic color tokens generated from Figma
8
+ - **Brand Colors**: Azion's official color palette with primary (orange), accent (violet), and surface colors
9
+ - **Theme Support**: Built-in light and dark mode theming
10
+ - **Tailwind Integration**: Plugin and preset for seamless Tailwind CSS integration
11
+ - **CSS Variables**: Automatic CSS variable generation for dynamic theming
12
+ - **Widget Support**: Separate theme variant for embedded widgets
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @aziontech/theme
18
+ # or
19
+ pnpm add @aziontech/theme
20
+ # or
21
+ yarn add @aziontech/theme
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ### Option 1: CSS Import (Recommended for web applications)
27
+
28
+ Import the main theme stylesheet:
29
+
30
+ ```javascript
31
+ // Default theme (includes light/dark mode support)
32
+ import '@aziontech/theme';
33
+ ```
34
+
35
+ Add the theme class to your root element:
36
+
37
+ ```html
38
+ <div class="azion">
39
+ <!-- Your application content -->
40
+ </div>
41
+
42
+ <!-- For dark mode -->
43
+ <div class="azion azion-dark">
44
+ <!-- Your application content -->
45
+ </div>
46
+ ```
47
+
48
+ ### Option 2: Tailwind CSS Integration
49
+
50
+ #### Using the Preset
51
+
52
+ Add the preset to your `tailwind.config.js`:
53
+
54
+ ```javascript
55
+ import { preset } from '@aziontech/theme/tokens';
56
+
57
+ export default {
58
+ presets: [preset],
59
+ // your config
60
+ };
61
+ ```
62
+
63
+ #### Using the Plugin
64
+
65
+ For static utility classes with light/dark mode support:
66
+
67
+ ```javascript
68
+ import { tokenUtilities } from '@aziontech/theme/tokens';
69
+
70
+ export default {
71
+ plugins: [
72
+ tokenUtilities({
73
+ darkSelector: '.dark',
74
+ extraDarkSelectors: ['.azion.azion-dark']
75
+ })
76
+ ]
77
+ };
78
+ ```
79
+
80
+ ### Option 3: JavaScript Token Access
81
+
82
+ Access tokens programmatically:
83
+
84
+ ```javascript
85
+ // Import all tokens
86
+ import {
87
+ primitives,
88
+ brandPrimitives,
89
+ surfacePrimitives,
90
+ textSemantic,
91
+ backgroundSemantic,
92
+ borderSemantic
93
+ } from '@aziontech/theme/tokens';
94
+
95
+ // Use primitive colors
96
+ const primaryColor = primitives.orange['500']; // '#fe601f'
97
+ const accentColor = primitives.violet['500']; // '#8a84ec'
98
+
99
+ // Use semantic tokens (returns token references)
100
+ const textColor = textSemantic.light.textColorBase; // tokenRef('primitives.neutral.900')
101
+ ```
102
+
103
+ ### Option 4: CSS Variables Injection
104
+
105
+ Inject CSS variables dynamically at runtime:
106
+
107
+ ```javascript
108
+ import { injectCssVars } from '@aziontech/theme/tokens';
109
+
110
+ // Injects <style data-azion-tokens> into document.head
111
+ const styleElement = injectCssVars();
112
+ ```
113
+
114
+ ## Token Structure
115
+
116
+ ### Primitive Colors
117
+
118
+ Base color palettes with numeric scales (50-950):
119
+
120
+ ```javascript
121
+ import { primitives } from '@aziontech/theme/tokens';
122
+
123
+ primitives.orange['500']; // Primary brand color
124
+ primitives.violet['500']; // Accent brand color
125
+ primitives.neutral['900']; // Dark surfaces
126
+ primitives.neutral['50']; // Light surfaces
127
+ ```
128
+
129
+ Available primitives:
130
+ - `base`: White and black
131
+ - `orange`: Primary brand color (11 shades)
132
+ - `violet`: Accent brand color (11 shades)
133
+ - `neutral`: Gray scale for surfaces (11 shades)
134
+ - `gray`, `slate`: Additional gray variants
135
+ - `red`: Semantic danger color
136
+ - `green`: Semantic success color
137
+ - `yellow`: Semantic warning color
138
+ - `blue`: Link colors
139
+
140
+ ### Brand Primitives
141
+
142
+ Azion-specific brand colors:
143
+
144
+ ```javascript
145
+ import { brandPrimitives } from '@aziontech/theme/tokens';
146
+
147
+ brandPrimitives.primary['500']; // Orange brand color
148
+ brandPrimitives.accent['500']; // Violet accent color
149
+ brandPrimitives.absolute.white; // Pure white
150
+ brandPrimitives.absolute.black; // Pure black
151
+ ```
152
+
153
+ ### Surface Primitives
154
+
155
+ Surface color scales for backgrounds:
156
+
157
+ ```javascript
158
+ import { surfacePrimitives } from '@aziontech/theme/tokens';
159
+
160
+ surfacePrimitives.surface['0']; // White
161
+ surfacePrimitives.surface['50']; // Lightest gray
162
+ surfacePrimitives.surface['900']; // Very dark gray
163
+ surfacePrimitives.surface['950']; // Almost black
164
+ ```
165
+
166
+ ### Semantic Tokens
167
+
168
+ Context-aware tokens that automatically adapt to light/dark themes:
169
+
170
+ #### Background Tokens
171
+
172
+ ```javascript
173
+ import { backgroundSemantic } from '@aziontech/theme/tokens';
174
+
175
+ // Light mode
176
+ backgroundSemantic.light.bgLayer1; // Surface 0 (white)
177
+ backgroundSemantic.light.bgLayer2; // Surface 50
178
+ backgroundSemantic.light.bgCanvas; // Surface 100
179
+
180
+ // Dark mode
181
+ backgroundSemantic.dark.bgLayer1; // Surface 800
182
+ backgroundSemantic.dark.bgCanvas; // Surface 950
183
+ ```
184
+
185
+ #### Text Tokens
186
+
187
+ ```javascript
188
+ import { textSemantic } from '@aziontech/theme/tokens';
189
+
190
+ // Light mode
191
+ textSemantic.light.textColorBase; // neutral.900
192
+ textSemantic.light.textColorMuted; // neutral.600
193
+ textSemantic.light.textColorLink; // blue.600
194
+
195
+ // Dark mode
196
+ textSemantic.dark.textColorBase; // neutral.50
197
+ textSemantic.dark.textColorMuted; // neutral.400
198
+ textSemantic.dark.textColorLink; // blue.300
199
+ ```
200
+
201
+ #### Border Tokens
202
+
203
+ ```javascript
204
+ import { borderSemantic } from '@aziontech/theme/tokens';
205
+
206
+ borderSemantic.light.borderBase; // surface.200
207
+ borderSemantic.light.borderPrimary; // primary.500
208
+ borderSemantic.light.borderDanger; // red.600
209
+
210
+ borderSemantic.dark.borderBase; // surface.700
211
+ borderSemantic.dark.borderDanger; // red.400
212
+ ```
213
+
214
+ ## Theming
215
+
216
+ ### Light Mode (Default)
217
+
218
+ ```html
219
+ <div class="azion azion-light">
220
+ <!-- Light theme content -->
221
+ </div>
222
+ ```
223
+
224
+ ### Dark Mode
225
+
226
+ ```html
227
+ <div class="azion azion-dark">
228
+ <!-- Dark theme content -->
229
+ </div>
230
+ ```
231
+
232
+ Or use the standard Tailwind dark mode class:
233
+
234
+ ```html
235
+ <div class="azion dark">
236
+ <!-- Dark theme content -->
237
+ </div>
238
+ ```
239
+
240
+ ### Dynamic Theme Switching
241
+
242
+ ```javascript
243
+ // Toggle dark mode
244
+ const root = document.querySelector('.azion');
245
+ root.classList.toggle('azion-dark');
246
+ root.classList.toggle('azion-light');
247
+ ```
248
+
249
+ ## Tailwind CSS Usage
250
+
251
+ ### With Preset (Dynamic CSS Variables)
252
+
253
+ ```html
254
+ <!-- Background colors -->
255
+ <div class="bg-layer1">Layer 1 background</div>
256
+ <div class="bg-canvas">Canvas background</div>
257
+ <div class="bg-base">Base background</div>
258
+
259
+ <!-- Text colors -->
260
+ <p class="text-base">Base text</p>
261
+ <p class="text-muted">Muted text</p>
262
+ <a class="text-link">Link text</a>
263
+
264
+ <!-- Border colors -->
265
+ <div class="border border-base">Default border</div>
266
+ <div class="border border-primary">Primary border</div>
267
+ ```
268
+
269
+ ### With Plugin (Static Utilities)
270
+
271
+ When using the `tokenUtilities` plugin:
272
+
273
+ ```html
274
+ <!-- These generate static values for both light and dark -->
275
+ <div class="bg-layer1">Light: white / Dark: surface-800</div>
276
+ <div class="text-base">Light: neutral-900 / Dark: neutral-50</div>
277
+ ```
278
+
279
+ ### Complete Tailwind Config Example
280
+
281
+ ```javascript
282
+ import { preset, tokenUtilities } from '@aziontech/theme/tokens';
283
+
284
+ export default {
285
+ content: ['./src/**/*.{js,ts,jsx,tsx}'],
286
+ presets: [preset],
287
+ darkMode: 'class',
288
+ plugins: [
289
+ tokenUtilities({
290
+ darkSelector: '.dark',
291
+ extraDarkSelectors: ['.azion.azion-dark']
292
+ })
293
+ ]
294
+ };
295
+ ```
296
+
297
+ ## CSS Variables
298
+
299
+ All semantic tokens are available as CSS variables:
300
+
301
+ ```css
302
+ /* Automatically generated */
303
+ :root, [data-theme=light], .azion.azion-light {
304
+ --text-textColorBase: #171717;
305
+ --background-bgLayer1: #ffffff;
306
+ --border-borderBase: #e5e5e5;
307
+ }
308
+
309
+ [data-theme=dark], .dark, .azion.azion-dark {
310
+ --text-textColorBase: #fafafa;
311
+ --background-bgLayer1: #262626;
312
+ --border-borderBase: #404040;
313
+ }
314
+ ```
315
+
316
+ Use in your CSS:
317
+
318
+ ```css
319
+ .custom-component {
320
+ color: var(--text-textColorBase);
321
+ background-color: var(--background-bgLayer1);
322
+ border-color: var(--border-borderBase);
323
+ }
324
+ ```
325
+
326
+ ## Widget Theme
327
+
328
+ For embedded widgets and iframes, use the widget theme variant:
329
+
330
+ ```javascript
331
+ import '@aziontech/theme/widget';
332
+ ```
333
+
334
+ The widget theme includes:
335
+ - Compact variable definitions
336
+ - Optimized for isolated contexts
337
+ - Same token structure as main theme
338
+
339
+ ## API Reference
340
+
341
+ ### Exports
342
+
343
+ #### Default Export
344
+ - `@aziontech/theme` - Main CSS theme (default.js)
345
+ - `@aziontech/theme/widget` - Widget CSS theme (widget.js)
346
+ - `@aziontech/theme/tokens` - JavaScript token system (src/tokens/index.js)
347
+
348
+ #### Token Exports
349
+
350
+ ```javascript
351
+ // Primitive tokens
352
+ export { primitives } from './primitives/colors.js';
353
+ export { brandPrimitives, surfacePrimitives } from './primitives/brand.js';
354
+
355
+ // Semantic tokens
356
+ export { textSemantic } from './semantic/text.js';
357
+ export { backgroundSemantic } from './semantic/backgrounds.js';
358
+ export { borderSemantic } from './semantic/borders.js';
359
+
360
+ // Build utilities
361
+ export { tokenRef } from './build/refs.js';
362
+ export { resolveRefsToCssVars } from './build/resolve.js';
363
+ export { createCssVars, cssVarsString, injectCssVars } from './build/css-vars.js';
364
+ export { preset } from './build/preset.js';
365
+ export { tokenUtilities } from './build/tailwind-plugin.js';
366
+ ```
367
+
368
+ ## Token Resolution
369
+
370
+ Tokens use a reference system for maintainability:
371
+
372
+ ```javascript
373
+ // Define token reference
374
+ const textColor = tokenRef('primitives.neutral.900');
375
+
376
+ // Resolve to actual value
377
+ resolveRefsToCssVars({
378
+ primitives,
379
+ textSemantic
380
+ });
381
+ // Output: { '--text-textColorBase': '#171717' }
382
+ ```
383
+
384
+ ## Development
385
+
386
+ ### Prerequisites
387
+
388
+ - Node.js (LTS version)
389
+ - pnpm (v9+)
390
+
391
+ ### Scripts
392
+
393
+ ```bash
394
+ # Format code
395
+ pnpm format
396
+
397
+ # Dry-run package
398
+ pnpm pack:dry
399
+
400
+ # Publish (requires dist build)
401
+ pnpm publish
402
+ ```
403
+
404
+ ### Project Structure
405
+
406
+ ```
407
+ packages/theme/
408
+ ├── default.js # Main entry point
409
+ ├── widget.js # Widget entry point
410
+ ├── src/
411
+ │ ├── azion/ # CSS theme files
412
+ │ │ ├── theme.scss # Main theme
413
+ │ │ ├── theme-widget.scss
414
+ │ │ ├── _variables.scss
415
+ │ │ ├── _fonts.scss
416
+ │ │ ├── theme-base/ # Base components
417
+ │ │ ├── extended-components/
418
+ │ │ └── custom/
419
+ │ └── tokens/ # JavaScript tokens
420
+ │ ├── index.js # Public API
421
+ │ ├── primitives/ # Base colors
422
+ │ ├── semantic/ # Context-aware tokens
423
+ │ └── build/ # Build utilities
424
+ │ ├── preset.js
425
+ │ ├── css-vars.js
426
+ │ └── tailwind-plugin.js
427
+ └── package.json
428
+ ```
429
+
430
+ ## Browser Support
431
+
432
+ - Modern browsers with CSS Variables support
433
+ - Chrome, Firefox, Safari, Edge (latest versions)
434
+
435
+ ## Versioning
436
+
437
+ This package follows [Semantic Versioning](https://semver.org/). Version numbers are automatically managed via semantic-release.
438
+
439
+ ## Contributing
440
+
441
+ This package is part of the Azion WebKit monorepo. Please see the main repository for contribution guidelines.
442
+
443
+ ## License
444
+
445
+ MIT © Azion Technologies
446
+
447
+ ## Links
448
+
449
+ - [GitHub Repository](https://github.com/aziontech/webkit)
450
+ - [NPM Package](https://www.npmjs.com/package/@aziontech/theme)
451
+ - [Issue Tracker](https://github.com/aziontech/webkit/issues)
452
+
453
+ ## Changelog
454
+
455
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aziontech/theme",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "author": "aziontech",
6
6
  "license": "MIT",
7
7
  "repository": {