@thorprovider/storefront 0.4.0-mvp.0 → 0.4.0-mvp.2
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 +173 -153
- package/VENDOR.md +69 -0
- package/assets/openspec/config.yaml +38 -0
- package/assets/templates/AGENTS.md +76 -0
- package/assets/templates/app/app/[[...slug]]/page.tsx +42 -1
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +13 -2
- package/assets/templates/app/app/globals.css +5 -8
- package/assets/templates/app/app/layout.tsx +1 -5
- package/assets/templates/app/app/robots.ts +9 -3
- package/assets/templates/app/app/sitemap.ts +64 -5
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +70 -0
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +15 -5
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +71 -0
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +36 -4
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +82 -50
- package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +3 -0
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +29 -14
- package/assets/templates/app/lib/__STOREFRONT__/section-observation.ts +182 -0
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +130 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +31 -7
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +56 -26
- package/assets/templates/app/lib/__STOREFRONT__/spec/seo.ts +165 -0
- package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +26 -7
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +100 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +39 -0
- package/assets/templates/features/checkout/handlers.ts +6 -0
- package/assets/templates/features/customer-auth/state.ts +10 -1
- package/assets/templates/views/account/index.tsx +1 -1
- package/assets/templates/views/account/registry.tsx +80 -19
- package/assets/templates/views/account/schema.ts +1 -0
- package/assets/templates/views/cart/content.ts +11 -0
- package/assets/templates/views/cart/data.ts +23 -0
- package/assets/templates/views/cart/index.tsx +53 -0
- package/assets/templates/views/cart/props.ts +12 -0
- package/assets/templates/views/cart/registry.tsx +81 -0
- package/assets/templates/views/cart/schema.ts +52 -0
- package/assets/templates/views/category/assembly/assembly.json +1 -0
- package/assets/templates/views/category/assembly/index.skeleton.tsx +64 -6
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +2 -1
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +5 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/catalog.part +4 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/element.part +7 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/registry.part +18 -0
- package/assets/templates/views/category/index.tsx +76 -7
- package/assets/templates/views/category/props.ts +7 -0
- package/assets/templates/views/category/registry.tsx +19 -0
- package/assets/templates/views/category/schema.ts +13 -0
- package/assets/templates/views/home/assembly/assembly.json +9 -0
- package/assets/templates/views/home/assembly/index.skeleton.tsx +22 -4
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/element.part +1 -1
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/registry.part +2 -2
- package/assets/templates/views/home/data.ts +9 -0
- package/assets/templates/views/home/index.tsx +23 -5
- package/assets/templates/views/home/registry.tsx +2 -2
- package/assets/templates/views/product/data.ts +4 -2
- package/assets/templates/views/product/index.tsx +49 -5
- package/assets/templates/views/product/props.ts +7 -0
- package/assets/templates/views/product/registry.tsx +25 -0
- package/assets/templates/views/product/schema.ts +13 -0
- package/assets/templates/views/static/content.ts +4 -4
- package/assets/templates/views/static/index.tsx +1 -1
- package/bin/storefront.js +1231 -154
- package/examples/merchandising/category-led.json +37 -0
- package/examples/merchandising/collection-led.json +37 -0
- package/package.json +11 -7
- package/recipes/archetypes.json +9 -22
- package/recipes/catalog.json +40 -1
- package/recipes/features.json +25 -2
- package/recipes/recipe.schema.json +1 -1
- package/recipes/recipes.json +32 -30
- package/recipes/sections.json +10 -0
- package/recipes/validate.mjs +54 -0
- package/scripts/candidate.mjs +4 -4
- package/scripts/composers.mjs +25 -5
- package/scripts/env-file.mjs +86 -0
- package/scripts/file-classes.mjs +5 -0
- package/scripts/migrate-english-routes.mjs +276 -0
- package/scripts/pinning.mjs +74 -5
- package/scripts/plan-apply.mjs +149 -5
- package/scripts/reconcile.mjs +49 -11
- package/scripts/render-templates.mjs +97 -44
- package/scripts/section-config.mjs +253 -0
- package/scripts/starter.mjs +17 -0
- package/scripts/theme/color.mjs +185 -0
- package/scripts/theme/css-theme.mjs +233 -0
- package/scripts/theme/fonts.mjs +123 -0
- package/scripts/theme/import-export.mjs +125 -0
- package/scripts/theme/preset.mjs +93 -0
- package/scripts/theme/theme-plan.mjs +292 -0
- package/scripts/theme/tokens.mjs +137 -0
- package/scripts/view-assembly.mjs +47 -1
- package/skills/sf-feature/SKILL.md +32 -19
- package/skills/sf-setup/SKILL.md +79 -0
- package/skills/sf-theme-gen/SKILL.md +99 -36
- package/skills/sf-theme-gen/references/shadcn-theming.md +87 -0
- package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md +15 -19
- package/skills/{shadcn-theming → sf-theme-gen}/references/theming-guide.md +6 -11
- package/skills/sf-view-gen/SKILL.md +63 -40
- package/skills/sf-view-gen/assets/recipes/archetypes.json +9 -22
- package/skills/sf-view-gen/assets/recipes/catalog.json +40 -1
- package/skills/sf-view-gen/assets/recipes/features.json +25 -2
- package/skills/sf-view-gen/assets/recipes/recipes.json +32 -30
- package/skills/sf-view-gen/assets/recipes/sections.json +10 -0
- package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +100 -0
- package/skills/sf-view-gen/assets/templates/views/sections/products.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +39 -0
- package/skills/{json-render-core/SKILL.md → sf-view-gen/references/json-render-core.md} +4 -27
- package/skills/{json-render-next/SKILL.md → sf-view-gen/references/json-render-next.md} +5 -8
- package/skills/{json-render-react/SKILL.md → sf-view-gen/references/json-render-react.md} +3 -5
- package/skills/{json-render-shadcn/SKILL.md → sf-view-gen/references/json-render-shadcn.md} +3 -5
- package/skills/sf-view-gen/references/views.md +28 -37
- package/skills/sf-view-gen/scripts/validate.mjs +54 -0
- package/skills/storefront-workflow/SKILL.md +94 -31
- package/skills/{storefront-best-practices/reference/design.md → storefront-workflow/references/design-consistency.md} +13 -29
- package/CHANGELOG.md +0 -84
- package/assets/templates/views/user-panel/index.tsx +0 -106
- package/assets/templates/views/user-panel/registry.tsx +0 -54
- package/assets/templates/views/user-panel/schema.ts +0 -79
- package/commands/sf-add-view.md +0 -57
- package/commands/sf-feature.md +0 -28
- package/commands/sf-theme.md +0 -26
- package/commands/sf-view.md +0 -67
- package/skills/building-storefronts/SKILL.md +0 -178
- package/skills/building-storefronts/references/frontend-integration.md +0 -229
- package/skills/json-render-remotion/SKILL.md +0 -111
- package/skills/json-render-solid/SKILL.md +0 -204
- package/skills/nextjs-shadcn/SKILL.md +0 -367
- package/skills/nextjs-shadcn/references/architecture.md +0 -499
- package/skills/nextjs-shadcn/references/project-setup.md +0 -162
- package/skills/nextjs-shadcn/references/shadcn-platform.md +0 -261
- package/skills/nextjs-shadcn/references/sidebar.md +0 -274
- package/skills/nextjs-shadcn/references/styling.md +0 -555
- package/skills/shadcn-component-discovery/SKILL.md +0 -273
- package/skills/shadcn-component-discovery/references/registries.md +0 -226
- package/skills/shadcn-theming/SKILL.md +0 -104
- package/skills/storefront-best-practices/SKILL.md +0 -421
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +0 -123
- package/skills/storefront-best-practices/reference/components/cart-popup.md +0 -189
- package/skills/storefront-best-practices/reference/components/country-selector.md +0 -298
- package/skills/storefront-best-practices/reference/components/footer.md +0 -112
- package/skills/storefront-best-practices/reference/components/hero.md +0 -241
- package/skills/storefront-best-practices/reference/components/megamenu.md +0 -239
- package/skills/storefront-best-practices/reference/components/navbar.md +0 -397
- package/skills/storefront-best-practices/reference/components/popups.md +0 -221
- package/skills/storefront-best-practices/reference/components/product-card.md +0 -125
- package/skills/storefront-best-practices/reference/components/product-reviews.md +0 -217
- package/skills/storefront-best-practices/reference/components/product-slider.md +0 -174
- package/skills/storefront-best-practices/reference/components/search.md +0 -101
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +0 -391
- package/skills/storefront-best-practices/reference/features/promotions.md +0 -307
- package/skills/storefront-best-practices/reference/features/wishlist.md +0 -230
- package/skills/storefront-best-practices/reference/layouts/account.md +0 -380
- package/skills/storefront-best-practices/reference/layouts/cart.md +0 -316
- package/skills/storefront-best-practices/reference/layouts/checkout.md +0 -486
- package/skills/storefront-best-practices/reference/layouts/home-page.md +0 -264
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +0 -231
- package/skills/storefront-best-practices/reference/layouts/product-details.md +0 -527
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +0 -520
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +0 -356
- package/skills/storefront-best-practices/reference/medusa.md +0 -307
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/mobile-responsiveness.md +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/seo.md +0 -0
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sf-feature
|
|
3
|
-
description: Add or remove a Thor Commerce storefront feature bundle. Use when the user
|
|
3
|
+
description: Add or remove a Thor Commerce storefront feature bundle, and explain how a feature owns views, routes, and state versus mounting into a host view's slot. Use when the user asks to add or remove a feature (for example checkout, customer auth, or a category filter), or asks why a view cannot be added directly. Delegates every structural write to the `storefront` CLI.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# sf-feature
|
|
7
7
|
|
|
8
|
-
A **feature** is a capability bundle
|
|
9
|
-
handlers, and declared adapter needs, and may declare an owned route and one
|
|
10
|
-
more instance mounts into a host view's slot.
|
|
11
|
-
routes, and mounts; removing it takes them away. The CLI writes every derived
|
|
8
|
+
A **feature** is a capability bundle. It may own views plus its state slices,
|
|
9
|
+
handlers, and declared adapter needs, and it may declare an owned route and one
|
|
10
|
+
or more instance mounts into a host view's slot. The CLI writes every derived
|
|
12
11
|
file; agents never do.
|
|
13
12
|
|
|
14
|
-
## Read the
|
|
13
|
+
## Read the curated feature set through the CLI (never from memory)
|
|
15
14
|
|
|
16
|
-
Run from the storefront project root (
|
|
15
|
+
Run from the storefront project root (the CLI resolves the project from the
|
|
16
|
+
current directory; do not pass a directory):
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
npx @thorprovider/storefront features --json
|
|
20
20
|
npx @thorprovider/storefront recipes --json
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
`features --json` is the registry the CLI validates against, annotated with
|
|
24
|
+
`installed`, `mvp`, `route`, `views`, `state`, `handlers`, `adapter`, `presentations`,
|
|
25
|
+
`mounts`, and `surfaces` per feature. There is **no fixed feature list in this
|
|
26
|
+
skill**: whatever the registry reports is the authoritative set, so a feature
|
|
27
|
+
added to or removed from the registry is reflected without editing this text. Do
|
|
28
|
+
not read the JSON files directly; they are an implementation detail.
|
|
29
|
+
|
|
30
|
+
## Feature-owned vs mount-only (read this before routing a request)
|
|
31
|
+
|
|
32
|
+
- **Feature-owned view** — `views` is non-empty (for example a `checkout` feature
|
|
33
|
+
that owns the `checkout` view). Install and remove the whole bundle through the
|
|
34
|
+
feature; a direct `view add <owned-view>` is rejected. The CLI installs the
|
|
35
|
+
owned views, route, and mounts together.
|
|
36
|
+
- **Mount-only feature** — `views` is empty and `mounts` (or `surfaces`) is
|
|
37
|
+
non-empty. It injects into a host view's declared slot without owning a view.
|
|
38
|
+
Removing it leaves the host view installed and preserves the host's user-owned
|
|
39
|
+
content.
|
|
40
|
+
- **Held feature** — `mvp: false`. The CLI rejects it before any write; report it
|
|
41
|
+
as not available rather than trying to install it.
|
|
29
42
|
|
|
30
43
|
## Add a feature
|
|
31
44
|
|
|
@@ -33,9 +46,10 @@ any write; do not try to install them.
|
|
|
33
46
|
npx @thorprovider/storefront feature add <name>
|
|
34
47
|
```
|
|
35
48
|
|
|
36
|
-
This installs the feature
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
This installs the feature, every view it owns, its owned route, and its mounts,
|
|
50
|
+
and reconciles the state/handlers/adapter wiring. If the CLI exits non-zero,
|
|
51
|
+
relay its message and the supported options; do not hand-edit derived files to
|
|
52
|
+
work around it.
|
|
39
53
|
|
|
40
54
|
## Remove a feature
|
|
41
55
|
|
|
@@ -52,9 +66,8 @@ path to the user.
|
|
|
52
66
|
|
|
53
67
|
- UI only `@thorprovider/blocks`; data only `@thorprovider/adapters` +
|
|
54
68
|
`@thorprovider/runtime/commerce`.
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
wiring.
|
|
69
|
+
- A missing capability is a gap to report, not a reason to install another UI
|
|
70
|
+
framework or hand-edit a derived file.
|
|
58
71
|
|
|
59
72
|
## Workflow model
|
|
60
73
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf-setup
|
|
3
|
+
description: Connect or re-point a Thor Commerce storefront to a Medusa backend — set the backend URL, publishable API key, sales channel id, and region, or preserve the current environment when no key is supplied. Use when the user asks to connect or reconnect the backend, change the region or API key, switch the data source, or "set up" the store's data. Delegates to the `storefront setup` CLI command.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# sf-setup
|
|
7
|
+
|
|
8
|
+
Connect a storefront to a real Medusa backend, or re-point an already-connected
|
|
9
|
+
store. `setup` takes the sales channel id as an explicit input (there is no store API
|
|
10
|
+
that reads the channels bound to a publishable key), derives the region's currency,
|
|
11
|
+
then writes them to `.env.local`. The CLI writes the file; agents never hand-edit it.
|
|
12
|
+
|
|
13
|
+
## Run it
|
|
14
|
+
|
|
15
|
+
Run from the storefront project root:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @thorprovider/storefront setup \
|
|
19
|
+
--backend-url http://localhost:9000 \
|
|
20
|
+
--publishable-key <pk_...> \
|
|
21
|
+
--sales-channel-id <sc_...> \
|
|
22
|
+
--region-id <reg_...>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
On a terminal with no flags it runs an interactive wizard (backend URL →
|
|
26
|
+
publishable key → sales channel id → region). Pass the flags to run
|
|
27
|
+
non-interactively (CI, scripts).
|
|
28
|
+
|
|
29
|
+
## Flags
|
|
30
|
+
|
|
31
|
+
| Flag | Meaning |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `--backend-url` | Medusa backend base URL. Defaults to `http://localhost:9000`. |
|
|
34
|
+
| `--publishable-key` | Publishable API key (`pk_...`). Required to connect. |
|
|
35
|
+
| `--sales-channel-id` | Sales channel id (`sc_...`) from the Medusa admin (Settings → Sales Channels). Required without a terminal. |
|
|
36
|
+
| `--region-id` | Region id to bind. Required without a terminal; the wizard offers the available regions. |
|
|
37
|
+
|
|
38
|
+
## No key — the existing environment is preserved
|
|
39
|
+
|
|
40
|
+
With no publishable key, `setup` makes no network calls, **changes no files**, and
|
|
41
|
+
exits 0, so it is safe to run in CI/bootstrap without a key. It does not switch
|
|
42
|
+
the store to `mock`: the existing data source is left exactly as it was (`mock`
|
|
43
|
+
stays `mock`, `medusa` stays `medusa`). A freshly created store is already in
|
|
44
|
+
`mock` mode, so running with no key simply leaves it there.
|
|
45
|
+
|
|
46
|
+
## What it writes
|
|
47
|
+
|
|
48
|
+
Only the keys `setup` manages are upserted in `.env.local`; everything else (the
|
|
49
|
+
session secret, the site URL, store identity, and any user additions) is
|
|
50
|
+
preserved:
|
|
51
|
+
|
|
52
|
+
- `THOR_DATA_SOURCE=medusa`
|
|
53
|
+
- `MEDUSA_BASE_URL`
|
|
54
|
+
- `MEDUSA_PUBLISHABLE_KEY`
|
|
55
|
+
- `MEDUSA_REGION_ID`
|
|
56
|
+
- `MEDUSA_SALES_CHANNEL_ID` (from the `--sales-channel-id` input)
|
|
57
|
+
- `MEDUSA_CURRENCY_CODE` (derived from `GET /store/regions`)
|
|
58
|
+
|
|
59
|
+
Restart the dev server to pick up the change.
|
|
60
|
+
|
|
61
|
+
## Failure behavior
|
|
62
|
+
|
|
63
|
+
If the backend is unreachable, the key is rejected, the sales channel id is
|
|
64
|
+
missing, or the region is missing or has no currency, `setup` prints the reason,
|
|
65
|
+
**changes no files**, preserves the existing environment (`mock` stays `mock`,
|
|
66
|
+
`medusa` stays `medusa`), and exits non-zero. The store is placed in `medusa` mode
|
|
67
|
+
only after the backend URL, publishable key, sales channel id, and region are all
|
|
68
|
+
resolved and the region's currency resolves successfully. Relay the message to the
|
|
69
|
+
user and fix the input; do not hand-edit `.env.local`.
|
|
70
|
+
|
|
71
|
+
## Workflow model
|
|
72
|
+
|
|
73
|
+
Read `../storefront-workflow/SKILL.md` for the four phases and the CLI/agent
|
|
74
|
+
authority.
|
|
75
|
+
|
|
76
|
+
## Completion criteria
|
|
77
|
+
|
|
78
|
+
- `.env.local` contains the managed keys for the chosen backend and region.
|
|
79
|
+
- The dev server starts and loads data from the connected backend.
|
|
@@ -1,68 +1,131 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sf-theme-gen
|
|
3
|
-
description: Customize a Thor Commerce storefront's OKLCH
|
|
3
|
+
description: Customize a Thor Commerce storefront's theme — OKLCH colors, radius, fonts, shadcn presets and imported themes, plus typography and global identity/SEO metadata. Use when the user asks to change the storefront's colors, brand, theme, typography, site name, or SEO metadata.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# sf-theme-gen
|
|
7
7
|
|
|
8
|
-
Customize a storefront's theme and identity.
|
|
8
|
+
Customize a storefront's theme and identity. Prefer the deterministic
|
|
9
|
+
`storefront theme` controls; fall back to hand-editing the two external files only
|
|
10
|
+
within their bounded surface. When a required choice is not determined by the
|
|
11
|
+
references, ask the user.
|
|
9
12
|
|
|
10
|
-
##
|
|
13
|
+
## Inputs
|
|
11
14
|
|
|
12
|
-
The manifest
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
- The manifest `storefront.config.json` — the theme authority for the **mode**.
|
|
16
|
+
- The two external files `app/globals.css` and `app/layout.tsx` — the current
|
|
17
|
+
visual tokens, fonts, and identity.
|
|
18
|
+
- The user's chosen customization area and value.
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
## Outputs
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
- Edited `app/globals.css` (tokens, `@theme` bridge, font variables) and/or
|
|
23
|
+
`app/layout.tsx` (font loading, metadata/identity) — produced by
|
|
24
|
+
`storefront theme` when a control exists, or by hand within the bounds below.
|
|
25
|
+
- A summary listing every file edited and every command run.
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
- the existence of `lib/<name>/`
|
|
23
|
-
- the existence of the project's `.opencode/`
|
|
24
|
-
- the values returned by the wizard (which area to customize, and its value)
|
|
27
|
+
## Scope (bounded external surface)
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
| Area | File | Allowed change |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| Design tokens (OKLCH, light/dark) | `app/globals.css` | token values + foreground pairs, `@theme` bridge, font variable |
|
|
32
|
+
| Typography | `app/layout.tsx` + `globals.css` | load the font with `next/font`, point `--font-sans` at it |
|
|
33
|
+
| Identity / metadata / Open Graph | `app/layout.tsx` | the `metadata` object |
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
Everything else in these files is **CLI-managed and must be preserved**: the
|
|
36
|
+
stylesheet import, the provider import and its marker, the theme-mode marker, and
|
|
37
|
+
the block token contract. The CLI appends idempotently; never remove or duplicate
|
|
38
|
+
a marker, and never edit the mode wiring by hand.
|
|
31
39
|
|
|
32
|
-
##
|
|
40
|
+
## CLI controls (preferred path)
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
| Design tokens (shadcn) | `app/globals.css` |
|
|
37
|
-
| Typography + metadata | `app/layout.tsx` |
|
|
42
|
+
Visual values live in `app/globals.css`; the mode lives in the manifest. All
|
|
43
|
+
controls are one command and are validated before any write:
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
```
|
|
46
|
+
storefront theme --inspect [--json] # read-only: current tokens, names, formats
|
|
47
|
+
storefront theme --mode light|dark|system # site color mode (manifest + wiring)
|
|
48
|
+
storefront theme --brand orange # named brand -> full primary family
|
|
49
|
+
storefront theme --primary '#f97316' # one color (named | #hex | oklch(...))
|
|
50
|
+
storefront theme --accent 'oklch(0.6 0.15 200)'
|
|
51
|
+
storefront theme --radius 0.75rem # base radius (drives the radius scale)
|
|
52
|
+
storefront theme --font-sans google:Inter # loads the font, points --font-sans at it
|
|
53
|
+
storefront theme --set light.primary=#f97316 # scope = light | dark | shared; repeatable
|
|
54
|
+
storefront theme --preset <name|code|url> [--only theme|font|theme,font]
|
|
55
|
+
storefront theme --import ./theme.css|./theme.json|<registry-url>
|
|
56
|
+
storefront theme --export ./brand.theme.json # portable snapshot; never overwrites
|
|
57
|
+
storefront theme ... --dry-run # describe the change, write nothing
|
|
58
|
+
storefront theme ... --json # machine-readable result envelope
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`--brand`/`--primary` set the primary family (primary, foreground, hover, soft,
|
|
62
|
+
ring, nav) in both modes. Explicit `--set` values win over shortcuts; later
|
|
63
|
+
arguments win over earlier ones. A `--preset` applies **theme and fonts only** —
|
|
64
|
+
it never reinstalls or restyles components.
|
|
65
|
+
|
|
66
|
+
## Free theme workflow (generator → CLI)
|
|
67
|
+
|
|
68
|
+
1. Design the palette in a free editor and export its CSS: the official builder
|
|
69
|
+
at `ui.shadcn.com/create` (preset code/URL) or a CSS export from tweakcn /
|
|
70
|
+
Shadcn Studio. These are authoring tools; the CLI is the writer.
|
|
71
|
+
2. Apply it: `storefront theme --preset <code>` for a preset, or
|
|
72
|
+
`storefront theme --import ./exported.css` for a CSS export (only theme tokens
|
|
73
|
+
and font variables are merged; unrelated CSS is ignored).
|
|
74
|
+
3. Fine-tune: `--brand`, `--primary`, `--accent`, `--radius`, `--set`, `--font-*`.
|
|
75
|
+
4. `storefront theme --export ./brand.theme.json` to keep a portable snapshot;
|
|
76
|
+
replay it elsewhere with `--import ./brand.theme.json`.
|
|
41
77
|
|
|
42
78
|
## Color rules
|
|
79
|
+
|
|
43
80
|
- Colors are CSS variables, never raw Tailwind color utilities.
|
|
44
81
|
- OKLCH only; define complete background/foreground pairs.
|
|
45
|
-
-
|
|
46
|
-
|
|
82
|
+
- The CLI pairs a changed color with its foreground using **measured contrast**
|
|
83
|
+
(WCAG relative luminance), not a lightness threshold; auto-selected foregrounds
|
|
84
|
+
meet >= 4.5:1. A contrast below 4.5:1 is reported as a warning but never
|
|
85
|
+
silently changes an explicit pair — use `--set light.primary-foreground=#fff`
|
|
86
|
+
to force a specific pairing.
|
|
87
|
+
- Accepts `<name>` (see `storefront theme --inspect`), `#hex`, `oklch(...)`.
|
|
47
88
|
|
|
48
89
|
## Workflow
|
|
49
90
|
|
|
50
|
-
1.
|
|
51
|
-
2. **Mode
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
91
|
+
1. Ask what to customize: colors/brand, radius, typography, identity, SEO, Open Graph.
|
|
92
|
+
2. **Mode** is deterministic: `storefront theme --mode light|dark|system`; never
|
|
93
|
+
edit the mode wiring by hand. There is no visitor-facing toggle by design.
|
|
94
|
+
3. **Colors**: prefer `storefront theme --brand/--primary/--accent` or `--set`.
|
|
95
|
+
For a full palette, import a generator export (see above). Hand-edit only a
|
|
96
|
+
value the CLI cannot express, updating BOTH `:root` and `.dark`.
|
|
97
|
+
4. **Pairs**: a color change gets its foreground pair; the CLI does this and
|
|
98
|
+
warns on low contrast.
|
|
99
|
+
5. **Typography**: `storefront theme --font-sans google:Inter` loads the font with
|
|
100
|
+
`next/font` and points `--font-sans` at it. Use `system:<stack>` for a CSS
|
|
101
|
+
stack. Existing local fonts are preserved unless explicitly replaced. A font
|
|
102
|
+
name alone is not proof it loads — verify rendering.
|
|
103
|
+
6. **Identity**: update the `metadata` object in `app/layout.tsx` (title,
|
|
104
|
+
description) and add Open Graph + Twitter Card fields. Confirm the current
|
|
105
|
+
Next.js Metadata API before writing.
|
|
106
|
+
7. **Verify**: `storefront theme --dry-run` first, then apply; run the dev server
|
|
107
|
+
and confirm both color modes, the font, and the head metadata. `yarn build` is
|
|
108
|
+
the final acceptance. A `sync` must leave the CLI-managed markers intact and
|
|
109
|
+
the theme unchanged.
|
|
110
|
+
|
|
111
|
+
## Limits
|
|
112
|
+
|
|
113
|
+
- A preset changes theme tokens and font wiring only; it cannot redesign
|
|
114
|
+
package-owned `@thorprovider/blocks` beyond their tokens.
|
|
115
|
+
- `--export` is read-only over the project and refuses to overwrite a file.
|
|
116
|
+
- Invalid input (unknown color/token/length/font, unsupported import) fails with
|
|
117
|
+
a diagnostic and writes nothing.
|
|
57
118
|
|
|
58
119
|
## Error handling
|
|
120
|
+
|
|
59
121
|
- Invalid color input → re-prompt (accept `<name>`, `#hex`, `oklch(...)`).
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
- Mode change → always via `npx @thorprovider/storefront theme --mode ...`; never edit the layout by hand.
|
|
122
|
+
- Unknown token key → run `storefront theme --inspect` (lists supported tokens).
|
|
123
|
+
- Mode change → always via `storefront theme --mode ...`; never edit by hand.
|
|
63
124
|
|
|
64
125
|
## Generation headers
|
|
126
|
+
|
|
65
127
|
```
|
|
66
128
|
// Themed by @thorprovider/storefront (sf-theme-gen)
|
|
67
129
|
```
|
|
130
|
+
|
|
68
131
|
Never remove existing tokens; only override values.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# shadcn theming reference
|
|
2
|
+
|
|
3
|
+
Reference material for the `sf-theme-gen` skill. It documents shadcn/ui design
|
|
4
|
+
tokens, OKLCH color rules, dark/light mode CSS variables, and the Tailwind v4
|
|
5
|
+
`@theme` bridge for the two external files `app/globals.css` and
|
|
6
|
+
`app/layout.tsx`.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
| Feature | Description |
|
|
11
|
+
|---------|-------------|
|
|
12
|
+
| **CSS Variables** | `--background`, `--foreground`, `--primary`, etc. |
|
|
13
|
+
| **OKLCH Colors** | Wide-gamut P3 color space, perceptually uniform |
|
|
14
|
+
| **Dark Mode** | `.dark` class or `prefers-color-scheme` |
|
|
15
|
+
| **Tailwind v4** | `@theme` directive integration |
|
|
16
|
+
|
|
17
|
+
## Critical rules
|
|
18
|
+
|
|
19
|
+
1. **ALWAYS use OKLCH** color space for all tokens.
|
|
20
|
+
2. **ALWAYS define dark mode** overrides for every token.
|
|
21
|
+
3. **NEVER hard-code** hex or rgb in components.
|
|
22
|
+
4. **USE the `@theme`** directive for Tailwind v4 integration.
|
|
23
|
+
5. **MAP semantic tokens** to primitive OKLCH values.
|
|
24
|
+
|
|
25
|
+
## Lightness rule (contrast)
|
|
26
|
+
|
|
27
|
+
Apply it to every custom pair (`--secondary`, `--accent`, `--destructive`, `--muted`):
|
|
28
|
+
|
|
29
|
+
- Background `L < 0.55` → foreground `L >= 0.93`.
|
|
30
|
+
- Background `L >= 0.55` → foreground `L <= 0.20`.
|
|
31
|
+
|
|
32
|
+
## Token hierarchy
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Component: --card, --card-foreground, --button-*
|
|
36
|
+
↑
|
|
37
|
+
Semantic: --primary, --secondary, --accent, --muted
|
|
38
|
+
↑
|
|
39
|
+
Primitive: oklch(55% 0.20 260), oklch(98% 0.01 260)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## File scope
|
|
43
|
+
|
|
44
|
+
Only these two external files are touched, and only for tokens, fonts, and
|
|
45
|
+
identity. The CLI-managed imports and markers inside them must survive.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
app/globals.css # :root + .dark token definitions, @theme bridge
|
|
49
|
+
app/layout.tsx # font wiring (next/font) + metadata/identity
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The theme mode (`light` / `dark` / `system`) is a CLI operation
|
|
53
|
+
(`storefront theme --mode ...`); do not hand-edit the `ThemeProvider` wiring in
|
|
54
|
+
`app/layout.tsx`.
|
|
55
|
+
|
|
56
|
+
## Validation checklist
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
[ ] CSS variables defined in :root
|
|
60
|
+
[ ] Dark mode overrides in .dark
|
|
61
|
+
[ ] OKLCH color space used
|
|
62
|
+
[ ] Chart variables (--chart-1 to --chart-5) if used
|
|
63
|
+
[ ] Sidebar variables if applicable
|
|
64
|
+
[ ] No hard-coded hex in components
|
|
65
|
+
[ ] @theme bridge maps each semantic token
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Best practices
|
|
69
|
+
|
|
70
|
+
### DO
|
|
71
|
+
- Use OKLCH for all colors.
|
|
72
|
+
- Define semantic tokens mapped to primitives.
|
|
73
|
+
- Provide dark mode overrides for all tokens.
|
|
74
|
+
- Use `@theme` for Tailwind v4 integration.
|
|
75
|
+
|
|
76
|
+
### DON'T
|
|
77
|
+
- Hard-code hex or rgb values.
|
|
78
|
+
- Skip dark mode definitions.
|
|
79
|
+
- Mix color spaces (hex + oklch).
|
|
80
|
+
- Define tokens only in a Tailwind config.
|
|
81
|
+
|
|
82
|
+
## Reference guide
|
|
83
|
+
|
|
84
|
+
| Topic | Reference | When to consult |
|
|
85
|
+
|-------|-----------|-----------------|
|
|
86
|
+
| Theming guide | [theming-guide.md](theming-guide.md) | CSS variables and OKLCH setup |
|
|
87
|
+
| Complete theme template | [theme-setup.md](theme-setup.md) | Light + dark token definitions and `@theme` bridge |
|
package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md
RENAMED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: theme-setup
|
|
3
|
-
description: Complete shadcn/ui theme with CSS variables, dark mode, and Tailwind v4 integration
|
|
4
|
-
keywords: theme, setup, css, oklch, dark-mode, tailwind
|
|
5
|
-
---
|
|
6
|
-
|
|
7
1
|
# Theme Setup
|
|
8
2
|
|
|
3
|
+
Reference material for the `sf-theme-gen` skill: the complete light + dark theme
|
|
4
|
+
with CSS variables, dark mode, and Tailwind v4 integration.
|
|
5
|
+
|
|
9
6
|
## Complete Light + Dark Theme
|
|
10
7
|
|
|
11
8
|
```css
|
|
@@ -92,18 +89,17 @@ keywords: theme, setup, css, oklch, dark-mode, tailwind
|
|
|
92
89
|
}
|
|
93
90
|
```
|
|
94
91
|
|
|
95
|
-
## Theme
|
|
92
|
+
## Theme switching
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
The light/dark/system mode is a CLI operation, not a hand edit. Run
|
|
95
|
+
`npx @thorprovider/storefront theme --mode light|dark|system`: it rewrites the
|
|
96
|
+
`ThemeProvider` wiring in `app/layout.tsx` idempotently. Do **not** add your own
|
|
97
|
+
provider or toggle; the mode is a site setting and the CLI-managed import and
|
|
98
|
+
marker must survive. This template covers the `:root` / `.dark` token blocks and
|
|
99
|
+
the `@theme` bridge only.
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
```
|
|
101
|
+
## Marker preservation
|
|
102
|
+
|
|
103
|
+
`app/globals.css` and `app/layout.tsx` are `external` files: keep the CLI-managed
|
|
104
|
+
provider/mode/style imports and block-token markers intact. Change only token
|
|
105
|
+
values, font wiring, and global identity/metadata.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: theming-guide
|
|
3
|
-
description: CSS variables, OKLCH colors, chart/sidebar tokens, and Tailwind integration
|
|
4
|
-
when-to-use: When configuring theme tokens or color system
|
|
5
|
-
keywords: theme, oklch, css-variables, dark-mode, tailwind, tokens, colors
|
|
6
|
-
priority: high
|
|
7
|
-
related: ../SKILL.md
|
|
8
|
-
---
|
|
9
|
-
|
|
10
1
|
# Theming Guide
|
|
11
2
|
|
|
3
|
+
Reference material for the `sf-theme-gen` skill: CSS variables, OKLCH colors,
|
|
4
|
+
chart/sidebar tokens, and the Tailwind v4 integration used by the external
|
|
5
|
+
`app/globals.css`.
|
|
6
|
+
|
|
12
7
|
## Overview
|
|
13
8
|
|
|
14
9
|
shadcn/ui uses CSS custom properties with OKLCH color space for wide-gamut P3 support and perceptual uniformity. Tokens follow a 3-level hierarchy: primitive -> semantic -> component.
|
|
@@ -71,7 +66,7 @@ Use `.dark` class on `<html>` or CSS media query:
|
|
|
71
66
|
<html className={theme === "dark" ? "dark" : ""}>
|
|
72
67
|
```
|
|
73
68
|
|
|
74
|
-
For full
|
|
69
|
+
For the full token template, see [theme-setup.md](theme-setup.md).
|
|
75
70
|
|
|
76
71
|
---
|
|
77
72
|
|
|
@@ -87,4 +82,4 @@ For full setup with next-themes, see [theme-setup.md](templates/theme-setup.md).
|
|
|
87
82
|
|
|
88
83
|
## Related Templates
|
|
89
84
|
|
|
90
|
-
- [theme-setup.md](
|
|
85
|
+
- [theme-setup.md](theme-setup.md) - Complete theme configuration
|