@trinitydesign/design-system 1.2.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/MIGRATION.md ADDED
@@ -0,0 +1,347 @@
1
+ # Trinity Design System - Migration Guide
2
+
3
+ This document outlines breaking changes and migration paths for the Trinity Design System.
4
+
5
+ ---
6
+
7
+ ## v1.2.0 - Build Optimization (Breaking Change)
8
+
9
+ ### Overview
10
+
11
+ The npm package has been optimized from **169MB to 261KB** (99.85% reduction) by:
12
+ - Removing inlined image assets from the bundle
13
+ - Restructuring dependencies as peer dependencies
14
+ - Optimizing chunk splitting
15
+
16
+ ### Breaking Changes
17
+
18
+ #### 1. Asset Exports Removed
19
+
20
+ The following exports are **no longer available** from the main package:
21
+
22
+ ```typescript
23
+ // ❌ No longer works
24
+ import { gradientIcons, backgroundImages, brandGradients } from '@trinity/design-system';
25
+ ```
26
+
27
+ **Migration:** If you need Trinity brand assets:
28
+ 1. Copy from `node_modules/@trinity/design-system/src/assets/` to your public folder
29
+ 2. Import directly in your source (your bundler will handle them)
30
+ 3. Use a CDN for production
31
+
32
+ Type definitions are still exported:
33
+ ```typescript
34
+ // ✅ Still works
35
+ import type { GradientIconName, BackgroundCategory } from '@trinity/design-system';
36
+ ```
37
+
38
+ #### 2. New Peer Dependencies
39
+
40
+ The following are now **peer dependencies** (install separately):
41
+
42
+ | Dependency | Required | Notes |
43
+ |------------|----------|-------|
44
+ | `@mui/icons-material` | **Yes** | Previously bundled |
45
+ | `@mui/x-data-grid` | Optional | Only for DataTable |
46
+ | `@mui/x-date-pickers` | Optional | Only for DatePicker |
47
+ | `dayjs` | Optional | Only for DatePicker |
48
+ | `recharts` | Optional | Only for Charts |
49
+
50
+ **Migration:**
51
+ ```bash
52
+ # Required
53
+ npm install @mui/icons-material
54
+
55
+ # Optional (if using these components)
56
+ npm install @mui/x-data-grid @mui/x-date-pickers dayjs recharts
57
+ ```
58
+
59
+ #### 3. Removed Dependencies
60
+
61
+ - `@mui/x-date-pickers-pro` - No longer used; date range functionality now uses two standard `DatePicker` components
62
+
63
+ ---
64
+
65
+ ## Phase 3.3 & 3.4 - Color Token Normalization
66
+
67
+ ### Overview
68
+
69
+ Phase 3.3 and 3.4 normalized internal color references to improve token consistency. **No breaking API changes** were introduced, and visual output is unchanged.
70
+
71
+ ### Consumer Impact: **No Action Required**
72
+
73
+ All changes are internal refactors. If you're consuming Trinity components normally:
74
+ - ✅ No import changes needed
75
+ - ✅ No prop changes needed
76
+ - ✅ No theme override adjustments needed
77
+ - ✅ Visual appearance is identical
78
+
79
+ ### What Changed Internally
80
+
81
+ #### 1. Normalized Token References
82
+
83
+ These inline hex values were replaced with canonical token references:
84
+
85
+ | Location | Before | After |
86
+ |----------|--------|-------|
87
+ | `aiTokens.aiHover` | `'#E8E0F4'` | `baseTokens.colors.indigo[100]` |
88
+ | `aiTokens.aiHoverDark` | `'#3D2E5C'` | `baseTokens.colors.indigo[900]` |
89
+ | Charts sequential palette | `'#EDE9FE'` through `'#3730A3'` | `baseTokens.colors.indigo[50-900]` |
90
+ | Navigation `alpha('#fff', x)` | `'#fff'` literal | `brandColors.neutral.white` |
91
+ | AI components `'#FFFFFF'` | Hex literal | `brandColors.neutral.white` |
92
+
93
+ #### 2. Intentional Palette Extensions (NOT Normalized)
94
+
95
+ These colors intentionally differ from base tokens for functional reasons:
96
+
97
+ **Charts Categorical Palette** - Uses full brand spectrum for maximum data distinction:
98
+ ```typescript
99
+ // Intentionally uses multiple brand color families
100
+ categorical: [
101
+ brandColors.primary.navy, // Navy for primary series
102
+ brandColors.accent.coral, // Coral for contrast
103
+ brandColors.accent.teal, // Teal for tertiary
104
+ brandColors.secondary.purple, // Purple for additional series
105
+ // ... additional distinct colors
106
+ ]
107
+ ```
108
+
109
+ **Status Illustration Colors** - Tailwind-standard colors for universal recognition:
110
+ ```typescript
111
+ // In IllustratedMessage.tsx - NOT from brand palette
112
+ const illustrationStatusColors = {
113
+ error: { main: '#EF4444', light: '#FEE2E2' }, // red-500
114
+ warning: { main: '#F59E0B', light: '#FEF3C7' }, // amber-500
115
+ success: { main: '#10B981', light: '#D1FAE5' }, // emerald-500
116
+ };
117
+ ```
118
+
119
+ #### 3. Intentional Structural Overrides (NOT Normalized)
120
+
121
+ **DataTable Header Grays** - Tuned for dense tabular readability:
122
+ ```typescript
123
+ // In DataTable/tokens.ts - intentionally differs from baseTokens.gray
124
+ header: {
125
+ background: '#F3F4F6', // NOT gray[100] = '#F4F4F5'
126
+ borderColor: '#D1D5DB', // NOT gray[300] = '#D4D4D8'
127
+ }
128
+ ```
129
+
130
+ These values were specifically chosen for optimal contrast in data-dense table contexts and are documented inline.
131
+
132
+ ### Commits
133
+
134
+ - `4544c91` - refactor(tokens): normalize AI and Charts color references (phase 3.3)
135
+ - `d58e2ec` - refactor(ui): centralize non-tokenized semantic colors (phase 3.4)
136
+
137
+ ---
138
+
139
+ ## Version 1.1.0
140
+
141
+ ### New Features
142
+
143
+ #### 1. Comprehensive Token Type System
144
+
145
+ All token layers now have complete TypeScript interfaces:
146
+
147
+ ```typescript
148
+ import type {
149
+ TrinityTokens,
150
+ TrinityBaseTokens,
151
+ TrinitySemanticTokens,
152
+ TrinityComponentTokens,
153
+ TrinityDarkModeTokens,
154
+ } from '@trinity/design-system';
155
+ ```
156
+
157
+ #### 2. Auto-generated CSS Variables
158
+
159
+ New utilities to automatically generate CSS custom properties from all tokens:
160
+
161
+ ```typescript
162
+ import {
163
+ generateCssVariables,
164
+ generateDarkModeCssVariables,
165
+ injectTrinityCssVariables,
166
+ injectDarkModeCssVariables
167
+ } from '@trinity/design-system';
168
+
169
+ // Inject all variables into :root
170
+ injectTrinityCssVariables();
171
+
172
+ // Also inject dark mode variables (responds to prefers-color-scheme)
173
+ injectDarkModeCssVariables();
174
+ ```
175
+
176
+ Available CSS variables follow the pattern:
177
+ - Colors: `--trinity-color-{palette}-{shade}` (e.g., `--trinity-color-navy-900`)
178
+ - Spacing: `--trinity-spacing-{size}` (e.g., `--trinity-spacing-4`)
179
+ - Font sizes: `--trinity-font-size-{size}` (e.g., `--trinity-font-size-base`)
180
+ - Border radius: `--trinity-radius-{size}` (e.g., `--trinity-radius-md`)
181
+ - Shadows: `--trinity-shadow-{size}` (e.g., `--trinity-shadow-md`)
182
+ - Semantic tokens: `--trinity-semantic-{category}-{name}`
183
+ - Component tokens: `--trinity-component-{component}-{property}`
184
+
185
+ #### 3. useTrinityTokens Hook
186
+
187
+ New React hook for accessing tokens with theme awareness:
188
+
189
+ ```typescript
190
+ import { useTrinityTokens } from '@trinity/design-system';
191
+
192
+ function MyComponent() {
193
+ const {
194
+ base,
195
+ semantic,
196
+ component,
197
+ mode,
198
+ isDarkMode,
199
+ spacing,
200
+ spacingCss,
201
+ radius,
202
+ shadow,
203
+ getColor,
204
+ getSemanticColor
205
+ } = useTrinityTokens();
206
+
207
+ return (
208
+ <Box sx={{
209
+ backgroundColor: getColor(
210
+ semantic.colors.background.primary,
211
+ darkMode.colors.background.primary
212
+ ),
213
+ padding: spacingCss(4), // '16px'
214
+ borderRadius: radius('md'), // 6
215
+ boxShadow: shadow('md'),
216
+ }} />
217
+ );
218
+ }
219
+ ```
220
+
221
+ #### 4. Enhanced Dark Mode Tokens
222
+
223
+ Dark mode tokens now include complete overrides for:
224
+ - Interactive states (hover, active, focus, disabled)
225
+ - Status colors (error, warning, success, info)
226
+
227
+ ```typescript
228
+ import { darkModeTokens } from '@trinity/design-system';
229
+
230
+ // New dark mode interactive colors
231
+ darkModeTokens.colors.interactive.hover
232
+ darkModeTokens.colors.interactive.focus
233
+
234
+ // New dark mode status colors
235
+ darkModeTokens.colors.status.error.text
236
+ darkModeTokens.colors.status.error.background
237
+ ```
238
+
239
+ ### Breaking Changes
240
+
241
+ #### Token Types
242
+
243
+ The `TrinityTokens` interface now uses specific types instead of `any`:
244
+
245
+ **Before:**
246
+ ```typescript
247
+ export interface TrinityTokens {
248
+ base: TrinityBaseTokens;
249
+ semantic: any;
250
+ component: any;
251
+ darkMode: any;
252
+ }
253
+ ```
254
+
255
+ **After:**
256
+ ```typescript
257
+ export interface TrinityTokens {
258
+ base: TrinityBaseTokens;
259
+ semantic: TrinitySemanticTokens;
260
+ component: TrinityComponentTokens;
261
+ darkMode: TrinityDarkModeTokens;
262
+ }
263
+ ```
264
+
265
+ **Migration:** Update any code that relied on loose typing of semantic, component, or darkMode tokens.
266
+
267
+ #### CSS Variable Names
268
+
269
+ The `injectTrinityCssVariables` function now generates comprehensive CSS variables instead of just a few key ones.
270
+
271
+ **Before:**
272
+ - Limited variables like `--trinity-primary`, `--trinity-spacing-md`
273
+
274
+ **After:**
275
+ - Full variable system: `--trinity-color-navy-900`, `--trinity-spacing-4`, etc.
276
+
277
+ **Migration:** Update any CSS that referenced the old variable names:
278
+
279
+ | Old Variable | New Variable |
280
+ |-------------|--------------|
281
+ | `--trinity-primary` | `--trinity-color-navy-900` |
282
+ | `--trinity-secondary` | `--trinity-color-purple-700` |
283
+ | `--trinity-coral` | `--trinity-color-coral-800` |
284
+ | `--trinity-spacing-md` | `--trinity-spacing-4` |
285
+ | `--trinity-radius-lg` | `--trinity-radius-lg` (unchanged) |
286
+
287
+ ### New Exports
288
+
289
+ The following are now exported from the main entry point:
290
+
291
+ ```typescript
292
+ // Types
293
+ export type {
294
+ TrinityTokens,
295
+ TrinityBaseTokens,
296
+ TrinitySemanticTokens,
297
+ TrinityComponentTokens,
298
+ TrinityDarkModeTokens,
299
+ TrinityColorShades,
300
+ TrinityBaseColors,
301
+ TrinitySpacing,
302
+ TrinityFontSize,
303
+ TrinityFontWeight,
304
+ TrinityBorderRadius,
305
+ TrinityShadows,
306
+ TrinitySemanticColors,
307
+ TrinityTypographyStyle,
308
+ TrinityButtonTokens,
309
+ TrinityInputTokens,
310
+ TrinityCardTokens,
311
+ TrinityNavigationTokens,
312
+ UseTrinityTokensResult,
313
+ };
314
+
315
+ // Utilities
316
+ export {
317
+ generateCssVariables,
318
+ generateDarkModeCssVariables,
319
+ injectTrinityCssVariables,
320
+ injectDarkModeCssVariables,
321
+ useTrinityTokens,
322
+ };
323
+ ```
324
+
325
+ ### Recommended Upgrade Steps
326
+
327
+ 1. **Update imports** to use the new main entry point if needed:
328
+ ```typescript
329
+ // New unified import
330
+ import { tokens, useTrinityTokens, injectTrinityCssVariables } from '@trinity/design-system';
331
+ ```
332
+
333
+ 2. **Update CSS variable references** to use the new naming convention.
334
+
335
+ 3. **Add type annotations** where you were previously using `any` with token objects.
336
+
337
+ 4. **Consider using `useTrinityTokens`** hook for theme-aware token access in React components.
338
+
339
+ 5. **Run tests** to ensure token values haven't changed unexpectedly.
340
+
341
+ ### Deprecations
342
+
343
+ None in this release.
344
+
345
+ ### Questions or Issues?
346
+
347
+ If you encounter any issues during migration, please open an issue on the GitHub repository.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # Trinity Design System
2
+
3
+ A customizable MUI-based design system with Trinity branding, WCAG 2.1 AA accessible color palette, and reusable navigation components.
4
+
5
+ ## � Documentation
6
+
7
+ | Guide | Description |
8
+ |-------|-------------|
9
+ | [**Quick Start**](./docs/QUICK_START.md) | Get running in 5 minutes |
10
+ | [**Developer Guide**](./docs/DEVELOPER_GUIDE.md) | Complete integration guide |
11
+ | [**Storybook**](http://localhost:6006) | Interactive component demos |
12
+
13
+ ---
14
+
15
+ ## 🚀 Quick Start
16
+
17
+ ### Install
18
+
19
+ ```bash
20
+ npm install @trinity/design-system @mui/material @mui/icons-material @emotion/react @emotion/styled
21
+ ```
22
+
23
+ **Optional dependencies** (only if using these features):
24
+ ```bash
25
+ # For DataTable component
26
+ npm install @mui/x-data-grid
27
+
28
+ # For DatePicker components
29
+ npm install @mui/x-date-pickers dayjs
30
+
31
+ # For Charts components
32
+ npm install recharts
33
+ ```
34
+
35
+ ### Setup
36
+
37
+ ```tsx
38
+ import { ThemeProvider, CssBaseline } from '@mui/material';
39
+ import { lightTheme } from '@trinity/design-system';
40
+
41
+ function App() {
42
+ return (
43
+ <ThemeProvider theme={lightTheme}>
44
+ <CssBaseline />
45
+ <YourApp />
46
+ </ThemeProvider>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### Use Components
52
+
53
+ ```tsx
54
+ import { Button, Card } from '@mui/material';
55
+ import { StatusIndicator, Modal } from '@trinity/design-system';
56
+
57
+ <Card sx={{ p: 3 }}>
58
+ <Button variant="contained">Save</Button>
59
+ <StatusIndicator status="success" label="Active" />
60
+ </Card>
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 🎨 Features
66
+
67
+ - **Trinity Branding** - Pre-configured colors, typography, and component styles
68
+ - **Accessible** - WCAG 2.1 AA compliant color combinations
69
+ - **Dark Mode** - Light and dark themes included
70
+ - **TypeScript** - Full type definitions
71
+ - **Tree-Shakeable** - Import only what you need
72
+
73
+ ---
74
+
75
+ ## 📦 What's Included
76
+
77
+ ### Themes
78
+ ```tsx
79
+ import { lightTheme, darkTheme, createTrinityTheme } from '@trinity/design-system';
80
+ ```
81
+
82
+ ### Components
83
+ ```tsx
84
+ import {
85
+ TopNavHeader, // Navigation header
86
+ TopNavWithSidebar, // Full layout with sidebar
87
+ StatusIndicator, // Status badges
88
+ Modal, // Accessible dialogs
89
+ FileUpload, // Drag-and-drop upload
90
+ AIChat, // AI chat interface
91
+ AIPromptInput, // AI prompt input
92
+ } from '@trinity/design-system';
93
+ ```
94
+
95
+ ### Design Tokens
96
+ ```tsx
97
+ import { baseTokens, semanticTokens, brandColors } from '@trinity/design-system';
98
+ ```
99
+
100
+ ### Utilities
101
+ ```tsx
102
+ import {
103
+ accessibleCombinations, // Pre-validated color pairs
104
+ getContrastRatio, // Check color contrast
105
+ validateAccessibility, // WCAG validation
106
+ } from '@trinity/design-system';
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 🛠 Development
112
+
113
+ ### Prerequisites
114
+ - Node.js 20.19+ or 22.12+
115
+ - npm, yarn, or pnpm
116
+
117
+ ### Setup
118
+
119
+ ```bash
120
+ # Clone and install
121
+ git clone <repo-url>
122
+ cd trinity-design-system
123
+ npm install
124
+
125
+ # Start development
126
+ npm run dev # App at http://localhost:5173
127
+ npm run storybook # Docs at http://localhost:6006
128
+ ```
129
+
130
+ ### Scripts
131
+
132
+ | Command | Description |
133
+ |---------|-------------|
134
+ | `npm run dev` | Start dev server |
135
+ | `npm run storybook` | Start Storybook |
136
+ | `npm run build` | Build for production |
137
+ | `npm run test` | Run tests |
138
+ | `npm run lint` | Run linter |
139
+
140
+ ---
141
+
142
+ **Trinity Design System** - Built with ❤️ using [MUI](https://mui.com/) and [Vite](https://vitejs.dev/)