@fr0mpy/component-system 2.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.
Files changed (43) hide show
  1. package/bin/cli.js +283 -0
  2. package/index.js +12 -0
  3. package/package.json +45 -0
  4. package/templates/commands/component-harness.md +116 -0
  5. package/templates/commands/setup-styling.md +111 -0
  6. package/templates/component-recipes/accordion.md +153 -0
  7. package/templates/component-recipes/alert.md +145 -0
  8. package/templates/component-recipes/avatar.md +165 -0
  9. package/templates/component-recipes/badge.md +126 -0
  10. package/templates/component-recipes/breadcrumb.md +220 -0
  11. package/templates/component-recipes/button.md +90 -0
  12. package/templates/component-recipes/card.md +130 -0
  13. package/templates/component-recipes/carousel.md +277 -0
  14. package/templates/component-recipes/checkbox.md +117 -0
  15. package/templates/component-recipes/collapsible.md +201 -0
  16. package/templates/component-recipes/combobox.md +193 -0
  17. package/templates/component-recipes/context-menu.md +254 -0
  18. package/templates/component-recipes/dialog.md +193 -0
  19. package/templates/component-recipes/drawer.md +196 -0
  20. package/templates/component-recipes/dropdown-menu.md +263 -0
  21. package/templates/component-recipes/hover-card.md +230 -0
  22. package/templates/component-recipes/input.md +113 -0
  23. package/templates/component-recipes/label.md +259 -0
  24. package/templates/component-recipes/modal.md +155 -0
  25. package/templates/component-recipes/navigation-menu.md +310 -0
  26. package/templates/component-recipes/pagination.md +223 -0
  27. package/templates/component-recipes/popover.md +156 -0
  28. package/templates/component-recipes/progress.md +185 -0
  29. package/templates/component-recipes/radio.md +148 -0
  30. package/templates/component-recipes/select.md +154 -0
  31. package/templates/component-recipes/separator.md +124 -0
  32. package/templates/component-recipes/skeleton.md +186 -0
  33. package/templates/component-recipes/slider.md +114 -0
  34. package/templates/component-recipes/spinner.md +225 -0
  35. package/templates/component-recipes/switch.md +100 -0
  36. package/templates/component-recipes/table.md +161 -0
  37. package/templates/component-recipes/tabs.md +145 -0
  38. package/templates/component-recipes/textarea.md +234 -0
  39. package/templates/component-recipes/toast.md +209 -0
  40. package/templates/component-recipes/toggle-group.md +216 -0
  41. package/templates/component-recipes/tooltip.md +115 -0
  42. package/templates/hooks/triggers.d/styling.json +23 -0
  43. package/templates/skills/styling.md +173 -0
