stitch-kit 1.5.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/AGENTS.md +139 -0
- package/CHANGELOG.md +86 -0
- package/README.md +167 -0
- package/agents/stitch-kit.md +93 -0
- package/bin/stitch-kit.mjs +430 -0
- package/docs/architecture.md +118 -0
- package/docs/color-prompt-guide.md +119 -0
- package/docs/mcp-naming-convention.md +64 -0
- package/docs/mcp-schemas/README.md +130 -0
- package/docs/mcp-schemas/apply_design_system.json +36 -0
- package/docs/mcp-schemas/create_design_system.json +78 -0
- package/docs/mcp-schemas/create_project.json +290 -0
- package/docs/mcp-schemas/delete_project.json +20 -0
- package/docs/mcp-schemas/edit_screens.json +46 -0
- package/docs/mcp-schemas/generate_screen_from_text.json +242 -0
- package/docs/mcp-schemas/generate_variants.json +77 -0
- package/docs/mcp-schemas/get_project.json +137 -0
- package/docs/mcp-schemas/get_screen.json +92 -0
- package/docs/mcp-schemas/list_design_systems.json +32 -0
- package/docs/mcp-schemas/list_projects.json +136 -0
- package/docs/mcp-schemas/list_screens.json +56 -0
- package/docs/mcp-schemas/update_design_system.json +32 -0
- package/docs/mcp-schemas/upload_screens_from_images.json +52 -0
- package/docs/prd-to-stitch-workflow.md +137 -0
- package/docs/skills-index.md +108 -0
- package/docs/tailwind-reference.md +207 -0
- package/package.json +41 -0
- package/skills/stitch-a11y/SKILL.md +428 -0
- package/skills/stitch-a11y/resources/audit-checklist.md +102 -0
- package/skills/stitch-animate/SKILL.md +371 -0
- package/skills/stitch-animate/resources/animation-patterns.md +248 -0
- package/skills/stitch-design-md/SKILL.md +215 -0
- package/skills/stitch-design-md/examples/DESIGN.md +54 -0
- package/skills/stitch-design-md/examples/usage.md +67 -0
- package/skills/stitch-design-md/scripts/fetch-stitch.sh +35 -0
- package/skills/stitch-design-system/SKILL.md +314 -0
- package/skills/stitch-design-system/resources/tokens-template.css +237 -0
- package/skills/stitch-html-components/SKILL.md +344 -0
- package/skills/stitch-html-components/resources/architecture-checklist.md +74 -0
- package/skills/stitch-html-components/scripts/fetch-stitch.sh +45 -0
- package/skills/stitch-loop/SKILL.md +183 -0
- package/skills/stitch-loop/examples/SITE.md +39 -0
- package/skills/stitch-loop/examples/next-prompt.md +24 -0
- package/skills/stitch-loop/examples/usage.md +77 -0
- package/skills/stitch-mcp-apply-design-system/SKILL.md +82 -0
- package/skills/stitch-mcp-create-design-system/SKILL.md +117 -0
- package/skills/stitch-mcp-create-project/SKILL.md +77 -0
- package/skills/stitch-mcp-delete-project/SKILL.md +62 -0
- package/skills/stitch-mcp-edit-screens/SKILL.md +121 -0
- package/skills/stitch-mcp-generate-screen-from-text/SKILL.md +102 -0
- package/skills/stitch-mcp-generate-screen-from-text/examples/desktop.md +53 -0
- package/skills/stitch-mcp-generate-screen-from-text/examples/mobile.md +71 -0
- package/skills/stitch-mcp-generate-variants/SKILL.md +124 -0
- package/skills/stitch-mcp-get-project/SKILL.md +67 -0
- package/skills/stitch-mcp-get-screen/SKILL.md +117 -0
- package/skills/stitch-mcp-get-screen/scripts/fetch-stitch.sh +35 -0
- package/skills/stitch-mcp-list-design-systems/SKILL.md +84 -0
- package/skills/stitch-mcp-list-projects/SKILL.md +77 -0
- package/skills/stitch-mcp-list-screens/SKILL.md +69 -0
- package/skills/stitch-mcp-update-design-system/SKILL.md +82 -0
- package/skills/stitch-mcp-upload-screens-from-images/SKILL.md +95 -0
- package/skills/stitch-mcp-upload-screens-from-images/scripts/encode-image.sh +43 -0
- package/skills/stitch-nextjs-components/SKILL.md +181 -0
- package/skills/stitch-nextjs-components/resources/architecture-checklist.md +65 -0
- package/skills/stitch-nextjs-components/resources/component-template.tsx +101 -0
- package/skills/stitch-nextjs-components/scripts/fetch-stitch.sh +45 -0
- package/skills/stitch-orchestrator/SKILL.md +337 -0
- package/skills/stitch-orchestrator/examples/workflow.md +173 -0
- package/skills/stitch-react-components/SKILL.md +236 -0
- package/skills/stitch-react-components/references/tailwind-to-react.md +117 -0
- package/skills/stitch-react-components/resources/architecture-checklist.md +34 -0
- package/skills/stitch-react-components/resources/component-template.tsx +35 -0
- package/skills/stitch-react-components/scripts/fetch-stitch.sh +35 -0
- package/skills/stitch-react-native-components/SKILL.md +333 -0
- package/skills/stitch-react-native-components/resources/architecture-checklist.md +74 -0
- package/skills/stitch-react-native-components/resources/component-template.tsx +104 -0
- package/skills/stitch-react-native-components/scripts/fetch-stitch.sh +45 -0
- package/skills/stitch-remotion/SKILL.md +280 -0
- package/skills/stitch-setup/SKILL.md +183 -0
- package/skills/stitch-shadcn-ui/SKILL.md +255 -0
- package/skills/stitch-skill-creator/SKILL.md +257 -0
- package/skills/stitch-skill-creator/references/output-patterns.md +71 -0
- package/skills/stitch-skill-creator/scripts/init_stitch_skill.py +229 -0
- package/skills/stitch-svelte-components/SKILL.md +282 -0
- package/skills/stitch-svelte-components/resources/architecture-checklist.md +62 -0
- package/skills/stitch-svelte-components/resources/component-template.svelte +193 -0
- package/skills/stitch-svelte-components/scripts/fetch-stitch.sh +36 -0
- package/skills/stitch-swiftui-components/SKILL.md +424 -0
- package/skills/stitch-swiftui-components/resources/architecture-checklist.md +83 -0
- package/skills/stitch-swiftui-components/resources/component-template.swift +131 -0
- package/skills/stitch-swiftui-components/resources/layout-mapping.md +155 -0
- package/skills/stitch-swiftui-components/scripts/fetch-stitch.sh +45 -0
- package/skills/stitch-ued-guide/SKILL.md +124 -0
- package/skills/stitch-ui-design-spec-generator/SKILL.md +115 -0
- package/skills/stitch-ui-design-spec-generator/examples/usage.md +79 -0
- package/skills/stitch-ui-design-variants/SKILL.md +127 -0
- package/skills/stitch-ui-prompt-architect/SKILL.md +196 -0
- package/skills/stitch-ui-prompt-architect/references/KEYWORDS.md +170 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stitch-react-components
|
|
3
|
+
description: Converts Stitch designs into modular Vite + React components — TypeScript, theme-mapped Tailwind, dark mode via CSS variables, and clean component architecture. Use this for Vite/React apps without App Router. For Next.js 15 App Router, use stitch-nextjs-components instead.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- "stitch*:*"
|
|
6
|
+
- "Bash"
|
|
7
|
+
- "Read"
|
|
8
|
+
- "Write"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Stitch → Vite / React Components
|
|
12
|
+
|
|
13
|
+
**Constraint:** Only use this skill when the user explicitly mentions "Stitch" and React (Vite, CRA, or just "React app" without Next.js).
|
|
14
|
+
|
|
15
|
+
You are a frontend engineer converting Stitch mobile/desktop designs into clean, modular React components using Vite + TypeScript. This skill targets plain React apps — **not** Next.js App Router. For Next.js, use `stitch-nextjs-components` instead.
|
|
16
|
+
|
|
17
|
+
## When to use this skill vs. Next.js
|
|
18
|
+
|
|
19
|
+
| Scenario | Use |
|
|
20
|
+
|----------|-----|
|
|
21
|
+
| User says "React app", "Vite", "CRA" | `stitch-react-components` |
|
|
22
|
+
| User says "Next.js", "App Router", "SSR" | `stitch-nextjs-components` |
|
|
23
|
+
| User wants shadcn/ui components added after | `stitch-react-components` → then `stitch-shadcn-ui` |
|
|
24
|
+
| User wants server-side rendering or file-based routing | `stitch-nextjs-components` |
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
- Stitch MCP Server configured (or use downloaded HTML directly)
|
|
29
|
+
- Node.js + npm/pnpm
|
|
30
|
+
- Vite + React project initialized: `npm create vite@latest my-app -- --template react-ts`
|
|
31
|
+
|
|
32
|
+
## Step 1: Retrieve the design
|
|
33
|
+
|
|
34
|
+
1. Run `list_tools` → find Stitch MCP prefix
|
|
35
|
+
2. Call `[prefix]:get_screen` with numeric `projectId` and `screenId`
|
|
36
|
+
3. Download HTML: `bash scripts/fetch-stitch.sh "[htmlCode.downloadUrl]" "temp/source.html"`
|
|
37
|
+
4. Check `screenshot.downloadUrl` — verify layout matches expectations
|
|
38
|
+
|
|
39
|
+
## Step 2: Project structure
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
src/
|
|
43
|
+
├── components/ ← One file per component
|
|
44
|
+
│ └── [Name].tsx
|
|
45
|
+
├── data/
|
|
46
|
+
│ └── mockData.ts ← Static content (never in components)
|
|
47
|
+
├── theme/
|
|
48
|
+
│ ├── tokens.ts ← Design token constants
|
|
49
|
+
│ └── useTheme.ts ← Dark mode hook
|
|
50
|
+
├── types/
|
|
51
|
+
│ └── index.ts ← Shared TypeScript types
|
|
52
|
+
├── App.tsx ← Root component
|
|
53
|
+
└── main.tsx ← Entry point
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Step 3: Extract design tokens
|
|
57
|
+
|
|
58
|
+
From the Stitch HTML `<head>`, find the `tailwind.config` or CSS variable definitions.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// src/theme/tokens.ts — extract hex values from Stitch HTML
|
|
62
|
+
export const lightTokens = {
|
|
63
|
+
background: '#FFFFFF',
|
|
64
|
+
surface: '#F4F4F5',
|
|
65
|
+
primary: '#6366F1',
|
|
66
|
+
primaryFg: '#FFFFFF',
|
|
67
|
+
text: '#09090B',
|
|
68
|
+
textMuted: '#71717A',
|
|
69
|
+
border: '#E4E4E7',
|
|
70
|
+
} as const
|
|
71
|
+
|
|
72
|
+
export const darkTokens = {
|
|
73
|
+
background: '#09090B',
|
|
74
|
+
surface: '#18181B',
|
|
75
|
+
primary: '#818CF8',
|
|
76
|
+
primaryFg: '#09090B',
|
|
77
|
+
text: '#FAFAFA',
|
|
78
|
+
textMuted: '#A1A1AA',
|
|
79
|
+
border: '#27272A',
|
|
80
|
+
} as const
|
|
81
|
+
|
|
82
|
+
export type ThemeTokens = typeof lightTokens
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
// src/theme/useTheme.ts
|
|
87
|
+
import { useEffect, useState } from 'react'
|
|
88
|
+
import { lightTokens, darkTokens, type ThemeTokens } from './tokens'
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns current theme tokens based on system color scheme.
|
|
92
|
+
* Listens for system-level dark/light mode changes.
|
|
93
|
+
*/
|
|
94
|
+
export function useTheme(): ThemeTokens {
|
|
95
|
+
const [isDark, setIsDark] = useState(
|
|
96
|
+
() => window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const mq = window.matchMedia('(prefers-color-scheme: dark)')
|
|
101
|
+
const handler = (e: MediaQueryListEvent) => setIsDark(e.matches)
|
|
102
|
+
mq.addEventListener('change', handler)
|
|
103
|
+
return () => mq.removeEventListener('change', handler)
|
|
104
|
+
}, [])
|
|
105
|
+
|
|
106
|
+
return isDark ? darkTokens : lightTokens
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Step 4: Component conversion rules
|
|
111
|
+
|
|
112
|
+
### Layout mapping
|
|
113
|
+
|
|
114
|
+
| HTML/CSS | → React / Tailwind |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `display:flex; flex-direction:column` | `<div className="flex flex-col gap-4">` |
|
|
117
|
+
| `display:flex; flex-direction:row` | `<div className="flex items-center gap-2">` |
|
|
118
|
+
| `justify-content:space-between` | `<div className="flex justify-between">` |
|
|
119
|
+
| `display:grid; grid-template-columns:1fr 1fr` | `<div className="grid grid-cols-2 gap-4">` |
|
|
120
|
+
| `overflow-y:scroll` | `<div className="overflow-y-auto">` |
|
|
121
|
+
| Long list | `items.map(item => <Card key={item.id} {...item} />)` |
|
|
122
|
+
| `<img>` | `<img src="..." alt="..." className="object-cover">` |
|
|
123
|
+
|
|
124
|
+
### Tailwind class mapping
|
|
125
|
+
|
|
126
|
+
Use the Stitch HTML classes directly in JSX where they don't reference Stitch-specific tokens. Map Stitch tokens to CSS variables:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// Stitch HTML: bg-primary → CSS variable → Tailwind arbitrary value
|
|
130
|
+
// OR: use inline style with token value
|
|
131
|
+
|
|
132
|
+
// Option A — Tailwind arbitrary value (if custom tokens in tailwind.config)
|
|
133
|
+
<div className="bg-[--color-primary] text-[--color-primaryFg]">
|
|
134
|
+
|
|
135
|
+
// Option B — inline style with useTheme()
|
|
136
|
+
const theme = useTheme()
|
|
137
|
+
<div style={{ backgroundColor: theme.primary, color: theme.primaryFg }}>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Component template
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
// src/components/StitchComponent.tsx
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Props for StitchComponent — all data via props, never fetched inside.
|
|
147
|
+
*/
|
|
148
|
+
interface StitchComponentProps {
|
|
149
|
+
/** Primary heading text */
|
|
150
|
+
title: string
|
|
151
|
+
/** Supporting description — optional */
|
|
152
|
+
description?: string
|
|
153
|
+
/** Primary action callback */
|
|
154
|
+
onAction?: () => void
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* StitchComponent — [describe purpose in one sentence]
|
|
159
|
+
*/
|
|
160
|
+
export function StitchComponent({
|
|
161
|
+
title,
|
|
162
|
+
description,
|
|
163
|
+
onAction,
|
|
164
|
+
}: Readonly<StitchComponentProps>) {
|
|
165
|
+
const theme = useTheme()
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<div
|
|
169
|
+
className="rounded-xl border p-4 gap-2 flex flex-col"
|
|
170
|
+
style={{
|
|
171
|
+
backgroundColor: theme.surface,
|
|
172
|
+
borderColor: theme.border,
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
<h3 className="text-base font-semibold" style={{ color: theme.text }}>
|
|
176
|
+
{title}
|
|
177
|
+
</h3>
|
|
178
|
+
|
|
179
|
+
{description ? (
|
|
180
|
+
<p className="text-sm" style={{ color: theme.textMuted }}>
|
|
181
|
+
{description}
|
|
182
|
+
</p>
|
|
183
|
+
) : null}
|
|
184
|
+
|
|
185
|
+
{onAction ? (
|
|
186
|
+
<button
|
|
187
|
+
onClick={onAction}
|
|
188
|
+
className="rounded-lg px-4 py-2 text-sm font-medium transition-opacity hover:opacity-90"
|
|
189
|
+
style={{ backgroundColor: theme.primary, color: theme.primaryFg }}
|
|
190
|
+
type="button"
|
|
191
|
+
>
|
|
192
|
+
Action
|
|
193
|
+
</button>
|
|
194
|
+
) : null}
|
|
195
|
+
</div>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Step 5: Architectural rules
|
|
201
|
+
|
|
202
|
+
- **One component per file** — no single-file spaghetti
|
|
203
|
+
- **Static data in `src/data/mockData.ts`** — never hardcoded in JSX
|
|
204
|
+
- **Shared types in `src/types/index.ts`**
|
|
205
|
+
- **Every component has `Readonly<ComponentNameProps>` interface**
|
|
206
|
+
- **No hardcoded hex colors** — use `useTheme()` or CSS variables
|
|
207
|
+
- **No `any` types**
|
|
208
|
+
|
|
209
|
+
## Step 6: Integration with shadcn/ui
|
|
210
|
+
|
|
211
|
+
After converting the Stitch design to base React components, you can layer in shadcn/ui:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npx shadcn@latest init # Set up shadcn in your Vite project
|
|
215
|
+
npx shadcn@latest add button card input dialog
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Then use `stitch-shadcn-ui` skill to replace raw HTML elements with shadcn components while preserving the Stitch design tokens.
|
|
219
|
+
|
|
220
|
+
## Troubleshooting
|
|
221
|
+
|
|
222
|
+
| Issue | Fix |
|
|
223
|
+
|-------|-----|
|
|
224
|
+
| Tailwind classes not applying | Check `tailwind.config.js` includes `./src/**/*.{ts,tsx}` in content |
|
|
225
|
+
| Dark mode not toggling | Verify `useTheme()` is called at component level, not hoisted |
|
|
226
|
+
| Images not showing | Add explicit `width` and `height` or use `className="w-full h-auto"` |
|
|
227
|
+
| Type error on props | Ensure `Readonly<>` wrapper and all required props are provided |
|
|
228
|
+
|
|
229
|
+
## References
|
|
230
|
+
|
|
231
|
+
- `resources/component-template.tsx` — Boilerplate component
|
|
232
|
+
- `resources/architecture-checklist.md` — Pre-ship checklist
|
|
233
|
+
- `references/tailwind-to-react.md` — Token + class mapping guide (Stitch HTML → React/Tailwind)
|
|
234
|
+
- `scripts/fetch-stitch.sh` — Reliable GCS HTML downloader
|
|
235
|
+
- `stitch-shadcn-ui` — Add shadcn/ui components after base conversion
|
|
236
|
+
- `docs/tailwind-reference.md` — Tailwind utility class lookup
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Tailwind → React (Vite + Tailwind) Mapping
|
|
2
|
+
|
|
3
|
+
When converting **Stitch HTML** to React, **keep Tailwind utility classes** but **map Stitch design tokens to the project theme** (`tailwind.config`, CSS variables). Never copy raw hex when a theme key exists.
|
|
4
|
+
|
|
5
|
+
> Rule: Extract Stitch's inline `tailwind.config` (from the HTML `<script>` block or `DESIGN.md`) and sync with your project's `tailwind.config.*` before generating components.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Layout
|
|
10
|
+
|
|
11
|
+
| Tailwind pattern | React output |
|
|
12
|
+
|------------------|--------------|
|
|
13
|
+
| `flex`, `flex-col`, `flex items-center` | Keep as-is |
|
|
14
|
+
| `grid`, `grid-cols-2`, `grid-cols-3` | Keep as-is |
|
|
15
|
+
| `sticky top-0` | Keep as-is |
|
|
16
|
+
| `container`, `mx-auto` | Keep as-is |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. Spacing
|
|
21
|
+
|
|
22
|
+
| Tailwind | React |
|
|
23
|
+
|----------|-------|
|
|
24
|
+
| `p-*`, `px-*`, `py-*` | Keep (`p-4`, `px-6`) |
|
|
25
|
+
| `mb-*`, `gap-*`, `space-y-*` | Keep |
|
|
26
|
+
|
|
27
|
+
No conversion needed — Tailwind spacing IS the output.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 3. Sizing
|
|
32
|
+
|
|
33
|
+
| Tailwind | React |
|
|
34
|
+
|----------|-------|
|
|
35
|
+
| `w-full`, `w-10`, `h-*`, `min-h-screen` | Keep all |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 4. Typography
|
|
40
|
+
|
|
41
|
+
| Tailwind | React |
|
|
42
|
+
|----------|-------|
|
|
43
|
+
| `text-xs` → `text-2xl` | Keep |
|
|
44
|
+
| `font-normal`, `font-medium`, `font-bold` | Keep |
|
|
45
|
+
| `text-gray-500` | Keep OR map to `text-muted-foreground` if project uses shadcn-style tokens |
|
|
46
|
+
| `text-primary` | Map to theme: ensure `primary` is in `theme.extend.colors` |
|
|
47
|
+
|
|
48
|
+
Prefer **semantic token names** (`text-foreground`, `text-muted-foreground`) over raw `text-gray-*` when the project has them.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 5. Colors — Stitch → project theme
|
|
53
|
+
|
|
54
|
+
| Stitch / Tailwind | React |
|
|
55
|
+
|-------------------|-------|
|
|
56
|
+
| `bg-primary`, `text-primary` | Map to `tailwind.config` `theme.extend.colors.primary` |
|
|
57
|
+
| `background-light`, `background-dark` | Map to theme `background` or use `bg-[#hex]` only if no theme key |
|
|
58
|
+
| `card-light`, `card-dark` | Map to `card`, `card-foreground` (shadcn-style) |
|
|
59
|
+
| `border-light`, `border-dark` | Map to theme border color |
|
|
60
|
+
| `shadow-soft`, `shadow-floating` (Stitch) | Define in `theme.extend.boxShadow`; then use `shadow-soft` in JSX |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 6. Borders & Radius
|
|
65
|
+
|
|
66
|
+
| Tailwind | React |
|
|
67
|
+
|----------|-------|
|
|
68
|
+
| `border`, `border-b`, `border-2 border-dashed` | Keep |
|
|
69
|
+
| `rounded`, `rounded-lg`, `rounded-xl`, `rounded-full` | Keep; add to `theme.extend.borderRadius` if Stitch overrides defaults |
|
|
70
|
+
| `border-gray-200`, `dark:border-gray-700` | Keep or map to `border`, `border-muted` |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 7. Effects
|
|
75
|
+
|
|
76
|
+
| Tailwind | React |
|
|
77
|
+
|----------|-------|
|
|
78
|
+
| `shadow-sm`, `shadow-md` | Keep |
|
|
79
|
+
| `shadow-soft` (Stitch custom) | Add to `theme.extend.boxShadow` in config |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 8. Interactivity
|
|
84
|
+
|
|
85
|
+
| Tailwind | React |
|
|
86
|
+
|----------|-------|
|
|
87
|
+
| `hover:bg-gray-100` | Keep or theme `hover:bg-accent` |
|
|
88
|
+
| `focus:ring-1 focus:ring-primary` | Keep; ensure `primary` in theme |
|
|
89
|
+
| `dark:*` variants | Keep; ensure dark mode is configured (`class` or `media`) |
|
|
90
|
+
| `peer`, `peer-checked:` | Keep OR replace with React `useState` + conditional class |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 9. Icons — Material Symbols → React
|
|
95
|
+
|
|
96
|
+
Stitch HTML uses Material Symbols font icons. Replace in React:
|
|
97
|
+
|
|
98
|
+
| Stitch | React (Lucide) |
|
|
99
|
+
|--------|----------------|
|
|
100
|
+
| `chevron_left` | `<ChevronLeft />` |
|
|
101
|
+
| `expand_more` | `<ChevronDown />` |
|
|
102
|
+
| `add` | `<Plus />` |
|
|
103
|
+
| `remove` | `<Minus />` |
|
|
104
|
+
| `add_photo_alternate` | `<ImagePlus />` |
|
|
105
|
+
| `search` | `<Search />` |
|
|
106
|
+
| `close` | `<X />` |
|
|
107
|
+
|
|
108
|
+
Do not include Material Symbols font in React unless the project explicitly uses it.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 10. Don't do these
|
|
113
|
+
|
|
114
|
+
- Don't use raw hex in `className` when a theme key exists (`bg-primary` not `bg-[#1677FF]`)
|
|
115
|
+
- Don't leave Stitch token names (`background-light`) in JSX unless they're in your `tailwind.config`
|
|
116
|
+
- Don't use raw `<button>` or `<input>` when the project has shared components — use those with `className` passed through
|
|
117
|
+
- Don't forget to add Stitch's custom `borderRadius` and `boxShadow` to the project config — otherwise `rounded-xl` and `shadow-soft` won't compile correctly
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# React (Vite) Components — Architecture Checklist
|
|
2
|
+
|
|
3
|
+
Run through this before marking the conversion complete.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- [ ] Each component is in its own file under `src/components/`
|
|
7
|
+
- [ ] Custom hooks extracted to `src/hooks/`
|
|
8
|
+
- [ ] Static content (labels, mock data, lists) in `src/data/mockData.ts`
|
|
9
|
+
- [ ] No single monolithic file — if it's over 200 lines, split it
|
|
10
|
+
|
|
11
|
+
## Type safety
|
|
12
|
+
- [ ] Props interfaces use `Readonly<ComponentNameProps>`
|
|
13
|
+
- [ ] No `any` types — use `unknown` and narrow
|
|
14
|
+
- [ ] Template placeholder `StitchComponent` replaced with real component name
|
|
15
|
+
|
|
16
|
+
## Styling
|
|
17
|
+
- [ ] Stitch design tokens extracted and synced to `tailwind.config` (`theme.extend.colors`, `borderRadius`, `boxShadow`)
|
|
18
|
+
- [ ] Theme-mapped class names used (`bg-primary`, `text-foreground`) — no raw hex in className
|
|
19
|
+
- [ ] Dark mode (`dark:` variants) applied where applicable
|
|
20
|
+
- [ ] No leftover Stitch-only tokens (e.g. `background-light`) unless defined in project config
|
|
21
|
+
|
|
22
|
+
## Functionality
|
|
23
|
+
- [ ] `useTheme()` hook implemented and wired to `dark:` classes or CSS variable root
|
|
24
|
+
- [ ] All interactive elements have `onClick` / `onChange` handlers (or clear TODO comments)
|
|
25
|
+
- [ ] No `console.log` in production code
|
|
26
|
+
|
|
27
|
+
## Accessibility
|
|
28
|
+
- [ ] All interactive elements are keyboard accessible
|
|
29
|
+
- [ ] `<img>` elements have descriptive `alt` text
|
|
30
|
+
- [ ] ARIA attributes added where semantic HTML isn't enough
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
- `references/tailwind-to-react.md` — token + class mapping guide
|
|
34
|
+
- `resources/component-template.tsx` — base component structure
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Template for Stitch-converted React components.
|
|
5
|
+
* Replace `StitchComponent` with the actual component name.
|
|
6
|
+
* Replace `StitchComponentProps` with domain-specific props.
|
|
7
|
+
*
|
|
8
|
+
* @see resources/architecture-checklist.md before shipping
|
|
9
|
+
* @see references/tailwind-to-react.md for class mapping patterns
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface StitchComponentProps {
|
|
13
|
+
/** Content to render inside the component */
|
|
14
|
+
readonly children?: React.ReactNode;
|
|
15
|
+
/** Additional Tailwind classes to merge in */
|
|
16
|
+
readonly className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base Stitch component wrapper.
|
|
21
|
+
* Demonstrates: typed props, className passthrough, dark mode readiness.
|
|
22
|
+
*/
|
|
23
|
+
export const StitchComponent: React.FC<StitchComponentProps> = ({
|
|
24
|
+
children,
|
|
25
|
+
className = '',
|
|
26
|
+
}) => {
|
|
27
|
+
return (
|
|
28
|
+
// Use theme-mapped tokens (bg-background, text-foreground) — never hardcoded hex
|
|
29
|
+
<div className={`relative bg-background text-foreground ${className}`}>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default StitchComponent;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# fetch-stitch.sh
|
|
3
|
+
# Reliably downloads Stitch HTML from Google Cloud Storage URLs.
|
|
4
|
+
# GCS URLs require redirect handling and security handshakes that AI fetch tools fail on.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# bash scripts/fetch-stitch.sh "<url>" "<output-path>"
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
# bash scripts/fetch-stitch.sh "$htmlCode_downloadUrl" "temp/source.html"
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
URL="${1:?Usage: fetch-stitch.sh <url> <output-path>}"
|
|
15
|
+
OUTPUT="${2:?Usage: fetch-stitch.sh <url> <output-path>}"
|
|
16
|
+
|
|
17
|
+
mkdir -p "$(dirname "$OUTPUT")"
|
|
18
|
+
|
|
19
|
+
curl -L \
|
|
20
|
+
-A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \
|
|
21
|
+
--compressed \
|
|
22
|
+
--retry 3 \
|
|
23
|
+
--retry-delay 1 \
|
|
24
|
+
--max-time 30 \
|
|
25
|
+
--silent \
|
|
26
|
+
--show-error \
|
|
27
|
+
--output "$OUTPUT" \
|
|
28
|
+
"$URL"
|
|
29
|
+
|
|
30
|
+
if [ ! -s "$OUTPUT" ]; then
|
|
31
|
+
echo "Error: Downloaded file is empty. URL may be expired or invalid." >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
echo "Downloaded to: $OUTPUT ($(wc -c < "$OUTPUT") bytes)"
|