create-skybridge 0.0.0-dev.171ea52 → 0.0.0-dev.173bfe3
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/dist/index.js +357 -157
- package/package.json +9 -7
- package/templates/blank/.dockerignore +4 -0
- package/templates/blank/AGENTS.md +1 -0
- package/templates/blank/Dockerfile +53 -0
- package/templates/blank/README.md +92 -0
- package/{template → templates/blank}/_gitignore +3 -1
- package/templates/blank/node_modules/.bin/alpic +21 -0
- package/templates/blank/node_modules/.bin/sb +21 -0
- package/templates/blank/node_modules/.bin/skybridge +21 -0
- package/templates/blank/node_modules/.bin/tsc +21 -0
- package/templates/blank/node_modules/.bin/tsserver +21 -0
- package/templates/blank/node_modules/.bin/tsx +21 -0
- package/templates/blank/node_modules/.bin/vite +21 -0
- package/templates/blank/package.json +29 -0
- package/templates/blank/src/helpers.ts +4 -0
- package/templates/blank/src/server.ts +16 -0
- package/templates/blank/tsconfig.json +5 -0
- package/templates/blank/vite.config.ts +12 -0
- package/templates/demo/.dockerignore +4 -0
- package/templates/demo/AGENTS.md +1 -0
- package/templates/demo/Dockerfile +53 -0
- package/templates/demo/README.md +95 -0
- package/templates/demo/_gitignore +7 -0
- package/templates/demo/alpic.json +3 -0
- package/templates/demo/node_modules/.bin/alpic +21 -0
- package/templates/demo/node_modules/.bin/sb +21 -0
- package/templates/demo/node_modules/.bin/skybridge +21 -0
- package/templates/demo/node_modules/.bin/tsc +21 -0
- package/templates/demo/node_modules/.bin/tsserver +21 -0
- package/templates/demo/node_modules/.bin/tsx +21 -0
- package/templates/demo/node_modules/.bin/vite +21 -0
- package/templates/demo/package.json +41 -0
- package/templates/demo/src/helpers.ts +4 -0
- package/templates/demo/src/index.css +59 -0
- package/templates/demo/src/server.ts +94 -0
- package/templates/demo/src/views/components/doc-link.tsx +22 -0
- package/templates/demo/src/views/components/doc.tsx +21 -0
- package/templates/demo/src/views/components/nav.tsx +31 -0
- package/templates/demo/src/views/components/progress.tsx +35 -0
- package/templates/demo/src/views/components/steps/outro.tsx +68 -0
- package/templates/demo/src/views/components/steps/state.tsx +47 -0
- package/templates/demo/src/views/components/steps/tool-call.tsx +53 -0
- package/templates/demo/src/views/components/steps/tool-output.tsx +40 -0
- package/templates/demo/src/views/images/mascot/beret.png +0 -0
- package/templates/demo/src/views/images/mascot/chapka.png +0 -0
- package/templates/demo/src/views/images/mascot/cowboy-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/fez.png +0 -0
- package/templates/demo/src/views/images/mascot/jester-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/mitre.png +0 -0
- package/templates/demo/src/views/images/mascot/non-la.png +0 -0
- package/templates/demo/src/views/images/mascot/original.png +0 -0
- package/templates/demo/src/views/images/mascot/propeller-beanie.png +0 -0
- package/templates/demo/src/views/images/mascot/ski-mask.png +0 -0
- package/templates/demo/src/views/images/mascot/sombrero.png +0 -0
- package/templates/demo/src/views/images/mascot/top-hat.png +0 -0
- package/templates/demo/src/views/images/mascot/viking-helmet.png +0 -0
- package/templates/demo/src/views/onboarding.tsx +63 -0
- package/templates/demo/src/views/use-mascot.ts +60 -0
- package/templates/demo/tsconfig.json +11 -0
- package/templates/demo/vite.config.ts +20 -0
- package/templates/ecom/.dockerignore +4 -0
- package/templates/ecom/.env.template +7 -0
- package/templates/ecom/.ladle/components.tsx +26 -0
- package/templates/ecom/.ladle/config.mjs +11 -0
- package/templates/ecom/.ladle/vite.config.ts +11 -0
- package/templates/ecom/AGENTS.md +2 -0
- package/templates/ecom/Dockerfile +53 -0
- package/templates/ecom/README.md +92 -0
- package/templates/ecom/_gitignore +9 -0
- package/templates/ecom/alpic.json +3 -0
- package/templates/ecom/node_modules/.bin/alpic +21 -0
- package/templates/ecom/node_modules/.bin/ladle +21 -0
- package/templates/ecom/node_modules/.bin/sb +21 -0
- package/templates/ecom/node_modules/.bin/skybridge +21 -0
- package/templates/ecom/node_modules/.bin/tsc +21 -0
- package/templates/ecom/node_modules/.bin/tsserver +21 -0
- package/templates/ecom/node_modules/.bin/tsx +21 -0
- package/templates/ecom/node_modules/.bin/vite +21 -0
- package/templates/ecom/package.json +41 -0
- package/templates/ecom/src/catalog/index.ts +19 -0
- package/templates/ecom/src/catalog/mock.ts +134 -0
- package/templates/ecom/src/catalog/shopify.ts +264 -0
- package/templates/ecom/src/components/chip.css.ts +63 -0
- package/templates/ecom/src/components/chip.stories.tsx +27 -0
- package/templates/ecom/src/components/chip.tsx +49 -0
- package/templates/ecom/src/components/empty-state.stories.tsx +3 -0
- package/templates/ecom/src/components/empty-state.tsx +12 -0
- package/templates/ecom/src/components/expandable-text.css.ts +49 -0
- package/templates/ecom/src/components/expandable-text.stories.tsx +20 -0
- package/templates/ecom/src/components/expandable-text.tsx +53 -0
- package/templates/ecom/src/components/image-gallery.css.ts +172 -0
- package/templates/ecom/src/components/image-gallery.stories.tsx +30 -0
- package/templates/ecom/src/components/image-gallery.tsx +163 -0
- package/templates/ecom/src/components/product-card.css.ts +159 -0
- package/templates/ecom/src/components/product-card.stories.tsx +58 -0
- package/templates/ecom/src/components/product-card.tsx +102 -0
- package/templates/ecom/src/components/product-carousel.css.ts +134 -0
- package/templates/ecom/src/components/product-carousel.stories.tsx +64 -0
- package/templates/ecom/src/components/product-carousel.tsx +202 -0
- package/templates/ecom/src/components/variant-picker.css.ts +27 -0
- package/templates/ecom/src/components/variant-picker.stories.tsx +67 -0
- package/templates/ecom/src/components/variant-picker.tsx +70 -0
- package/templates/ecom/src/components/view-frame.css.ts +22 -0
- package/templates/ecom/src/components/view-frame.tsx +27 -0
- package/templates/ecom/src/config.ts +12 -0
- package/templates/ecom/src/design/contract.css.ts +39 -0
- package/templates/ecom/src/design/fonts.css +15 -0
- package/templates/ecom/src/design/primitives.css.ts +101 -0
- package/templates/ecom/src/design/recipes/typography.css.ts +75 -0
- package/templates/ecom/src/design/sprinkles.css.ts +128 -0
- package/templates/ecom/src/design/themes/dark.css.ts +36 -0
- package/templates/ecom/src/design/themes/light.css.ts +36 -0
- package/templates/ecom/src/design/tokens.ts +8 -0
- package/templates/ecom/src/helpers.ts +4 -0
- package/templates/ecom/src/i18n.ts +35 -0
- package/templates/ecom/src/index.css +9 -0
- package/templates/ecom/src/lib/cx.ts +9 -0
- package/templates/ecom/src/lib/format.ts +9 -0
- package/templates/ecom/src/lib/variants.ts +150 -0
- package/templates/ecom/src/server.ts +43 -0
- package/templates/ecom/src/tools/render-carousel.ts +161 -0
- package/templates/ecom/src/tools/search-products.ts +196 -0
- package/templates/ecom/src/types.ts +87 -0
- package/templates/ecom/src/views/carousel/detail/detail.css.ts +115 -0
- package/templates/ecom/src/views/carousel/detail/detail.stories.tsx +133 -0
- package/templates/ecom/src/views/carousel/detail/index.tsx +254 -0
- package/templates/ecom/src/views/carousel/index.tsx +233 -0
- package/templates/ecom/tsconfig.json +11 -0
- package/templates/ecom/vite.config.ts +8 -0
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -23
- package/template/README.md +0 -77
- package/template/node_modules/.bin/mcp-inspector +0 -21
- package/template/node_modules/.bin/nodemon +0 -21
- package/template/node_modules/.bin/sb +0 -21
- package/template/node_modules/.bin/shx +0 -21
- package/template/node_modules/.bin/skybridge +0 -21
- package/template/node_modules/.bin/tsc +0 -21
- package/template/node_modules/.bin/tsserver +0 -21
- package/template/node_modules/.bin/tsx +0 -21
- package/template/node_modules/.bin/vite +0 -21
- package/template/nodemon.json +0 -5
- package/template/package.json +0 -43
- package/template/server/src/index.ts +0 -51
- package/template/server/src/middleware.ts +0 -54
- package/template/server/src/server.ts +0 -61
- package/template/tsconfig.json +0 -23
- package/template/tsconfig.server.json +0 -11
- package/template/web/src/helpers.ts +0 -4
- package/template/web/src/index.css +0 -31
- package/template/web/src/widgets/magic-8-ball.tsx +0 -24
- package/template/web/vite.config.ts +0 -15
- /package/{template → templates/blank}/alpic.json +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createGlobalTheme } from "@vanilla-extract/css";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Non-mode-aware design primitives: the raw scales every theme and recipe
|
|
5
|
+
* draws from. Values here are brand-neutral placeholders.
|
|
6
|
+
*
|
|
7
|
+
* @todo: replace these with your brand's real tokens (ideally extracted from
|
|
8
|
+
* a Figma design file). Change values, not the shape: the space/radius/font
|
|
9
|
+
* keys are referenced by sprinkles.css.ts and the recipes. Nothing outside
|
|
10
|
+
* this file should hard-code a hex, size, or spacing value.
|
|
11
|
+
*/
|
|
12
|
+
export const primitives = createGlobalTheme(":root", {
|
|
13
|
+
// Spacing scale (4px based). Used for padding, margin, and gap via sprinkles.
|
|
14
|
+
space: {
|
|
15
|
+
none: "0",
|
|
16
|
+
"5xs": "2px",
|
|
17
|
+
"4xs": "4px",
|
|
18
|
+
"3xs": "8px",
|
|
19
|
+
"2xs": "12px",
|
|
20
|
+
xs: "16px",
|
|
21
|
+
s: "24px",
|
|
22
|
+
m: "32px",
|
|
23
|
+
l: "40px",
|
|
24
|
+
xl: "48px",
|
|
25
|
+
"2xl": "56px",
|
|
26
|
+
"3xl": "64px",
|
|
27
|
+
},
|
|
28
|
+
radius: {
|
|
29
|
+
none: "0",
|
|
30
|
+
xs: "2px",
|
|
31
|
+
s: "4px",
|
|
32
|
+
m: "8px",
|
|
33
|
+
l: "16px",
|
|
34
|
+
xl: "32px",
|
|
35
|
+
full: "999px",
|
|
36
|
+
},
|
|
37
|
+
font: {
|
|
38
|
+
family: {
|
|
39
|
+
// @todo: swap in your brand font (add its @font-face to fonts.css). The
|
|
40
|
+
// system stack is the zero-asset default.
|
|
41
|
+
primary:
|
|
42
|
+
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
|
43
|
+
},
|
|
44
|
+
weight: {
|
|
45
|
+
regular: "400",
|
|
46
|
+
medium: "500",
|
|
47
|
+
semibold: "600",
|
|
48
|
+
bold: "700",
|
|
49
|
+
},
|
|
50
|
+
size: {
|
|
51
|
+
xs: "12px",
|
|
52
|
+
s: "14px",
|
|
53
|
+
m: "16px",
|
|
54
|
+
l: "20px",
|
|
55
|
+
xl: "24px",
|
|
56
|
+
"2xl": "32px",
|
|
57
|
+
"3xl": "40px",
|
|
58
|
+
},
|
|
59
|
+
lineHeight: {
|
|
60
|
+
tight: "1.25",
|
|
61
|
+
normal: "1.5",
|
|
62
|
+
},
|
|
63
|
+
letterSpacing: {
|
|
64
|
+
default: "0",
|
|
65
|
+
wide: "0.5px",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
stroke: {
|
|
69
|
+
thin: "1px",
|
|
70
|
+
medium: "1.5px",
|
|
71
|
+
thick: "2px",
|
|
72
|
+
},
|
|
73
|
+
// Raw greyscale ramp. Themes pick from these for surface/content/border.
|
|
74
|
+
grey: {
|
|
75
|
+
white: "#ffffff",
|
|
76
|
+
"50": "#f8f8f8",
|
|
77
|
+
"100": "#f2f2f2",
|
|
78
|
+
"200": "#e1e1e1",
|
|
79
|
+
"300": "#b4b4b4",
|
|
80
|
+
"400": "#929292",
|
|
81
|
+
"500": "#727272",
|
|
82
|
+
"600": "#636363",
|
|
83
|
+
"700": "#4c4c4c",
|
|
84
|
+
"800": "#333333",
|
|
85
|
+
"900": "#1a1a1a",
|
|
86
|
+
black: "#000000",
|
|
87
|
+
},
|
|
88
|
+
// @todo: your brand accent ramp (call-to-action, links, highlights). Steps
|
|
89
|
+
// named by lightness, like the grey ramp; each theme picks the shade that
|
|
90
|
+
// reads well on its surface (light mode the darker step, dark mode the
|
|
91
|
+
// lighter one). Add more steps as needed.
|
|
92
|
+
accent: {
|
|
93
|
+
"400": "#7ba0f5",
|
|
94
|
+
"600": "#3b6cf0",
|
|
95
|
+
},
|
|
96
|
+
// Status colors, shared across themes.
|
|
97
|
+
status: {
|
|
98
|
+
error: "#c53929",
|
|
99
|
+
success: "#5c7d0b",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { recipe } from "@vanilla-extract/recipes";
|
|
2
|
+
import { primitives } from "../primitives.css";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The one text style, driven by variants. Call it as:
|
|
6
|
+
* text({ style: "headingM", weight: "medium" })
|
|
7
|
+
*
|
|
8
|
+
* `style` picks the size/line-height pair; `weight` picks the font weight.
|
|
9
|
+
* This is the workhorse recipe: use it for all typography rather than setting
|
|
10
|
+
* fontSize/fontWeight by hand.
|
|
11
|
+
*
|
|
12
|
+
* @todo: adjust the styles to your type scale. Add a component recipe (button,
|
|
13
|
+
* tag, card) only when a component has real variants; otherwise style with
|
|
14
|
+
* sprinkles or a `style()` block.
|
|
15
|
+
*/
|
|
16
|
+
export const text = recipe({
|
|
17
|
+
base: {
|
|
18
|
+
fontFamily: primitives.font.family.primary,
|
|
19
|
+
letterSpacing: primitives.font.letterSpacing.default,
|
|
20
|
+
fontWeight: primitives.font.weight.regular,
|
|
21
|
+
margin: 0,
|
|
22
|
+
},
|
|
23
|
+
variants: {
|
|
24
|
+
style: {
|
|
25
|
+
display: {
|
|
26
|
+
fontSize: primitives.font.size["3xl"],
|
|
27
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
28
|
+
},
|
|
29
|
+
headingL: {
|
|
30
|
+
fontSize: primitives.font.size["2xl"],
|
|
31
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
32
|
+
},
|
|
33
|
+
headingM: {
|
|
34
|
+
fontSize: primitives.font.size.xl,
|
|
35
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
36
|
+
},
|
|
37
|
+
headingS: {
|
|
38
|
+
fontSize: primitives.font.size.l,
|
|
39
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
40
|
+
},
|
|
41
|
+
bodyM: {
|
|
42
|
+
fontSize: primitives.font.size.m,
|
|
43
|
+
lineHeight: primitives.font.lineHeight.normal,
|
|
44
|
+
},
|
|
45
|
+
bodyS: {
|
|
46
|
+
fontSize: primitives.font.size.s,
|
|
47
|
+
lineHeight: primitives.font.lineHeight.normal,
|
|
48
|
+
},
|
|
49
|
+
labelM: {
|
|
50
|
+
fontSize: primitives.font.size.m,
|
|
51
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
52
|
+
},
|
|
53
|
+
labelS: {
|
|
54
|
+
fontSize: primitives.font.size.s,
|
|
55
|
+
lineHeight: primitives.font.lineHeight.tight,
|
|
56
|
+
},
|
|
57
|
+
overline: {
|
|
58
|
+
fontSize: primitives.font.size.xs,
|
|
59
|
+
lineHeight: primitives.font.lineHeight.normal,
|
|
60
|
+
letterSpacing: primitives.font.letterSpacing.wide,
|
|
61
|
+
textTransform: "uppercase",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
weight: {
|
|
65
|
+
regular: { fontWeight: primitives.font.weight.regular },
|
|
66
|
+
medium: { fontWeight: primitives.font.weight.medium },
|
|
67
|
+
semibold: { fontWeight: primitives.font.weight.semibold },
|
|
68
|
+
bold: { fontWeight: primitives.font.weight.bold },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
style: "bodyM",
|
|
73
|
+
weight: "regular",
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createSprinkles, defineProperties } from "@vanilla-extract/sprinkles";
|
|
2
|
+
import { colors } from "./contract.css";
|
|
3
|
+
import { primitives } from "./primitives.css";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Atomic style props built on the primitives + color contract. Use sprinkles
|
|
7
|
+
* for one-off layout/spacing/color on an element, e.g.
|
|
8
|
+
* sprinkles({ display: "flex", gap: "s", color: "intense" })
|
|
9
|
+
*
|
|
10
|
+
* Structural component styling belongs in a co-located `.css.ts` `style()`
|
|
11
|
+
* block; sprinkles is the thin glue layer on top.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const spaceProperties = defineProperties({
|
|
15
|
+
properties: {
|
|
16
|
+
padding: primitives.space,
|
|
17
|
+
paddingTop: primitives.space,
|
|
18
|
+
paddingRight: primitives.space,
|
|
19
|
+
paddingBottom: primitives.space,
|
|
20
|
+
paddingLeft: primitives.space,
|
|
21
|
+
margin: primitives.space,
|
|
22
|
+
marginTop: primitives.space,
|
|
23
|
+
marginRight: primitives.space,
|
|
24
|
+
marginBottom: primitives.space,
|
|
25
|
+
marginLeft: primitives.space,
|
|
26
|
+
gap: primitives.space,
|
|
27
|
+
rowGap: primitives.space,
|
|
28
|
+
columnGap: primitives.space,
|
|
29
|
+
},
|
|
30
|
+
shorthands: {
|
|
31
|
+
p: ["padding"],
|
|
32
|
+
pt: ["paddingTop"],
|
|
33
|
+
pr: ["paddingRight"],
|
|
34
|
+
pb: ["paddingBottom"],
|
|
35
|
+
pl: ["paddingLeft"],
|
|
36
|
+
px: ["paddingLeft", "paddingRight"],
|
|
37
|
+
py: ["paddingTop", "paddingBottom"],
|
|
38
|
+
m: ["margin"],
|
|
39
|
+
mt: ["marginTop"],
|
|
40
|
+
mr: ["marginRight"],
|
|
41
|
+
mb: ["marginBottom"],
|
|
42
|
+
ml: ["marginLeft"],
|
|
43
|
+
mx: ["marginLeft", "marginRight"],
|
|
44
|
+
my: ["marginTop", "marginBottom"],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const colorProperties = defineProperties({
|
|
49
|
+
properties: {
|
|
50
|
+
backgroundColor: {
|
|
51
|
+
...colors.surface,
|
|
52
|
+
accent: colors.common.accent,
|
|
53
|
+
invertAccent: colors.common.invertAccent,
|
|
54
|
+
highlight: colors.common.highlight,
|
|
55
|
+
transparent: "transparent",
|
|
56
|
+
},
|
|
57
|
+
color: {
|
|
58
|
+
...colors.content,
|
|
59
|
+
accent: colors.common.accent,
|
|
60
|
+
invertAccent: colors.common.invertAccent,
|
|
61
|
+
highlight: colors.common.highlight,
|
|
62
|
+
error: colors.common.error,
|
|
63
|
+
success: colors.common.success,
|
|
64
|
+
},
|
|
65
|
+
borderColor: {
|
|
66
|
+
...colors.border,
|
|
67
|
+
accent: colors.common.accent,
|
|
68
|
+
invertAccent: colors.common.invertAccent,
|
|
69
|
+
highlight: colors.common.highlight,
|
|
70
|
+
transparent: "transparent",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const radiusProperties = defineProperties({
|
|
76
|
+
properties: {
|
|
77
|
+
borderRadius: primitives.radius,
|
|
78
|
+
borderTopLeftRadius: primitives.radius,
|
|
79
|
+
borderTopRightRadius: primitives.radius,
|
|
80
|
+
borderBottomLeftRadius: primitives.radius,
|
|
81
|
+
borderBottomRightRadius: primitives.radius,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const typographyProperties = defineProperties({
|
|
86
|
+
properties: {
|
|
87
|
+
fontFamily: primitives.font.family,
|
|
88
|
+
fontWeight: primitives.font.weight,
|
|
89
|
+
fontSize: primitives.font.size,
|
|
90
|
+
lineHeight: primitives.font.lineHeight,
|
|
91
|
+
letterSpacing: primitives.font.letterSpacing,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const strokeProperties = defineProperties({
|
|
96
|
+
properties: {
|
|
97
|
+
borderWidth: primitives.stroke,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const layoutProperties = defineProperties({
|
|
102
|
+
properties: {
|
|
103
|
+
display: ["none", "flex", "inline-flex", "block", "inline-block", "grid"],
|
|
104
|
+
flexDirection: ["row", "column", "row-reverse", "column-reverse"],
|
|
105
|
+
alignItems: ["flex-start", "center", "flex-end", "stretch", "baseline"],
|
|
106
|
+
justifyContent: [
|
|
107
|
+
"flex-start",
|
|
108
|
+
"center",
|
|
109
|
+
"flex-end",
|
|
110
|
+
"space-between",
|
|
111
|
+
"space-around",
|
|
112
|
+
"space-evenly",
|
|
113
|
+
],
|
|
114
|
+
flexWrap: ["wrap", "nowrap", "wrap-reverse"],
|
|
115
|
+
textAlign: ["left", "center", "right"],
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export const sprinkles = createSprinkles(
|
|
120
|
+
spaceProperties,
|
|
121
|
+
colorProperties,
|
|
122
|
+
radiusProperties,
|
|
123
|
+
typographyProperties,
|
|
124
|
+
strokeProperties,
|
|
125
|
+
layoutProperties,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export type Sprinkles = Parameters<typeof sprinkles>[0];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createTheme } from "@vanilla-extract/css";
|
|
2
|
+
import { colors } from "../contract.css";
|
|
3
|
+
import { primitives } from "../primitives.css";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dark palette. Fills the same contract slots as light.css.ts (surface and
|
|
7
|
+
* content swap ends of the grey ramp).
|
|
8
|
+
*
|
|
9
|
+
* @todo: tune these mappings to your brand.
|
|
10
|
+
*/
|
|
11
|
+
export const darkTheme = createTheme(colors, {
|
|
12
|
+
surface: {
|
|
13
|
+
extraLight: primitives.grey.black,
|
|
14
|
+
light: primitives.grey["900"],
|
|
15
|
+
subtle: primitives.grey["700"],
|
|
16
|
+
intense: primitives.grey["400"],
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
intense: primitives.grey["50"],
|
|
20
|
+
subtle: primitives.grey["300"],
|
|
21
|
+
invertIntense: primitives.grey["900"],
|
|
22
|
+
invertSubtle: primitives.grey["500"],
|
|
23
|
+
},
|
|
24
|
+
border: {
|
|
25
|
+
thin: primitives.grey["700"],
|
|
26
|
+
subtle: primitives.grey["600"],
|
|
27
|
+
intense: primitives.grey["400"],
|
|
28
|
+
},
|
|
29
|
+
common: {
|
|
30
|
+
accent: primitives.accent["400"],
|
|
31
|
+
invertAccent: primitives.grey.black,
|
|
32
|
+
highlight: primitives.accent["400"],
|
|
33
|
+
error: primitives.status.error,
|
|
34
|
+
success: primitives.status.success,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createTheme } from "@vanilla-extract/css";
|
|
2
|
+
import { colors } from "../contract.css";
|
|
3
|
+
import { primitives } from "../primitives.css";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Light palette: maps each semantic slot to a primitive.
|
|
7
|
+
*
|
|
8
|
+
* @todo: tune these mappings to your brand. dark.css.ts must fill the same
|
|
9
|
+
* slots (the contract enforces it).
|
|
10
|
+
*/
|
|
11
|
+
export const lightTheme = createTheme(colors, {
|
|
12
|
+
surface: {
|
|
13
|
+
extraLight: primitives.grey.white,
|
|
14
|
+
light: primitives.grey["50"],
|
|
15
|
+
subtle: primitives.grey["200"],
|
|
16
|
+
intense: primitives.grey["400"],
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
intense: primitives.grey["900"],
|
|
20
|
+
subtle: primitives.grey["500"],
|
|
21
|
+
invertIntense: primitives.grey["50"],
|
|
22
|
+
invertSubtle: primitives.grey["300"],
|
|
23
|
+
},
|
|
24
|
+
border: {
|
|
25
|
+
thin: primitives.grey["200"],
|
|
26
|
+
subtle: primitives.grey["300"],
|
|
27
|
+
intense: primitives.grey["400"],
|
|
28
|
+
},
|
|
29
|
+
common: {
|
|
30
|
+
accent: primitives.accent["600"],
|
|
31
|
+
invertAccent: primitives.grey.white,
|
|
32
|
+
highlight: primitives.accent["600"],
|
|
33
|
+
error: primitives.status.error,
|
|
34
|
+
success: primitives.status.success,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Barrel for the design system. Import tokens from here rather than reaching
|
|
2
|
+
// into individual files.
|
|
3
|
+
export { colors } from "./contract.css";
|
|
4
|
+
export { primitives } from "./primitives.css";
|
|
5
|
+
export { text } from "./recipes/typography.css";
|
|
6
|
+
export { type Sprinkles, sprinkles } from "./sprinkles.css";
|
|
7
|
+
export { darkTheme } from "./themes/dark.css";
|
|
8
|
+
export { lightTheme } from "./themes/light.css";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useUser } from "skybridge/web";
|
|
2
|
+
|
|
3
|
+
// Centralized UI labels. The active locale comes from the host via useUser();
|
|
4
|
+
// useLabels matches on the language subtag ("en-US" -> "en") and falls back to
|
|
5
|
+
// English for anything unlisted.
|
|
6
|
+
// @todo: adapt the English copy to your brand voice, and add a locale key (e.g.
|
|
7
|
+
// `fr`) with the same shape for each language you want to support.
|
|
8
|
+
const LABELS = {
|
|
9
|
+
en: {
|
|
10
|
+
outOfStock: "Out of stock",
|
|
11
|
+
combinationUnavailable: "Combination unavailable",
|
|
12
|
+
noProducts: "No products to show.",
|
|
13
|
+
carousel: "carousel",
|
|
14
|
+
products: "Products",
|
|
15
|
+
previous: "Previous",
|
|
16
|
+
next: "Next",
|
|
17
|
+
// Detail view.
|
|
18
|
+
reference: "Ref.",
|
|
19
|
+
viewOnSite: "View on site",
|
|
20
|
+
priceOnRequest: "Price on request",
|
|
21
|
+
specifications: "Specifications",
|
|
22
|
+
readMore: "Read more",
|
|
23
|
+
readLess: "Read less",
|
|
24
|
+
},
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
const DEFAULT_LOCALE = "en";
|
|
28
|
+
|
|
29
|
+
export type Labels = (typeof LABELS)[typeof DEFAULT_LOCALE];
|
|
30
|
+
|
|
31
|
+
export function useLabels(): Labels {
|
|
32
|
+
const { locale } = useUser();
|
|
33
|
+
const lang = locale.split("-")[0] ?? DEFAULT_LOCALE;
|
|
34
|
+
return lang in LABELS ? LABELS[lang as keyof typeof LABELS] : LABELS.en;
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dep class-name joiner. vanilla-extract's `recipe`/`style` return plain
|
|
3
|
+
* strings, so merging a recipe class with an optional consumer `className`
|
|
4
|
+
* just needs string concatenation that tolerates `undefined`/`false`/`null`.
|
|
5
|
+
*
|
|
6
|
+
* className={cx(text({ style: "bodyM" }), sprinkles({ color: "accent" }))}
|
|
7
|
+
*/
|
|
8
|
+
export const cx = (...classes: (string | false | null | undefined)[]) =>
|
|
9
|
+
classes.filter(Boolean).join(" ");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Price } from "../types.js";
|
|
2
|
+
|
|
3
|
+
// Pass useUser().locale from the view; omit for the runtime default.
|
|
4
|
+
export function formatPrice(price: Price, locale?: string): string {
|
|
5
|
+
return new Intl.NumberFormat(locale, {
|
|
6
|
+
style: "currency",
|
|
7
|
+
currency: price.currency,
|
|
8
|
+
}).format(price.amount);
|
|
9
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { Product, Variant } from "../types.js";
|
|
2
|
+
|
|
3
|
+
// Pure helpers that turn the client's option choices into a concrete variant.
|
|
4
|
+
// The `variants` list is SPARSE: only combinations that exist are present, and
|
|
5
|
+
// that is the whole contingency model. These helpers never encode rules; they
|
|
6
|
+
// filter the list. A variant may also skip an axis entirely (a one-size cap in
|
|
7
|
+
// a capacity x size catalog carries no `size`): that axis is simply "not
|
|
8
|
+
// applicable" to it, and the helpers treat the absence as its own value.
|
|
9
|
+
//
|
|
10
|
+
// Availability is computed TOP-DOWN (the Shopify convention): an axis is
|
|
11
|
+
// constrained only by the choices on the axes declared BEFORE it. So the first
|
|
12
|
+
// axis is never disabled by a later choice, and each later axis narrows under
|
|
13
|
+
// the ones above. Order the `options` array accordingly.
|
|
14
|
+
|
|
15
|
+
// A selection is one chosen value per axis, keyed by Option.id -> OptionValue.id.
|
|
16
|
+
export type Selection = Record<string, string>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The variant that exactly matches a selection, or undefined if none does.
|
|
20
|
+
* Strict per-axis equality with "missing" normalized to null: a partial
|
|
21
|
+
* selection resolves nothing, and a variant that skips an axis matches only a
|
|
22
|
+
* selection that also leaves it unset. A product with no options resolves to
|
|
23
|
+
* its single variant on an empty selection.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveVariant(
|
|
26
|
+
product: Product,
|
|
27
|
+
selection: Selection,
|
|
28
|
+
): Variant | undefined {
|
|
29
|
+
return product.variants.find((variant) =>
|
|
30
|
+
product.options.every(
|
|
31
|
+
(option) =>
|
|
32
|
+
(variant.selection[option.id] ?? null) ===
|
|
33
|
+
(selection[option.id] ?? null),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The state of every value of `axisId` given the choices on the axes ABOVE it:
|
|
40
|
+
* - "inStock": at least one matching variant is purchasable → normal chip.
|
|
41
|
+
* - "soldOut": matching variants exist, none in stock → struck, clickable.
|
|
42
|
+
* - absent: a hole in the variant matrix → hard-disabled chip.
|
|
43
|
+
* An empty map means the axis does not apply to the current configuration (a
|
|
44
|
+
* one-size colorway has no Size), and the picker hides its row.
|
|
45
|
+
*/
|
|
46
|
+
export function axisStates(
|
|
47
|
+
product: Product,
|
|
48
|
+
axisId: string,
|
|
49
|
+
selection: Selection,
|
|
50
|
+
): Map<string, "inStock" | "soldOut"> {
|
|
51
|
+
const states = new Map<string, "inStock" | "soldOut">();
|
|
52
|
+
for (const variant of product.variants) {
|
|
53
|
+
let matchesEarlier = true;
|
|
54
|
+
for (const option of product.options) {
|
|
55
|
+
if (option.id === axisId) {
|
|
56
|
+
break; // only the axes above constrain this one
|
|
57
|
+
}
|
|
58
|
+
const chosen = selection[option.id];
|
|
59
|
+
const carried = variant.selection[option.id];
|
|
60
|
+
if (chosen != null && carried !== undefined && carried !== chosen) {
|
|
61
|
+
matchesEarlier = false;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!matchesEarlier) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// A variant to which this axis does not apply carries no value to offer.
|
|
69
|
+
const value = variant.selection[axisId];
|
|
70
|
+
if (value !== undefined && states.get(value) !== "inStock") {
|
|
71
|
+
states.set(value, variant.outOfStock ? "soldOut" : "inStock");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return states;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The selection after picking `valueId` on `axisId`: the one state transition
|
|
79
|
+
* of the picker, rebuilt top-down.
|
|
80
|
+
* - An axis with no reachable value does not apply: its choice is dropped.
|
|
81
|
+
* - A prior choice that still EXISTS under the axes above is KEPT, even sold
|
|
82
|
+
* out: switching color never silently changes the size the user asked for.
|
|
83
|
+
* - Anything else fills with the first value in display order, preferring one
|
|
84
|
+
* that is in stock.
|
|
85
|
+
* The result resolves to a concrete variant, with one exception: a variant
|
|
86
|
+
* skipping an EARLIER axis keeps offering its later values under any choice on
|
|
87
|
+
* that axis, so picking one can compose a selection no variant matches. The
|
|
88
|
+
* detail renders that as "Combination unavailable".
|
|
89
|
+
*/
|
|
90
|
+
export function applyChoice(
|
|
91
|
+
product: Product,
|
|
92
|
+
selection: Selection,
|
|
93
|
+
axisId: string,
|
|
94
|
+
valueId: string,
|
|
95
|
+
): Selection {
|
|
96
|
+
const next: Selection = {};
|
|
97
|
+
for (const option of product.options) {
|
|
98
|
+
const candidate = option.id === axisId ? valueId : selection[option.id];
|
|
99
|
+
const states = axisStates(product, option.id, next);
|
|
100
|
+
if (states.size === 0) {
|
|
101
|
+
continue; // axis does not apply to the configuration above it
|
|
102
|
+
}
|
|
103
|
+
if (candidate != null && states.has(candidate)) {
|
|
104
|
+
next[option.id] = candidate;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
let fill: string | undefined;
|
|
108
|
+
for (const value of option.values) {
|
|
109
|
+
if (states.get(value.id) === "inStock") {
|
|
110
|
+
fill = value.id;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (fill === undefined) {
|
|
115
|
+
for (const value of option.values) {
|
|
116
|
+
if (states.has(value.id)) {
|
|
117
|
+
fill = value.id;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (fill !== undefined) {
|
|
123
|
+
next[option.id] = fill;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return next;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The selection to preselect when a product opens: the variant the client
|
|
131
|
+
* tapped (its id equals the opened product id), else the first IN-STOCK
|
|
132
|
+
* variant, else the first variant. A variant is always preselected when the
|
|
133
|
+
* product has any, so the buy CTA is live on open rather than starting
|
|
134
|
+
* disabled.
|
|
135
|
+
*/
|
|
136
|
+
export function initialSelection(product: Product): Selection {
|
|
137
|
+
let base: Variant | undefined;
|
|
138
|
+
let firstInStock: Variant | undefined;
|
|
139
|
+
for (const variant of product.variants) {
|
|
140
|
+
if (variant.id === product.id) {
|
|
141
|
+
base = variant;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
if (firstInStock === undefined && !variant.outOfStock) {
|
|
145
|
+
firstInStock = variant;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
base ??= firstInStock ?? product.variants[0];
|
|
149
|
+
return base ? { ...base.selection } : {};
|
|
150
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { McpServer } from "skybridge/server";
|
|
3
|
+
import { CAROUSEL_RANGE, MIN_SEARCH_ITERATIONS } from "./config.js";
|
|
4
|
+
import {
|
|
5
|
+
renderCarouselDefinition,
|
|
6
|
+
renderCarouselHandler,
|
|
7
|
+
} from "./tools/render-carousel.js";
|
|
8
|
+
import {
|
|
9
|
+
searchProductsDefinition,
|
|
10
|
+
searchProductsHandler,
|
|
11
|
+
} from "./tools/search-products.js";
|
|
12
|
+
|
|
13
|
+
// Load .env into process.env when present (native to Node, no dependency).
|
|
14
|
+
if (existsSync(".env")) {
|
|
15
|
+
process.loadEnvFile();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const server = new McpServer(
|
|
19
|
+
{
|
|
20
|
+
// @todo: name and version your app.
|
|
21
|
+
name: "skybridge-ecom",
|
|
22
|
+
version: "0.0.1",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// @todo: adapt this server-wide prompt to your catalog.
|
|
26
|
+
instructions: `\
|
|
27
|
+
Two phases:
|
|
28
|
+
|
|
29
|
+
SEARCH: Call search-products ${MIN_SEARCH_ITERATIONS}+ times before presenting, never off one call. \
|
|
30
|
+
Vary the keywords or page deeper. \
|
|
31
|
+
Stay silent while searching: emit NO text between calls. Speak only \
|
|
32
|
+
once the carousel renders.
|
|
33
|
+
|
|
34
|
+
RENDER: After curating, call render-carousel with the chosen product IDs (aim for ${CAROUSEL_RANGE}). \
|
|
35
|
+
Speak once it renders, then recommend products in carousel order.`,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
.registerTool(searchProductsDefinition, searchProductsHandler)
|
|
39
|
+
.registerTool(renderCarouselDefinition, renderCarouselHandler);
|
|
40
|
+
|
|
41
|
+
export default await server.run();
|
|
42
|
+
|
|
43
|
+
export type AppType = typeof server;
|