@trinityui/design-system 1.0.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/CHANGELOG.md +28 -0
- package/CONTRIBUTING.md +394 -0
- package/MIGRATION.md +347 -0
- package/README.md +298 -0
- package/dist/ai.js +4466 -0
- package/dist/charts.js +2650 -0
- package/dist/data.js +1519 -0
- package/dist/forms.js +971 -0
- package/dist/index.js +6566 -0
- package/dist/navigation.js +4661 -0
- package/dist/theme.js +1355 -0
- package/dist/tokens.js +25 -0
- package/dist/trinity.css +1286 -0
- package/package.json +180 -0
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,298 @@
|
|
|
1
|
+
# Trinity Design System
|
|
2
|
+
|
|
3
|
+
MUI v6/7 with Trinity branding. WCAG 2.1 AA accessible.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @trinity/design-system @mui/material @mui/icons-material @emotion/react @emotion/styled
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Setup (One Time)
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// App.tsx
|
|
13
|
+
import { ThemeProvider, CssBaseline } from '@mui/material';
|
|
14
|
+
import { lightTheme } from '@trinity/design-system';
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<ThemeProvider theme={lightTheme}>
|
|
19
|
+
<CssBaseline />
|
|
20
|
+
<YourApp />
|
|
21
|
+
</ThemeProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**That's it.** All MUI components now have Trinity styling.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## The Golden Rule
|
|
31
|
+
|
|
32
|
+
> **Use MUI for everything.** Trinity just gives you a theme + a few custom components.
|
|
33
|
+
|
|
34
|
+
### ✅ Use MUI (99% of your code)
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { Button, Card, TextField, Typography, Chip } from '@mui/material';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
These are already styled by Trinity's theme. No extra imports needed.
|
|
41
|
+
|
|
42
|
+
### ✅ Use Trinity (only for these)
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import {
|
|
46
|
+
StatusIndicator, // Status badges (success/warning/error)
|
|
47
|
+
Modal, // Accessible modal dialogs
|
|
48
|
+
Toast, useToast, // Notifications
|
|
49
|
+
FileUpload, // Drag-and-drop upload
|
|
50
|
+
SimpleTable, // Basic table (no dependencies)
|
|
51
|
+
DataCard, // KPI/metric cards
|
|
52
|
+
} from '@trinity/design-system';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Quick Reference
|
|
56
|
+
|
|
57
|
+
| Need | Import From |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| Button, Card, TextField, etc. | `@mui/material` |
|
|
60
|
+
| Status badge | `StatusIndicator` from Trinity |
|
|
61
|
+
| Modal dialog | `Modal` from Trinity |
|
|
62
|
+
| Toast notification | `Toast` from Trinity |
|
|
63
|
+
| Simple table | `SimpleTable` from Trinity |
|
|
64
|
+
| Advanced data grid | `@mui/x-data-grid` (optional dep) |
|
|
65
|
+
| Charts | `recharts` (optional dep) |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Entry Points
|
|
70
|
+
|
|
71
|
+
| Import | What You Get |
|
|
72
|
+
|--------|--------------|
|
|
73
|
+
| `/essentials` | **Start here.** Theme + 10 components (16 exports) |
|
|
74
|
+
| Main | Full API (100+ exports) |
|
|
75
|
+
| `/theme` | Theme utilities only |
|
|
76
|
+
| `/tokens` | Design tokens only |
|
|
77
|
+
| `/css` | CSS variables (no React) |
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
// Recommended for most projects
|
|
81
|
+
import { lightTheme, StatusIndicator, Modal } from '@trinity/design-system/essentials';
|
|
82
|
+
|
|
83
|
+
// Full API when needed
|
|
84
|
+
import { TopNavHeader, InsightEngine, DataTable } from '@trinity/design-system';
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Dark Mode
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { lightTheme, darkTheme } from '@trinity/design-system';
|
|
93
|
+
|
|
94
|
+
const theme = isDarkMode ? darkTheme : lightTheme;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## CSS-Only Theme (No React)
|
|
100
|
+
|
|
101
|
+
For projects **without React** (static HTML, Vue, Angular, vanilla JS), use the CSS file directly.
|
|
102
|
+
|
|
103
|
+
📄 **[View CSS Source](src/styles/trinity.css)**
|
|
104
|
+
|
|
105
|
+
### When to Use CSS-Only
|
|
106
|
+
|
|
107
|
+
| Use Case | Solution |
|
|
108
|
+
|----------|----------|
|
|
109
|
+
| React + MUI app | Use `lightTheme` / `darkTheme` (JS) |
|
|
110
|
+
| Static HTML site | Use CSS file |
|
|
111
|
+
| Vue / Angular / Svelte | Use CSS file |
|
|
112
|
+
| WordPress / PHP | Use CSS file |
|
|
113
|
+
| Email templates | Use CSS file |
|
|
114
|
+
|
|
115
|
+
### Setup
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<!-- Option 1: Link directly -->
|
|
119
|
+
<link rel="stylesheet" href="node_modules/@trinity/design-system/dist/trinity.css" />
|
|
120
|
+
|
|
121
|
+
<!-- Option 2: Copy to your project -->
|
|
122
|
+
<link rel="stylesheet" href="/css/trinity.css" />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```css
|
|
126
|
+
/* Option 3: Import in your CSS/SCSS */
|
|
127
|
+
@import '@trinity/design-system/css';
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Usage
|
|
131
|
+
|
|
132
|
+
```css
|
|
133
|
+
/* Use Trinity variables in your styles */
|
|
134
|
+
.card {
|
|
135
|
+
background: var(--trinity-surface);
|
|
136
|
+
border: 1px solid var(--trinity-border);
|
|
137
|
+
border-radius: var(--trinity-radius-lg);
|
|
138
|
+
padding: var(--trinity-space-4);
|
|
139
|
+
box-shadow: var(--trinity-shadow-md);
|
|
140
|
+
font-family: var(--trinity-font-family);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.button-primary {
|
|
144
|
+
background: var(--trinity-coral);
|
|
145
|
+
color: var(--trinity-white);
|
|
146
|
+
border-radius: var(--trinity-radius-pill);
|
|
147
|
+
padding: var(--trinity-space-2) var(--trinity-space-4);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.status-success {
|
|
151
|
+
color: var(--trinity-success);
|
|
152
|
+
background: var(--trinity-success-bg);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Dark Mode
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<!-- Add attribute to enable dark mode -->
|
|
160
|
+
<html data-theme="dark">
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
// Toggle with JavaScript
|
|
165
|
+
document.documentElement.setAttribute('data-theme', 'dark');
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Available Variables
|
|
169
|
+
|
|
170
|
+
| Category | Examples |
|
|
171
|
+
|----------|----------|
|
|
172
|
+
| Brand | `--trinity-navy`, `--trinity-coral`, `--trinity-purple`, `--trinity-azure` |
|
|
173
|
+
| Semantic | `--trinity-text`, `--trinity-background`, `--trinity-surface`, `--trinity-border` |
|
|
174
|
+
| Status | `--trinity-success`, `--trinity-warning`, `--trinity-error`, `--trinity-info` |
|
|
175
|
+
| Spacing | `--trinity-space-1` through `--trinity-space-16` |
|
|
176
|
+
| Radius | `--trinity-radius-sm`, `--trinity-radius-md`, `--trinity-radius-lg`, `--trinity-radius-pill` |
|
|
177
|
+
| Typography | `--trinity-font-family`, `--trinity-text-sm`, `--trinity-font-bold` |
|
|
178
|
+
| Shadows | `--trinity-shadow-sm`, `--trinity-shadow-md`, `--trinity-shadow-lg` |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Optional Dependencies
|
|
183
|
+
|
|
184
|
+
Only install if you need these features:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm install @mui/x-data-grid # For DataTable component
|
|
188
|
+
npm install recharts # For Charts components
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
> 💡 Use `SimpleTable` for basic tables — no extra deps needed.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Development
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm run storybook # Component docs at localhost:6006
|
|
199
|
+
npm run dev # Dev server at localhost:5173
|
|
200
|
+
npm run build # Production build
|
|
201
|
+
npm run test # Run tests
|
|
202
|
+
npm run lint # Lint code
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Developer Quick Start
|
|
208
|
+
|
|
209
|
+
### 1. Clone & Install
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
git clone git@github.com:Trinity-UI-Components/trinity-design-system.git
|
|
213
|
+
cd trinity-design-system
|
|
214
|
+
npm install
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 2. Run Storybook
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm run storybook
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Open http://localhost:6006 to see all components with live examples.
|
|
224
|
+
|
|
225
|
+
### 3. Project Structure
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
src/
|
|
229
|
+
├── components/ # All components
|
|
230
|
+
├── theme.ts # MUI theme (lightTheme, darkTheme)
|
|
231
|
+
├── tokens.ts # Design tokens
|
|
232
|
+
├── essentials.ts # Simplified entry point
|
|
233
|
+
├── index.ts # Full public API
|
|
234
|
+
└── stories/ # Storybook stories
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 4. Create a New Component
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
// src/components/MyComponent/MyComponent.tsx
|
|
241
|
+
import { Box } from '@mui/material';
|
|
242
|
+
import { semanticTokens } from '../../tokens';
|
|
243
|
+
|
|
244
|
+
export interface MyComponentProps {
|
|
245
|
+
label: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const MyComponent = ({ label }: MyComponentProps) => (
|
|
249
|
+
<Box sx={{ color: semanticTokens.text.primary }}>
|
|
250
|
+
{label}
|
|
251
|
+
</Box>
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
// src/components/MyComponent/index.ts
|
|
255
|
+
export { MyComponent } from './MyComponent';
|
|
256
|
+
export type { MyComponentProps } from './MyComponent';
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### 5. Add a Story
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
// src/stories/MyComponent.stories.tsx
|
|
263
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
264
|
+
import { MyComponent } from '../components/MyComponent';
|
|
265
|
+
|
|
266
|
+
const meta: Meta<typeof MyComponent> = {
|
|
267
|
+
title: 'Components/MyComponent',
|
|
268
|
+
component: MyComponent,
|
|
269
|
+
tags: ['autodocs'],
|
|
270
|
+
};
|
|
271
|
+
export default meta;
|
|
272
|
+
|
|
273
|
+
type Story = StoryObj<typeof meta>;
|
|
274
|
+
|
|
275
|
+
export const Default: Story = {
|
|
276
|
+
args: { label: 'Hello World' },
|
|
277
|
+
};
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 6. Export from Public API
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
// src/index.ts
|
|
284
|
+
export { MyComponent } from './components/MyComponent';
|
|
285
|
+
export type { MyComponentProps } from './components/MyComponent';
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Links
|
|
291
|
+
|
|
292
|
+
- [Storybook](http://localhost:6006) — Interactive component demos
|
|
293
|
+
- [Quick Start Guide](./docs/QUICK_START.md)
|
|
294
|
+
- [Developer Guide](./docs/DEVELOPER_GUIDE.md)
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
MIT License • Built with [MUI](https://mui.com) + [Vite](https://vite.dev)
|