create-skybridge 0.0.0-dev.356dbec → 0.0.0-dev.35a7b38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/dist/index.js +353 -157
  2. package/package.json +9 -7
  3. package/templates/blank/.dockerignore +4 -0
  4. package/templates/blank/AGENTS.md +1 -0
  5. package/templates/blank/Dockerfile +53 -0
  6. package/templates/blank/README.md +92 -0
  7. package/templates/blank/_gitignore +7 -0
  8. package/templates/blank/alpic.json +3 -0
  9. package/templates/blank/node_modules/.bin/alpic +21 -0
  10. package/templates/blank/node_modules/.bin/sb +21 -0
  11. package/templates/blank/node_modules/.bin/skybridge +21 -0
  12. package/templates/blank/node_modules/.bin/tsc +21 -0
  13. package/templates/blank/node_modules/.bin/tsserver +21 -0
  14. package/templates/blank/node_modules/.bin/tsx +21 -0
  15. package/templates/blank/node_modules/.bin/vite +21 -0
  16. package/templates/blank/package.json +29 -0
  17. package/templates/blank/src/helpers.ts +4 -0
  18. package/templates/blank/src/server.ts +16 -0
  19. package/templates/blank/tsconfig.json +5 -0
  20. package/templates/blank/vite.config.ts +6 -0
  21. package/templates/demo/.dockerignore +4 -0
  22. package/templates/demo/AGENTS.md +1 -0
  23. package/templates/demo/Dockerfile +53 -0
  24. package/templates/demo/README.md +95 -0
  25. package/templates/demo/_gitignore +7 -0
  26. package/templates/demo/alpic.json +3 -0
  27. package/templates/demo/node_modules/.bin/alpic +21 -0
  28. package/templates/demo/node_modules/.bin/sb +21 -0
  29. package/templates/demo/node_modules/.bin/skybridge +21 -0
  30. package/templates/demo/node_modules/.bin/tsc +21 -0
  31. package/templates/demo/node_modules/.bin/tsserver +21 -0
  32. package/templates/demo/node_modules/.bin/tsx +21 -0
  33. package/templates/demo/node_modules/.bin/vite +21 -0
  34. package/templates/demo/package.json +41 -0
  35. package/templates/demo/src/helpers.ts +4 -0
  36. package/templates/demo/src/index.css +59 -0
  37. package/templates/demo/src/server.ts +94 -0
  38. package/templates/demo/src/views/components/doc-link.tsx +22 -0
  39. package/templates/demo/src/views/components/doc.tsx +21 -0
  40. package/templates/demo/src/views/components/nav.tsx +31 -0
  41. package/templates/demo/src/views/components/progress.tsx +35 -0
  42. package/templates/demo/src/views/components/steps/outro.tsx +68 -0
  43. package/templates/demo/src/views/components/steps/state.tsx +47 -0
  44. package/templates/demo/src/views/components/steps/tool-call.tsx +53 -0
  45. package/templates/demo/src/views/components/steps/tool-output.tsx +40 -0
  46. package/templates/demo/src/views/images/mascot/beret.png +0 -0
  47. package/templates/demo/src/views/images/mascot/chapka.png +0 -0
  48. package/templates/demo/src/views/images/mascot/cowboy-hat.png +0 -0
  49. package/templates/demo/src/views/images/mascot/fez.png +0 -0
  50. package/templates/demo/src/views/images/mascot/jester-hat.png +0 -0
  51. package/templates/demo/src/views/images/mascot/mitre.png +0 -0
  52. package/templates/demo/src/views/images/mascot/non-la.png +0 -0
  53. package/templates/demo/src/views/images/mascot/original.png +0 -0
  54. package/templates/demo/src/views/images/mascot/propeller-beanie.png +0 -0
  55. package/templates/demo/src/views/images/mascot/ski-mask.png +0 -0
  56. package/templates/demo/src/views/images/mascot/sombrero.png +0 -0
  57. package/templates/demo/src/views/images/mascot/top-hat.png +0 -0
  58. package/templates/demo/src/views/images/mascot/viking-helmet.png +0 -0
  59. package/templates/demo/src/views/onboarding.tsx +63 -0
  60. package/templates/demo/src/views/use-mascot.ts +60 -0
  61. package/templates/demo/tsconfig.json +11 -0
  62. package/{template/web → templates/demo}/vite.config.ts +3 -4
  63. package/templates/ecom/.dockerignore +4 -0
  64. package/templates/ecom/.env.template +2 -0
  65. package/templates/ecom/.ladle/components.tsx +26 -0
  66. package/templates/ecom/.ladle/config.mjs +11 -0
  67. package/templates/ecom/.ladle/vite.config.ts +11 -0
  68. package/templates/ecom/AGENTS.md +2 -0
  69. package/templates/ecom/Dockerfile +53 -0
  70. package/templates/ecom/README.md +92 -0
  71. package/templates/ecom/_gitignore +9 -0
  72. package/templates/ecom/alpic.json +3 -0
  73. package/templates/ecom/node_modules/.bin/alpic +21 -0
  74. package/templates/ecom/node_modules/.bin/ladle +21 -0
  75. package/templates/ecom/node_modules/.bin/sb +21 -0
  76. package/templates/ecom/node_modules/.bin/skybridge +21 -0
  77. package/templates/ecom/node_modules/.bin/tsc +21 -0
  78. package/templates/ecom/node_modules/.bin/tsserver +21 -0
  79. package/templates/ecom/node_modules/.bin/tsx +21 -0
  80. package/templates/ecom/node_modules/.bin/vite +21 -0
  81. package/templates/ecom/package.json +41 -0
  82. package/templates/ecom/src/components/chip.css.ts +56 -0
  83. package/templates/ecom/src/components/chip.stories.tsx +26 -0
  84. package/templates/ecom/src/components/chip.tsx +41 -0
  85. package/templates/ecom/src/components/empty-state.stories.tsx +3 -0
  86. package/templates/ecom/src/components/empty-state.tsx +12 -0
  87. package/templates/ecom/src/components/expandable-text.css.ts +49 -0
  88. package/templates/ecom/src/components/expandable-text.stories.tsx +20 -0
  89. package/templates/ecom/src/components/expandable-text.tsx +53 -0
  90. package/templates/ecom/src/components/image-gallery.css.ts +172 -0
  91. package/templates/ecom/src/components/image-gallery.stories.tsx +30 -0
  92. package/templates/ecom/src/components/image-gallery.tsx +162 -0
  93. package/templates/ecom/src/components/product-card.css.ts +155 -0
  94. package/templates/ecom/src/components/product-card.stories.tsx +58 -0
  95. package/templates/ecom/src/components/product-card.tsx +101 -0
  96. package/templates/ecom/src/components/product-carousel.css.ts +134 -0
  97. package/templates/ecom/src/components/product-carousel.stories.tsx +64 -0
  98. package/templates/ecom/src/components/product-carousel.tsx +202 -0
  99. package/templates/ecom/src/components/variant-picker.css.ts +27 -0
  100. package/templates/ecom/src/components/variant-picker.stories.tsx +64 -0
  101. package/templates/ecom/src/components/variant-picker.tsx +82 -0
  102. package/templates/ecom/src/components/view-frame.css.ts +22 -0
  103. package/templates/ecom/src/components/view-frame.tsx +27 -0
  104. package/templates/ecom/src/config.ts +12 -0
  105. package/templates/ecom/src/design/contract.css.ts +39 -0
  106. package/templates/ecom/src/design/fonts.css +15 -0
  107. package/templates/ecom/src/design/primitives.css.ts +101 -0
  108. package/templates/ecom/src/design/recipes/typography.css.ts +75 -0
  109. package/templates/ecom/src/design/sprinkles.css.ts +128 -0
  110. package/templates/ecom/src/design/themes/dark.css.ts +36 -0
  111. package/templates/ecom/src/design/themes/light.css.ts +36 -0
  112. package/templates/ecom/src/design/tokens.ts +8 -0
  113. package/templates/ecom/src/helpers.ts +4 -0
  114. package/templates/ecom/src/i18n.ts +34 -0
  115. package/templates/ecom/src/index.css +9 -0
  116. package/templates/ecom/src/lib/cx.ts +9 -0
  117. package/templates/ecom/src/lib/format.ts +9 -0
  118. package/templates/ecom/src/lib/variants.ts +79 -0
  119. package/templates/ecom/src/server.ts +43 -0
  120. package/templates/ecom/src/tools/render-carousel.ts +242 -0
  121. package/templates/ecom/src/tools/search-products.ts +182 -0
  122. package/templates/ecom/src/types.ts +13 -0
  123. package/templates/ecom/src/views/carousel/detail/detail.css.ts +100 -0
  124. package/templates/ecom/src/views/carousel/detail/detail.stories.tsx +114 -0
  125. package/templates/ecom/src/views/carousel/detail/index.tsx +215 -0
  126. package/templates/ecom/src/views/carousel/index.tsx +234 -0
  127. package/templates/ecom/tsconfig.json +11 -0
  128. package/templates/ecom/vite.config.ts +8 -0
  129. package/dist/index.test.d.ts +0 -1
  130. package/dist/index.test.js +0 -23
  131. package/template/README.md +0 -77
  132. package/template/_gitignore +0 -4
  133. package/template/alpic.json +0 -4
  134. package/template/node_modules/.bin/mcp-inspector +0 -21
  135. package/template/node_modules/.bin/nodemon +0 -21
  136. package/template/node_modules/.bin/shx +0 -21
  137. package/template/node_modules/.bin/tsc +0 -21
  138. package/template/node_modules/.bin/tsserver +0 -21
  139. package/template/node_modules/.bin/tsx +0 -21
  140. package/template/node_modules/.bin/vite +0 -21
  141. package/template/nodemon.json +0 -5
  142. package/template/package.json +0 -42
  143. package/template/server/src/index.ts +0 -39
  144. package/template/server/src/middleware.ts +0 -54
  145. package/template/server/src/server.ts +0 -61
  146. package/template/tsconfig.json +0 -23
  147. package/template/tsconfig.server.json +0 -11
  148. package/template/web/src/helpers.ts +0 -4
  149. package/template/web/src/index.css +0 -31
  150. package/template/web/src/widgets/magic-8-ball.tsx +0 -24
