create-skybridge 0.0.0-dev.08be486 → 0.0.0-dev.09043e8

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 (75) hide show
  1. package/dist/index.js +52 -26
  2. package/package.json +1 -1
  3. package/templates/blank/package.json +2 -1
  4. package/templates/blank/vite.config.ts +1 -1
  5. package/templates/demo/package.json +2 -1
  6. package/templates/demo/vite.config.ts +1 -1
  7. package/templates/ecom/.dockerignore +4 -0
  8. package/templates/ecom/.env.template +7 -0
  9. package/templates/ecom/.ladle/components.tsx +26 -0
  10. package/templates/ecom/.ladle/config.mjs +11 -0
  11. package/templates/ecom/.ladle/vite.config.ts +11 -0
  12. package/templates/ecom/AGENTS.md +2 -0
  13. package/templates/ecom/Dockerfile +53 -0
  14. package/templates/ecom/README.md +92 -0
  15. package/templates/ecom/_gitignore +9 -0
  16. package/templates/ecom/alpic.json +3 -0
  17. package/templates/ecom/node_modules/.bin/alpic +21 -0
  18. package/templates/ecom/node_modules/.bin/ladle +21 -0
  19. package/templates/ecom/node_modules/.bin/sb +21 -0
  20. package/templates/ecom/node_modules/.bin/skybridge +21 -0
  21. package/templates/ecom/node_modules/.bin/tsc +21 -0
  22. package/templates/ecom/node_modules/.bin/tsserver +21 -0
  23. package/templates/ecom/node_modules/.bin/tsx +21 -0
  24. package/templates/ecom/node_modules/.bin/vite +21 -0
  25. package/templates/ecom/package.json +42 -0
  26. package/templates/ecom/src/catalog/index.ts +19 -0
  27. package/templates/ecom/src/catalog/mock.ts +134 -0
  28. package/templates/ecom/src/catalog/shopify.ts +264 -0
  29. package/templates/ecom/src/components/chip.css.ts +63 -0
  30. package/templates/ecom/src/components/chip.stories.tsx +27 -0
  31. package/templates/ecom/src/components/chip.tsx +49 -0
  32. package/templates/ecom/src/components/empty-state.stories.tsx +3 -0
  33. package/templates/ecom/src/components/empty-state.tsx +12 -0
  34. package/templates/ecom/src/components/expandable-text.css.ts +49 -0
  35. package/templates/ecom/src/components/expandable-text.stories.tsx +20 -0
  36. package/templates/ecom/src/components/expandable-text.tsx +53 -0
  37. package/templates/ecom/src/components/image-gallery.css.ts +172 -0
  38. package/templates/ecom/src/components/image-gallery.stories.tsx +30 -0
  39. package/templates/ecom/src/components/image-gallery.tsx +163 -0
  40. package/templates/ecom/src/components/product-card.css.ts +159 -0
  41. package/templates/ecom/src/components/product-card.stories.tsx +58 -0
  42. package/templates/ecom/src/components/product-card.tsx +102 -0
  43. package/templates/ecom/src/components/product-carousel.css.ts +134 -0
  44. package/templates/ecom/src/components/product-carousel.stories.tsx +64 -0
  45. package/templates/ecom/src/components/product-carousel.tsx +202 -0
  46. package/templates/ecom/src/components/variant-picker.css.ts +27 -0
  47. package/templates/ecom/src/components/variant-picker.stories.tsx +67 -0
  48. package/templates/ecom/src/components/variant-picker.tsx +70 -0
  49. package/templates/ecom/src/components/view-frame.css.ts +22 -0
  50. package/templates/ecom/src/components/view-frame.tsx +27 -0
  51. package/templates/ecom/src/config.ts +12 -0
  52. package/templates/ecom/src/design/contract.css.ts +39 -0
  53. package/templates/ecom/src/design/fonts.css +15 -0
  54. package/templates/ecom/src/design/primitives.css.ts +101 -0
  55. package/templates/ecom/src/design/recipes/typography.css.ts +75 -0
  56. package/templates/ecom/src/design/sprinkles.css.ts +128 -0
  57. package/templates/ecom/src/design/themes/dark.css.ts +36 -0
  58. package/templates/ecom/src/design/themes/light.css.ts +36 -0
  59. package/templates/ecom/src/design/tokens.ts +8 -0
  60. package/templates/ecom/src/helpers.ts +4 -0
  61. package/templates/ecom/src/i18n.ts +35 -0
  62. package/templates/ecom/src/index.css +9 -0
  63. package/templates/ecom/src/lib/cx.ts +9 -0
  64. package/templates/ecom/src/lib/format.ts +9 -0
  65. package/templates/ecom/src/lib/variants.ts +150 -0
  66. package/templates/ecom/src/server.ts +43 -0
  67. package/templates/ecom/src/tools/render-carousel.ts +161 -0
  68. package/templates/ecom/src/tools/search-products.ts +196 -0
  69. package/templates/ecom/src/types.ts +87 -0
  70. package/templates/ecom/src/views/carousel/detail/detail.css.ts +115 -0
  71. package/templates/ecom/src/views/carousel/detail/detail.stories.tsx +133 -0
  72. package/templates/ecom/src/views/carousel/detail/index.tsx +254 -0
  73. package/templates/ecom/src/views/carousel/index.tsx +233 -0
  74. package/templates/ecom/tsconfig.json +11 -0
  75. package/templates/ecom/vite.config.ts +8 -0
