@cere/cere-design-system 0.0.8 → 0.0.11

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.
@@ -0,0 +1,111 @@
1
+ ### Cere Design System — Development Guidelines (Material UI, Vite, Storybook, Jest)
2
+
3
+ These notes capture project-specific details for developing this Material UI–based design system. Components should be implemented first, then covered with comprehensive tests. They complement README/TESTING docs with nuances from this repo's configuration.
4
+
5
+ #### Build and Configuration
6
+ - Build tool: `tsup`
7
+ - Entry: `src/index.ts`
8
+ - Formats: CJS + ESM, with type declarations (`dts: true`)
9
+ - Externalized peer deps to keep bundle lean: `react`, `react-dom`, `@mui/*`, `@emotion/*`, `reactflow`, `@monaco-editor/react`
10
+ - Command: `npm run build`
11
+ - Type checking: `npm run type-check` (and `npm run check-types:ci` in CI)
12
+ - Linting: `npm run lint` or `npm run lint:fix`
13
+ - Vite (for Storybook and local tooling): minimal plugin setup in `vite.config.ts`
14
+ - Package entrypoints are defined in `package.json` `exports`, with `main/module/types` pointing to `dist/*`
15
+ - Peer dependencies (must be present in consumer app and in local dev):
16
+ - `@emotion/react`, `@emotion/styled`, `@mui/material`, `@mui/icons-material`, `@mui/lab`, `react`, `react-dom`, plus `reactflow`, `@monaco-editor/react` for third-party components
17
+
18
+ #### Storybook Setup (Vite)
19
+ - Start: `npm run storybook`
20
+ - Build: `npm run build-storybook`
21
+ - Customizations in `.storybook/main.ts`:
22
+ - CSS modules `localsConvention: 'camelCase'` to align class name access patterns
23
+ - `optimizeDeps.include` for `@monaco-editor/react`, `reactflow`, `monaco-editor`
24
+ - `define: { 'process.env': {} }` to satisfy Monaco in Vite/Storybook
25
+ - Accessibility: `.storybook/test-runner.ts` integrates `@axe-core/playwright` checks for every story root (`#storybook-root`). Run with `npm run test:storybook`.
26
+
27
+ #### Jest and RTL Configuration
28
+ - Jest setup in `jest.config.js`:
29
+ - Preset: `ts-jest`
30
+ - Environment: `jsdom`
31
+ - Roots: `<rootDir>/src`
32
+ - Test discovery: `**/__tests__/**/*.test.{ts,tsx}` and `**/*.test.{ts,tsx}` under `src/`
33
+ - Path alias: `^@/(.*)$ -> <rootDir>/src/$1`
34
+ - CSS modules auto-mocked via `identity-obj-proxy`
35
+ - Coverage excludes stories, test files, `src/index.ts`, and type decls
36
+ - Transform configured to ensure `jsx: 'react-jsx'`
37
+ - Test setup file: `src/setupTests.ts`
38
+ - Imports `@testing-library/jest-dom`
39
+ - Mocks `window.matchMedia` (important for MUI internals and components using media queries)
40
+ - Commands:
41
+ - All tests: `npm test`
42
+ - Watch: `npm run test:watch`
43
+ - Coverage: `npm run test:coverage`
44
+ - CI mode: `npm run test:ci`
45
+
46
+ #### Verified test run (local sanity)
47
+ A minimal Jest test was added temporarily at `src/__tests__/sanity.test.ts` and executed with:
48
+ ```
49
+ npm test -- src/__tests__/sanity.test.ts
50
+ ```
51
+ It passed (`1 passed`). The file was removed after verification to keep the repo clean. Use this pattern to quickly validate the test harness when needed.
52
+
53
+ #### Writing Tests (Pragmatic Workflow)
54
+ - Principle: Implement components first, then write comprehensive tests to ensure quality and prevent regressions.
55
+ - Where to put tests:
56
+ - Preferred: colocate under the component area using `__tests__` with `*.test.tsx` naming. Example: `src/components/layout/__tests__/Avatar.test.tsx`
57
+ - Alternatively: place a direct `*.test.tsx` beside the component; Jest will still pick it up.
58
+ - Wrap components with theme in tests:
59
+ ```
60
+ import { ThemeProvider } from '@mui/material';
61
+ import { theme } from '@/theme';
62
+ import { render } from '@testing-library/react';
63
+
64
+ const renderWithTheme = (ui: React.ReactElement) =>
65
+ render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>);
66
+ ```
67
+ - Use React Testing Library idioms:
68
+ - Prefer `getByRole`, `getByText`, `getByLabelText` and user-level interactions via `@testing-library/user-event`
69
+ - Use `@testing-library/jest-dom` matchers (already configured)
70
+ - Snapshot testing: Avoid broad snapshots for MUI; assert semantics and key props/attributes instead
71
+ - Accessibility: Validate roles, names, disabled state, focus management
72
+ - Example patterns already in repo: see `src/components/**/__tests__/*.test.tsx` (e.g., `Avatar.test.tsx`)
73
+
74
+ #### Adding Storybook Interaction Tests
75
+ - Add `play` functions to stories using `@storybook/test` utilities (e.g., `within`, `userEvent`)
76
+ - Run with: `npm run test:storybook`
77
+ - These tests also run automatic axe accessibility checks via the configured test runner
78
+
79
+ #### Component Authoring Conventions
80
+ - Material UI theming
81
+ - Use the shared `theme` from `src/theme` and expose component tokens via theme when practical
82
+ - Respect MUI variants/sizes; provide sensible defaults and typed props
83
+ - Public exports
84
+ - Ensure all new components are exported from `src/index.ts` and surfaced in the package
85
+ - CSS and classNames
86
+ - MUI’s `sx` and `styled` utilities are preferred; if class-based styling is necessary, remember Storybook’s CSS module config uses camelCase
87
+ - Third-party components
88
+ - If components integrate `reactflow` or `@monaco-editor/react`, keep their imports dynamic-friendly and avoid relying on Node globals; Storybook’s `process.env` shim is in place
89
+
90
+ #### Common Pitfalls and Fixes
91
+ - matchMedia not defined in JSDOM
92
+ - Already handled in `src/setupTests.ts`. If adding features that rely on different media APIs, extend this mock
93
+ - Failing to wrap with ThemeProvider in tests
94
+ - Most MUI components require theme context; tests should wrap components with `ThemeProvider`
95
+ - Missing peer dependencies in consumer app or local dev
96
+ - Install all listed peer deps to avoid runtime errors
97
+ - Class name expectations
98
+ - RTL queries should target roles and text over MUI-generated class names; class selectors may be brittle across MUI versions
99
+
100
+ #### Release Hygiene
101
+ - Run `npm run type-check && npm run lint && npm test && npm run build` before publishing
102
+ - Storybook should render locally (`npm run storybook`) for visual checks; optionally run `npm run test:storybook` for a11y/interaction coverage
103
+
104
+ #### Quick Development Loop
105
+ 1) Implement component following existing patterns and conventions
106
+ 2) Create Storybook story with all variants and states
107
+ 3) Write comprehensive tests under the component's `__tests__` folder
108
+ 4) Run `npm test -- componentPathOrPattern` to verify coverage
109
+ 5) Add `play` interaction tests to Storybook stories if relevant
110
+ 6) Verify accessibility with `npm run test:storybook`
111
+
package/README.md CHANGED
@@ -5,7 +5,7 @@ Cere Network Design System built with Material UI and React.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @cere-network/cere-design-system
8
+ npm install @cere/cere-design-system
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -205,6 +205,36 @@ npm run lint
205
205
 
