@lifeonlars/prime-yggdrasil 0.1.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 +30 -0
- package/README.md +276 -0
- package/dist/foundations.css +180 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +11 -0
- package/dist/vite.svg +1 -0
- package/dist/yggdrasil-dark.css +12 -0
- package/dist/yggdrasil-light.css +12 -0
- package/docs/AI-AGENT-GUIDE.md +575 -0
- package/docs/CONSUMPTION-GUIDE.md +384 -0
- package/docs/ELEVATION-IMPLEMENTATION.md +146 -0
- package/docs/ELEVATION-SYSTEM.md +104 -0
- package/docs/NPM-PUBLISHING-GUIDE.md +337 -0
- package/docs/PACKAGING-CHECKLIST.md +193 -0
- package/docs/PRE-PUBLISH-CHECKLIST.md +136 -0
- package/docs/README.md +161 -0
- package/docs/archive/README.md +27 -0
- package/docs/archive/SEMANTIC-MIGRATION-PLAN.md +177 -0
- package/docs/archive/YGGDRASIL_THEME.md +264 -0
- package/docs/archive/agentic_policy.md +216 -0
- package/docs/contrast-report.md +9 -0
- package/docs/scripts/README.md +180 -0
- package/package.json +113 -0
package/docs/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Yggdrasil Theme Documentation
|
|
2
|
+
|
|
3
|
+
This directory contains comprehensive documentation for the Yggdrasil theme system built on PrimeReact.
|
|
4
|
+
|
|
5
|
+
## 📚 Documentation Index
|
|
6
|
+
|
|
7
|
+
### Theme Architecture
|
|
8
|
+
- **[Theme Architecture](../src/theme/README.md)** - Complete overview of the theme file structure, design tokens, and usage patterns
|
|
9
|
+
|
|
10
|
+
### Design System Implementation
|
|
11
|
+
- **[Elevation System](./ELEVATION-SYSTEM.md)** - Research and best practices for elevation/shadows in light and dark modes
|
|
12
|
+
- **[Elevation Implementation](./ELEVATION-IMPLEMENTATION.md)** - Implementation guide for the 4-level elevation system
|
|
13
|
+
- **[Contrast Report](./contrast-report.md)** - APCA contrast test results for all semantic color tokens
|
|
14
|
+
|
|
15
|
+
### Scripts Documentation
|
|
16
|
+
- **[Scripts Guide](./scripts/README.md)** - Documentation for all theme build and analysis scripts
|
|
17
|
+
|
|
18
|
+
## 🎨 Design Principles
|
|
19
|
+
|
|
20
|
+
### 4px Soft Grid
|
|
21
|
+
All spacing, padding, margins, and border-radius values follow a 4px grid:
|
|
22
|
+
- ✅ Valid: `4px`, `8px`, `12px`, `16px`, `20px`, `24px`
|
|
23
|
+
- ❌ Invalid: `5px`, `6px`, `10px`, `15px`
|
|
24
|
+
|
|
25
|
+
### Semantic Token Architecture
|
|
26
|
+
```
|
|
27
|
+
Foundation Colors (foundations.css)
|
|
28
|
+
↓
|
|
29
|
+
Border Radius Tokens (radius.css)
|
|
30
|
+
↓
|
|
31
|
+
Semantic Tokens (semantic-light.css / semantic-dark.css)
|
|
32
|
+
↓
|
|
33
|
+
Component Styles (components.css)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Design Token Hierarchy
|
|
37
|
+
|
|
38
|
+
1. **Foundation Colors** - Raw color values, never used directly
|
|
39
|
+
- Sky, Sea, Forest, Sand, Berries, Rock palettes
|
|
40
|
+
|
|
41
|
+
2. **Border Radius** - Following 4px grid
|
|
42
|
+
- `--radius-sm` (4px), `--radius-md` (8px), `--radius-lg` (12px)
|
|
43
|
+
- Component-specific: `--button-radius`, `--input-radius`
|
|
44
|
+
|
|
45
|
+
3. **Semantic Tokens** - Theme-aware, context-based
|
|
46
|
+
- Surfaces: `--surface-neutral-primary`, `--surface-brand-primary`
|
|
47
|
+
- Text: `--text-neutral-default`, `--text-onsurface-onbrand`
|
|
48
|
+
- Borders: `--border-neutral-default`, `--border-state-focus`
|
|
49
|
+
- Elevation: `--elevation-subtle`, `--elevation-moderate`
|
|
50
|
+
|
|
51
|
+
4. **Utility Classes** - Direct application in JSX
|
|
52
|
+
- Shadows: `.shadow-1`, `.shadow-2`, `.shadow-3`
|
|
53
|
+
- Border radius: `.border-round`, `.border-round-lg`
|
|
54
|
+
|
|
55
|
+
## 🛠️ Development Workflow
|
|
56
|
+
|
|
57
|
+
### For Component Development
|
|
58
|
+
1. Use semantic tokens exclusively (never foundation colors)
|
|
59
|
+
2. Follow 4px grid for all spacing/radius
|
|
60
|
+
3. Test in both light and dark modes
|
|
61
|
+
4. Run contrast tests for new color combinations
|
|
62
|
+
|
|
63
|
+
### For Theme Modifications
|
|
64
|
+
1. Update semantic tokens in `semantic-light.css` / `semantic-dark.css`
|
|
65
|
+
2. Regenerate analysis reports if needed
|
|
66
|
+
3. Test Storybook in both themes
|
|
67
|
+
4. Update documentation if architecture changes
|
|
68
|
+
|
|
69
|
+
## 📊 Testing & Validation
|
|
70
|
+
|
|
71
|
+
### Contrast Testing
|
|
72
|
+
```bash
|
|
73
|
+
node scripts/test-contrast.js
|
|
74
|
+
```
|
|
75
|
+
Tests all semantic color tokens against WCAG 3.0 (APCA) requirements.
|
|
76
|
+
|
|
77
|
+
### Theme Validation
|
|
78
|
+
```bash
|
|
79
|
+
node scripts/validate-themes.js
|
|
80
|
+
```
|
|
81
|
+
Validates theme structure and token consistency.
|
|
82
|
+
|
|
83
|
+
## 🔄 Regenerating Reports
|
|
84
|
+
|
|
85
|
+
Analysis reports are gitignored and can be regenerated:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Analyze hardcoded colors
|
|
89
|
+
node scripts/analyze-hardcoded-colors.js
|
|
90
|
+
|
|
91
|
+
# Audit foundation variable usage
|
|
92
|
+
node scripts/audit-foundation-usage.js
|
|
93
|
+
|
|
94
|
+
# Generate contrast report
|
|
95
|
+
node scripts/test-contrast.js > docs/contrast-report.md
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 📁 Project Structure
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
prime-yggdrasil/
|
|
102
|
+
├── src/
|
|
103
|
+
│ ├── theme/
|
|
104
|
+
│ │ ├── README.md # Theme architecture guide
|
|
105
|
+
│ │ ├── foundations.css # Foundation color palette
|
|
106
|
+
│ │ ├── radius.css # Border radius tokens
|
|
107
|
+
│ │ ├── semantic-light.css # Light mode semantic tokens
|
|
108
|
+
│ │ ├── semantic-dark.css # Dark mode semantic tokens
|
|
109
|
+
│ │ ├── prime-palette.css # PrimeReact color mappings
|
|
110
|
+
│ │ └── components.css # Component styles + utilities
|
|
111
|
+
│ ├── blocks/ # Custom component blocks
|
|
112
|
+
│ └── stories/ # Storybook documentation
|
|
113
|
+
├── docs/
|
|
114
|
+
│ ├── README.md # This file
|
|
115
|
+
│ ├── ELEVATION-SYSTEM.md # Elevation research
|
|
116
|
+
│ ├── ELEVATION-IMPLEMENTATION.md
|
|
117
|
+
│ ├── contrast-report.md
|
|
118
|
+
│ └── scripts/ # Scripts documentation
|
|
119
|
+
└── scripts/
|
|
120
|
+
├── test-contrast.js # APCA contrast testing
|
|
121
|
+
├── validate-themes.js # Theme validation
|
|
122
|
+
├── replace-*.js # Bulk replacement scripts
|
|
123
|
+
└── analyze-*.js # Analysis scripts
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 🎯 Quick Reference
|
|
127
|
+
|
|
128
|
+
### Common Tasks
|
|
129
|
+
|
|
130
|
+
**Add a new semantic token:**
|
|
131
|
+
1. Add to `semantic-light.css` and `semantic-dark.css`
|
|
132
|
+
2. Update theme README if it's a new category
|
|
133
|
+
3. Test in Storybook
|
|
134
|
+
|
|
135
|
+
**Replace hardcoded colors:**
|
|
136
|
+
1. Use appropriate replacement script
|
|
137
|
+
2. Test components in both themes
|
|
138
|
+
3. Run contrast validation
|
|
139
|
+
|
|
140
|
+
**Update border radius:**
|
|
141
|
+
1. Modify `radius.css` tokens
|
|
142
|
+
2. Components automatically inherit changes
|
|
143
|
+
3. Test responsive layouts
|
|
144
|
+
|
|
145
|
+
## 🤖 For AI Agents
|
|
146
|
+
|
|
147
|
+
When working on this project:
|
|
148
|
+
- Always use semantic tokens, never foundation colors directly
|
|
149
|
+
- Follow the 4px grid for spacing/radius
|
|
150
|
+
- Test both light and dark modes
|
|
151
|
+
- Check contrast with APCA (WCAG 3.0)
|
|
152
|
+
- Update relevant documentation
|
|
153
|
+
- Regenerate reports after major changes
|
|
154
|
+
|
|
155
|
+
## 📝 Version History
|
|
156
|
+
|
|
157
|
+
See git commit history for detailed changes:
|
|
158
|
+
- Border radius system implementation
|
|
159
|
+
- Elevation/shadow system with dark mode support
|
|
160
|
+
- APCA contrast testing integration
|
|
161
|
+
- Semantic token refactoring
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Documentation Archive
|
|
2
|
+
|
|
3
|
+
This folder contains outdated or superseded documentation kept for historical reference.
|
|
4
|
+
|
|
5
|
+
## Archived Files
|
|
6
|
+
|
|
7
|
+
### SEMANTIC-MIGRATION-PLAN.md
|
|
8
|
+
**Status**: ✅ Completed
|
|
9
|
+
**Date Archived**: 2026-01-05
|
|
10
|
+
**Reason**: Migration successfully completed. 727 colors replaced with semantic tokens (96% coverage).
|
|
11
|
+
**Superseded By**: Work is complete, no replacement doc needed.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Files in this directory are kept for reference only and should not be used for current development.
|
|
16
|
+
|
|
17
|
+
### YGGDRASIL_THEME.md
|
|
18
|
+
**Status**: ⚠️ Superseded
|
|
19
|
+
**Date Archived**: 2026-01-05
|
|
20
|
+
**Reason**: Outdated theme documentation from early project stage.
|
|
21
|
+
**Superseded By**: `src/theme/README.md` and `docs/README.md`
|
|
22
|
+
|
|
23
|
+
### agentic_policy.md
|
|
24
|
+
**Status**: ⚠️ Superseded
|
|
25
|
+
**Date Archived**: 2026-01-05
|
|
26
|
+
**Reason**: Early agentic development policy, now replaced with comprehensive guide.
|
|
27
|
+
**Superseded By**: `docs/AI-AGENT-GUIDE.md`
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Semantic Token Migration Plan
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-01-04
|
|
4
|
+
**Status:** In Progress
|
|
5
|
+
**Total Hardcoded Colors:** 755
|
|
6
|
+
**Components Affected:** 67
|
|
7
|
+
|
|
8
|
+
## Migration Strategy
|
|
9
|
+
|
|
10
|
+
### Phase 1: High-Impact Components (Priority)
|
|
11
|
+
Components with most hardcoded colors that are commonly used:
|
|
12
|
+
|
|
13
|
+
1. **Button** (72 colors) - ⚠️ CRITICAL - Most used component
|
|
14
|
+
2. **DataTable** (32 colors) - ⚠️ HIGH - Complex data display
|
|
15
|
+
3. **Menu Components** (166 colors total across 6 menu types)
|
|
16
|
+
- Menubar (49)
|
|
17
|
+
- Megamenu (47)
|
|
18
|
+
- Menu (20)
|
|
19
|
+
- Slidemenu (20)
|
|
20
|
+
- Tieredmenu (19)
|
|
21
|
+
- Contextmenu (17)
|
|
22
|
+
|
|
23
|
+
### Phase 2: Form & Input Components
|
|
24
|
+
4. **Dropdown/Select Components** (31 colors)
|
|
25
|
+
- TreeSelect (19)
|
|
26
|
+
- CascadeSelect (12)
|
|
27
|
+
5. **Lists & Selection** (46 colors)
|
|
28
|
+
- Listbox (16)
|
|
29
|
+
- OrderList (16)
|
|
30
|
+
- PickList (14)
|
|
31
|
+
6. **Date/Time** (22 colors)
|
|
32
|
+
- DatePicker (22)
|
|
33
|
+
7. **Autocomplete** (8 colors)
|
|
34
|
+
|
|
35
|
+
### Phase 3: Navigation & Layout
|
|
36
|
+
8. **Accordion** (15 colors)
|
|
37
|
+
9. **TabView** (13 colors)
|
|
38
|
+
10. **Panel Components** (22 colors)
|
|
39
|
+
- Panel (12)
|
|
40
|
+
- Fieldset (10)
|
|
41
|
+
11. **Stepper** (12 colors)
|
|
42
|
+
12. **TabMenu** (10 colors)
|
|
43
|
+
13. **Breadcrumb** (7 colors)
|
|
44
|
+
|
|
45
|
+
### Phase 4: Data Display
|
|
46
|
+
14. **TreeTable** (28 colors)
|
|
47
|
+
15. **Tree** (13 colors)
|
|
48
|
+
16. **DataView** (8 colors)
|
|
49
|
+
17. **DataScroller** (9 colors)
|
|
50
|
+
18. **Galleria** (9 colors)
|
|
51
|
+
19. **Carousel** (5 colors)
|
|
52
|
+
20. **Timeline** (2 colors)
|
|
53
|
+
|
|
54
|
+
### Phase 5: Misc Components
|
|
55
|
+
21. **SplitButton** (23 colors)
|
|
56
|
+
22. **PanelMenu** (30 colors)
|
|
57
|
+
23. **OrganizationChart** (11 colors)
|
|
58
|
+
24. **ToggleButton** (13 colors)
|
|
59
|
+
25. **OverlayPanel** (8 colors)
|
|
60
|
+
26. **Remaining** (< 10 colors each)
|
|
61
|
+
|
|
62
|
+
## Required Semantic Tokens
|
|
63
|
+
|
|
64
|
+
Based on analysis, we need to ensure these semantic tokens exist:
|
|
65
|
+
|
|
66
|
+
### Button Variants
|
|
67
|
+
- `--button-primary-background`
|
|
68
|
+
- `--button-primary-text`
|
|
69
|
+
- `--button-primary-border`
|
|
70
|
+
- `--button-primary-hover-background`
|
|
71
|
+
- `--button-primary-active-background`
|
|
72
|
+
- `--button-secondary-*` (full set)
|
|
73
|
+
- `--button-help-*` (full set - purple variant)
|
|
74
|
+
- `--button-contrast-*` (full set - dark variant)
|
|
75
|
+
- `--button-outlined-*` (full set)
|
|
76
|
+
- `--button-text-*` (full set)
|
|
77
|
+
|
|
78
|
+
### Menu/Navigation
|
|
79
|
+
- `--menu-background`
|
|
80
|
+
- `--menu-item-background`
|
|
81
|
+
- `--menu-item-hover-background`
|
|
82
|
+
- `--menu-item-active-background`
|
|
83
|
+
- `--menu-text-default`
|
|
84
|
+
- `--menu-text-hover`
|
|
85
|
+
- `--menu-separator-border`
|
|
86
|
+
|
|
87
|
+
### Data Display
|
|
88
|
+
- `--table-header-background`
|
|
89
|
+
- `--table-header-text`
|
|
90
|
+
- `--table-row-background`
|
|
91
|
+
- `--table-row-alt-background` (striping)
|
|
92
|
+
- `--table-row-hover-background`
|
|
93
|
+
- `--table-row-selected-background`
|
|
94
|
+
- `--table-cell-border`
|
|
95
|
+
|
|
96
|
+
### Form Controls (extend existing)
|
|
97
|
+
- Need to verify all input states are covered
|
|
98
|
+
- Add any missing variant tokens
|
|
99
|
+
|
|
100
|
+
## Migration Workflow
|
|
101
|
+
|
|
102
|
+
### For Each Component:
|
|
103
|
+
|
|
104
|
+
1. **Analyze** - Review hardcoded colors in context
|
|
105
|
+
2. **Map** - Create semantic token mappings
|
|
106
|
+
3. **Add Tokens** - Add any missing tokens to both semantic-light.css and semantic-dark.css
|
|
107
|
+
4. **Replace** - Use targeted replacement script
|
|
108
|
+
5. **Test** - Verify in Storybook (light + dark)
|
|
109
|
+
6. **Contrast** - Run APCA tests for new tokens
|
|
110
|
+
7. **Document** - Update if new token categories added
|
|
111
|
+
|
|
112
|
+
### Example: Button Migration
|
|
113
|
+
|
|
114
|
+
```css
|
|
115
|
+
/* BEFORE */
|
|
116
|
+
.p-button {
|
|
117
|
+
background: #3b82f6;
|
|
118
|
+
color: #ffffff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* AFTER */
|
|
122
|
+
.p-button {
|
|
123
|
+
background: var(--button-primary-background);
|
|
124
|
+
color: var(--button-primary-text);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Current Status
|
|
129
|
+
|
|
130
|
+
### ✅ Completed Components
|
|
131
|
+
- Dialog
|
|
132
|
+
- Checkbox
|
|
133
|
+
- RadioButton
|
|
134
|
+
- Card (partial - uses semantic tokens)
|
|
135
|
+
|
|
136
|
+
### 🚧 In Progress
|
|
137
|
+
- None currently
|
|
138
|
+
|
|
139
|
+
### 📋 Next Up
|
|
140
|
+
1. Button (highest priority)
|
|
141
|
+
2. Menu components (second highest)
|
|
142
|
+
3. DataTable
|
|
143
|
+
|
|
144
|
+
## Token Addition Checklist
|
|
145
|
+
|
|
146
|
+
When adding new semantic tokens:
|
|
147
|
+
|
|
148
|
+
1. ☐ Add to `semantic-light.css`
|
|
149
|
+
2. ☐ Add to `semantic-dark.css`
|
|
150
|
+
3. ☐ Test contrast (APCA)
|
|
151
|
+
4. ☐ Document in theme README if new category
|
|
152
|
+
5. ☐ Update this migration plan
|
|
153
|
+
|
|
154
|
+
## Estimated Completion
|
|
155
|
+
|
|
156
|
+
- **Phase 1:** 3-4 sessions (~270 colors)
|
|
157
|
+
- **Phase 2:** 2-3 sessions (~107 colors)
|
|
158
|
+
- **Phase 3:** 2 sessions (~79 colors)
|
|
159
|
+
- **Phase 4:** 2 sessions (~89 colors)
|
|
160
|
+
- **Phase 5:** 2-3 sessions (~210 colors)
|
|
161
|
+
|
|
162
|
+
**Total:** 11-15 focused sessions
|
|
163
|
+
|
|
164
|
+
## Success Metrics
|
|
165
|
+
|
|
166
|
+
- ✅ All 755 hardcoded colors replaced
|
|
167
|
+
- ✅ 100% APCA contrast pass rate maintained
|
|
168
|
+
- ✅ Full dark mode support for all components
|
|
169
|
+
- ✅ Consistent theming across component library
|
|
170
|
+
|
|
171
|
+
## Notes for AI Agents
|
|
172
|
+
|
|
173
|
+
- Always work on one component at a time
|
|
174
|
+
- Test thoroughly in both themes before moving on
|
|
175
|
+
- Maintain contrast requirements
|
|
176
|
+
- Follow existing naming patterns for tokens
|
|
177
|
+
- Update this document after each component completion
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Yggdrasil Theme for PrimeReact
|
|
2
|
+
|
|
3
|
+
This document describes the custom Yggdrasil theme implementation for PrimeReact, including what was accomplished and what limitations exist with the standard theming approach.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Yggdrasil theme maps the Yggdrasil design system tokens to PrimeReact's CSS variables, creating both light and dark mode variants while maintaining full compatibility with PrimeReact's component library.
|
|
8
|
+
|
|
9
|
+
## Theme Files
|
|
10
|
+
|
|
11
|
+
- **[src/themes/yggdrasil-light.css](src/themes/yggdrasil-light.css)** - Light mode theme
|
|
12
|
+
- **[src/themes/yggdrasil-dark.css](src/themes/yggdrasil-dark.css)** - Dark mode theme
|
|
13
|
+
|
|
14
|
+
## What Was Accomplished
|
|
15
|
+
|
|
16
|
+
### ✅ Colors
|
|
17
|
+
|
|
18
|
+
Successfully mapped all Yggdrasil color tokens to PrimeReact CSS variables:
|
|
19
|
+
|
|
20
|
+
#### Primary/Brand Colors (Sky)
|
|
21
|
+
- Mapped Yggdrasil Sky palette to PrimeReact's `--primary-color` and `--blue-*` variables
|
|
22
|
+
- Light mode: `--foundation-sky-700` (#001F4A) as primary
|
|
23
|
+
- Dark mode: `--foundation-sky-600` (#183B60) as primary
|
|
24
|
+
|
|
25
|
+
#### Success Colors (Forest)
|
|
26
|
+
- Mapped Yggdrasil Forest palette to PrimeReact's `--green-*` variables
|
|
27
|
+
- Provides proper success states for both light and dark modes
|
|
28
|
+
|
|
29
|
+
#### Warning Colors (Sand)
|
|
30
|
+
- Mapped Yggdrasil Sand palette to PrimeReact's `--yellow-*` variables
|
|
31
|
+
- Provides proper warning states for both light and dark modes
|
|
32
|
+
|
|
33
|
+
#### Danger/Error Colors (Berries)
|
|
34
|
+
- Mapped Yggdrasil Berries palette to PrimeReact's `--red-*` variables
|
|
35
|
+
- Provides proper danger/error states for both light and dark modes
|
|
36
|
+
|
|
37
|
+
#### Info/Secondary Colors (Sea)
|
|
38
|
+
- Mapped Yggdrasil Sea palette to PrimeReact's `--cyan-*` variables
|
|
39
|
+
- Provides secondary/info color variations
|
|
40
|
+
|
|
41
|
+
#### Neutral Colors (Rock)
|
|
42
|
+
- Mapped Yggdrasil Rock palette to PrimeReact's `--gray-*` and `--surface-*` variables
|
|
43
|
+
- Provides full neutral color scale for text, borders, and surfaces
|
|
44
|
+
- Properly inverted for dark mode
|
|
45
|
+
|
|
46
|
+
### ✅ Typography - Roboto Font
|
|
47
|
+
|
|
48
|
+
Successfully replaced Inter font with Roboto while preserving font weights:
|
|
49
|
+
|
|
50
|
+
- **Font Family**: Changed from "Inter var" to "Roboto"
|
|
51
|
+
- **Font Weights**: Preserved all weights (100, 300, 400, 500, 700, 900) including italic variants
|
|
52
|
+
- **Loading**: Using Google Fonts CDN via `@import`
|
|
53
|
+
- **Hierarchy**: Font weight hierarchy remains intact across all components
|
|
54
|
+
|
|
55
|
+
### ✅ Border Radius - 4px Grid Alignment
|
|
56
|
+
|
|
57
|
+
Successfully adjusted border radius to adhere to 4px grid:
|
|
58
|
+
|
|
59
|
+
- **Previous**: `--border-radius: 6px` (Lara theme default)
|
|
60
|
+
- **Updated**: `--border-radius: 8px` (4px grid: 8 = 2×4)
|
|
61
|
+
- **Impact**: All components (buttons, inputs, cards, dialogs, etc.) now use 8px border radius
|
|
62
|
+
|
|
63
|
+
### ✅ Surface and Text Colors
|
|
64
|
+
|
|
65
|
+
- **Light Mode**:
|
|
66
|
+
- Primary surface: White (`--foundation-white`)
|
|
67
|
+
- Secondary surfaces: Rock 50/100 (`--foundation-rock-050`, `--foundation-rock-100`)
|
|
68
|
+
- Default text: Sky 700 (`--foundation-sky-700`)
|
|
69
|
+
- Secondary text: Rock 600 (`--foundation-rock-600`)
|
|
70
|
+
|
|
71
|
+
- **Dark Mode**:
|
|
72
|
+
- Primary surface: `#000D20` (custom dark blue)
|
|
73
|
+
- Secondary surfaces: Sky 900/950 (`--foundation-sky-900`, `--foundation-sky-950`)
|
|
74
|
+
- Default text: Rock 050 (`--foundation-rock-050`)
|
|
75
|
+
- Secondary text: Rock 400 (`--foundation-rock-400`)
|
|
76
|
+
|
|
77
|
+
### ✅ Focus and Highlight States
|
|
78
|
+
|
|
79
|
+
- Focus ring colors adjusted to use Yggdrasil Sky colors
|
|
80
|
+
- Hover states use proper Yggdrasil overlay colors (`--foundation-darker-050` for light, `--foundation-lighter-100` for dark)
|
|
81
|
+
- Selection/highlight backgrounds use Sky palette
|
|
82
|
+
|
|
83
|
+
### ✅ Color Scheme Detection
|
|
84
|
+
|
|
85
|
+
- Proper `color-scheme: light` and `color-scheme: dark` declarations
|
|
86
|
+
- Enables browser-level dark mode support
|
|
87
|
+
|
|
88
|
+
## Implementation Approach
|
|
89
|
+
|
|
90
|
+
The theme was implemented using **CSS variable overrides**, which is PrimeReact's standard theming approach:
|
|
91
|
+
|
|
92
|
+
1. **Base Theme Import**: Both themes import the base Lara Light Blue theme for component structure and styling
|
|
93
|
+
2. **Foundation Variables**: Define all Yggdrasil foundation color tokens as CSS variables
|
|
94
|
+
3. **Semantic Mapping**: Override PrimeReact's semantic CSS variables (`--primary-color`, `--surface-*`, `--text-color`, etc.) with Yggdrasil foundation tokens
|
|
95
|
+
4. **Font Replacement**: Override `font-family` and import Roboto from Google Fonts
|
|
96
|
+
5. **Border Radius**: Override `--border-radius` to use 8px
|
|
97
|
+
|
|
98
|
+
## Switching Between Light and Dark Modes
|
|
99
|
+
|
|
100
|
+
To switch between light and dark themes, change the import in:
|
|
101
|
+
|
|
102
|
+
### Light Mode (Current Default)
|
|
103
|
+
```typescript
|
|
104
|
+
// src/main.tsx
|
|
105
|
+
import './themes/yggdrasil-light.css'
|
|
106
|
+
|
|
107
|
+
// .storybook/preview.ts
|
|
108
|
+
import '../src/themes/yggdrasil-light.css'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Dark Mode
|
|
112
|
+
```typescript
|
|
113
|
+
// src/main.tsx
|
|
114
|
+
import './themes/yggdrasil-dark.css'
|
|
115
|
+
|
|
116
|
+
// .storybook/preview.ts
|
|
117
|
+
import '../src/themes/yggdrasil-dark.css'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Dynamic Theme Switching (Future Enhancement)
|
|
121
|
+
|
|
122
|
+
For runtime theme switching, you would need to:
|
|
123
|
+
1. Load both CSS files
|
|
124
|
+
2. Use a CSS class or data attribute on the root element
|
|
125
|
+
3. Scope theme variables within those selectors
|
|
126
|
+
|
|
127
|
+
Example approach:
|
|
128
|
+
```css
|
|
129
|
+
/* Not currently implemented, but would look like: */
|
|
130
|
+
[data-theme="light"] {
|
|
131
|
+
/* light mode variables */
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
[data-theme="dark"] {
|
|
135
|
+
/* dark mode variables */
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Limitations and What Wasn't Possible
|
|
140
|
+
|
|
141
|
+
### ⚠️ Component-Specific Fine-Tuning
|
|
142
|
+
|
|
143
|
+
**Limitation**: PrimeReact's CSS variable theming provides global-level customization but limited component-specific control.
|
|
144
|
+
|
|
145
|
+
**Impact**: Some Yggdrasil design patterns that specify different treatments for specific component types (e.g., different border styles for cards vs. buttons) cannot be implemented without:
|
|
146
|
+
- Using PrimeReact's PassThrough (PT) API for per-component styling
|
|
147
|
+
- Creating wrapper components with custom CSS
|
|
148
|
+
- Using SASS theme compilation (more complex approach)
|
|
149
|
+
|
|
150
|
+
**Workaround**: Use Block components (e.g., `Card`, `PageHeader`) which can apply additional component-specific styling on top of the theme.
|
|
151
|
+
|
|
152
|
+
### ⚠️ Opacity/Alpha Channel Values
|
|
153
|
+
|
|
154
|
+
**Limitation**: Some Yggdrasil foundation colors use explicit alpha channel values (e.g., `--foundation-darker-050: #000F260C`), but PrimeReact expects solid colors in most variables.
|
|
155
|
+
|
|
156
|
+
**Implementation**:
|
|
157
|
+
- Used the explicit hex+alpha values where supported
|
|
158
|
+
- For variables requiring solid colors, used the Yggdrasil semantic tokens that reference appropriate foundation colors
|
|
159
|
+
|
|
160
|
+
**Impact**: Some subtle transparency effects from the original Yggdrasil design may not be perfectly replicated.
|
|
161
|
+
|
|
162
|
+
### ⚠️ Inter Variable Font Features
|
|
163
|
+
|
|
164
|
+
**Limitation**: The Lara theme uses "Inter var" with specific `font-feature-settings` ("cv02", "cv03", "cv04", "cv11") for stylistic alternates.
|
|
165
|
+
|
|
166
|
+
**Implementation**: Roboto doesn't have equivalent OpenType features, so these are overridden but not replaced.
|
|
167
|
+
|
|
168
|
+
**Impact**: Typography rendering is slightly different, but this is expected and acceptable since we're using a different font family.
|
|
169
|
+
|
|
170
|
+
### ⚠️ Pink, Purple, Indigo, Teal Color Scales
|
|
171
|
+
|
|
172
|
+
**Limitation**: PrimeReact provides CSS variables for pink, purple, indigo, orange, and teal color scales, but Yggdrasil doesn't have direct equivalents.
|
|
173
|
+
|
|
174
|
+
**Implementation**: These variables remain unchanged from the Lara theme. They're rarely used in standard components but might appear in custom implementations.
|
|
175
|
+
|
|
176
|
+
**Impact**: If custom components reference these color scales, they won't match the Yggdrasil palette.
|
|
177
|
+
|
|
178
|
+
### ⚠️ Chart Colors
|
|
179
|
+
|
|
180
|
+
**Limitation**: Yggdrasil defines extensive chart color palettes (`--charts-*`), but PrimeReact doesn't have corresponding CSS variables for chart theming.
|
|
181
|
+
|
|
182
|
+
**Implementation**: Chart colors are not currently mapped to PrimeReact theme variables.
|
|
183
|
+
|
|
184
|
+
**Impact**: If using PrimeReact chart components (from PrimeReact Charts), you would need to manually configure colors or create wrapper components.
|
|
185
|
+
|
|
186
|
+
### ⚠️ Spacing and Layout Variables
|
|
187
|
+
|
|
188
|
+
**Limitation**: Yggdrasil uses a comprehensive spacing scale with specific semantic tokens, but PrimeReact's theme only exposes `--content-padding` and `--inline-spacing`.
|
|
189
|
+
|
|
190
|
+
**Implementation**: These remain at Lara theme defaults.
|
|
191
|
+
|
|
192
|
+
**Impact**: Component internal spacing follows PrimeReact's defaults, not Yggdrasil's 4px grid spacing system. Layout spacing is controlled via PrimeFlex utility classes following the architecture policy.
|
|
193
|
+
|
|
194
|
+
### ✅ What Works Perfectly
|
|
195
|
+
|
|
196
|
+
Despite limitations, the following aspects work excellently with standard theming:
|
|
197
|
+
|
|
198
|
+
1. **All color semantics** (primary, success, warning, danger, info, neutral)
|
|
199
|
+
2. **Complete light/dark mode support** with proper color inversion
|
|
200
|
+
3. **Typography** (font family replacement)
|
|
201
|
+
4. **Border radius** (4px grid alignment)
|
|
202
|
+
5. **Focus states**
|
|
203
|
+
6. **Hover/active states**
|
|
204
|
+
7. **Surface hierarchy** (cards, overlays, borders)
|
|
205
|
+
8. **Text color hierarchy** (default, subdued, loud, disabled)
|
|
206
|
+
|
|
207
|
+
## Testing
|
|
208
|
+
|
|
209
|
+
Both themes have been tested with:
|
|
210
|
+
|
|
211
|
+
- ✅ Vite build (`npm run build`)
|
|
212
|
+
- ✅ Storybook build (`npm run build-storybook`)
|
|
213
|
+
- ✅ All component stories in Storybook
|
|
214
|
+
- ✅ Design System Playground page
|
|
215
|
+
|
|
216
|
+
## Comparison to Designer API / SASS Approach
|
|
217
|
+
|
|
218
|
+
### CSS Variables Approach (Current Implementation)
|
|
219
|
+
|
|
220
|
+
**Pros**:
|
|
221
|
+
- Simple, maintainable
|
|
222
|
+
- No build tooling required
|
|
223
|
+
- Easy to understand and modify
|
|
224
|
+
- Fast iteration
|
|
225
|
+
- Works with existing PrimeReact distribution
|
|
226
|
+
|
|
227
|
+
**Cons**:
|
|
228
|
+
- Limited to global variables
|
|
229
|
+
- Can't customize component-specific styling deeply
|
|
230
|
+
- Some advanced features not accessible
|
|
231
|
+
|
|
232
|
+
### SASS Compilation Approach (Not Implemented)
|
|
233
|
+
|
|
234
|
+
**Pros**:
|
|
235
|
+
- Complete control over every component style
|
|
236
|
+
- Can customize component-specific details
|
|
237
|
+
- More alignment with original PrimeReact theming system
|
|
238
|
+
|
|
239
|
+
**Cons**:
|
|
240
|
+
- Requires SASS build tooling
|
|
241
|
+
- More complex setup and maintenance
|
|
242
|
+
- Need to maintain sync with PrimeReact updates
|
|
243
|
+
- Significantly more effort for "close enough" goal
|
|
244
|
+
|
|
245
|
+
**Decision**: The CSS variables approach was chosen because:
|
|
246
|
+
1. The goal is "close enough" not pixel-perfect
|
|
247
|
+
2. Maintains coherence with PrimeReact
|
|
248
|
+
3. Avoids breaking components
|
|
249
|
+
4. Significantly faster to implement and iterate
|
|
250
|
+
5. Easier for LLM-assisted development
|
|
251
|
+
|
|
252
|
+
## Future Enhancements
|
|
253
|
+
|
|
254
|
+
If deeper customization is needed, consider:
|
|
255
|
+
|
|
256
|
+
1. **PassThrough API**: Use PrimeReact's PT API for component-specific styling
|
|
257
|
+
2. **Block Components**: Create more Block components that encapsulate Yggdrasil-specific patterns
|
|
258
|
+
3. **Dynamic Theme Switching**: Implement runtime light/dark mode switching
|
|
259
|
+
4. **Chart Integration**: Map Yggdrasil chart colors to chart components
|
|
260
|
+
5. **Custom Components**: For patterns that can't be achieved with PrimeReact primitives
|
|
261
|
+
|
|
262
|
+
## Conclusion
|
|
263
|
+
|
|
264
|
+
The Yggdrasil theme successfully brings the Yggdrasil design system's color palette, typography (Roboto), and 4px grid border radius to PrimeReact using standard CSS variable theming. While some advanced customizations would require the SASS approach or PassThrough API, the current implementation achieves the "close enough" goal while maintaining full coherence with PrimeReact's component library.
|