@@ -0,0 +1,202 @@
1
+ import {
2
+ Children,
3
+ type ReactNode,
4
+ type RefObject,
5
+ useCallback,
6
+ useEffect,
7
+ useRef,
8
+ useState,
9
+ } from "react";
10
+ import { useLabels } from "../i18n";
11
+ import { cx } from "../lib/cx";
12
+ import * as styles from "./product-carousel.css";
13
+
14
+ // How long to wait after the last intersection change before reporting, so a
15
+ // fast scroll does not spam updates.
16
+ const VISIBILITY_DEBOUNCE_MS = 200;
17
+
18
+ // @todo: for boxed cards (border + background), set this to true and leave the
19
+ // carousel unframed. Pick one, not both.
20
+ const FRAMED = false;
21
+
22
+ function Chevron({ direction }: { direction: "left" | "right" }) {
23
+ const d = direction === "left" ? "M15 18l-6-6 6-6" : "M9 18l6-6-6-6";
24
+ return (
25
+ <svg
26
+ width="20"
27
+ height="20"
28
+ viewBox="0 0 24 24"
29
+ fill="none"
30
+ stroke="currentColor"
31
+ strokeWidth="2"
32
+ strokeLinecap="round"
33
+ strokeLinejoin="round"
34
+ aria-hidden="true"
35
+ >
36
+ <path d={d} />
37
+ </svg>
38
+ );
39
+ }
40
+
41
+ type ProductCarouselProps = {
42
+ children: ReactNode;
43
+ // Reports which child indices are at least half in view, in ascending order,
44
+ // debounced. Use it to narrate only what the user actually sees.
45
+ onVisibleChange?: (indices: number[]) => void;
46
+ // Skeleton state: locks the scroll and hides the nav buttons.
47
+ loading?: boolean;
48
+ // Optional external ref to the scroll track. The orchestrator uses it to save
49
+ // and restore scroll position across the carousel ⇄ detail transition (the
50
+ // carousel is hidden, not unmounted, but display:none resets scrollLeft).
51
+ trackRef?: RefObject<HTMLElement | null>;
52
+ };
53
+
54
+ /**
55
+ * Horizontal, scroll-snapping track of cards. Generic: it renders whatever
56
+ * children it is given, one per snap cell. Native scroll handles touch; the
57
+ * prev/next buttons are desktop-only affordances (see product-carousel.css.ts).
58
+ */
59
+ export function ProductCarousel({
60
+ children,
61
+ onVisibleChange,
62
+ loading = false,
63
+ trackRef: externalTrackRef,
64
+ }: ProductCarouselProps) {
65
+ const labels = useLabels();
66
+ const trackRef = useRef<HTMLElement>(null);
67
+ // Merge the internal ref with the optional external one via a callback ref, so
68
+ // the orchestrator can read/restore scroll while `trackRef` stays a plain
69
+ // useRef (its `.current` reads need no effect dependency).
70
+ const setTrackRef = useCallback(
71
+ (el: HTMLElement | null) => {
72
+ trackRef.current = el;
73
+ if (externalTrackRef) {
74
+ externalTrackRef.current = el;
75
+ }
76
+ },
77
+ [externalTrackRef],
78
+ );
79
+ const [canScrollLeft, setCanScrollLeft] = useState(false);
80
+ const [canScrollRight, setCanScrollRight] = useState(false);
81
+
82
+ useEffect(() => {
83
+ const el = trackRef.current;
84
+ if (!el) {
85
+ return;
86
+ }
87
+ const updateEdges = () => {
88
+ setCanScrollLeft(el.scrollLeft > 0);
89
+ setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
90
+ };
91
+ updateEdges();
92
+ el.addEventListener("scroll", updateEdges, { passive: true });
93
+ const observer = new ResizeObserver(updateEdges);
94
+ observer.observe(el);
95
+ return () => {
96
+ el.removeEventListener("scroll", updateEdges);
97
+ observer.disconnect();
98
+ };
99
+ }, []);
100
+
101
+ // Track which cells are in view and report them (only when a consumer asks).
102
+ // Pass a stable `onVisibleChange` (e.g. a useState setter): a new identity
103
+ // each render re-subscribes the observer.
104
+ const childCount = Children.count(children);
105
+ // biome-ignore lint/correctness/useExhaustiveDependencies: childCount re-subscribes when the number of cells changes; it is not read in the body.
106
+ useEffect(() => {
107
+ const el = trackRef.current;
108
+ if (!el || !onVisibleChange) {
109
+ return;
110
+ }
111
+ const cells = Array.from(el.children);
112
+ const visible = new Set<number>();
113
+ let timer: number | undefined;
114
+ const emit = () => {
115
+ const indices = [...visible].sort((a, b) => a - b);
116
+ onVisibleChange?.(indices);
117
+ };
118
+ const observer = new IntersectionObserver(
119
+ (entries) => {
120
+ for (const entry of entries) {
121
+ const index = cells.indexOf(entry.target);
122
+ if (index === -1) {
123
+ continue;
124
+ }
125
+ if (entry.isIntersecting) {
126
+ visible.add(index);
127
+ } else {
128
+ visible.delete(index);
129
+ }
130
+ }
131
+ window.clearTimeout(timer);
132
+ timer = window.setTimeout(emit, VISIBILITY_DEBOUNCE_MS);
133
+ },
134
+ { root: el, threshold: 0.5 },
135
+ );
136
+ for (const cell of cells) {
137
+ observer.observe(cell);
138
+ }
139
+ return () => {
140
+ window.clearTimeout(timer);
141
+ observer.disconnect();
142
+ };
143
+ }, [childCount, onVisibleChange]);
144
+
145
+ const step = (direction: 1 | -1) => {
146
+ const el = trackRef.current;
147
+ if (!el) {
148
+ return;
149
+ }
150
+ const cell = el.firstElementChild as HTMLElement | null;
151
+ const gap = Number.parseFloat(getComputedStyle(el).columnGap) || 0;
152
+ const distance = cell ? cell.offsetWidth + gap : el.clientWidth;
153
+ // No `behavior`: inherits the track's CSS scroll-behavior (respects
154
+ // prefers-reduced-motion).
155
+ el.scrollBy({ left: direction * distance });
156
+ };
157
+
158
+ const cells: ReactNode[] = [];
159
+ const items = Children.toArray(children);
160
+ for (let i = 0; i < items.length; i++) {
161
+ cells.push(
162
+ <div key={i} className={styles.cell}>
163
+ {items[i]}
164
+ </div>,
165
+ );
166
+ }
167
+
168
+ return (
169
+ <div className={styles.carousel({ framed: FRAMED })}>
170
+ <section
171
+ ref={setTrackRef}
172
+ className={styles.track({ framed: FRAMED, loading })}
173
+ aria-roledescription={labels.carousel}
174
+ aria-label={labels.products}
175
+ >
176
+ {cells}
177
+ </section>
178
+ {loading ? null : (
179
+ <>
180
+ <button
181
+ type="button"
182
+ aria-label={labels.previous}
183
+ className={cx(styles.nav, styles.navPrev)}
184
+ disabled={!canScrollLeft}
185
+ onClick={() => step(-1)}
186
+ >
187
+ <Chevron direction="left" />
188
+ </button>
189
+ <button
190
+ type="button"
191
+ aria-label={labels.next}
192
+ className={cx(styles.nav, styles.navNext)}
193
+ disabled={!canScrollRight}
194
+ onClick={() => step(1)}
195
+ >
196
+ <Chevron direction="right" />
197
+ </button>
198
+ </>
199
+ )}
200
+ </div>
201
+ );
202
+ }
@@ -0,0 +1,27 @@
1
+ import { style } from "@vanilla-extract/css";
2
+ import { colors, primitives } from "../design/tokens";
3
+
4
+ export const picker = style({
5
+ display: "flex",
6
+ flexDirection: "column",
7
+ gap: primitives.space.xs,
8
+ });
9
+
10
+ export const section = style({
11
+ display: "flex",
12
+ flexDirection: "column",
13
+ gap: primitives.space["3xs"],
14
+ });
15
+
16
+ export const label = style({
17
+ color: colors.content.subtle,
18
+ });
19
+
20
+ // Chip row: wraps to the next line when it overflows. @todo: swap for a
21
+ // horizontal scroll row with an edge fade (as the carousel track) if you expect
22
+ // many values on one axis.
23
+ export const values = style({
24
+ display: "flex",
25
+ flexWrap: "wrap",
26
+ gap: primitives.space["3xs"],
27
+ });
@@ -0,0 +1,64 @@
1
+ import { useState } from "react";
2
+ import { initialSelection, type Selection } from "../lib/variants.js";
3
+ import type { Product } from "../tools/render-carousel.js";
4
+ import { VariantPicker } from "./variant-picker";
5
+
6
+ // A sparse catalog: {black,40}, {black,42}, {white,40} exist — but not
7
+ // {white,42}. Picking "White" therefore disables "42".
8
+ function variant(
9
+ id: string,
10
+ color: string,
11
+ size: string,
12
+ ): Product["variants"][number] {
13
+ return {
14
+ id,
15
+ selection: { color, size },
16
+ title: `Sneaker ${color} ${size}`,
17
+ price: { amount: 120, currency: "EUR" },
18
+ media: [],
19
+ attributes: [],
20
+ };
21
+ }
22
+
23
+ const PRODUCT: Product = {
24
+ id: "sneaker",
25
+ options: [
26
+ {
27
+ id: "color",
28
+ label: "Color",
29
+ values: [
30
+ { id: "black", label: "Black" },
31
+ { id: "white", label: "White" },
32
+ ],
33
+ },
34
+ {
35
+ id: "size",
36
+ label: "Size",
37
+ values: [
38
+ { id: "40", label: "40" },
39
+ { id: "42", label: "42" },
40
+ ],
41
+ },
42
+ ],
43
+ variants: [
44
+ variant("s-b-40", "black", "40"),
45
+ variant("s-b-42", "black", "42"),
46
+ variant("s-w-40", "white", "40"),
47
+ ],
48
+ card: { title: "Sneaker", media: [], attributes: [] },
49
+ };
50
+
51
+ export const Contingency = () => {
52
+ const [selection, setSelection] = useState<Selection>(() =>
53
+ initialSelection(PRODUCT),
54
+ );
55
+ return (
56
+ <div style={{ maxWidth: 320 }}>
57
+ <VariantPicker
58
+ product={PRODUCT}
59
+ selection={selection}
60
+ onChange={setSelection}
61
+ />
62
+ </div>
63
+ );
64
+ };
@@ -0,0 +1,82 @@
1
+ import { text } from "../design/tokens";
2
+ import { cx } from "../lib/cx";
3
+ import { type Selection, selectableValues } from "../lib/variants.js";
4
+ import type { Product } from "../tools/render-carousel.js";
5
+ import { Chip } from "./chip";
6
+ import * as styles from "./variant-picker.css";
7
+
8
+ type VariantPickerProps = {
9
+ product: Product;
10
+ selection: Selection;
11
+ onChange: (selection: Selection) => void;
12
+ };
13
+
14
+ /**
15
+ * Renders one section per option axis and resolves the client's choices against
16
+ * the product's SPARSE variant list. Values with no surviving variant (given
17
+ * the other choices) are disabled, not hidden. Selecting a value that strands an
18
+ * earlier choice drops that choice so the selection stays reachable.
19
+ *
20
+ * This is the in-place model: every axis is local state, no remount. @todo: if
21
+ * a catalog models an axis (e.g. color) as separate products, promote it to a
22
+ * cross-product switch that changes the opened product id instead.
23
+ */
24
+ export function VariantPicker({
25
+ product,
26
+ selection,
27
+ onChange,
28
+ }: VariantPickerProps) {
29
+ function choose(axisId: string, valueId: string) {
30
+ const next: Selection = { ...selection, [axisId]: valueId };
31
+ // Repair: drop any other-axis choice the new pick just made unreachable.
32
+ for (const option of product.options) {
33
+ if (option.id === axisId) {
34
+ continue;
35
+ }
36
+ const chosen = next[option.id];
37
+ if (
38
+ chosen != null &&
39
+ !selectableValues(product, option.id, next).has(chosen)
40
+ ) {
41
+ delete next[option.id];
42
+ }
43
+ }
44
+ onChange(next);
45
+ }
46
+
47
+ return (
48
+ <div className={styles.picker}>
49
+ {product.options.map((option) => {
50
+ // A single-value axis is not a choice; skip it.
51
+ if (option.values.length <= 1) {
52
+ return null;
53
+ }
54
+ const reachable = selectableValues(product, option.id, selection);
55
+ return (
56
+ <div
57
+ key={option.id}
58
+ className={styles.section}
59
+ role="radiogroup"
60
+ aria-label={option.label}
61
+ >
62
+ <span className={cx(text({ style: "labelS" }), styles.label)}>
63
+ {option.label}
64
+ </span>
65
+ <div className={styles.values}>
66
+ {option.values.map((value) => (
67
+ <Chip
68
+ key={value.id}
69
+ label={value.label}
70
+ media={value.media}
71
+ selected={selection[option.id] === value.id}
72
+ disabled={!reachable.has(value.id)}
73
+ onSelect={() => choose(option.id, value.id)}
74
+ />
75
+ ))}
76
+ </div>
77
+ </div>
78
+ );
79
+ })}
80
+ </div>
81
+ );
82
+ }
@@ -0,0 +1,22 @@
1
+ import { globalStyle, style } from "@vanilla-extract/css";
2
+ import { colors, primitives } from "../design/tokens";
3
+
4
+ /**
5
+ * Base frame for every view. Transparent so the widget blends into the host
6
+ * surface; it pins the design system's font + content color so descendants
7
+ * inherit from the DS, not from the host page (whose text color could be white
8
+ * on a dark host and make card text vanish).
9
+ */
10
+ export const viewFrame = style({
11
+ color: colors.content.intense,
12
+ fontFamily: primitives.font.family.primary,
13
+ fontSize: primitives.font.size.m,
14
+ lineHeight: primitives.font.lineHeight.normal,
15
+ WebkitFontSmoothing: "antialiased",
16
+ MozOsxFontSmoothing: "grayscale",
17
+ });
18
+
19
+ // Box-sizing reset scoped to the frame subtree.
20
+ globalStyle(`${viewFrame} *, ${viewFrame} *::before, ${viewFrame} *::after`, {
21
+ boxSizing: "border-box",
22
+ });
@@ -0,0 +1,27 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { useLayout } from "skybridge/web";
3
+ import { darkTheme, lightTheme } from "../design/tokens";
4
+ import { cx } from "../lib/cx";
5
+ import { viewFrame } from "./view-frame.css";
6
+
7
+ /**
8
+ * ViewFrame: the top-level wrapper every view mounts inside. It activates the
9
+ * design system by applying the active theme class (which sets the CSS
10
+ * variables the color contract declares) and paints the base surface + font +
11
+ * content color so descendants inherit from the DS instead of the host page.
12
+ *
13
+ * It follows the host theme via useLayout(). To lock the widget to one palette
14
+ * (e.g. always light), drop useLayout and hardcode the theme class.
15
+ *
16
+ * Keep view entry files thin: render <ViewFrame> at the root and let this carry
17
+ * the theme + base-style boilerplate.
18
+ */
19
+ type ViewFrameProps = HTMLAttributes<HTMLDivElement>;
20
+
21
+ export function ViewFrame({ className, ...rest }: ViewFrameProps) {
22
+ const { theme } = useLayout();
23
+ const themeClass = theme === "dark" ? darkTheme : lightTheme;
24
+
25
+ return <div {...rest} className={cx(themeClass, viewFrame, className)} />;
26
+ }
27
+ ViewFrame.displayName = "ViewFrame";
@@ -0,0 +1,12 @@
1
+ // App-wide tuning knobs, shared by the server prompt and the tools.
2
+
3
+ // @todo: minimum number of searches the model runs before rendering. Feeds the
4
+ // prompts to enforce multi-call exploration; raise for deeper results.
5
+ export const MIN_SEARCH_ITERATIONS = 2;
6
+
7
+ // @todo: the maximum number of products the carousel shows.
8
+ export const CAROUSEL_MAX_SIZE = 6;
9
+
10
+ // A "min-max" string (e.g. "3-6") derived from CAROUSEL_MAX_SIZE, interpolated
11
+ // into the prompts to tell the model how many products to curate toward.
12
+ export const CAROUSEL_RANGE = `${Math.ceil(CAROUSEL_MAX_SIZE / 2)}-${CAROUSEL_MAX_SIZE}`;
@@ -0,0 +1,39 @@
1
+ import { createThemeContract } from "@vanilla-extract/css";
2
+
3
+ /**
4
+ * Semantic color contract. Every field must be satisfied by both
5
+ * themes/light.css.ts and themes/dark.css.ts: TypeScript errors on drift.
6
+ *
7
+ * Adding a field here forces both themes to set a value. The compiler is the
8
+ * enforcement mechanism that keeps light and dark coherent.
9
+ *
10
+ * @todo: add or remove semantic slots to fit your UI. Keep names intent-based
11
+ * (surface.subtle, content.intense), not literal (grey100): the point is that
12
+ * components reference meaning, and the theme decides the hex.
13
+ */
14
+ export const colors = createThemeContract({
15
+ surface: {
16
+ extraLight: null,
17
+ light: null,
18
+ subtle: null,
19
+ intense: null,
20
+ },
21
+ content: {
22
+ intense: null,
23
+ subtle: null,
24
+ invertIntense: null,
25
+ invertSubtle: null,
26
+ },
27
+ border: {
28
+ thin: null,
29
+ subtle: null,
30
+ intense: null,
31
+ },
32
+ common: {
33
+ accent: null,
34
+ invertAccent: null,
35
+ highlight: null,
36
+ error: null,
37
+ success: null,
38
+ },
39
+ });
@@ -0,0 +1,15 @@
1
+ /* @todo: add your brand's @font-face rules here, then point
2
+ primitives.font.family.primary at the family name. Drop the font files in
3
+ public/fonts/ so they are served under /assets/fonts/.
4
+
5
+ The template ships with the system font stack, which needs no @font-face,
6
+ so this file is empty by default. Example:
7
+
8
+ @font-face {
9
+ font-family: "My Brand";
10
+ font-style: normal;
11
+ font-weight: 400;
12
+ font-display: block;
13
+ src: url("/assets/fonts/MyBrand-Regular.woff2") format("woff2");
14
+ }
15
+ */
@@ -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
+ });