206
206
  - [Full Components Reference](./COMPONENTS.md) - Complete API documentation
207
207
  - [Integration Guide](./INTEGRATION.md) - Step-by-step integration instructions
208
+ - **[AI Agent Context](./.agent/README.md)** - Component reference optimized for AI agents (Claude, GPT-4, Cursor, etc.)
209
+
210
+ ## AI-Assisted Development
211
+
212
+ This design system includes comprehensive AI agent context to accelerate development with AI coding assistants.
213
+
214
+ ### For AI Agents (Cursor, Claude, GPT-4, etc.)
215
+
216
+ The package includes a complete component reference optimized for AI agents at `.agent/rules/COMPONENTS.md`.
217
+
218
+ **Quick Start:**
219
+ ```bash
220
+ # After installing the package
221
+ cat node_modules/@cere/cere-design-system/.agent/rules/COMPONENTS.md
222
+ ```
223
+
224
+ Paste the output into your AI conversation to give the agent complete knowledge of:
225
+ - All 70+ available components
226
+ - Props and TypeScript types
227
+ - Usage examples and patterns
228
+ - Theme configuration
229
+ - Best practices
230
+
231
+ **Setup Methods:**
232
+
233
+ 1. **Direct reference** - Copy the file content into your AI conversation
234
+ 2. **Project rules** - Add to `.cursorrules` or `.agent/rules/`
235
+ 3. **Auto-inject** - Use a postinstall script to copy to your project
236
+
237
+ See [.agent/README.md](./.agent/README.md) for detailed setup instructions and examples.
208
238
 
209
239
  ## Integration with Existing Projects
210
240
 
@@ -224,8 +254,8 @@ To use this package in `dynamic-indexer-client` or other projects:
224
254
 
225
255
  3. Use in your app:
226
256
  ```tsx
227
- import { theme } from '@cere-network/cere-design-system';
228
- import { Button, Dialog, Sidebar } from '@cere-network/cere-design-system';
257
+ import { theme } from '@cere/cere-design-system';
258
+ import { Button, Dialog, Sidebar } from '@cere/cere-design-system';
229
259
  ```
230
260
 
231
261
  See [INTEGRATION.md](./INTEGRATION.md) for detailed migration guide.
