@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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Trinity Design System will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2025-01-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Complete Trinity Design System component library
|
|
9
|
+
- MUI v6/v7 compatible themes (light and dark mode)
|
|
10
|
+
- CSS-only theme entry point (`@trinity/design-system/css`)
|
|
11
|
+
- Design tokens system (baseTokens, semanticTokens, componentTokens)
|
|
12
|
+
- Extended MUI palette with Trinity semantic colors
|
|
13
|
+
- Accessibility utilities with WCAG 2.1 AA compliance
|
|
14
|
+
- `useTrinityPalette` hook for theme-aware components
|
|
15
|
+
|
|
16
|
+
### Components
|
|
17
|
+
- **Navigation**: TopNavHeader, TopNavWithSidebar, Footer
|
|
18
|
+
- **Feedback**: Modal, Toast, StatusIndicator, IllustratedMessage
|
|
19
|
+
- **Data Display**: DataTable, DataCard, Charts
|
|
20
|
+
- **Forms**: FileUpload, Combobox, RichTextEditor, FilterBar
|
|
21
|
+
- **AI**: AIChat, AIMessage, AIPromptInput, InsightEngineInput
|
|
22
|
+
- **Layout**: AppLayout, DockLayout, SplitPane, PageHeader
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
- Storybook with interactive component demos
|
|
26
|
+
- WCAG 2.1 AA accessibility documentation
|
|
27
|
+
- Design token usage guidelines
|
|
28
|
+
- Quick start guide
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Contributing to Trinity Design System
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to the Trinity Design System! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Workflow](#development-workflow)
|
|
10
|
+
- [Component Guidelines](#component-guidelines)
|
|
11
|
+
- [Styling Guidelines](#styling-guidelines)
|
|
12
|
+
- [Accessibility Requirements](#accessibility-requirements)
|
|
13
|
+
- [Testing Requirements](#testing-requirements)
|
|
14
|
+
- [Documentation](#documentation)
|
|
15
|
+
- [Pull Request Process](#pull-request-process)
|
|
16
|
+
|
|
17
|
+
## Code of Conduct
|
|
18
|
+
|
|
19
|
+
Please be respectful and constructive in all interactions. We are committed to providing a welcoming and inclusive environment for all contributors.
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
- Node.js 18+
|
|
26
|
+
- npm 9+
|
|
27
|
+
- Git
|
|
28
|
+
|
|
29
|
+
### Setup
|
|
30
|
+
|
|
31
|
+
1. Clone the repository:
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/your-org/trinity-design-system.git
|
|
34
|
+
cd trinity-design-system
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
2. Install dependencies:
|
|
38
|
+
```bash
|
|
39
|
+
npm install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. Start the development server:
|
|
43
|
+
```bash
|
|
44
|
+
npm run dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
4. Start Storybook:
|
|
48
|
+
```bash
|
|
49
|
+
npm run storybook
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Development Workflow
|
|
53
|
+
|
|
54
|
+
### Branch Naming
|
|
55
|
+
|
|
56
|
+
- `feature/` - New features
|
|
57
|
+
- `fix/` - Bug fixes
|
|
58
|
+
- `docs/` - Documentation updates
|
|
59
|
+
- `refactor/` - Code refactoring
|
|
60
|
+
- `test/` - Test additions or updates
|
|
61
|
+
|
|
62
|
+
Example: `feature/add-date-picker-component`
|
|
63
|
+
|
|
64
|
+
### Commit Messages
|
|
65
|
+
|
|
66
|
+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
type(scope): description
|
|
70
|
+
|
|
71
|
+
[optional body]
|
|
72
|
+
|
|
73
|
+
[optional footer]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Types:
|
|
77
|
+
- `feat`: New feature
|
|
78
|
+
- `fix`: Bug fix
|
|
79
|
+
- `docs`: Documentation only
|
|
80
|
+
- `style`: Formatting (no code change)
|
|
81
|
+
- `refactor`: Code refactoring
|
|
82
|
+
- `test`: Adding tests
|
|
83
|
+
- `chore`: Maintenance tasks
|
|
84
|
+
|
|
85
|
+
Examples:
|
|
86
|
+
```
|
|
87
|
+
feat(Button): add loading state prop
|
|
88
|
+
fix(StatusIndicator): correct color contrast for warning state
|
|
89
|
+
docs(README): update installation instructions
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Component Guidelines
|
|
93
|
+
|
|
94
|
+
### File Structure
|
|
95
|
+
|
|
96
|
+
New components should follow this structure:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
src/components/ComponentName/
|
|
100
|
+
├── index.ts # Barrel exports
|
|
101
|
+
├── ComponentName.tsx # Main component
|
|
102
|
+
├── types.ts # TypeScript types/interfaces
|
|
103
|
+
├── styles.ts # Styled components (if needed)
|
|
104
|
+
└── utils.ts # Helper functions (if needed)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Component Template
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import React from 'react';
|
|
111
|
+
import { Box, SxProps, Theme } from '@mui/material';
|
|
112
|
+
|
|
113
|
+
export interface MyComponentProps {
|
|
114
|
+
/** Description of the prop */
|
|
115
|
+
variant?: 'primary' | 'secondary';
|
|
116
|
+
/** Additional custom styles */
|
|
117
|
+
sx?: SxProps<Theme>;
|
|
118
|
+
/** Component content */
|
|
119
|
+
children?: React.ReactNode;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* MyComponent - Brief description of what the component does.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* <MyComponent variant="primary">Content</MyComponent>
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export const MyComponent: React.FC<MyComponentProps> = ({
|
|
131
|
+
variant = 'primary',
|
|
132
|
+
sx,
|
|
133
|
+
children,
|
|
134
|
+
}) => {
|
|
135
|
+
return (
|
|
136
|
+
<Box
|
|
137
|
+
sx={{
|
|
138
|
+
// Component styles
|
|
139
|
+
...sx,
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
{children}
|
|
143
|
+
</Box>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Export Components
|
|
149
|
+
|
|
150
|
+
Add exports to `src/components/index.ts`:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
export * from './MyComponent';
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Styling Guidelines
|
|
157
|
+
|
|
158
|
+
### Use Theme Tokens
|
|
159
|
+
|
|
160
|
+
Always use theme tokens from `src/theme.ts`:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
// ✅ Good
|
|
164
|
+
<Box sx={{ color: 'primary.main', borderRadius: 2 }}>
|
|
165
|
+
|
|
166
|
+
// ❌ Avoid
|
|
167
|
+
<Box sx={{ color: '#003366', borderRadius: '16px' }}>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Accessible Color Combinations
|
|
171
|
+
|
|
172
|
+
Use `accessibleCombinations` for text/background pairs:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { accessibleCombinations } from '../theme';
|
|
176
|
+
|
|
177
|
+
<Box sx={{
|
|
178
|
+
backgroundColor: accessibleCombinations.whiteOnNavy.bg,
|
|
179
|
+
color: accessibleCombinations.whiteOnNavy.text,
|
|
180
|
+
}}>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Trinity-Specific Patterns
|
|
184
|
+
|
|
185
|
+
- **Buttons**: Pill shape (`borderRadius: 100`), no elevation
|
|
186
|
+
- **Cards/Containers**: 16px border radius (light), 8px (dark)
|
|
187
|
+
- **Inputs**: 6px border radius for small inputs
|
|
188
|
+
- **Typography**: Montserrat font, no uppercase buttons
|
|
189
|
+
|
|
190
|
+
## Accessibility Requirements
|
|
191
|
+
|
|
192
|
+
All components must meet **WCAG 2.1 AA** standards:
|
|
193
|
+
|
|
194
|
+
### Minimum Requirements
|
|
195
|
+
|
|
196
|
+
1. **Color Contrast**: 4.5:1 for normal text, 3:1 for large text
|
|
197
|
+
2. **Keyboard Navigation**: All interactive elements must be keyboard accessible
|
|
198
|
+
3. **Focus Indicators**: Visible focus states for all focusable elements
|
|
199
|
+
4. **ARIA Labels**: Proper labels for screen readers
|
|
200
|
+
5. **Reduced Motion**: Respect `prefers-reduced-motion` preference
|
|
201
|
+
|
|
202
|
+
### Testing Accessibility
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
// Use accessibility utilities
|
|
206
|
+
import { useReducedMotion, VisuallyHidden } from '../accessibility';
|
|
207
|
+
|
|
208
|
+
const MyComponent = () => {
|
|
209
|
+
const prefersReducedMotion = useReducedMotion();
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<button>
|
|
213
|
+
<VisuallyHidden>Screen reader text</VisuallyHidden>
|
|
214
|
+
<Icon aria-hidden="true" />
|
|
215
|
+
</button>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Storybook Accessibility Addon
|
|
221
|
+
|
|
222
|
+
Run accessibility audits in Storybook using the addon-a11y panel.
|
|
223
|
+
|
|
224
|
+
## Testing Requirements
|
|
225
|
+
|
|
226
|
+
### Test Structure
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
src/
|
|
230
|
+
├── components/
|
|
231
|
+
│ ├── __tests__/
|
|
232
|
+
│ │ └── MyComponent.test.tsx
|
|
233
|
+
│ └── MyComponent.tsx
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Running Tests
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Run all tests
|
|
240
|
+
npm test
|
|
241
|
+
|
|
242
|
+
# Run tests with coverage
|
|
243
|
+
npm run test:coverage
|
|
244
|
+
|
|
245
|
+
# Run tests in watch mode
|
|
246
|
+
npm run test:watch
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Test Template
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
253
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
254
|
+
import { MyComponent } from '../MyComponent';
|
|
255
|
+
|
|
256
|
+
describe('MyComponent', () => {
|
|
257
|
+
it('should render with default props', () => {
|
|
258
|
+
render(<MyComponent>Content</MyComponent>);
|
|
259
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should handle click events', () => {
|
|
263
|
+
const onClick = vi.fn();
|
|
264
|
+
render(<MyComponent onClick={onClick}>Click me</MyComponent>);
|
|
265
|
+
|
|
266
|
+
fireEvent.click(screen.getByText('Click me'));
|
|
267
|
+
expect(onClick).toHaveBeenCalled();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('should apply custom styles', () => {
|
|
271
|
+
render(<MyComponent sx={{ color: 'red' }}>Styled</MyComponent>);
|
|
272
|
+
// Assert styles
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Coverage Requirements
|
|
278
|
+
|
|
279
|
+
- Minimum 80% code coverage for new components
|
|
280
|
+
- All public APIs must have tests
|
|
281
|
+
- Edge cases and error states should be tested
|
|
282
|
+
|
|
283
|
+
## Documentation
|
|
284
|
+
|
|
285
|
+
### Storybook Stories
|
|
286
|
+
|
|
287
|
+
Every component needs a Storybook story:
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
// src/stories/MyComponent.stories.tsx
|
|
291
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
292
|
+
import { MyComponent } from '../components/MyComponent';
|
|
293
|
+
|
|
294
|
+
const meta: Meta<typeof MyComponent> = {
|
|
295
|
+
title: 'Components/MyComponent',
|
|
296
|
+
component: MyComponent,
|
|
297
|
+
tags: ['autodocs'],
|
|
298
|
+
argTypes: {
|
|
299
|
+
variant: {
|
|
300
|
+
control: 'select',
|
|
301
|
+
options: ['primary', 'secondary'],
|
|
302
|
+
description: 'Visual variant',
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export default meta;
|
|
308
|
+
type Story = StoryObj<typeof meta>;
|
|
309
|
+
|
|
310
|
+
export const Default: Story = {
|
|
311
|
+
args: {
|
|
312
|
+
children: 'Default content',
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export const Secondary: Story = {
|
|
317
|
+
args: {
|
|
318
|
+
variant: 'secondary',
|
|
319
|
+
children: 'Secondary variant',
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### JSDoc Comments
|
|
325
|
+
|
|
326
|
+
All exported functions and components should have JSDoc comments:
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
/**
|
|
330
|
+
* Calculates the accessible color for a given background.
|
|
331
|
+
*
|
|
332
|
+
* @param backgroundColor - The background color in hex format
|
|
333
|
+
* @returns The appropriate text color for accessibility
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```tsx
|
|
337
|
+
* const textColor = getAccessibleColor('#003366');
|
|
338
|
+
* // Returns '#ffffff'
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
export const getAccessibleColor = (backgroundColor: string): string => {
|
|
342
|
+
// Implementation
|
|
343
|
+
};
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Pull Request Process
|
|
347
|
+
|
|
348
|
+
### Before Submitting
|
|
349
|
+
|
|
350
|
+
1. ✅ Run `npm run lint` and fix any issues
|
|
351
|
+
2. ✅ Run `npm test` and ensure all tests pass
|
|
352
|
+
3. ✅ Run `npm run build` to verify build succeeds
|
|
353
|
+
4. ✅ Update documentation if needed
|
|
354
|
+
5. ✅ Add/update Storybook stories
|
|
355
|
+
6. ✅ Update CHANGELOG.md with your changes
|
|
356
|
+
|
|
357
|
+
### PR Template
|
|
358
|
+
|
|
359
|
+
```markdown
|
|
360
|
+
## Description
|
|
361
|
+
Brief description of the changes.
|
|
362
|
+
|
|
363
|
+
## Type of Change
|
|
364
|
+
- [ ] Bug fix
|
|
365
|
+
- [ ] New feature
|
|
366
|
+
- [ ] Breaking change
|
|
367
|
+
- [ ] Documentation update
|
|
368
|
+
|
|
369
|
+
## Checklist
|
|
370
|
+
- [ ] Tests added/updated
|
|
371
|
+
- [ ] Documentation updated
|
|
372
|
+
- [ ] Storybook stories added/updated
|
|
373
|
+
- [ ] CHANGELOG.md updated
|
|
374
|
+
- [ ] Accessibility requirements met
|
|
375
|
+
- [ ] Token compliance verified (`npm run lint:tokens`)
|
|
376
|
+
- [ ] Any `eslint-disable` for colors references [INTENTIONAL_EXCEPTIONS.md](docs/INTENTIONAL_EXCEPTIONS.md)
|
|
377
|
+
|
|
378
|
+
## Screenshots (if applicable)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Review Process
|
|
382
|
+
|
|
383
|
+
1. Create PR against `main` branch
|
|
384
|
+
2. Request review from team members
|
|
385
|
+
3. Address feedback and update PR
|
|
386
|
+
4. Squash and merge when approved
|
|
387
|
+
|
|
388
|
+
## Questions?
|
|
389
|
+
|
|
390
|
+
If you have questions, feel free to:
|
|
391
|
+
- Open a GitHub issue
|
|
392
|
+
- Reach out to the design system team
|
|
393
|
+
|
|
394
|
+
Thank you for contributing! 🎉
|