skillstore-cli 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/README.md +95 -0
- package/data/bundles/devflow-complete.json +19 -0
- package/data/free-skills/devflow-agile/manifest.json +19 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/retro.md +23 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/review.md +21 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/sprint.md +30 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile/standup.md +20 -0
- package/data/free-skills/devflow-agile/plugin/commands/agile.md +35 -0
- package/data/free-skills/devflow-agile/plugin/commands/devflow.md +42 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/SKILL.md +93 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/assets/sample-output.md +182 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-architecture.md +361 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-code-guide.md +207 -0
- package/data/free-skills/devflow-agile/plugin/skills/developer/references/debugging-methodology.md +191 -0
- package/data/free-skills/devflow-agile/template/agents/agile-coach.md +76 -0
- package/data/free-skills/devflow-agile/template/workflows/agile-sprint-workflow.md +81 -0
- package/data/free-skills/devflow-bootstrap/manifest.json +8 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap/auto.md +31 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap.md +38 -0
- package/data/free-skills/devflow-bootstrap/plugin/commands/devflow.md +20 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/SKILL.md +56 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/assets/sample-output.md +216 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/architecture-decisions.md +254 -0
- package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/stack-templates.md +400 -0
- package/data/free-skills/devflow-bootstrap/template/agents/bootstrap-specialist.md +56 -0
- package/data/free-skills/devflow-bootstrap/template/workflows/bootstrap-workflow.md +70 -0
- package/data/free-skills/devflow-docs/manifest.json +8 -0
- package/data/free-skills/devflow-docs/plugin/commands/devflow.md +20 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs/generate.md +17 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs/parse.md +19 -0
- package/data/free-skills/devflow-docs/plugin/commands/docs.md +26 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/SKILL.md +59 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/assets/sample-output.md +114 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/extraction-techniques.md +115 -0
- package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/ocr-strategies.md +167 -0
- package/data/free-skills/devflow-docs/template/agents/docs-specialist.md +35 -0
- package/data/free-skills/devflow-docs/template/workflows/docs-workflow.md +70 -0
- package/data/free-skills/devflow-postproject/manifest.json +13 -0
- package/data/free-skills/devflow-postproject/plugin/commands/devflow.md +34 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/handover.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/retro.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject/support.md +21 -0
- package/data/free-skills/devflow-postproject/plugin/commands/postproject.md +32 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/SKILL.md +70 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/assets/sample-output.md +79 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/facilitation-techniques.md +178 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/lessons-learned-template.md +118 -0
- package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/retro-techniques.md +100 -0
- package/data/free-skills/devflow-postproject/template/agents/transition-manager.md +71 -0
- package/data/free-skills/devflow-postproject/template/workflows/transition-workflow.md +72 -0
- package/data/free-skills/devflow-presale/manifest.json +15 -0
- package/data/free-skills/devflow-presale/plugin/commands/devflow.md +47 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/analyze.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/estimate.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/price.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale/propose.md +30 -0
- package/data/free-skills/devflow-presale/plugin/commands/presale.md +42 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/SKILL.md +63 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/assets/sample-output.md +129 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/extraction-framework.md +140 -0
- package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/output-template.md +132 -0
- package/data/free-skills/devflow-presale/template/agents/presale-lead.md +83 -0
- package/data/free-skills/devflow-presale/template/agents/proposal-reviewer.md +63 -0
- package/data/free-skills/devflow-presale/template/workflows/presale-workflow.md +70 -0
- package/data/registry/categories.json +7 -0
- package/data/registry/packages.json +184 -0
- package/data/shared/framework/agents/brainstormer.md +74 -0
- package/data/shared/framework/agents/code-reviewer.md +87 -0
- package/data/shared/framework/agents/debugger.md +84 -0
- package/data/shared/framework/agents/docs-manager.md +55 -0
- package/data/shared/framework/agents/git-manager.md +59 -0
- package/data/shared/framework/agents/planner.md +68 -0
- package/data/shared/framework/agents/researcher.md +66 -0
- package/data/shared/framework/agents/tester.md +65 -0
- package/data/shared/framework/commands/cook/auto.md +27 -0
- package/data/shared/framework/commands/cook.md +45 -0
- package/data/shared/framework/commands/fix/ci.md +21 -0
- package/data/shared/framework/commands/fix/test.md +26 -0
- package/data/shared/framework/commands/fix/types.md +29 -0
- package/data/shared/framework/commands/fix.md +26 -0
- package/data/shared/framework/commands/git/cm.md +37 -0
- package/data/shared/framework/commands/git/pr.md +40 -0
- package/data/shared/framework/config/CLAUDE.md.template +26 -0
- package/data/shared/framework/config/settings.json +41 -0
- package/data/shared/framework/config/skillstore.config.json +29 -0
- package/data/shared/framework/hooks/discord-notify.sh +85 -0
- package/data/shared/framework/hooks/docs-sync.sh +53 -0
- package/data/shared/framework/hooks/modularization-hook.js +103 -0
- package/data/shared/framework/hooks/notification.js +94 -0
- package/data/shared/framework/hooks/quality-gate.js +109 -0
- package/data/shared/framework/hooks/scout-block.js +77 -0
- package/data/shared/framework/hooks/telegram-notify.sh +77 -0
- package/data/shared/framework/protocols/error-recovery.md +80 -0
- package/data/shared/framework/protocols/orchestration-protocol.md +112 -0
- package/data/shared/framework/quality/review-protocol.md +76 -0
- package/data/shared/framework/quality/verification-protocol.md +66 -0
- package/data/shared/framework/rules/development-rules.md +75 -0
- package/data/shared/framework/skills/backend-development/SKILL.md +77 -0
- package/data/shared/framework/skills/backend-development/assets/sample-output.md +175 -0
- package/data/shared/framework/skills/backend-development/references/advanced-patterns.md +180 -0
- package/data/shared/framework/skills/backend-development/references/api-design-guide.md +160 -0
- package/data/shared/framework/skills/backend-development/references/architecture-patterns.md +183 -0
- package/data/shared/framework/skills/backend-development/references/observability-resilience.md +155 -0
- package/data/shared/framework/skills/backend-development/references/troubleshooting.md +199 -0
- package/data/shared/framework/skills/codebase-analysis/SKILL.md +72 -0
- package/data/shared/framework/skills/codebase-analysis/assets/sample-output.md +263 -0
- package/data/shared/framework/skills/codebase-analysis/references/analysis-techniques.md +241 -0
- package/data/shared/framework/skills/codebase-analysis/references/dependency-mapping.md +280 -0
- package/data/shared/framework/skills/codebase-analysis/references/tech-debt-assessment.md +208 -0
- package/data/shared/framework/skills/databases/SKILL.md +72 -0
- package/data/shared/framework/skills/databases/assets/sample-output.md +212 -0
- package/data/shared/framework/skills/databases/references/advanced-data-patterns.md +259 -0
- package/data/shared/framework/skills/databases/references/query-optimization.md +214 -0
- package/data/shared/framework/skills/databases/references/schema-design.md +159 -0
- package/data/shared/framework/skills/databases/references/troubleshooting.md +214 -0
- package/data/shared/framework/skills/debugging-investigation/SKILL.md +84 -0
- package/data/shared/framework/skills/debugging-investigation/assets/sample-output.md +314 -0
- package/data/shared/framework/skills/debugging-investigation/references/systematic-debugging.md +197 -0
- package/data/shared/framework/skills/debugging-investigation/references/tool-specific-guides.md +202 -0
- package/data/shared/framework/skills/debugging-investigation/references/troubleshooting-patterns.md +196 -0
- package/data/shared/framework/skills/frontend-development/SKILL.md +67 -0
- package/data/shared/framework/skills/frontend-development/assets/sample-output.md +110 -0
- package/data/shared/framework/skills/frontend-development/references/component-patterns.md +112 -0
- package/data/shared/framework/skills/frontend-development/references/performance-guide.md +169 -0
- package/data/shared/framework/skills/frontend-development/references/routing-forms-realtime.md +374 -0
- package/data/shared/framework/skills/frontend-development/references/ssr-rsc-patterns.md +284 -0
- package/data/shared/framework/skills/frontend-development/references/troubleshooting.md +154 -0
- package/data/shared/framework/skills/mobile-development/SKILL.md +67 -0
- package/data/shared/framework/skills/mobile-development/assets/sample-output.md +382 -0
- package/data/shared/framework/skills/mobile-development/references/mobile-patterns.md +681 -0
- package/data/shared/framework/skills/mobile-development/references/mobile-performance.md +524 -0
- package/data/shared/framework/skills/mobile-development/references/troubleshooting.md +158 -0
- package/data/shared/framework/skills/security-audit/SKILL.md +83 -0
- package/data/shared/framework/skills/security-audit/assets/sample-output.md +451 -0
- package/data/shared/framework/skills/security-audit/references/owasp-checklist.md +580 -0
- package/data/shared/framework/skills/security-audit/references/secure-coding-patterns.md +433 -0
- package/data/shared/framework/skills/security-audit/references/vulnerability-remediation.md +331 -0
- package/data/shared/framework/skills/ui-generation/SKILL.md +70 -0
- package/data/shared/framework/skills/ui-generation/assets/sample-output.md +139 -0
- package/data/shared/framework/skills/ui-generation/references/accessibility-responsive.md +127 -0
- package/data/shared/framework/skills/ui-generation/references/compound-components.md +252 -0
- package/data/shared/framework/skills/ui-generation/references/generation-patterns.md +110 -0
- package/data/shared/framework/skills/ui-generation/references/storybook-design-system.md +278 -0
- package/data/shared/framework/skills/ui-generation/references/troubleshooting.md +198 -0
- package/data/shared/framework/workflows/documentation-management.md +58 -0
- package/data/shared/framework/workflows/primary-workflow.md +88 -0
- package/dist/commands/activate.d.ts +3 -0
- package/dist/commands/activate.d.ts.map +1 -0
- package/dist/commands/activate.js +34 -0
- package/dist/commands/activate.js.map +1 -0
- package/dist/commands/bundle.d.ts +3 -0
- package/dist/commands/bundle.d.ts.map +1 -0
- package/dist/commands/bundle.js +64 -0
- package/dist/commands/bundle.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +99 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +37 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +30 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +35 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +68 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/download/cache.d.ts +3 -0
- package/dist/download/cache.d.ts.map +1 -0
- package/dist/download/cache.js +18 -0
- package/dist/download/cache.js.map +1 -0
- package/dist/download/client.d.ts +2 -0
- package/dist/download/client.d.ts.map +1 -0
- package/dist/download/client.js +58 -0
- package/dist/download/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/file-copier.d.ts +6 -0
- package/dist/installer/file-copier.d.ts.map +1 -0
- package/dist/installer/file-copier.js +32 -0
- package/dist/installer/file-copier.js.map +1 -0
- package/dist/installer/plugin-installer.d.ts +12 -0
- package/dist/installer/plugin-installer.d.ts.map +1 -0
- package/dist/installer/plugin-installer.js +33 -0
- package/dist/installer/plugin-installer.js.map +1 -0
- package/dist/installer/template-installer.d.ts +12 -0
- package/dist/installer/template-installer.d.ts.map +1 -0
- package/dist/installer/template-installer.js +45 -0
- package/dist/installer/template-installer.js.map +1 -0
- package/dist/license/crypto.d.ts +16 -0
- package/dist/license/crypto.d.ts.map +1 -0
- package/dist/license/crypto.js +50 -0
- package/dist/license/crypto.js.map +1 -0
- package/dist/license/license-store.d.ts +19 -0
- package/dist/license/license-store.d.ts.map +1 -0
- package/dist/license/license-store.js +99 -0
- package/dist/license/license-store.js.map +1 -0
- package/dist/license/validator.d.ts +32 -0
- package/dist/license/validator.d.ts.map +1 -0
- package/dist/license/validator.js +81 -0
- package/dist/license/validator.js.map +1 -0
- package/dist/registry/loader.d.ts +30 -0
- package/dist/registry/loader.d.ts.map +1 -0
- package/dist/registry/loader.js +22 -0
- package/dist/registry/loader.js.map +1 -0
- package/dist/registry/search-engine.d.ts +9 -0
- package/dist/registry/search-engine.d.ts.map +1 -0
- package/dist/registry/search-engine.js +30 -0
- package/dist/registry/search-engine.js.map +1 -0
- package/dist/utils/config.d.ts +14 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +28 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/paths.d.ts +20 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +79 -0
- package/dist/utils/paths.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Compound Components & Design System Patterns
|
|
2
|
+
|
|
3
|
+
## Compound Component Pattern (React)
|
|
4
|
+
|
|
5
|
+
Compound components share implicit state through Context, giving consumers full control over rendering order and structure.
|
|
6
|
+
|
|
7
|
+
### Core Pattern
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { createContext, useContext, useState, ReactNode } from 'react';
|
|
11
|
+
|
|
12
|
+
// 1. Shared context
|
|
13
|
+
interface TabsContextValue {
|
|
14
|
+
activeTab: string;
|
|
15
|
+
setActiveTab: (id: string) => void;
|
|
16
|
+
}
|
|
17
|
+
const TabsContext = createContext<TabsContextValue | null>(null);
|
|
18
|
+
|
|
19
|
+
function useTabsContext() {
|
|
20
|
+
const ctx = useContext(TabsContext);
|
|
21
|
+
if (!ctx) throw new Error('Tabs compound components must be used within <Tabs>');
|
|
22
|
+
return ctx;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 2. Root component owns the state
|
|
26
|
+
interface TabsProps {
|
|
27
|
+
defaultTab: string;
|
|
28
|
+
children: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
function Tabs({ defaultTab, children }: TabsProps) {
|
|
31
|
+
const [activeTab, setActiveTab] = useState(defaultTab);
|
|
32
|
+
return (
|
|
33
|
+
<TabsContext.Provider value={{ activeTab, setActiveTab }}>
|
|
34
|
+
<div role="tablist">{children}</div>
|
|
35
|
+
</TabsContext.Provider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 3. Child components consume context
|
|
40
|
+
function Tab({ id, children }: { id: string; children: ReactNode }) {
|
|
41
|
+
const { activeTab, setActiveTab } = useTabsContext();
|
|
42
|
+
return (
|
|
43
|
+
<button
|
|
44
|
+
role="tab"
|
|
45
|
+
aria-selected={activeTab === id}
|
|
46
|
+
onClick={() => setActiveTab(id)}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</button>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Panel({ id, children }: { id: string; children: ReactNode }) {
|
|
54
|
+
const { activeTab } = useTabsContext();
|
|
55
|
+
if (activeTab !== id) return null;
|
|
56
|
+
return <div role="tabpanel">{children}</div>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 4. Attach sub-components for dot notation
|
|
60
|
+
Tabs.Tab = Tab;
|
|
61
|
+
Tabs.Panel = Panel;
|
|
62
|
+
|
|
63
|
+
// Usage
|
|
64
|
+
<Tabs defaultTab="settings">
|
|
65
|
+
<Tabs.Tab id="profile">Profile</Tabs.Tab>
|
|
66
|
+
<Tabs.Tab id="settings">Settings</Tabs.Tab>
|
|
67
|
+
<Tabs.Panel id="profile">Profile content</Tabs.Panel>
|
|
68
|
+
<Tabs.Panel id="settings">Settings content</Tabs.Panel>
|
|
69
|
+
</Tabs>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### When to Use Compound Components
|
|
73
|
+
- Components with multiple related pieces (Tabs, Accordion, Select, Menu)
|
|
74
|
+
- Consumer needs flexibility in ordering and wrapping sub-components
|
|
75
|
+
- Shared state should be implicit, not passed via props drilling
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Headless UI Libraries
|
|
80
|
+
|
|
81
|
+
Headless libraries provide behavior and accessibility with zero styling, giving full visual control.
|
|
82
|
+
|
|
83
|
+
### Comparison
|
|
84
|
+
|
|
85
|
+
| Library | Framework | Styling Approach | Component Count | Key Strength |
|
|
86
|
+
|---|---|---|---|---|
|
|
87
|
+
| Radix UI | React | Fully unstyled | 30+ primitives | Best accessibility, fine-grained parts |
|
|
88
|
+
| Headless UI | React, Vue | Fully unstyled | ~10 components | Tailwind Labs, tight Tailwind integration |
|
|
89
|
+
| Ark UI | React, Vue, Solid | Fully unstyled | 40+ components | State machine driven (Zag.js), multi-framework |
|
|
90
|
+
|
|
91
|
+
### Radix UI Usage Pattern
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import * as Select from '@radix-ui/react-select';
|
|
95
|
+
|
|
96
|
+
<Select.Root>
|
|
97
|
+
<Select.Trigger className="px-4 py-2 border rounded">
|
|
98
|
+
<Select.Value placeholder="Choose..." />
|
|
99
|
+
<Select.Icon />
|
|
100
|
+
</Select.Trigger>
|
|
101
|
+
<Select.Portal>
|
|
102
|
+
<Select.Content className="bg-white shadow-lg rounded-md p-1">
|
|
103
|
+
<Select.Viewport>
|
|
104
|
+
<Select.Item value="react" className="px-3 py-2 cursor-pointer hover:bg-gray-100 rounded">
|
|
105
|
+
<Select.ItemText>React</Select.ItemText>
|
|
106
|
+
</Select.Item>
|
|
107
|
+
<Select.Item value="vue" className="px-3 py-2 cursor-pointer hover:bg-gray-100 rounded">
|
|
108
|
+
<Select.ItemText>Vue</Select.ItemText>
|
|
109
|
+
</Select.Item>
|
|
110
|
+
</Select.Viewport>
|
|
111
|
+
</Select.Content>
|
|
112
|
+
</Select.Portal>
|
|
113
|
+
</Select.Root>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Slot-Based vs Children-Based Composition
|
|
119
|
+
|
|
120
|
+
### Vue Slots
|
|
121
|
+
|
|
122
|
+
```vue
|
|
123
|
+
<!-- BaseCard.vue -->
|
|
124
|
+
<template>
|
|
125
|
+
<div class="card">
|
|
126
|
+
<header v-if="$slots.header"><slot name="header" /></header>
|
|
127
|
+
<div class="card-body"><slot /></div>
|
|
128
|
+
<footer v-if="$slots.footer"><slot name="footer" :count="itemCount" /></footer>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
|
|
132
|
+
<!-- Usage: scoped slot receives data from child -->
|
|
133
|
+
<BaseCard>
|
|
134
|
+
<template #header>Order Summary</template>
|
|
135
|
+
<p>Main content here</p>
|
|
136
|
+
<template #footer="{ count }">{{ count }} items</template>
|
|
137
|
+
</BaseCard>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### React Children Equivalent
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
// React achieves the same via props or render props
|
|
144
|
+
<Card
|
|
145
|
+
header={<h3>Order Summary</h3>}
|
|
146
|
+
footer={(count) => <span>{count} items</span>}
|
|
147
|
+
>
|
|
148
|
+
<p>Main content here</p>
|
|
149
|
+
</Card>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Key difference**: Vue slots are a first-class template feature with named/scoped variants. React uses composition through props (ReactNode) or render props (functions). Both achieve the same flexibility — choose based on your framework.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Design System Governance
|
|
157
|
+
|
|
158
|
+
### Component API Stability
|
|
159
|
+
|
|
160
|
+
- **Stable**: shipped, documented, covered by semver — breaking changes require a major version
|
|
161
|
+
- **Beta**: functional but API may change — prefix with `Beta` or flag in docs
|
|
162
|
+
- **Deprecated**: still works but scheduled for removal — log console warnings, link to migration guide
|
|
163
|
+
|
|
164
|
+
### Versioning Policy
|
|
165
|
+
|
|
166
|
+
1. **Patch** (1.0.x): bug fixes, style tweaks that don't change API
|
|
167
|
+
2. **Minor** (1.x.0): new components, new optional props on existing components
|
|
168
|
+
3. **Major** (x.0.0): removed props, renamed components, changed default behavior
|
|
169
|
+
|
|
170
|
+
### Deprecation Process
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
/** @deprecated Use `variant` prop instead. Will be removed in v4.0. */
|
|
174
|
+
interface ButtonProps {
|
|
175
|
+
/** @deprecated */ type?: 'primary' | 'secondary';
|
|
176
|
+
variant?: 'primary' | 'secondary';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function Button({ type, variant, ...props }: ButtonProps) {
|
|
180
|
+
if (type && !variant) {
|
|
181
|
+
console.warn('[DesignSystem] Button `type` prop is deprecated. Use `variant` instead.');
|
|
182
|
+
variant = type;
|
|
183
|
+
}
|
|
184
|
+
// ...
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Token-Driven Theming
|
|
191
|
+
|
|
192
|
+
### Design Token Format (W3C Draft)
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"color": {
|
|
197
|
+
"primary": { "$value": "#2563eb", "$type": "color" },
|
|
198
|
+
"primary-hover": { "$value": "#1d4ed8", "$type": "color" }
|
|
199
|
+
},
|
|
200
|
+
"spacing": {
|
|
201
|
+
"sm": { "$value": "8px", "$type": "dimension" },
|
|
202
|
+
"md": { "$value": "16px", "$type": "dimension" },
|
|
203
|
+
"lg": { "$value": "24px", "$type": "dimension" }
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### CSS Custom Properties Pipeline
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
tokens.json → Style Dictionary → css/variables.css + tailwind.config.ts
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
/* Generated: css/variables.css */
|
|
216
|
+
:root {
|
|
217
|
+
--color-primary: #2563eb;
|
|
218
|
+
--color-primary-hover: #1d4ed8;
|
|
219
|
+
--spacing-sm: 8px;
|
|
220
|
+
--spacing-md: 16px;
|
|
221
|
+
--spacing-lg: 24px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Dark theme override */
|
|
225
|
+
[data-theme="dark"] {
|
|
226
|
+
--color-primary: #60a5fa;
|
|
227
|
+
--color-primary-hover: #93bbfd;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Tailwind Integration
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// tailwind.config.ts
|
|
235
|
+
export default {
|
|
236
|
+
theme: {
|
|
237
|
+
extend: {
|
|
238
|
+
colors: {
|
|
239
|
+
primary: 'var(--color-primary)',
|
|
240
|
+
'primary-hover': 'var(--color-primary-hover)',
|
|
241
|
+
},
|
|
242
|
+
spacing: {
|
|
243
|
+
sm: 'var(--spacing-sm)',
|
|
244
|
+
md: 'var(--spacing-md)',
|
|
245
|
+
lg: 'var(--spacing-lg)',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
This pipeline lets you change a token value in one place and have it propagate to CSS, Tailwind utilities, and any platform (iOS, Android) that consumes the same tokens.json source.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Generation Patterns
|
|
2
|
+
|
|
3
|
+
## Description Parsing
|
|
4
|
+
|
|
5
|
+
### Keyword-to-Component Mapping
|
|
6
|
+
|
|
7
|
+
| Keywords | Component Type | Base Structure |
|
|
8
|
+
|----------|---------------|----------------|
|
|
9
|
+
| form, input, submit, field | Form | `<form>` with labeled inputs |
|
|
10
|
+
| table, list, grid, data | Data Display | `<table>` or grid layout |
|
|
11
|
+
| card, tile, item | Card | Flex/grid container with card items |
|
|
12
|
+
| nav, menu, sidebar, header | Navigation | `<nav>` with links/buttons |
|
|
13
|
+
| modal, dialog, popup | Overlay | Dialog with backdrop |
|
|
14
|
+
| dashboard, overview, stats | Dashboard | Grid of metric cards + charts |
|
|
15
|
+
| tabs, accordion, panel | Content Switcher | Tab/accordion pattern |
|
|
16
|
+
|
|
17
|
+
### Modifier Detection
|
|
18
|
+
|
|
19
|
+
| Modifier | Effect |
|
|
20
|
+
|----------|--------|
|
|
21
|
+
| "sortable" | Add sort handlers and indicators |
|
|
22
|
+
| "searchable" / "filterable" | Add search/filter input above content |
|
|
23
|
+
| "paginated" | Add pagination controls |
|
|
24
|
+
| "editable" / "inline edit" | Add edit mode toggle |
|
|
25
|
+
| "draggable" | Add drag handles and reorder logic |
|
|
26
|
+
| "collapsible" | Add expand/collapse toggle |
|
|
27
|
+
|
|
28
|
+
## Framework Templates
|
|
29
|
+
|
|
30
|
+
### React (JSX + Tailwind)
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
interface ComponentProps {
|
|
34
|
+
// Define based on parsed requirements
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function Component({ ...props }: ComponentProps) {
|
|
38
|
+
return (
|
|
39
|
+
<div className="...">
|
|
40
|
+
{/* Semantic structure */}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Vue (SFC)
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
interface Props {
|
|
51
|
+
// Define based on parsed requirements
|
|
52
|
+
}
|
|
53
|
+
const props = defineProps<Props>();
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<div class="...">
|
|
58
|
+
<!-- Semantic structure -->
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### HTML/CSS
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<div class="component">
|
|
67
|
+
<!-- Semantic structure -->
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
.component {
|
|
72
|
+
/* Layout and styling */
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Design Token Integration
|
|
78
|
+
|
|
79
|
+
### Spacing Scale
|
|
80
|
+
Use project tokens if available, otherwise default to 4px base:
|
|
81
|
+
- `xs`: 4px | `sm`: 8px | `md`: 16px | `lg`: 24px | `xl`: 32px | `2xl`: 48px
|
|
82
|
+
|
|
83
|
+
### Typography Scale
|
|
84
|
+
- `text-xs`: 12px | `text-sm`: 14px | `text-base`: 16px
|
|
85
|
+
- `text-lg`: 18px | `text-xl`: 20px | `text-2xl`: 24px
|
|
86
|
+
|
|
87
|
+
### Color Strategy
|
|
88
|
+
- Use semantic color names: `primary`, `secondary`, `success`, `warning`, `error`
|
|
89
|
+
- Always define both light and dark mode variants
|
|
90
|
+
- Ensure contrast ratios meet WCAG AA
|
|
91
|
+
|
|
92
|
+
## State & Props Design
|
|
93
|
+
|
|
94
|
+
### Props Principles
|
|
95
|
+
- Required props: data the component cannot function without
|
|
96
|
+
- Optional props with defaults: customization points
|
|
97
|
+
- Render props / slots: composition for complex content areas
|
|
98
|
+
- Event handlers: callbacks for user interactions
|
|
99
|
+
|
|
100
|
+
### State Patterns
|
|
101
|
+
- **Controlled**: Parent owns state, component receives via props — use for forms, filters
|
|
102
|
+
- **Uncontrolled**: Component owns internal state — use for UI-only state (open/closed, hover)
|
|
103
|
+
- **Server state**: Fetched data managed by query library — use for data display components
|
|
104
|
+
|
|
105
|
+
### Multi-State Rendering
|
|
106
|
+
Every data-driven component must handle:
|
|
107
|
+
1. **Loading** — skeleton or spinner
|
|
108
|
+
2. **Empty** — helpful message with action suggestion
|
|
109
|
+
3. **Error** — error message with retry action
|
|
110
|
+
4. **Populated** — the actual content
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Storybook & Design System Documentation
|
|
2
|
+
|
|
3
|
+
## Storybook 8 Setup
|
|
4
|
+
|
|
5
|
+
### CSF3 Format (Component Story Format 3)
|
|
6
|
+
|
|
7
|
+
CSF3 uses objects instead of functions for cleaner, more declarative stories.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// Button.stories.ts
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
+
import { Button } from './Button';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'Components/Button',
|
|
16
|
+
component: Button,
|
|
17
|
+
tags: ['autodocs'], // enables automatic docs page
|
|
18
|
+
argTypes: {
|
|
19
|
+
variant: {
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: ['primary', 'secondary', 'ghost'],
|
|
22
|
+
},
|
|
23
|
+
size: { control: 'radio', options: ['sm', 'md', 'lg'] },
|
|
24
|
+
disabled: { control: 'boolean' },
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
children: 'Click me',
|
|
28
|
+
variant: 'primary',
|
|
29
|
+
size: 'md',
|
|
30
|
+
},
|
|
31
|
+
} satisfies Meta<typeof Button>;
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
35
|
+
|
|
36
|
+
// Each export is a story — just an object with args
|
|
37
|
+
export const Primary: Story = {
|
|
38
|
+
args: { variant: 'primary' },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Secondary: Story = {
|
|
42
|
+
args: { variant: 'secondary' },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Disabled: Story = {
|
|
46
|
+
args: { disabled: true },
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Automatic Docs (autodocs)
|
|
51
|
+
|
|
52
|
+
Adding `tags: ['autodocs']` in the meta generates a docs page with:
|
|
53
|
+
- Component description (from JSDoc on the component)
|
|
54
|
+
- Props table (auto-extracted from TypeScript types)
|
|
55
|
+
- Live examples from all exported stories
|
|
56
|
+
- Controls panel for interactive prop editing
|
|
57
|
+
|
|
58
|
+
Configure globally in `.storybook/preview.ts`:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const preview: Preview = {
|
|
62
|
+
tags: ['autodocs'], // enable for all stories
|
|
63
|
+
};
|
|
64
|
+
export default preview;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Visual Testing with Chromatic
|
|
70
|
+
|
|
71
|
+
### Integration Setup
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install --save-dev chromatic
|
|
75
|
+
npx chromatic --project-token=<token>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### CI Pipeline (GitHub Actions)
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
# .github/workflows/chromatic.yml
|
|
82
|
+
name: Chromatic
|
|
83
|
+
on: push
|
|
84
|
+
jobs:
|
|
85
|
+
chromatic:
|
|
86
|
+
runs-on: ubuntu-latest
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/checkout@v4
|
|
89
|
+
with:
|
|
90
|
+
fetch-depth: 0 # required for baseline comparison
|
|
91
|
+
- run: npm ci
|
|
92
|
+
- uses: chromaui/action@latest
|
|
93
|
+
with:
|
|
94
|
+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
|
95
|
+
autoAcceptChanges: main # auto-accept on main branch
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### How It Works
|
|
99
|
+
1. Chromatic captures a screenshot of every story on every push
|
|
100
|
+
2. Compares against the accepted baseline screenshot
|
|
101
|
+
3. Highlights pixel differences in a review UI
|
|
102
|
+
4. Reviewers accept or reject visual changes before merge
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Design System Documentation Pages
|
|
107
|
+
|
|
108
|
+
Use Storybook MDX to create non-component documentation pages.
|
|
109
|
+
|
|
110
|
+
### Color Palette Page
|
|
111
|
+
|
|
112
|
+
```mdx
|
|
113
|
+
{/* docs/Colors.mdx */}
|
|
114
|
+
import { Meta, ColorPalette, ColorItem } from '@storybook/blocks';
|
|
115
|
+
|
|
116
|
+
<Meta title="Foundations/Colors" />
|
|
117
|
+
|
|
118
|
+
# Color Palette
|
|
119
|
+
|
|
120
|
+
<ColorPalette>
|
|
121
|
+
<ColorItem title="Primary" colors={{ Default: '#2563eb', Hover: '#1d4ed8', Light: '#dbeafe' }} />
|
|
122
|
+
<ColorItem title="Neutral" colors={{ 900: '#111827', 500: '#6b7280', 100: '#f3f4f6' }} />
|
|
123
|
+
<ColorItem title="Semantic" colors={{ Success: '#16a34a', Warning: '#f59e0b', Error: '#dc2626' }} />
|
|
124
|
+
</ColorPalette>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Typography and Spacing
|
|
128
|
+
|
|
129
|
+
```mdx
|
|
130
|
+
{/* docs/Typography.mdx */}
|
|
131
|
+
import { Meta, Typeset } from '@storybook/blocks';
|
|
132
|
+
|
|
133
|
+
<Meta title="Foundations/Typography" />
|
|
134
|
+
|
|
135
|
+
# Typography
|
|
136
|
+
|
|
137
|
+
<Typeset
|
|
138
|
+
fontSizes={['14px', '16px', '20px', '24px', '32px']}
|
|
139
|
+
fontFamily="Inter, system-ui, sans-serif"
|
|
140
|
+
fontWeight={400}
|
|
141
|
+
sampleText="The quick brown fox jumps over the lazy dog"
|
|
142
|
+
/>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Component Variants Matrix
|
|
148
|
+
|
|
149
|
+
Display all combinations of a component's visual states in one story.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Button.stories.ts
|
|
153
|
+
export const VariantsMatrix: Story = {
|
|
154
|
+
render: () => (
|
|
155
|
+
<table style={{ borderCollapse: 'collapse' }}>
|
|
156
|
+
<thead>
|
|
157
|
+
<tr>
|
|
158
|
+
<th />
|
|
159
|
+
{['sm', 'md', 'lg'].map(size => <th key={size}>{size}</th>)}
|
|
160
|
+
</tr>
|
|
161
|
+
</thead>
|
|
162
|
+
<tbody>
|
|
163
|
+
{['primary', 'secondary', 'ghost'].map(variant => (
|
|
164
|
+
<tr key={variant}>
|
|
165
|
+
<td style={{ padding: '8px', fontWeight: 600 }}>{variant}</td>
|
|
166
|
+
{['sm', 'md', 'lg'].map(size => (
|
|
167
|
+
<td key={size} style={{ padding: '8px' }}>
|
|
168
|
+
<Button variant={variant} size={size}>Label</Button>
|
|
169
|
+
</td>
|
|
170
|
+
))}
|
|
171
|
+
</tr>
|
|
172
|
+
))}
|
|
173
|
+
</tbody>
|
|
174
|
+
</table>
|
|
175
|
+
),
|
|
176
|
+
};
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This pattern makes it easy to visually audit every combination of size, color, and state in a single view. Add rows for disabled and loading states as needed.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Interaction Testing with Play Functions
|
|
184
|
+
|
|
185
|
+
Play functions simulate user behavior directly in Storybook stories.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { expect, fn, userEvent, within } from '@storybook/test';
|
|
189
|
+
|
|
190
|
+
export const FormSubmission: Story = {
|
|
191
|
+
args: {
|
|
192
|
+
onSubmit: fn(), // mock function
|
|
193
|
+
},
|
|
194
|
+
play: async ({ canvasElement, args }) => {
|
|
195
|
+
const canvas = within(canvasElement);
|
|
196
|
+
|
|
197
|
+
// Simulate user filling out a form
|
|
198
|
+
await userEvent.type(canvas.getByLabelText('Email'), 'user@example.com');
|
|
199
|
+
await userEvent.type(canvas.getByLabelText('Password'), 'secret123');
|
|
200
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Sign in' }));
|
|
201
|
+
|
|
202
|
+
// Assert the callback was called with correct data
|
|
203
|
+
await expect(args.onSubmit).toHaveBeenCalledWith({
|
|
204
|
+
email: 'user@example.com',
|
|
205
|
+
password: 'secret123',
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export const ValidationError: Story = {
|
|
211
|
+
play: async ({ canvasElement }) => {
|
|
212
|
+
const canvas = within(canvasElement);
|
|
213
|
+
|
|
214
|
+
// Submit without filling required fields
|
|
215
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Sign in' }));
|
|
216
|
+
|
|
217
|
+
// Assert error messages appear
|
|
218
|
+
await expect(canvas.getByText('Email is required')).toBeInTheDocument();
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Running Interaction Tests
|
|
224
|
+
- In Storybook UI: open the "Interactions" panel to see step-by-step playback
|
|
225
|
+
- In CI: `npx test-storybook` runs all play functions headlessly via Playwright
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Accessibility Addon
|
|
230
|
+
|
|
231
|
+
### Setup
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npm install --save-dev @storybook/addon-a11y
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
// .storybook/main.ts
|
|
239
|
+
const config: StorybookConfig = {
|
|
240
|
+
addons: [
|
|
241
|
+
'@storybook/addon-a11y',
|
|
242
|
+
// ... other addons
|
|
243
|
+
],
|
|
244
|
+
};
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Per-Story Configuration
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
export const HighContrast: Story = {
|
|
251
|
+
args: { variant: 'primary' },
|
|
252
|
+
parameters: {
|
|
253
|
+
a11y: {
|
|
254
|
+
config: {
|
|
255
|
+
rules: [
|
|
256
|
+
{ id: 'color-contrast', enabled: true },
|
|
257
|
+
{ id: 'heading-order', enabled: true },
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// Disable a11y checks for a decorative-only story
|
|
265
|
+
export const IconShowcase: Story = {
|
|
266
|
+
parameters: {
|
|
267
|
+
a11y: { disable: true },
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### What It Checks
|
|
273
|
+
- Color contrast ratios (WCAG AA and AAA)
|
|
274
|
+
- Missing alt text, label associations, ARIA roles
|
|
275
|
+
- Keyboard navigation issues, focus management
|
|
276
|
+
- Landmark regions, heading hierarchy
|
|
277
|
+
|
|
278
|
+
Results appear in the "Accessibility" panel as violations, passes, and incomplete checks powered by axe-core.
|