@lifeonlars/prime-yggdrasil 0.2.6 → 0.4.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.
@@ -1,264 +0,0 @@
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.
@@ -1,216 +0,0 @@
1
- # Agentic UI Architecture & PrimeFlex Policy
2
-
3
- ## Purpose
4
-
5
- This document defines the **UI architecture and styling approach**, with a specific focus on **agentic (LLM-assisted) development**. The goal is to enable fast iteration while maintaining visual consistency, reducing UI drift, and keeping long-term maintenance costs low.
6
-
7
- ---
8
-
9
- ## Core Principles
10
-
11
- 1. **Design-system-first, not utility-first** \
12
- Utilities are implementation details, not the design language. UI should be composed from approved components and patterns, not invented ad hoc.
13
-
14
- 2. **Composition over invention** \
15
- Both humans and LLMs should assemble interfaces from existing primitives and blocks rather than creating bespoke layouts or styles in each view.
16
-
17
- 3. **Guardrails enable speed** \
18
- Constraints are intentional. By limiting where and how styling decisions can be made, we reduce cognitive load, rework, and visual inconsistency.
19
-
20
- 4. **Storybook is the contract** \
21
- If a component or pattern is not represented in Storybook, it should not be created implicitly in a product view.
22
-
23
- ---
24
-
25
- ## High-Level Architecture
26
-
27
- The UI system is organised into **three explicit tiers**. This structure is intentional and exists to balance speed, flexibility, and long-term consistency — especially in an agent-assisted workflow.
28
-
29
- ---
30
-
31
- ### Tier 1: Global Design System (`prime-yggdrasil`)
32
-
33
- This is the **authoritative UI layer** shared across projects.
34
-
35
- Includes:
36
- - PrimeReact primitives (styled mode, PrimeOne-based theme)
37
- - Shared Blocks
38
- - Shared Layout Blocks
39
- - Theme CSS and Provider setup
40
- - Storybook (stories + MDX docs)
41
- - Chromatic visual regression
42
-
43
- Rules:
44
- - This tier defines the visual and interaction language
45
- - Storybook here is the **single source of truth**
46
- - Components in this tier are stable, documented, and versioned
47
- - Changes require intent and review (visual diffs are expected and reviewed)
48
-
49
- Storybook’s role:
50
- - Executable documentation
51
- - Usage guidelines for humans and LLMs
52
- - Canonical examples and edge cases
53
-
54
- Storybook is **read-only reference** for consuming apps. It does not run inside them.
55
-
56
- ---
57
-
58
- ### Tier 2: Local Blocks (inside consuming apps)
59
-
60
- Local Blocks are **allowed and encouraged** for speed and experimentation.
61
-
62
- Includes:
63
- - App-specific Blocks and Layout Blocks
64
- - Composition of:
65
- - Global Blocks
66
- - PrimeReact primitives
67
- - PrimeFlex (layout-only)
68
-
69
- Rules:
70
- - No local primitives
71
- - No new visual language
72
- - No new tokens, colours, or elevation systems
73
- - PrimeFlex usage follows the same whitelist as Views
74
- - If a pattern is reused or proven useful, it becomes a **promotion candidate** to the global design system
75
-
76
- Local Blocks are intentionally second-class:
77
- - Faster to create
78
- - Allowed to be imperfect
79
- - Expected to evolve or be deleted
80
-
81
- ---
82
-
83
- ### Tier 3: Views (Screens)
84
-
85
- Views are responsible for:
86
- - Data fetching
87
- - State management
88
- - Wiring interactions
89
- - Composing Blocks and Layout Blocks
90
-
91
- Rules:
92
- - No visual styling
93
- - Minimal layout only
94
- - PrimeFlex allowed strictly for page scaffolding
95
-
96
- Views should never invent UI patterns.
97
-
98
- ---
99
-
100
- ## PrimeFlex Usage Policy
101
-
102
-
103
- PrimeFlex is the **layout utility layer** alongside PrimeReact + PrimeOne (styled mode). Its job is *structural scaffolding*, not visual styling.
104
-
105
- To keep agentic development predictable and prevent drift, we use a **strict whitelist** of PrimeFlex utilities that are allowed inside **Views**.
106
-
107
- ### View whitelist (allowed PrimeFlex classes)
108
-
109
- Views may use PrimeFlex **only** for page scaffolding, using **only** the following families:
110
-
111
- 1) **Grid scaffolding (preferred)**
112
- - `grid`
113
- - `col-*` (e.g. `col-12`, `col-6`, `col-3`)
114
- - Responsive variants of `col-*` (e.g. `md:col-6`, `lg:col-4`, `xl:col-3`)
115
-
116
- 2) **Flex scaffolding (allowed, but secondary)**
117
- - `flex`
118
- - `flex-wrap`
119
- - Responsive variants (e.g. `md:flex`)
120
-
121
- 3) **Spacing between layout regions**
122
- - `gap-*` and responsive variants (e.g. `gap-3`, `md:gap-4`)
123
-
124
- 4) **Alignment for structural layout**
125
- - `align-items-*` (e.g. `align-items-start|center|end|stretch`) + responsive variants
126
- - `justify-content-*` (e.g. `justify-content-start|center|end|between|around|evenly`) + responsive variants
127
-
128
- 5) **Outer page padding only** (single wrapper)
129
- - Exactly one outer wrapper may use:
130
- - `p-*` **or** `px-*`/`py-*`
131
- - Optional responsive variants (e.g. `p-3 md:p-4`)
132
-
133
- That’s it.
134
-
135
- ### View blacklist (explicitly forbidden)
136
-
137
- Views must **not** use PrimeFlex for:
138
-
139
- - **Colours / visual identity** (anything that changes colours, borders, shadows)
140
- - **Typography** (font sizing/weights/line-height)
141
- - **Radius, shadows, effects**
142
- - **Ad-hoc spacing for visual tuning**
143
- - No `m-*`, `mx-*`, `my-*`, `mt-*`, `mb-*`, `ml-*`, `mr-*`
144
- - No extra `p-*` beyond the single outer wrapper
145
- - **One-off layout hacks** (absolute positioning, z-index games, negative margins)
146
-
147
- If you feel tempted: you don’t need more PrimeFlex — you need a **Block**.
148
-
149
- ### Canonical view patterns (examples)
150
-
151
- **Page scaffold (grid-first):**
152
- - Outer wrapper: `p-3 md:p-4`
153
- - Main layout: `grid`
154
- - Spacing: `gap-3 md:gap-4`
155
- - Columns: `col-12 md:col-8` + `col-12 md:col-4`
156
-
157
- **Header row (structural flex):**
158
- - `flex align-items-center justify-content-between`
159
-
160
- ### Block and Layout Block rules (where styling lives)
161
-
162
- - Blocks/Layout Blocks may use PrimeFlex *freely* for internal spacing and composition.
163
- - Blocks/Layout Blocks may own any additional styling decisions (component props, PT config, custom CSS where justified).
164
- - Any repeated pattern found in multiple views should be promoted into a Block/Layout Block and documented in Storybook.
165
-
166
- This keeps views thin, predictable, and safe for LLM-assisted iteration.
167
-
168
- ---
169
-
170
- ## Storybook & Chromatic
171
-
172
- ### Storybook
173
-
174
- Storybook serves as:
175
-
176
- - Executable documentation of approved primitives, blocks, and layouts
177
- - The reference for both human developers and LLM agents
178
- - A safe environment to explore states (loading, empty, error, dense, edge cases)
179
-
180
- Suggested structure:
181
-
182
- - `Foundations/`
183
- - `Primitives/`
184
- - `Blocks/`
185
- - `Layouts/`
186
- - `Screens/` (optional reference screens)
187
-
188
- ### Chromatic
189
-
190
- Chromatic provides:
191
-
192
- - Visual regression testing
193
- - Confidence when refactoring or extending UI via LLMs
194
- - A review mechanism for unintended visual drift
195
-
196
- Visual diffs are treated as **intentional review points**, not noise.
197
-
198
- ---
199
-
200
- ## LLM Agent Guidelines (Summary)
201
-
202
- - Use **PrimeReact primitives** for all basic UI elements
203
- - Prefer **existing Blocks and Layout Blocks** over new custom layouts
204
- - Do not introduce new PrimeFlex styling in views beyond the allowed set
205
- - If a new pattern is required:
206
- 1. Create or extend a Block
207
- 2. Add it to Storybook
208
- 3. Validate via Chromatic
209
- - Assemble UI from approved patterns rather than inventing new ones
210
-
211
- ---
212
-
213
- ## Intent
214
-
215
- This architecture is designed to let **LLMs act as force multipliers**, not uncontrolled designers. By clearly separating responsibilities and constraining where styling decisions can be made, development can move fast without creating long-term UI debt.
216
-
@@ -1,9 +0,0 @@
1
- # APCA Contrast Test Report
2
-
3
- **Generated:** 2025-12-30T08:57:08.866Z
4
-
5
- **Total Tests:** 24
6
- **Passing:** 24 ✓
7
- **Failing:** 0 ✗
8
- **Success Rate:** 100.0%
9
-