@qazuor/claude-code-config 0.1.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/LICENSE +21 -0
- package/README.md +1248 -0
- package/dist/bin.cjs +11886 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +11869 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.cjs +3887 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1325 -0
- package/dist/index.d.ts +1325 -0
- package/dist/index.js +3835 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/.log/notifications.log +1775 -0
- package/templates/agents/README.md +164 -0
- package/templates/agents/_registry.json +443 -0
- package/templates/agents/design/content-writer.md +353 -0
- package/templates/agents/design/ux-ui-designer.md +382 -0
- package/templates/agents/engineering/astro-engineer.md +293 -0
- package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
- package/templates/agents/engineering/express-engineer.md +316 -0
- package/templates/agents/engineering/fastify-engineer.md +399 -0
- package/templates/agents/engineering/hono-engineer.md +263 -0
- package/templates/agents/engineering/mongoose-engineer.md +473 -0
- package/templates/agents/engineering/nestjs-engineer.md +429 -0
- package/templates/agents/engineering/nextjs-engineer.md +451 -0
- package/templates/agents/engineering/node-typescript-engineer.md +347 -0
- package/templates/agents/engineering/prisma-engineer.md +432 -0
- package/templates/agents/engineering/react-senior-dev.md +394 -0
- package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
- package/templates/agents/engineering/tech-lead.md +269 -0
- package/templates/agents/product/product-functional.md +329 -0
- package/templates/agents/product/product-technical.md +578 -0
- package/templates/agents/quality/debugger.md +514 -0
- package/templates/agents/quality/qa-engineer.md +390 -0
- package/templates/agents/specialized/enrichment-agent.md +277 -0
- package/templates/agents/specialized/i18n-specialist.md +322 -0
- package/templates/agents/specialized/seo-ai-specialist.md +387 -0
- package/templates/agents/specialized/tech-writer.md +300 -0
- package/templates/code-style/.editorconfig +27 -0
- package/templates/code-style/.prettierignore +25 -0
- package/templates/code-style/.prettierrc +12 -0
- package/templates/code-style/biome.json +78 -0
- package/templates/code-style/commitlint.config.js +44 -0
- package/templates/commands/README.md +175 -0
- package/templates/commands/_registry.json +420 -0
- package/templates/commands/add-new-entity.md +211 -0
- package/templates/commands/audit/accessibility-audit.md +360 -0
- package/templates/commands/audit/performance-audit.md +290 -0
- package/templates/commands/audit/security-audit.md +231 -0
- package/templates/commands/code-check.md +127 -0
- package/templates/commands/five-why.md +225 -0
- package/templates/commands/formatting/format-markdown.md +197 -0
- package/templates/commands/git/commit.md +247 -0
- package/templates/commands/meta/create-agent.md +257 -0
- package/templates/commands/meta/create-command.md +312 -0
- package/templates/commands/meta/create-skill.md +321 -0
- package/templates/commands/meta/help.md +318 -0
- package/templates/commands/planning/check-completed-tasks.md +224 -0
- package/templates/commands/planning/cleanup-issues.md +248 -0
- package/templates/commands/planning/planning-cleanup.md +251 -0
- package/templates/commands/planning/sync-planning-github.md +133 -0
- package/templates/commands/planning/sync-todos-github.md +203 -0
- package/templates/commands/quality-check.md +211 -0
- package/templates/commands/run-tests.md +159 -0
- package/templates/commands/start-feature-plan.md +232 -0
- package/templates/commands/start-refactor-plan.md +244 -0
- package/templates/commands/sync-planning.md +176 -0
- package/templates/commands/update-docs.md +242 -0
- package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
- package/templates/docs/INDEX.md +677 -0
- package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
- package/templates/docs/_registry.json +329 -0
- package/templates/docs/diagrams/README.md +220 -0
- package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
- package/templates/docs/diagrams/documentation-map.mmd +61 -0
- package/templates/docs/diagrams/tools-relationship.mmd +55 -0
- package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
- package/templates/docs/doc-sync.md +533 -0
- package/templates/docs/examples/end-to-end-workflow.md +1505 -0
- package/templates/docs/glossary.md +495 -0
- package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
- package/templates/docs/guides/mockup-setup.md +737 -0
- package/templates/docs/learnings/README.md +250 -0
- package/templates/docs/learnings/common-architectural-patterns.md +123 -0
- package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
- package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
- package/templates/docs/learnings/monorepo-command-execution.md +64 -0
- package/templates/docs/learnings/optimization-tips.md +146 -0
- package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
- package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
- package/templates/docs/learnings/test-organization-structure.md +68 -0
- package/templates/docs/mcp-installation.md +613 -0
- package/templates/docs/mcp-servers.md +989 -0
- package/templates/docs/notification-installation.md +570 -0
- package/templates/docs/quick-start.md +354 -0
- package/templates/docs/standards/architecture-patterns.md +1064 -0
- package/templates/docs/standards/atomic-commits.md +513 -0
- package/templates/docs/standards/code-standards.md +993 -0
- package/templates/docs/standards/design-standards.md +656 -0
- package/templates/docs/standards/documentation-standards.md +1160 -0
- package/templates/docs/standards/testing-standards.md +969 -0
- package/templates/docs/system-maintenance.md +604 -0
- package/templates/docs/templates/PDR-template.md +561 -0
- package/templates/docs/templates/TODOs-template.md +534 -0
- package/templates/docs/templates/tech-analysis-template.md +800 -0
- package/templates/docs/workflows/README.md +519 -0
- package/templates/docs/workflows/atomic-task-protocol.md +955 -0
- package/templates/docs/workflows/decision-tree.md +482 -0
- package/templates/docs/workflows/edge-cases.md +856 -0
- package/templates/docs/workflows/phase-1-planning.md +957 -0
- package/templates/docs/workflows/phase-2-implementation.md +896 -0
- package/templates/docs/workflows/phase-3-validation.md +792 -0
- package/templates/docs/workflows/phase-4-finalization.md +927 -0
- package/templates/docs/workflows/quick-fix-protocol.md +505 -0
- package/templates/docs/workflows/task-atomization.md +537 -0
- package/templates/docs/workflows/task-completion-protocol.md +448 -0
- package/templates/hooks/on-notification.sh +28 -0
- package/templates/schemas/checkpoint.schema.json +97 -0
- package/templates/schemas/code-registry.schema.json +84 -0
- package/templates/schemas/pdr.schema.json +314 -0
- package/templates/schemas/problems.schema.json +55 -0
- package/templates/schemas/tech-analysis.schema.json +404 -0
- package/templates/schemas/telemetry.schema.json +298 -0
- package/templates/schemas/todos.schema.json +234 -0
- package/templates/schemas/workflows.schema.json +69 -0
- package/templates/scripts/add-changelogs.sh +105 -0
- package/templates/scripts/generate-code-registry.ts +270 -0
- package/templates/scripts/health-check.sh +343 -0
- package/templates/scripts/sync-registry.sh +40 -0
- package/templates/scripts/telemetry-report.ts +36 -0
- package/templates/scripts/validate-docs.sh +224 -0
- package/templates/scripts/validate-registry.sh +225 -0
- package/templates/scripts/validate-schemas.ts +283 -0
- package/templates/scripts/validate-structure.sh +165 -0
- package/templates/scripts/worktree-cleanup.sh +81 -0
- package/templates/scripts/worktree-create.sh +63 -0
- package/templates/sessions/planning/.gitkeep +0 -0
- package/templates/sessions/planning/archived/.gitkeep +0 -0
- package/templates/settings.json +202 -0
- package/templates/settings.local.json +138 -0
- package/templates/skills/README.md +197 -0
- package/templates/skills/_registry.json +473 -0
- package/templates/skills/audit/accessibility-audit.md +309 -0
- package/templates/skills/audit/performance-audit.md +257 -0
- package/templates/skills/audit/security-audit.md +217 -0
- package/templates/skills/auth/nextauth-patterns.md +308 -0
- package/templates/skills/brand-guidelines.md +240 -0
- package/templates/skills/documentation/markdown-formatter.md +302 -0
- package/templates/skills/git/git-commit-helper.md +321 -0
- package/templates/skills/i18n/i18n-patterns.md +251 -0
- package/templates/skills/patterns/error-handling-patterns.md +242 -0
- package/templates/skills/patterns/tdd-methodology.md +342 -0
- package/templates/skills/qa/qa-criteria-validator.md +383 -0
- package/templates/skills/qa/web-app-testing.md +398 -0
- package/templates/skills/react/react-hook-form-patterns.md +359 -0
- package/templates/skills/state/redux-toolkit-patterns.md +272 -0
- package/templates/skills/state/tanstack-query-patterns.md +299 -0
- package/templates/skills/state/zustand-patterns.md +301 -0
- package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
- package/templates/skills/tech/shadcn-specialist.md +252 -0
- package/templates/skills/tech/vercel-specialist.md +297 -0
- package/templates/skills/testing/api-app-testing.md +254 -0
- package/templates/skills/testing/performance-testing.md +275 -0
- package/templates/skills/testing/security-testing.md +348 -0
- package/templates/skills/utils/add-memory.md +295 -0
- package/templates/skills/utils/json-data-auditor.md +283 -0
- package/templates/skills/utils/pdf-creator-editor.md +342 -0
- package/templates/tools/format-markdown.sh +185 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mermaid-diagram-specialist
|
|
3
|
+
category: tech
|
|
4
|
+
description: Create technical diagrams using Mermaid syntax for documentation and architecture visualization
|
|
5
|
+
usage: When visualizing workflows, documenting architecture, creating ERDs, or explaining system design
|
|
6
|
+
input: System description, architecture requirements, data model, process flows
|
|
7
|
+
output: Mermaid diagram code in markdown format
|
|
8
|
+
config_required:
|
|
9
|
+
- diagram_style: "Color scheme and theme configuration"
|
|
10
|
+
- default_direction: "Flow direction preference (TD, LR, etc.)"
|
|
11
|
+
- max_complexity: "Maximum nodes per diagram for readability"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Mermaid Diagram Specialist
|
|
15
|
+
|
|
16
|
+
## ⚙️ Configuration
|
|
17
|
+
|
|
18
|
+
| Setting | Description | Example |
|
|
19
|
+
|---------|-------------|---------|
|
|
20
|
+
| `diagram_style` | Theme and color scheme | `base`, `dark`, `forest`, `neutral` |
|
|
21
|
+
| `primary_color` | Main color for nodes | `#3B82F6` (blue) |
|
|
22
|
+
| `default_direction` | Default flow direction | `TD` (top-down), `LR` (left-right) |
|
|
23
|
+
| `max_nodes` | Max nodes per diagram | `20` for readability |
|
|
24
|
+
| `line_style` | Connection line style | `solid`, `dotted`, `curved` |
|
|
25
|
+
|
|
26
|
+
## Purpose
|
|
27
|
+
|
|
28
|
+
Create technical diagrams using Mermaid syntax for documentation, architecture visualization, and process mapping. Supports flowcharts, sequence diagrams, ERDs, C4 diagrams, state machines, and more.
|
|
29
|
+
|
|
30
|
+
## Capabilities
|
|
31
|
+
|
|
32
|
+
- Flowcharts for decision flows and processes
|
|
33
|
+
- Sequence diagrams for API interactions
|
|
34
|
+
- ERDs for database schemas
|
|
35
|
+
- C4 diagrams for architecture levels
|
|
36
|
+
- State diagrams for lifecycle visualization
|
|
37
|
+
- Class diagrams for object design
|
|
38
|
+
- Gantt charts for timelines
|
|
39
|
+
|
|
40
|
+
## Diagram Types
|
|
41
|
+
|
|
42
|
+
### Flowchart
|
|
43
|
+
|
|
44
|
+
**Use for**: Process flows, decision trees, algorithms
|
|
45
|
+
|
|
46
|
+
```mermaid
|
|
47
|
+
flowchart TD
|
|
48
|
+
Start([Start]) --> Input[/User Input/]
|
|
49
|
+
Input --> Validate{Valid?}
|
|
50
|
+
Validate -->|Yes| Process[Process Data]
|
|
51
|
+
Validate -->|No| Error[Show Error]
|
|
52
|
+
Process --> Save[(Save)]
|
|
53
|
+
Save --> End([End])
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Node shapes**: `[Rectangle]`, `([Rounded])`, `{Diamond}`, `[/Parallelogram/]`, `[(Database)]`
|
|
57
|
+
|
|
58
|
+
### Sequence Diagram
|
|
59
|
+
|
|
60
|
+
**Use for**: API flows, message passing, system interactions
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
sequenceDiagram
|
|
64
|
+
actor User
|
|
65
|
+
participant Frontend
|
|
66
|
+
participant API
|
|
67
|
+
participant DB
|
|
68
|
+
|
|
69
|
+
User->>Frontend: Submit Form
|
|
70
|
+
Frontend->>API: POST /resource
|
|
71
|
+
API->>DB: Insert Data
|
|
72
|
+
DB-->>API: Success
|
|
73
|
+
API-->>Frontend: 201 Created
|
|
74
|
+
Frontend-->>User: Show Success
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### ERD (Entity Relationship)
|
|
78
|
+
|
|
79
|
+
**Use for**: Database schemas, data models
|
|
80
|
+
|
|
81
|
+
```mermaid
|
|
82
|
+
erDiagram
|
|
83
|
+
USER ||--o{ ORDER : creates
|
|
84
|
+
ORDER ||--|| PAYMENT : has
|
|
85
|
+
ORDER ||--|{ ITEM : contains
|
|
86
|
+
|
|
87
|
+
USER {
|
|
88
|
+
uuid id PK
|
|
89
|
+
string email UK
|
|
90
|
+
string name
|
|
91
|
+
}
|
|
92
|
+
ORDER {
|
|
93
|
+
uuid id PK
|
|
94
|
+
uuid user_id FK
|
|
95
|
+
decimal total
|
|
96
|
+
enum status
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Relationships**: `||--||` (one-to-one), `||--o{` (one-to-many), `}o--o{` (many-to-many)
|
|
101
|
+
|
|
102
|
+
### State Diagram
|
|
103
|
+
|
|
104
|
+
**Use for**: Lifecycle management, status transitions
|
|
105
|
+
|
|
106
|
+
```mermaid
|
|
107
|
+
stateDiagram-v2
|
|
108
|
+
[*] --> Pending
|
|
109
|
+
Pending --> Confirmed: Payment Success
|
|
110
|
+
Pending --> Cancelled: Payment Failed
|
|
111
|
+
Confirmed --> Active: Start Date
|
|
112
|
+
Active --> Completed: End Date
|
|
113
|
+
Confirmed --> Cancelled: User Cancels
|
|
114
|
+
Completed --> [*]
|
|
115
|
+
Cancelled --> [*]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Best Practices
|
|
119
|
+
|
|
120
|
+
| Practice | Description |
|
|
121
|
+
|----------|-------------|
|
|
122
|
+
| **Simplicity** | Keep diagrams under configured max nodes |
|
|
123
|
+
| **Direction** | Use consistent flow direction per diagram type |
|
|
124
|
+
| **Labels** | Clear, descriptive labels for all elements |
|
|
125
|
+
| **Grouping** | Use subgraphs to organize related elements |
|
|
126
|
+
| **Colors** | Apply theme consistently across diagrams |
|
|
127
|
+
| **Testing** | Verify rendering in target markdown viewer |
|
|
128
|
+
|
|
129
|
+
## Common Patterns
|
|
130
|
+
|
|
131
|
+
### API Request Flow
|
|
132
|
+
|
|
133
|
+
```mermaid
|
|
134
|
+
sequenceDiagram
|
|
135
|
+
Client->>+API: Request
|
|
136
|
+
API->>+Service: Process
|
|
137
|
+
Service->>+Model: Query
|
|
138
|
+
Model->>+DB: Execute
|
|
139
|
+
DB-->>-Model: Data
|
|
140
|
+
Model-->>-Service: Result
|
|
141
|
+
Service-->>-API: Response
|
|
142
|
+
API-->>-Client: JSON
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Error Handling
|
|
146
|
+
|
|
147
|
+
```mermaid
|
|
148
|
+
flowchart TD
|
|
149
|
+
Request --> Validate{Valid?}
|
|
150
|
+
Validate -->|No| Error[Error Handler]
|
|
151
|
+
Validate -->|Yes| Process
|
|
152
|
+
Process --> DB{Success?}
|
|
153
|
+
DB -->|No| Error
|
|
154
|
+
DB -->|Yes| Success
|
|
155
|
+
Error --> Log[Log Error]
|
|
156
|
+
Log --> Response[Error Response]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Styling
|
|
160
|
+
|
|
161
|
+
Apply theme configuration:
|
|
162
|
+
|
|
163
|
+
```mermaid
|
|
164
|
+
%%{init: {'theme':'base', 'themeVariables': {
|
|
165
|
+
'primaryColor':'#3B82F6',
|
|
166
|
+
'primaryTextColor':'#fff',
|
|
167
|
+
'lineColor':'#6B7280'
|
|
168
|
+
}}}%%
|
|
169
|
+
flowchart TD
|
|
170
|
+
A --> B --> C
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Use class styling:
|
|
174
|
+
|
|
175
|
+
```mermaid
|
|
176
|
+
flowchart TD
|
|
177
|
+
A[Normal] --> B[Success]
|
|
178
|
+
B --> C[Error]
|
|
179
|
+
|
|
180
|
+
classDef success fill:#10B981,stroke:#059669
|
|
181
|
+
classDef error fill:#EF4444,stroke:#DC2626
|
|
182
|
+
|
|
183
|
+
class B success
|
|
184
|
+
class C error
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Checklist
|
|
188
|
+
|
|
189
|
+
- [ ] Diagram type appropriate for content
|
|
190
|
+
- [ ] All nodes clearly labeled
|
|
191
|
+
- [ ] Relationships accurate
|
|
192
|
+
- [ ] Theme colors configured
|
|
193
|
+
- [ ] Renders correctly in markdown
|
|
194
|
+
- [ ] Complexity within limits
|
|
195
|
+
- [ ] Direction consistent
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: component-library-specialist
|
|
3
|
+
category: tech
|
|
4
|
+
description: Implement and customize component library systems with consistent theming and accessibility
|
|
5
|
+
usage: When adding UI components, customizing themes, or ensuring design system consistency
|
|
6
|
+
input: Component requirements, theme configuration, accessibility standards
|
|
7
|
+
output: Component implementations with proper theming and WCAG compliance
|
|
8
|
+
config_required:
|
|
9
|
+
- library_name: "Component library being used (e.g., shadcn, chakra, mui)"
|
|
10
|
+
- component_path: "Path to components directory"
|
|
11
|
+
- theme_file: "Path to theme configuration"
|
|
12
|
+
- accessibility_level: "WCAG compliance level (AA or AAA)"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Component Library Specialist
|
|
16
|
+
|
|
17
|
+
## ⚙️ Configuration
|
|
18
|
+
|
|
19
|
+
| Setting | Description | Example |
|
|
20
|
+
|---------|-------------|---------|
|
|
21
|
+
| `library_name` | Component library | `shadcn-ui`, `chakra-ui`, `material-ui` |
|
|
22
|
+
| `component_path` | Components directory | `src/components/ui` |
|
|
23
|
+
| `theme_file` | Theme config location | `src/styles/theme.css` |
|
|
24
|
+
| `base_color` | Primary theme color | `slate`, `blue`, `neutral` |
|
|
25
|
+
| `css_variables` | Use CSS variables | `true` (recommended) |
|
|
26
|
+
| `wcag_level` | Accessibility level | `AA` (minimum), `AAA` (enhanced) |
|
|
27
|
+
|
|
28
|
+
## Purpose
|
|
29
|
+
|
|
30
|
+
Expert guidance on implementing component library systems with consistent theming, proper accessibility (WCAG 2.1), and design system best practices.
|
|
31
|
+
|
|
32
|
+
## Capabilities
|
|
33
|
+
|
|
34
|
+
- Component installation and configuration
|
|
35
|
+
- Theme customization with CSS variables
|
|
36
|
+
- Variant creation for custom designs
|
|
37
|
+
- Accessibility compliance (WCAG AA/AAA)
|
|
38
|
+
- Form integration with validation
|
|
39
|
+
- Responsive design implementation
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### Setup Component Library
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Install specific component
|
|
47
|
+
npx library-cli add button input form
|
|
48
|
+
|
|
49
|
+
# Configure registry
|
|
50
|
+
{
|
|
51
|
+
"style": "default",
|
|
52
|
+
"tailwind": {
|
|
53
|
+
"config": "tailwind.config.ts",
|
|
54
|
+
"css": "src/styles/globals.css",
|
|
55
|
+
"baseColor": "slate",
|
|
56
|
+
"cssVariables": true
|
|
57
|
+
},
|
|
58
|
+
"aliases": {
|
|
59
|
+
"components": "@/components",
|
|
60
|
+
"utils": "@/lib/utils"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Theme Customization
|
|
66
|
+
|
|
67
|
+
### CSS Variables
|
|
68
|
+
|
|
69
|
+
```css
|
|
70
|
+
@layer base {
|
|
71
|
+
:root {
|
|
72
|
+
--background: 0 0% 100%;
|
|
73
|
+
--foreground: 222.2 84% 4.9%;
|
|
74
|
+
--primary: 221.2 83.2% 53.3%;
|
|
75
|
+
--primary-foreground: 210 40% 98%;
|
|
76
|
+
--destructive: 0 84.2% 60.2%;
|
|
77
|
+
--border: 214.3 31.8% 91.4%;
|
|
78
|
+
--radius: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dark {
|
|
82
|
+
--background: 222.2 84% 4.9%;
|
|
83
|
+
--foreground: 210 40% 98%;
|
|
84
|
+
--primary: 217.2 91.2% 59.8%;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Component Patterns
|
|
90
|
+
|
|
91
|
+
### Form with Validation
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { useForm } from 'react-hook-form';
|
|
95
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
96
|
+
import { z } from 'zod';
|
|
97
|
+
import { Button, Form, FormField, Input } from '@/components/ui';
|
|
98
|
+
|
|
99
|
+
const schema = z.object({
|
|
100
|
+
email: z.string().email(),
|
|
101
|
+
password: z.string().min(8),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export function LoginForm() {
|
|
105
|
+
const form = useForm({
|
|
106
|
+
resolver: zodResolver(schema),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Form {...form}>
|
|
111
|
+
<form onSubmit={form.handleSubmit(onSubmit)}>
|
|
112
|
+
<FormField name="email" render={...} />
|
|
113
|
+
<FormField name="password" render={...} />
|
|
114
|
+
<Button type="submit">Submit</Button>
|
|
115
|
+
</form>
|
|
116
|
+
</Form>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Dialog/Modal
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui';
|
|
125
|
+
|
|
126
|
+
export function ConfirmDialog({ onConfirm }) {
|
|
127
|
+
return (
|
|
128
|
+
<Dialog>
|
|
129
|
+
<DialogTrigger asChild>
|
|
130
|
+
<Button>Delete</Button>
|
|
131
|
+
</DialogTrigger>
|
|
132
|
+
<DialogContent>
|
|
133
|
+
<DialogHeader>
|
|
134
|
+
<DialogTitle>Confirm Action</DialogTitle>
|
|
135
|
+
</DialogHeader>
|
|
136
|
+
<DialogFooter>
|
|
137
|
+
<Button variant="outline">Cancel</Button>
|
|
138
|
+
<Button variant="destructive" onClick={onConfirm}>
|
|
139
|
+
Confirm
|
|
140
|
+
</Button>
|
|
141
|
+
</DialogFooter>
|
|
142
|
+
</DialogContent>
|
|
143
|
+
</Dialog>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Custom Variants
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { cva } from 'class-variance-authority';
|
|
152
|
+
|
|
153
|
+
const buttonVariants = cva(
|
|
154
|
+
'inline-flex items-center justify-center rounded-md',
|
|
155
|
+
{
|
|
156
|
+
variants: {
|
|
157
|
+
variant: {
|
|
158
|
+
default: 'bg-primary text-primary-foreground',
|
|
159
|
+
destructive: 'bg-destructive text-destructive-foreground',
|
|
160
|
+
// Custom variants
|
|
161
|
+
success: 'bg-green-600 text-white',
|
|
162
|
+
warning: 'bg-yellow-600 text-white',
|
|
163
|
+
},
|
|
164
|
+
size: {
|
|
165
|
+
default: 'h-10 px-4',
|
|
166
|
+
sm: 'h-9 px-3',
|
|
167
|
+
lg: 'h-11 px-8',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Accessibility
|
|
175
|
+
|
|
176
|
+
### ARIA Labels
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<Button aria-label="Close dialog">
|
|
180
|
+
<X className="h-4 w-4" />
|
|
181
|
+
</Button>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Keyboard Navigation
|
|
185
|
+
|
|
186
|
+
- Tab for focus movement
|
|
187
|
+
- Enter/Space for activation
|
|
188
|
+
- Escape for closing modals
|
|
189
|
+
- Arrow keys for lists/menus
|
|
190
|
+
|
|
191
|
+
### Focus Management
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
const closeButtonRef = useRef<HTMLButtonElement>(null);
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (open) {
|
|
198
|
+
closeButtonRef.current?.focus();
|
|
199
|
+
}
|
|
200
|
+
}, [open]);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Color Contrast
|
|
204
|
+
|
|
205
|
+
- Normal text: ≥ 4.5:1 contrast ratio
|
|
206
|
+
- Large text: ≥ 3:1 contrast ratio
|
|
207
|
+
- Test in both light and dark modes
|
|
208
|
+
|
|
209
|
+
## Testing
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { render, screen } from '@testing-library/react';
|
|
213
|
+
|
|
214
|
+
describe('Button', () => {
|
|
215
|
+
it('renders and handles clicks', () => {
|
|
216
|
+
const handleClick = vi.fn();
|
|
217
|
+
render(<Button onClick={handleClick}>Click</Button>);
|
|
218
|
+
|
|
219
|
+
screen.getByText('Click').click();
|
|
220
|
+
expect(handleClick).toHaveBeenCalled();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('applies variant classes', () => {
|
|
224
|
+
const { container } = render(<Button variant="destructive">Delete</Button>);
|
|
225
|
+
expect(container.firstChild).toHaveClass('bg-destructive');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Best Practices
|
|
231
|
+
|
|
232
|
+
| Practice | Description |
|
|
233
|
+
|----------|-------------|
|
|
234
|
+
| **Theme Tokens** | Always use CSS variables, never hardcode colors |
|
|
235
|
+
| **Composition** | Combine primitives for complex components |
|
|
236
|
+
| **Accessibility** | ARIA labels, keyboard nav, focus management |
|
|
237
|
+
| **TypeScript** | Leverage component prop types |
|
|
238
|
+
| **Variants** | Use CVA for consistent variant patterns |
|
|
239
|
+
| **Testing** | ≥ 90% coverage for all components |
|
|
240
|
+
| **Responsive** | Test mobile, tablet, desktop |
|
|
241
|
+
| **Dark Mode** | Test both light and dark themes |
|
|
242
|
+
|
|
243
|
+
## Checklist
|
|
244
|
+
|
|
245
|
+
- [ ] Components installed correctly
|
|
246
|
+
- [ ] Theme matches brand guidelines
|
|
247
|
+
- [ ] WCAG compliance level met
|
|
248
|
+
- [ ] Keyboard accessible
|
|
249
|
+
- [ ] Focus management correct
|
|
250
|
+
- [ ] Color contrast compliant
|
|
251
|
+
- [ ] Tests passing (≥ 90% coverage)
|
|
252
|
+
- [ ] Responsive on all devices
|