Binary file
package/dist/index.css ADDED
@@ -0,0 +1,79 @@
1
+ /* src/assets/fonts/human-sans-font.css */
2
+ @font-face {
3
+ font-family: "HumanSans";
4
+ font-weight: 200;
5
+ font-style: normal;
6
+ font-display: swap;
7
+ src: url("./HumanSans-ExtraLight-VL7DEKQ4.otf") format("opentype");
8
+ }
9
+ @font-face {
10
+ font-family: "HumanSans";
11
+ font-weight: 300;
12
+ font-style: normal;
13
+ font-display: swap;
14
+ src: url("./HumanSans-Light-YV7AFKRB.otf") format("opentype");
15
+ }
16
+ @font-face {
17
+ font-family: "HumanSans";
18
+ font-weight: 400;
19
+ font-style: normal;
20
+ font-display: swap;
21
+ src: url("./HumanSans-Regular-QMFEP3F6.otf") format("opentype");
22
+ }
23
+ @font-face {
24
+ font-family: "HumanSans";
25
+ font-weight: 500;
26
+ font-style: normal;
27
+ font-display: swap;
28
+ src: url("./HumanSans-Medium-UULJ3PIR.otf") format("opentype");
29
+ }
30
+ @font-face {
31
+ font-family: "HumanSans";
32
+ font-weight: 700;
33
+ font-style: normal;
34
+ font-display: swap;
35
+ src: url("./HumanSans-Bold-4EAJ3L3T.otf") format("opentype");
36
+ }
37
+ @font-face {
38
+ font-family: "HumanSans";
39
+ font-weight: 900;
40
+ font-style: normal;
41
+ font-display: swap;
42
+ src: url("./HumanSans-Black-C4YJONK7.otf") format("opentype");
43
+ }
44
+ @font-face {
45
+ font-family: "HumanSans";
46
+ font-weight: 200;
47
+ font-style: oblique;
48
+ font-display: swap;
49
+ src: url("./HumanSans-ExtraLightOblique-VK2JTUXF.otf") format("opentype");
50
+ }
51
+ @font-face {
52
+ font-family: "HumanSans";
53
+ font-weight: 300;
54
+ font-style: oblique;
55
+ font-display: swap;
56
+ src: url("./HumanSans-LightOblique-VIXV7QA6.otf") format("opentype");
57
+ }
58
+ @font-face {
59
+ font-family: "HumanSans";
60
+ font-weight: 400;
61
+ font-style: oblique;
62
+ font-display: swap;
63
+ src: url("./HumanSans-RegularOblique-YPKQJAAM.otf") format("opentype");
64
+ }
65
+ @font-face {
66
+ font-family: "HumanSans";
67
+ font-weight: 500;
68
+ font-style: oblique;
69
+ font-display: swap;
70
+ src: url("./HumanSans-MediumOblique-M7FHDZRS.otf") format("opentype");
71
+ }
72
+ @font-face {
73
+ font-family: "HumanSans";
74
+ font-weight: 700;
75
+ font-style: oblique;
76
+ font-display: swap;
77
+ src: url("./HumanSans-BoldOblique-4D325T4F.otf") format("opentype");
78
+ }
79
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/assets/fonts/human-sans-font.css"],"sourcesContent":["@font-face {\n font-family: 'HumanSans';\n font-weight: 200;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-ExtraLight.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 300;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-Light.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 400;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-Regular.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 500;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-Medium.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 700;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-Bold.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 900;\n font-style: normal;\n font-display: swap;\n src: url('./HumanSans-Black.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 200;\n font-style: oblique;\n font-display: swap;\n src: url('./HumanSans-ExtraLightOblique.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 300;\n font-style: oblique;\n font-display: swap;\n src: url('./HumanSans-LightOblique.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 400;\n font-style: oblique;\n font-display: swap;\n src: url('./HumanSans-RegularOblique.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 500;\n font-style: oblique;\n font-display: swap;\n src: url('./HumanSans-MediumOblique.otf') format('opentype');\n}\n\n@font-face {\n font-family: 'HumanSans';\n font-weight: 700;\n font-style: oblique;\n font-display: swap;\n src: url('./HumanSans-BoldOblique.otf') format('opentype');\n}\n\n"],"mappings":";AAAA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,2CAAkC,OAAO;AAChD;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,sCAA6B,OAAO;AAC3C;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,wCAA+B,OAAO;AAC7C;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,uCAA8B,OAAO;AAC5C;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,qCAA4B,OAAO;AAC1C;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,sCAA6B,OAAO;AAC3C;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,kDAAyC,OAAO;AACvD;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,6CAAoC,OAAO;AAClD;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,+CAAsC,OAAO;AACpD;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,8CAAqC,OAAO;AACnD;AAEA;AACE,eAAa;AACb,eAAa;AACb,cAAY;AACZ,gBAAc;AACd,OAAK,4CAAmC,OAAO;AACjD;","names":[]}