@@ -0,0 +1,53 @@
1
+ import { useLayoutEffect, useRef, useState } from "react";
2
+ import { text } from "../design/tokens";
3
+ import { useLabels } from "../i18n";
4
+ import { cx } from "../lib/cx";
5
+ import * as styles from "./expandable-text.css";
6
+
7
+ /**
8
+ * Clamps long copy to a few lines with a "read more" toggle. Truncation is
9
+ * measured, not assumed: the toggle only appears when the text actually
10
+ * overflows the collapsed height, so short copy shows no button.
11
+ */
12
+ export function ExpandableText({ children }: { children: string }) {
13
+ const labels = useLabels();
14
+ const bodyRef = useRef<HTMLParagraphElement>(null);
15
+ const [expanded, setExpanded] = useState(false);
16
+ const [overflows, setOverflows] = useState(false);
17
+
18
+ const collapsed = !expanded;
19
+
20
+ // Measure against the collapsed height (the clamp is applied whenever
21
+ // collapsed, so scrollHeight vs clientHeight is meaningful). Re-run when the
22
+ // text changes (e.g. the client switches variant) so the toggle tracks it.
23
+ // biome-ignore lint/correctness/useExhaustiveDependencies: children re-triggers the measure, it is not read in the body.
24
+ useLayoutEffect(() => {
25
+ const el = bodyRef.current;
26
+ if (el && collapsed) {
27
+ setOverflows(el.scrollHeight > el.clientHeight + 1);
28
+ }
29
+ }, [children, collapsed]);
30
+
31
+ return (
32
+ <div className={styles.container}>
33
+ <p
34
+ ref={bodyRef}
35
+ className={cx(
36
+ text({ style: "bodyS" }),
37
+ styles.body({ clamp: collapsed, fade: collapsed && overflows }),
38
+ )}
39
+ >
40
+ {children}
41
+ </p>
42
+ {overflows ? (
43
+ <button
44
+ type="button"
45
+ className={styles.toggle}
46
+ onClick={() => setExpanded((v) => !v)}
47
+ >
48
+ {expanded ? labels.readLess : labels.readMore}
49
+ </button>
50
+ ) : null}
51
+ </div>
52
+ );
53
+ }
@@ -0,0 +1,172 @@
1
+ import { globalStyle, style } from "@vanilla-extract/css";
2
+ import { colors, primitives } from "../design/tokens";
3
+
4
+ export const gallery = style({
5
+ position: "relative",
6
+ });
7
+
8
+ // Rail mode only (THUMBNAIL_RAIL): lay the rail beside the image on desktop. The
9
+ // breakpoint matches the PDP's two-column grid and resolves against the same
10
+ // `.detail` container, so the rail appears exactly when the page goes two-column.
11
+ export const galleryRail = style({
12
+ "@container": {
13
+ "(min-width: 560px)": {
14
+ display: "flex",
15
+ flexDirection: "row",
16
+ gap: primitives.space["2xs"],
17
+ // Top-align so the rail sits beside the image; the rail's own max-height
18
+ // (set from the measured image height) caps it and scrolls the excess.
19
+ alignItems: "flex-start",
20
+ },
21
+ },
22
+ });
23
+
24
+ // Image column: the positioning context for the overlaid chevrons, and the flex
25
+ // child that takes the width left of the rail on desktop.
26
+ export const mainCol = style({
27
+ position: "relative",
28
+ minWidth: 0,
29
+ "@container": {
30
+ "(min-width: 560px)": { flex: 1 },
31
+ },
32
+ });
33
+
34
+ // Scroll-snap track: one image per view. Native swipe on touch; the chevrons
35
+ // are the pointer affordance. Scrollbar hidden.
36
+ export const track = style({
37
+ display: "flex",
38
+ overflowX: "auto",
39
+ scrollSnapType: "x mandatory",
40
+ scrollBehavior: "smooth",
41
+ scrollbarWidth: "none",
42
+ borderRadius: primitives.radius.m,
43
+ "@media": {
44
+ "(prefers-reduced-motion: reduce)": { scrollBehavior: "auto" },
45
+ },
46
+ });
47
+
48
+ globalStyle(`${track}::-webkit-scrollbar`, { display: "none" });
49
+
50
+ export const slide = style({
51
+ flex: "0 0 100%",
52
+ scrollSnapAlign: "start",
53
+ // Reserve the box so images load without shifting the page. @todo: use the
54
+ // same aspect ratio / fit you chose for the card from the real image sample.
55
+ aspectRatio: "1",
56
+ backgroundColor: colors.surface.subtle,
57
+ });
58
+
59
+ export const image = style({
60
+ width: "100%",
61
+ height: "100%",
62
+ objectFit: "contain",
63
+ display: "block",
64
+ pointerEvents: "none",
65
+ userSelect: "none",
66
+ });
67
+
68
+ // Prev/next chevrons, vertically centered, disabled at the ends.
69
+ export const nav = style({
70
+ position: "absolute",
71
+ top: "50%",
72
+ transform: "translateY(-50%)",
73
+ display: "grid",
74
+ placeItems: "center",
75
+ width: "36px",
76
+ height: "36px",
77
+ padding: 0,
78
+ borderRadius: primitives.radius.full,
79
+ border: `${primitives.stroke.thin} solid ${colors.border.subtle}`,
80
+ backgroundColor: colors.surface.extraLight,
81
+ color: colors.content.intense,
82
+ cursor: "pointer",
83
+ transition: "opacity 150ms ease",
84
+ selectors: {
85
+ "&:disabled": { opacity: 0, pointerEvents: "none" },
86
+ },
87
+ });
88
+
89
+ export const navPrev = style({ left: primitives.space["3xs"] });
90
+ export const navNext = style({ right: primitives.space["3xs"] });
91
+
92
+ // Position indicator: a thin track with a fill sized to (index + 1) / count.
93
+ // @todo: style to your brand — height, track/fill colors, radius, width, and placement.
94
+ export const progress = style({
95
+ height: "3px",
96
+ marginTop: primitives.space["3xs"],
97
+ borderRadius: primitives.radius.full,
98
+ backgroundColor: colors.border.thin,
99
+ overflow: "hidden",
100
+ });
101
+
102
+ export const progressFill = style({
103
+ height: "100%",
104
+ borderRadius: primitives.radius.full,
105
+ backgroundColor: colors.content.intense,
106
+ transition: "width 200ms ease",
107
+ "@media": {
108
+ "(prefers-reduced-motion: reduce)": { transition: "none" },
109
+ },
110
+ });
111
+
112
+ // In rail mode the rail conveys position on desktop, so the progress bar is
113
+ // mobile-only there.
114
+ export const progressMobileOnly = style({
115
+ "@container": {
116
+ "(min-width: 560px)": { display: "none" },
117
+ },
118
+ });
119
+
120
+ // Desktop thumbnail rail (THUMBNAIL_RAIL). Hidden on mobile, where the swipe
121
+ // track + progress bar own navigation. Capped to the image height via an inline
122
+ // max-height and scrolls the excess. @todo: tune the rail width / thumb size.
123
+ export const rail = style({
124
+ display: "none",
125
+ "@container": {
126
+ "(min-width: 560px)": {
127
+ display: "flex",
128
+ flexDirection: "column",
129
+ flexShrink: 0,
130
+ gap: primitives.space["2xs"],
131
+ width: "64px",
132
+ minHeight: 0,
133
+ overflowY: "auto",
134
+ scrollbarWidth: "none",
135
+ },
136
+ },
137
+ });
138
+
139
+ globalStyle(`${rail}::-webkit-scrollbar`, { display: "none" });
140
+
141
+ export const thumb = style({
142
+ boxSizing: "border-box",
143
+ flexShrink: 0,
144
+ width: "100%",
145
+ aspectRatio: "1",
146
+ minHeight: 0, // let aspect-ratio win over the flex-item default min-height
147
+ padding: primitives.space["4xs"],
148
+ borderRadius: primitives.radius.m,
149
+ border: `${primitives.stroke.thin} solid ${colors.border.subtle}`,
150
+ backgroundColor: colors.surface.extraLight,
151
+ cursor: "pointer",
152
+ transition: "border-color 150ms ease",
153
+ "@media": {
154
+ "(prefers-reduced-motion: reduce)": { transition: "none" },
155
+ },
156
+ });
157
+
158
+ // Selected thumb: thicker, accented border. border-box keeps the width swap from
159
+ // shifting the rail layout.
160
+ export const thumbActive = style({
161
+ borderColor: colors.common.accent,
162
+ borderWidth: primitives.stroke.medium,
163
+ });
164
+
165
+ export const thumbImage = style({
166
+ width: "100%",
167
+ height: "100%",
168
+ objectFit: "contain",
169
+ display: "block",
170
+ pointerEvents: "none",
171
+ userSelect: "none",
172
+ });
@@ -0,0 +1,30 @@
1
+ import { ImageGallery } from "./image-gallery";
2
+
3
+ function shot(fill: string) {
4
+ return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Crect width='400' height='400' fill='%23${fill}'/%3E%3Ccircle cx='200' cy='200' r='110' fill='%23ffffff' fill-opacity='0.5'/%3E%3C/svg%3E`;
5
+ }
6
+
7
+ // The gallery's desktop layout (and the optional THUMBNAIL_RAIL) query a
8
+ // `container-type` host, which the PDP's `.detail` provides in the app. The
9
+ // story supplies its own so it previews at a realistic width and renders
10
+ // correctly whichever way THUMBNAIL_RAIL is set — swipe when off, rail when on.
11
+ const frame = {
12
+ containerType: "inline-size" as const,
13
+ width: 600,
14
+ maxWidth: "100%",
15
+ };
16
+
17
+ export const Multiple = () => (
18
+ <div style={frame}>
19
+ <ImageGallery
20
+ media={[shot("e1e1e1"), shot("c9d4f5"), shot("f5d4c9")]}
21
+ alt="Product"
22
+ />
23
+ </div>
24
+ );
25
+
26
+ export const Single = () => (
27
+ <div style={frame}>
28
+ <ImageGallery media={[shot("e1e1e1")]} alt="Product" />
29
+ </div>
30
+ );
@@ -0,0 +1,163 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import { useLabels } from "../i18n";
3
+ import { cx } from "../lib/cx";
4
+ import * as styles from "./image-gallery.css";
5
+
6
+ // @todo: show a thumbnail rail beside the image on desktop (at the two-column
7
+ // breakpoint); swipe-only when false. Off by default. When true, tune the rail
8
+ // width / thumb size in image-gallery.css.ts. The rail is capped to the image
9
+ // height and scrolls its excess; deferred polish (add if it earns it): an
10
+ // edge-fade mask and auto-centering the active thumb. Progress bar is hidden
11
+ // when thumbnail rail is active.
12
+ const THUMBNAIL_RAIL: boolean = false;
13
+
14
+ function Chevron({ direction }: { direction: "left" | "right" }) {
15
+ const d = direction === "left" ? "M15 18l-6-6 6-6" : "M9 18l6-6-6-6";
16
+ return (
17
+ <svg
18
+ width="20"
19
+ height="20"
20
+ viewBox="0 0 24 24"
21
+ fill="none"
22
+ stroke="currentColor"
23
+ strokeWidth="2"
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round"
26
+ aria-hidden="true"
27
+ >
28
+ <path d={d} />
29
+ </svg>
30
+ );
31
+ }
32
+
33
+ /**
34
+ * Product image gallery: a native scroll-snap track with prev/next chevrons and
35
+ * a progress bar; the current index is read from scroll position (no library).
36
+ * With the rail on, a desktop thumbnail rail controls the SAME track (shared
37
+ * index, click = scroll), and the progress bar is hidden where the rail shows
38
+ * (desktop) so the two never appear together. Mobile is always the swipe track.
39
+ */
40
+ export function ImageGallery({ media, alt }: { media: string[]; alt: string }) {
41
+ const labels = useLabels();
42
+ const trackRef = useRef<HTMLDivElement>(null);
43
+ const [index, setIndex] = useState(0);
44
+ const [imageHeight, setImageHeight] = useState<number>();
45
+
46
+ function onScroll() {
47
+ const el = trackRef.current;
48
+ if (el) {
49
+ setIndex(Math.round(el.scrollLeft / el.clientWidth));
50
+ }
51
+ }
52
+
53
+ function scrollToIndex(i: number) {
54
+ const el = trackRef.current;
55
+ if (el) {
56
+ el.scrollTo({ left: i * el.clientWidth });
57
+ }
58
+ }
59
+
60
+ // Rail only: cap the rail to the main image's height so its extra thumbnails
61
+ // scroll instead of dangling past the image. A vertical scroll container needs
62
+ // a definite height; the square image provides it, measured here.
63
+ useEffect(() => {
64
+ if (!THUMBNAIL_RAIL) {
65
+ return;
66
+ }
67
+ const el = trackRef.current;
68
+ if (!el) {
69
+ return;
70
+ }
71
+ const measure = () => setImageHeight(el.clientHeight);
72
+ measure();
73
+ const observer = new ResizeObserver(measure);
74
+ observer.observe(el);
75
+ return () => observer.disconnect();
76
+ }, []);
77
+
78
+ const multiple = media.length > 1;
79
+
80
+ return (
81
+ <section
82
+ className={cx(styles.gallery, THUMBNAIL_RAIL && styles.galleryRail)}
83
+ aria-roledescription={labels.carousel}
84
+ aria-label={alt}
85
+ >
86
+ {THUMBNAIL_RAIL && multiple ? (
87
+ <div
88
+ className={styles.rail}
89
+ style={{ maxHeight: imageHeight ? `${imageHeight}px` : undefined }}
90
+ >
91
+ {media.map((src, i) => (
92
+ <button
93
+ key={src}
94
+ type="button"
95
+ className={cx(styles.thumb, i === index && styles.thumbActive)}
96
+ aria-label={`${alt} (${i + 1})`}
97
+ aria-current={i === index}
98
+ onClick={() => scrollToIndex(i)}
99
+ >
100
+ <img
101
+ className={styles.thumbImage}
102
+ src={src}
103
+ alt=""
104
+ draggable={false}
105
+ />
106
+ </button>
107
+ ))}
108
+ </div>
109
+ ) : null}
110
+
111
+ <div className={styles.mainCol}>
112
+ <div ref={trackRef} className={styles.track} onScroll={onScroll}>
113
+ {media.map((src, i) => (
114
+ <div key={src} className={styles.slide}>
115
+ <img
116
+ className={styles.image}
117
+ src={src}
118
+ alt={i === 0 ? alt : ""}
119
+ loading={i === 0 ? "eager" : "lazy"}
120
+ draggable={false}
121
+ />
122
+ </div>
123
+ ))}
124
+ </div>
125
+
126
+ {multiple ? (
127
+ <>
128
+ <button
129
+ type="button"
130
+ aria-label={labels.previous}
131
+ className={cx(styles.nav, styles.navPrev)}
132
+ disabled={index === 0}
133
+ onClick={() => scrollToIndex(index - 1)}
134
+ >
135
+ <Chevron direction="left" />
136
+ </button>
137
+ <button
138
+ type="button"
139
+ aria-label={labels.next}
140
+ className={cx(styles.nav, styles.navNext)}
141
+ disabled={index === media.length - 1}
142
+ onClick={() => scrollToIndex(index + 1)}
143
+ >
144
+ <Chevron direction="right" />
145
+ </button>
146
+ <div
147
+ className={cx(
148
+ styles.progress,
149
+ THUMBNAIL_RAIL && styles.progressMobileOnly,
150
+ )}
151
+ aria-hidden="true"
152
+ >
153
+ <div
154
+ className={styles.progressFill}
155
+ style={{ width: `${((index + 1) / media.length) * 100}%` }}
156
+ />
157
+ </div>
158
+ </>
159
+ ) : null}
160
+ </div>
161
+ </section>
162
+ );
163
+ }
@@ -0,0 +1,159 @@
1
+ import { keyframes, style } from "@vanilla-extract/css";
2
+ import { recipe } from "@vanilla-extract/recipes";
3
+ import { colors, primitives } from "../design/tokens";
4
+
5
+ // @todo: number of title lines before it truncates with an ellipsis. Exported
6
+ // so the skeleton reserves the same number of lines.
7
+ export const TITLE_LINES = 2;
8
+
9
+ // `framed: true` gives each card its own container; the default is a plain
10
+ // layout shell (pair it with a framed carousel instead). Pick one, not both.
11
+ export const card = recipe({
12
+ base: {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ gap: primitives.space["3xs"],
16
+ width: "100%",
17
+ textAlign: "left",
18
+ },
19
+ variants: {
20
+ framed: {
21
+ // @todo: tune the card container to your brand.
22
+ true: {
23
+ padding: primitives.space["3xs"],
24
+ borderRadius: primitives.radius.m,
25
+ border: `${primitives.stroke.thin} solid ${colors.border.thin}`,
26
+ backgroundColor: colors.surface.extraLight,
27
+ },
28
+ false: {},
29
+ },
30
+ },
31
+ defaultVariants: { framed: false },
32
+ });
33
+
34
+ // Turns a whole card into one tap target (opens the detail view) using the
35
+ // stretched-link pattern: the card renders normally, and a transparent <button>
36
+ // overlays it. A real button (not role="button") gives keyboard + screen-reader
37
+ // support for free, and it holds no flow content, so the markup stays valid
38
+ // (a <button> wrapping the card's <article>/<p> would not be).
39
+ export const cardClickable = style({ position: "relative" });
40
+
41
+ export const cardButton = style({
42
+ position: "absolute",
43
+ inset: 0,
44
+ width: "100%",
45
+ height: "100%",
46
+ padding: 0,
47
+ border: "none",
48
+ background: "none",
49
+ cursor: "pointer",
50
+ borderRadius: primitives.radius.m,
51
+ });
52
+
53
+ export const imageBox = style({
54
+ position: "relative",
55
+ // @todo: aspect ratio for product imagery. Do not assume: fetch a sample of
56
+ // the catalog's real images and pick from what they actually are (square,
57
+ // portrait for fashion, landscape…). Keep it consistent with the gallery.
58
+ aspectRatio: "1",
59
+ overflow: "hidden",
60
+ borderRadius: primitives.radius.m,
61
+ // Stage behind the product image. @todo: pick the surface from that same image
62
+ // sample (a neutral grey for transparent cutouts, `extraLight`/white for
63
+ // full-bleed photos).
64
+ backgroundColor: colors.surface.subtle,
65
+ });
66
+
67
+ export const image = style({
68
+ width: "100%",
69
+ height: "100%",
70
+ // @todo: object-fit, from that same image sample: `contain` never crops (good
71
+ // for cutouts or mixed ratios); `cover` fills for a uniform grid (good for
72
+ // consistent, bleed-friendly photos).
73
+ objectFit: "contain",
74
+ display: "block",
75
+ // Keep image drag from hijacking the swipe/scroll gesture.
76
+ pointerEvents: "none",
77
+ userSelect: "none",
78
+ });
79
+
80
+ export const imageDimmed = style({ opacity: 0.5 });
81
+
82
+ export const placeholder = style({
83
+ width: "100%",
84
+ height: "100%",
85
+ backgroundColor: colors.surface.subtle,
86
+ });
87
+
88
+ export const oosBadge = style({
89
+ position: "absolute",
90
+ top: primitives.space["3xs"],
91
+ left: primitives.space["3xs"],
92
+ padding: `${primitives.space["5xs"]} ${primitives.space["3xs"]}`,
93
+ borderRadius: primitives.radius.s,
94
+ backgroundColor: colors.surface.extraLight,
95
+ color: colors.content.intense,
96
+ fontFamily: primitives.font.family.primary,
97
+ fontSize: primitives.font.size.xs,
98
+ });
99
+
100
+ export const body = style({
101
+ display: "flex",
102
+ flexDirection: "column",
103
+ gap: primitives.space["5xs"],
104
+ });
105
+
106
+ export const title = style({
107
+ color: colors.content.intense,
108
+ display: "-webkit-box",
109
+ WebkitLineClamp: TITLE_LINES,
110
+ WebkitBoxOrient: "vertical",
111
+ overflow: "hidden",
112
+ // Reserve the clamp height (title line-height is 1.5) so prices line up
113
+ // across cards whatever the title length.
114
+ minHeight: `calc(${TITLE_LINES} * 1.5em)`,
115
+ });
116
+
117
+ export const price = style({ color: colors.content.subtle });
118
+
119
+ // Skeleton (loading state).
120
+ const pulse = keyframes({
121
+ "0%": { opacity: 1 },
122
+ "50%": { opacity: 0.4 },
123
+ "100%": { opacity: 1 },
124
+ });
125
+
126
+ export const skeletonBox = style({
127
+ backgroundColor: colors.surface.subtle,
128
+ borderRadius: primitives.radius.s,
129
+ animation: `${pulse} 1.5s ease-in-out infinite`,
130
+ "@media": {
131
+ "(prefers-reduced-motion: reduce)": { animation: "none" },
132
+ },
133
+ });
134
+
135
+ export const skeletonImage = style({
136
+ aspectRatio: "1",
137
+ borderRadius: primitives.radius.m,
138
+ });
139
+
140
+ // Text rows (title lines + price), evenly spaced. Its own container rather than
141
+ // `body` so the skeleton can breathe a little more without moving the real card.
142
+ export const skeletonBody = style({
143
+ display: "flex",
144
+ flexDirection: "column",
145
+ gap: primitives.space["4xs"],
146
+ });
147
+
148
+ export const skeletonLine = style({ height: primitives.font.size.m });
149
+
150
+ // Last title line and the price row are stubbed short, the way text ends.
151
+ export const skeletonLineShort = style({
152
+ height: primitives.font.size.m,
153
+ width: "60%",
154
+ });
155
+
156
+ export const skeletonPrice = style({
157
+ height: primitives.font.size.m,
158
+ width: "40%",
159
+ });
@@ -0,0 +1,58 @@
1
+ import { ProductCard, ProductCardSkeleton } from "./product-card";
2
+
3
+ const IMAGE =
4
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Crect width='240' height='240' fill='%23e5e5e5'/%3E%3Ccircle cx='120' cy='120' r='70' fill='%23bcbcbc'/%3E%3C/svg%3E";
5
+
6
+ const frame = { maxWidth: 220 };
7
+
8
+ export const Default = () => (
9
+ <div style={frame}>
10
+ <ProductCard
11
+ title="Merino wool sweater"
12
+ price={{ amount: 129.9, currency: "EUR" }}
13
+ media={[IMAGE]}
14
+ />
15
+ </div>
16
+ );
17
+
18
+ export const LongTitle = () => (
19
+ <div style={frame}>
20
+ <ProductCard
21
+ title="Extra long product title that wraps onto two lines and then clamps"
22
+ price={{ amount: 1290, currency: "USD" }}
23
+ media={[IMAGE]}
24
+ />
25
+ </div>
26
+ );
27
+
28
+ export const NoImage = () => (
29
+ <div style={frame}>
30
+ <ProductCard
31
+ title="Product without an image"
32
+ price={{ amount: 49, currency: "EUR" }}
33
+ />
34
+ </div>
35
+ );
36
+
37
+ export const NoPrice = () => (
38
+ <div style={frame}>
39
+ <ProductCard title="Price on request" media={[IMAGE]} />
40
+ </div>
41
+ );
42
+
43
+ export const OutOfStock = () => (
44
+ <div style={frame}>
45
+ <ProductCard
46
+ title="Sold out product"
47
+ price={{ amount: 89, currency: "EUR" }}
48
+ media={[IMAGE]}
49
+ outOfStock
50
+ />
51
+ </div>
52
+ );
53
+
54
+ export const Skeleton = () => (
55
+ <div style={frame}>
56
+ <ProductCardSkeleton />
57
+ </div>
58
+ );