@@ -0,0 +1,173 @@
1
+ # Styling System
2
+
3
+ Apply this skill when generating, modifying, or reviewing UI components.
4
+
5
+ ## When to Apply
6
+
7
+ - Creating new UI components (buttons, cards, inputs, modals, etc.)
8
+ - Modifying existing component styles
9
+ - Reviewing code for styling consistency
10
+ - User asks about design tokens or component patterns
11
+
12
+ ## Configuration Loading
13
+
14
+ Before generating any UI code:
15
+
16
+ 1. **Check for config** at `.claude/styling-config.json`
17
+ 2. **Check for recipes** in `.claude/component-recipes/`
18
+ 3. If neither exists, suggest running `/setup-styling` to configure the design system
19
+
20
+ ## Token Usage
21
+
22
+ When `.claude/styling-config.json` exists, use semantic tokens instead of hardcoded values:
23
+
24
+ | Instead of | Use |
25
+ |------------|-----|
26
+ | `bg-blue-500` | `bg-primary` |
27
+ | `#3b82f6` | Token from config |
28
+ | `rounded-lg` (assumed) | `{tokens.radius}` from config |
29
+ | `shadow-md` (assumed) | `{tokens.shadow}` from config |
30
+
31
+ ### Token Reference
32
+
33
+ ```
34
+ tokens.colors.primary → bg-primary, text-primary, border-primary
35
+ tokens.colors.secondary → bg-secondary, text-secondary
36
+ tokens.colors.destructive → bg-destructive, text-destructive
37
+ tokens.colors.muted → bg-muted, text-muted-foreground
38
+ tokens.colors.surface → bg-surface (cards, panels)
39
+ tokens.colors.background → bg-background (page)
40
+ tokens.colors.foreground → text-foreground
41
+ tokens.colors.border → border-border
42
+ tokens.radius → border radius class
43
+ tokens.shadow → shadow class
44
+ tokens.spacing.tight/normal/loose → padding values
45
+ tokens.typography.family → font family class
46
+ ```
47
+
48
+ ## Recipe Compliance
49
+
50
+ If a recipe exists in `.claude/component-recipes/[component].md`:
51
+
52
+ 1. Read the recipe first
53
+ 2. Follow the defined structure
54
+ 3. Use the exact variants specified
55
+ 4. Apply the Tailwind classes from the recipe
56
+ 5. Include all required states (hover, focus, disabled)
57
+
58
+ ## Interactive Element Rules
59
+
60
+ All interactive elements MUST have `cursor: pointer`:
61
+
62
+ - Buttons (`<button>`, `role="button"`)
63
+ - Clickable cards or list items
64
+ - Links styled as buttons
65
+ - Toggle switches, checkboxes, radio buttons
66
+ - Dropdown triggers
67
+ - Tab buttons
68
+ - Any element with an `onClick` handler
69
+
70
+ ```tsx
71
+ // Correct
72
+ <button className="cursor-pointer ...">Click me</button>
73
+
74
+ // Incorrect - missing cursor pointer
75
+ <button className="...">Click me</button>
76
+ ```
77
+
78
+ ## Mobile-First Design (REQUIRED)
79
+
80
+ All components MUST be built mobile-first. This means:
81
+
82
+ 1. **Default styles target mobile** - Base classes without breakpoint prefixes are for mobile
83
+ 2. **Progressive enhancement** - Add `sm:`, `md:`, `lg:`, `xl:` prefixes for larger screens
84
+ 3. **Touch-friendly targets** - Minimum 44x44px touch targets on interactive elements
85
+ 4. **Responsive typography** - Use responsive text sizes (`text-sm md:text-base lg:text-lg`)
86
+ 5. **Flexible layouts** - Use `flex-col` by default, `sm:flex-row` for larger screens
87
+ 6. **Full-width on mobile** - Components should be `w-full` on mobile, constrained on larger screens
88
+
89
+ ### Mobile-First Pattern Examples
90
+
91
+ ```tsx
92
+ // CORRECT - Mobile first
93
+ <div className="flex flex-col gap-2 sm:flex-row sm:gap-4">
94
+ <div className="p-4 md:p-6 lg:p-8">
95
+ <button className="w-full sm:w-auto px-4 py-3 min-h-[44px]">
96
+ <h1 className="text-lg md:text-xl lg:text-2xl">
97
+
98
+ // INCORRECT - Desktop first (never do this)
99
+ <div className="flex flex-row gap-4 max-sm:flex-col max-sm:gap-2">
100
+ <div className="p-8 max-md:p-6 max-lg:p-4">
101
+ ```
102
+
103
+ ### Responsive Breakpoint Reference
104
+
105
+ | Prefix | Min Width | Typical Device |
106
+ |--------|-----------|----------------|
107
+ | (none) | 0px | Mobile phones |
108
+ | `sm:` | 640px | Large phones / small tablets |
109
+ | `md:` | 768px | Tablets |
110
+ | `lg:` | 1024px | Laptops |
111
+ | `xl:` | 1280px | Desktops |
112
+ | `2xl:` | 1536px | Large desktops |
113
+
114
+ ## Component Generation Checklist
115
+
116
+ Before delivering any UI component:
117
+
118
+ - [ ] **MOBILE-FIRST: Base styles target mobile (no breakpoint prefix)**
119
+ - [ ] **MOBILE-FIRST: Larger screen styles use sm:/md:/lg: prefixes**
120
+ - [ ] **MOBILE-FIRST: Touch targets are minimum 44x44px**
121
+ - [ ] **MOBILE-FIRST: Layout is flexible (flex-col → sm:flex-row pattern)**
122
+ - [ ] Loaded styling config (if exists)
123
+ - [ ] Checked for component recipe (if exists)
124
+ - [ ] Using token-based colors (not hardcoded)
125
+ - [ ] Radius matches config personality
126
+ - [ ] Shadow matches config personality
127
+ - [ ] Spacing matches config density
128
+ - [ ] All interactive states included
129
+ - [ ] Interactive elements have `cursor-pointer`
130
+ - [ ] Accessible (focus-visible, aria labels where needed)
131
+
132
+ ## Auditing (when asked to review/audit)
133
+
134
+ Scan UI files for violations:
135
+
136
+ ### Critical Violations
137
+ - **Desktop-first responsive patterns** (using `max-sm:`, `max-md:` instead of `sm:`, `md:`)
138
+ - **Missing responsive breakpoints** for layout/spacing/typography
139
+ - **Touch targets smaller than 44x44px** on interactive elements
140
+ - Hardcoded hex colors (`#[0-9a-fA-F]{3,8}`)
141
+ - Hardcoded rgb/rgba values
142
+ - Inline styles with color/spacing values
143
+ - Non-semantic Tailwind colors (`bg-blue-500` instead of `bg-primary`)
144
+ - Interactive elements missing `cursor-pointer`
145
+
146
+ ### Warnings
147
+ - Inconsistent border radius across components
148
+ - Inconsistent shadow depth
149
+ - Spacing that doesn't match density setting
150
+
151
+ ### Audit Output Format
152
+
153
+ ```
154
+ Styling Audit Report
155
+ ====================
156
+ Configuration: [loaded | not found]
157
+ Files scanned: [count]
158
+
159
+ CRITICAL:
160
+ - file.tsx:24 → Hardcoded `#3b82f6` → Use `bg-primary`
161
+
162
+ WARNINGS:
163
+ - file.tsx:12 → `rounded-xl` but config is `rounded-lg`
164
+
165
+ Compliance: [X]%
166
+ ```
167
+
168
+ ## Fallback Behavior
169
+
170
+ If no styling config exists:
171
+ - Use sensible defaults: `rounded-md`, `shadow-sm`, system font
172
+ - Warn about inconsistency risk
173
+ - Suggest: "Run `/setup-styling` to define your project's design tokens"