@snowcone-app/ui 0.1.43 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +18 -4
- package/package.json +9 -5
- package/src/components/CanvasIsolationBoundary.tsx +202 -0
- package/src/components/LoadingOverlayPrism.tsx +251 -0
- package/src/composed/AddToCart.tsx +229 -0
- package/src/composed/ArtAlignment.tsx +703 -0
- package/src/composed/ArtSelector.tsx +290 -0
- package/src/composed/ArtworkCustomizer.tsx +212 -0
- package/src/composed/CanvasEditor.tsx +79 -0
- package/src/composed/ColorPicker.tsx +111 -0
- package/src/composed/CurrentSelectionDisplay.tsx +86 -0
- package/src/composed/HeroProductImage.tsx +1071 -0
- package/src/composed/Lightbox.index.ts +2 -0
- package/src/composed/Lightbox.tsx +230 -0
- package/src/composed/PlacementClipShapeSelector.tsx +88 -0
- package/src/composed/PlacementTabs.tsx +179 -0
- package/src/composed/ProductCard.tsx +298 -0
- package/src/composed/ProductGallery.tsx +54 -0
- package/src/composed/ProductImage.tsx +129 -0
- package/src/composed/ProductList.tsx +147 -0
- package/src/composed/ProductOptions.tsx +305 -0
- package/src/composed/RealtimeMockup.tsx +121 -0
- package/src/composed/TileCount.tsx +348 -0
- package/src/composed/carousels/HeroCarousel.tsx +240 -0
- package/src/composed/carousels/MobileProductCarousel.tsx +1002 -0
- package/src/composed/carousels/index.ts +11 -0
- package/src/composed/carousels/types.ts +58 -0
- package/src/composed/grids/MasonryGrid.tsx +238 -0
- package/src/composed/grids/index.ts +9 -0
- package/src/composed/search/CurrentRefinements.tsx +80 -0
- package/src/composed/search/Filters.tsx +49 -0
- package/src/composed/search/FiltersButton.tsx +57 -0
- package/src/composed/search/FiltersDrawer.tsx +375 -0
- package/src/composed/search/ProductGrid.tsx +118 -0
- package/src/composed/search/ProductHit.tsx +56 -0
- package/src/composed/search/SearchBox.tsx +109 -0
- package/src/composed/search/SearchProvider.tsx +136 -0
- package/src/composed/search/facetConfig.ts +16 -0
- package/src/composed/search/index.ts +22 -0
- package/src/composed/search/meilisearchAdapter.ts +20 -0
- package/src/composed/search/types.ts +22 -0
- package/src/composed/zoom/EnhancedImageViewer.tsx +505 -0
- package/src/composed/zoom/ResponsiveZoom.tsx +134 -0
- package/src/composed/zoom/ZoomOverlay.tsx +194 -0
- package/src/composed/zoom/index.ts +12 -0
- package/src/composed/zoom/types.ts +12 -0
- package/src/design-system/ColorPalette.tsx +126 -0
- package/src/design-system/ColorSwatch.tsx +49 -0
- package/src/design-system/DesignSystemPage.tsx +130 -0
- package/src/design-system/ThemeSwitcher.tsx +181 -0
- package/src/design-system/TypographyScale.tsx +106 -0
- package/src/design-system/index.ts +5 -0
- package/src/ecommerce/stories/HeroProductImage.stories.tsx +66 -0
- package/src/ecommerce/stories/PDPHeroGallery.stories.tsx +105 -0
- package/src/ecommerce/stories/PDPInfoPanel.stories.tsx +472 -0
- package/src/ecommerce/stories/PDPLayout.stories.tsx +365 -0
- package/src/hooks/useBrand.ts +41 -0
- package/src/hooks/useCanvasContext.ts +127 -0
- package/src/hooks/useDeviceDetection.ts +64 -0
- package/src/hooks/useFocusTrap.ts +70 -0
- package/src/hooks/useImagePreloader.ts +268 -0
- package/src/hooks/useImageTransition.ts +608 -0
- package/src/hooks/usePlacementsProcessor.ts +74 -0
- package/src/hooks/useProductGallery.ts +193 -0
- package/src/hooks/useProductPage.ts +467 -0
- package/src/hooks/useRenderGuard.ts +96 -0
- package/src/hooks/useScrollDirection.ts +196 -0
- package/src/hooks/viewport/index.ts +25 -0
- package/src/hooks/viewport/useContainerWidth.ts +59 -0
- package/src/hooks/viewport/useMediaQuery.ts +52 -0
- package/src/hooks/viewport/useResponsiveImageCap.ts +149 -0
- package/src/hooks/viewport/useViewportDimensions.ts +135 -0
- package/src/hooks/viewport/useWideMonitorMode.ts +150 -0
- package/src/hooks/visibility/index.ts +15 -0
- package/src/hooks/visibility/observerPool.ts +150 -0
- package/src/index.ts +240 -0
- package/src/layouts/hero-zoom/HeroShrinkLayout.tsx +209 -0
- package/src/layouts/hero-zoom/HeroZoomLayout.tsx +351 -0
- package/src/layouts/hero-zoom/index.ts +30 -0
- package/src/layouts/hero-zoom/stories/HeroZoomLayout.stories.tsx +350 -0
- package/src/layouts/hero-zoom/types.ts +113 -0
- package/src/layouts/hero-zoom/useHeroZoomScales.ts +156 -0
- package/src/layouts/index.ts +9 -0
- package/src/layouts/pdp/EdgeBlurBox.tsx +210 -0
- package/src/layouts/pdp/ImageBlurExtension.tsx +215 -0
- package/src/layouts/pdp/ImageEdgeBlur.tsx +215 -0
- package/src/layouts/pdp/PDPLayout.tsx +246 -0
- package/src/layouts/pdp/SimpleImageBlur.tsx +140 -0
- package/src/layouts/pdp/index.ts +40 -0
- package/src/lib/env.ts +15 -0
- package/src/lib/locale.ts +167 -0
- package/src/lib/router.tsx +46 -0
- package/src/lib/utils.ts +6 -0
- package/src/lightbox/README.md +77 -0
- package/src/next/index.tsx +26 -0
- package/src/patterns/MockupPriorityProvider.tsx +1014 -0
- package/src/patterns/Product.tsx +850 -0
- package/src/patterns/ProductPageProvider.tsx +224 -0
- package/src/patterns/RealtimeProvider.tsx +1162 -0
- package/src/patterns/ShopProvider.tsx +603 -0
- package/src/personalization/PersonalizationBridge.tsx +235 -0
- package/src/personalization/PersonalizationContext.ts +29 -0
- package/src/personalization/PersonalizationInputs.tsx +110 -0
- package/src/personalization/PersonalizationProvider.tsx +407 -0
- package/src/personalization/canvas-stub.d.ts +22 -0
- package/src/personalization/index.ts +43 -0
- package/src/personalization/types.ts +48 -0
- package/src/personalization/usePersonalization.ts +32 -0
- package/src/personalization/usePersonalizationShimmer.ts +159 -0
- package/src/personalization/utils.ts +59 -0
- package/src/primitives/BrandLogo.tsx +65 -0
- package/src/primitives/BrandName.tsx +51 -0
- package/src/primitives/Button.tsx +123 -0
- package/src/primitives/ColorSwatch.tsx +221 -0
- package/src/primitives/DragHintAnimation.tsx +190 -0
- package/src/primitives/EdgeSwipeGuards.tsx +60 -0
- package/src/primitives/FloatingActionGroup.tsx +176 -0
- package/src/primitives/ProductPrice.tsx +171 -0
- package/src/primitives/ProgressiveBlur.tsx +295 -0
- package/src/primitives/ThemeToggle.tsx +125 -0
- package/src/primitives/__tests__/story-coverage.test.ts +98 -0
- package/src/primitives/accordion.tsx +280 -0
- package/src/primitives/badge.tsx +137 -0
- package/src/primitives/card.tsx +61 -0
- package/src/primitives/checkbox.tsx +56 -0
- package/src/primitives/collapsible.tsx +51 -0
- package/src/primitives/drawer.tsx +828 -0
- package/src/primitives/dropdown-menu.tsx +197 -0
- package/src/primitives/fieldset.tsx +73 -0
- package/src/primitives/index.ts +138 -0
- package/src/primitives/input.tsx +91 -0
- package/src/primitives/kbd.tsx +130 -0
- package/src/primitives/label.tsx +20 -0
- package/src/primitives/link.tsx +182 -0
- package/src/primitives/popover.tsx +80 -0
- package/src/primitives/radio-group.tsx +79 -0
- package/src/primitives/scroll-fade.tsx +159 -0
- package/src/primitives/select.tsx +170 -0
- package/src/primitives/separator.tsx +25 -0
- package/src/primitives/slider.tsx +221 -0
- package/src/primitives/spinner.tsx +72 -0
- package/src/primitives/stories/Accordion.stories.tsx +121 -0
- package/src/primitives/stories/Badge.stories.tsx +221 -0
- package/src/primitives/stories/Button.stories.tsx +185 -0
- package/src/primitives/stories/Card.stories.tsx +171 -0
- package/src/primitives/stories/Checkbox.stories.tsx +214 -0
- package/src/primitives/stories/Collapsible.stories.tsx +230 -0
- package/src/primitives/stories/Drawer.stories.tsx +378 -0
- package/src/primitives/stories/DropdownMenu.stories.tsx +182 -0
- package/src/primitives/stories/Fieldset.stories.tsx +212 -0
- package/src/primitives/stories/Input.stories.tsx +172 -0
- package/src/primitives/stories/Kbd.stories.tsx +183 -0
- package/src/primitives/stories/Label.stories.tsx +98 -0
- package/src/primitives/stories/Link.stories.tsx +260 -0
- package/src/primitives/stories/Popover.stories.tsx +178 -0
- package/src/primitives/stories/RadioGroup.stories.tsx +205 -0
- package/src/primitives/stories/Select.stories.tsx +222 -0
- package/src/primitives/stories/Separator.stories.tsx +134 -0
- package/src/primitives/stories/Slider.stories.tsx +203 -0
- package/src/primitives/stories/Spinner.stories.tsx +142 -0
- package/src/primitives/stories/Surface.stories.tsx +257 -0
- package/src/primitives/stories/Switch.stories.tsx +131 -0
- package/src/primitives/stories/Tabs.stories.tsx +275 -0
- package/src/primitives/stories/TextField.stories.tsx +139 -0
- package/src/primitives/stories/Textarea.stories.tsx +148 -0
- package/src/primitives/stories/Tooltip.stories.tsx +119 -0
- package/src/primitives/surface.tsx +86 -0
- package/src/primitives/switch.tsx +35 -0
- package/src/primitives/tabs.tsx +206 -0
- package/src/primitives/text-field.tsx +84 -0
- package/src/primitives/textarea.tsx +50 -0
- package/src/primitives/tooltip.tsx +58 -0
- package/src/services/CanvasExportService.ts +518 -0
- package/src/styles/base.css +380 -0
- package/src/styles/defaults.css +280 -0
- package/src/styles/globals.css +1242 -0
- package/src/styles/index.css +17 -0
- package/src/styles/ne-themes.css +4740 -0
- package/src/styles/tailwind.css +11 -0
- package/src/styles/tokens.css +117 -0
- package/src/styles/utilities.css +188 -0
- package/src/themes/apply-theme.ts +449 -0
- package/src/themes/getThemeStyles.ts +454 -0
- package/src/themes/index.ts +48 -0
- package/src/themes/oklch-theme.ts +283 -0
- package/src/themes/presets.ts +989 -0
- package/src/themes/types.ts +386 -0
- package/src/themes/useTheme.tsx +450 -0
- package/src/utils/dev-warnings.ts +161 -0
- package/src/utils/devWarnings.ts +153 -0
- package/dist/styles.css +0 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { type ReactNode } from "react";
|
|
4
|
+
import { Shop, type ShopProps } from "./ShopProvider";
|
|
5
|
+
import { Product, type ProductProviderProps } from "./Product";
|
|
6
|
+
import { RealtimeProvider, type RealtimeProviderProps } from "./RealtimeProvider";
|
|
7
|
+
import { MockupPriorityProvider } from "./MockupPriorityProvider";
|
|
8
|
+
import type { Artwork } from "./Product";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ProductPageProvider - Quick-start provider for product pages
|
|
12
|
+
*
|
|
13
|
+
* A convenience wrapper that sets up the complete provider stack needed for
|
|
14
|
+
* a fully-featured product page. Use this instead of manually nesting
|
|
15
|
+
* Shop > RealtimeProvider > MockupPriorityProvider > Product.
|
|
16
|
+
*
|
|
17
|
+
* **This provider includes:**
|
|
18
|
+
* - `Shop` - Global artwork state and image throttling
|
|
19
|
+
* - `RealtimeProvider` - Live mockup updates (optional, enabled by default)
|
|
20
|
+
* - `MockupPriorityProvider` - Priority-based mockup rendering
|
|
21
|
+
* - `Product` - Product data and variant selection
|
|
22
|
+
*
|
|
23
|
+
* **Minimal setup:**
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ProductPageProvider productId="shirt-123">
|
|
26
|
+
* <ArtSelector artworks={[...]} />
|
|
27
|
+
* <ProductImage />
|
|
28
|
+
* <ProductOptions />
|
|
29
|
+
* <AddToCart />
|
|
30
|
+
* </ProductPageProvider>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* **With configuration:**
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <ProductPageProvider
|
|
36
|
+
* productId="shirt-123"
|
|
37
|
+
* initialArtwork={{ type: 'regular', src: 'https://...' }}
|
|
38
|
+
* enableRealtime={true}
|
|
39
|
+
* mockupUrl="https://api.example.com"
|
|
40
|
+
* >
|
|
41
|
+
* <MyProductPage />
|
|
42
|
+
* </ProductPageProvider>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* // Complete product detail page
|
|
48
|
+
* function ProductDetailPage({ productId }: { productId: string }) {
|
|
49
|
+
* return (
|
|
50
|
+
* <ProductPageProvider productId={productId}>
|
|
51
|
+
* <div className="grid md:grid-cols-2 gap-8">
|
|
52
|
+
* <ProductImage />
|
|
53
|
+
* <div>
|
|
54
|
+
* <ProductName />
|
|
55
|
+
* <ProductPrice />
|
|
56
|
+
* <ArtSelector artworks={artworkOptions} />
|
|
57
|
+
* <ProductOptions />
|
|
58
|
+
* <AddToCart onClick={handleAddToCart} />
|
|
59
|
+
* </div>
|
|
60
|
+
* </div>
|
|
61
|
+
* </ProductPageProvider>
|
|
62
|
+
* );
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx
|
|
68
|
+
* // Using the useProductPage hook inside
|
|
69
|
+
* function MyCustomComponent() {
|
|
70
|
+
* const {
|
|
71
|
+
* product,
|
|
72
|
+
* selection,
|
|
73
|
+
* selectedArtwork,
|
|
74
|
+
* realtime,
|
|
75
|
+
* providers,
|
|
76
|
+
* } = useProductPage();
|
|
77
|
+
*
|
|
78
|
+
* return <div>{product?.name}</div>;
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* <ProductPageProvider productId="shirt-123">
|
|
82
|
+
* <MyCustomComponent />
|
|
83
|
+
* </ProductPageProvider>
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export interface ProductPageProviderProps {
|
|
87
|
+
children: ReactNode;
|
|
88
|
+
|
|
89
|
+
// ── Product Configuration ──────────────────────────────────────────────────
|
|
90
|
+
/** Product ID to load */
|
|
91
|
+
productId: string;
|
|
92
|
+
/** Pre-loaded product data (skips fetch) */
|
|
93
|
+
productData?: ProductProviderProps["productData"];
|
|
94
|
+
|
|
95
|
+
// ── Shop Configuration ─────────────────────────────────────────────────────
|
|
96
|
+
/** API endpoint for product data */
|
|
97
|
+
endpoint?: string;
|
|
98
|
+
/** Mockup generation URL */
|
|
99
|
+
mockupUrl?: string;
|
|
100
|
+
/** Your public Shop ID (same value as `&shop=` in mockup/buy URLs) */
|
|
101
|
+
shop?: string;
|
|
102
|
+
/** Initial artwork to select (avoids layout shift) */
|
|
103
|
+
initialArtwork?: Artwork;
|
|
104
|
+
|
|
105
|
+
// ── Realtime Configuration ─────────────────────────────────────────────────
|
|
106
|
+
/** Enable realtime mockups (default: true) */
|
|
107
|
+
enableRealtime?: boolean;
|
|
108
|
+
/** WebSocket URL for realtime mockups */
|
|
109
|
+
realtimeWsUrl?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Endpoint that issues a realtime session grant (POST { shopId } →
|
|
112
|
+
* { token, expiresAt }). With this set, realtime authorizes via a renewable
|
|
113
|
+
* token billed to the shop (the `shop` prop, = shop.id); without it the
|
|
114
|
+
* legacy seal runs.
|
|
115
|
+
*/
|
|
116
|
+
realtimeGrantUrl?: string;
|
|
117
|
+
|
|
118
|
+
// ── Priority Configuration ─────────────────────────────────────────────────
|
|
119
|
+
/** Enable priority-based mockup rendering (default: true) */
|
|
120
|
+
enablePriority?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function ProductPageProvider({
|
|
124
|
+
children,
|
|
125
|
+
productId,
|
|
126
|
+
productData,
|
|
127
|
+
endpoint,
|
|
128
|
+
mockupUrl,
|
|
129
|
+
shop,
|
|
130
|
+
initialArtwork,
|
|
131
|
+
enableRealtime = true,
|
|
132
|
+
realtimeWsUrl,
|
|
133
|
+
realtimeGrantUrl,
|
|
134
|
+
enablePriority = true,
|
|
135
|
+
}: ProductPageProviderProps) {
|
|
136
|
+
// Build the provider tree
|
|
137
|
+
let content = (
|
|
138
|
+
<Product productId={productId} productData={productData}>
|
|
139
|
+
{children}
|
|
140
|
+
</Product>
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// Wrap with MockupPriorityProvider if enabled
|
|
144
|
+
if (enablePriority) {
|
|
145
|
+
content = <MockupPriorityProvider>{content}</MockupPriorityProvider>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Wrap with RealtimeProvider if enabled
|
|
149
|
+
if (enableRealtime) {
|
|
150
|
+
content = (
|
|
151
|
+
<RealtimeProvider
|
|
152
|
+
wsUrl={realtimeWsUrl}
|
|
153
|
+
shop={shop}
|
|
154
|
+
grantUrl={realtimeGrantUrl}
|
|
155
|
+
>
|
|
156
|
+
{content}
|
|
157
|
+
</RealtimeProvider>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Always wrap with Shop (required for artwork management)
|
|
162
|
+
return (
|
|
163
|
+
<Shop
|
|
164
|
+
endpoint={endpoint}
|
|
165
|
+
mockupUrl={mockupUrl}
|
|
166
|
+
shop={shop}
|
|
167
|
+
initialArtwork={initialArtwork}
|
|
168
|
+
>
|
|
169
|
+
{content}
|
|
170
|
+
</Shop>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* ProductPageProviderMinimal - Lightweight provider for simple use cases
|
|
176
|
+
*
|
|
177
|
+
* A minimal provider that only includes Shop and Product contexts.
|
|
178
|
+
* Use this when you don't need realtime mockups or priority rendering.
|
|
179
|
+
*
|
|
180
|
+
* **Use cases:**
|
|
181
|
+
* - Product listing pages (no live editing)
|
|
182
|
+
* - Simple product cards
|
|
183
|
+
* - Static mockup display
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```tsx
|
|
187
|
+
* <ProductPageProviderMinimal productId="shirt-123">
|
|
188
|
+
* <ProductImage />
|
|
189
|
+
* <ProductPrice />
|
|
190
|
+
* </ProductPageProviderMinimal>
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export interface ProductPageProviderMinimalProps {
|
|
194
|
+
children: ReactNode;
|
|
195
|
+
productId: string;
|
|
196
|
+
productData?: ProductProviderProps["productData"];
|
|
197
|
+
endpoint?: string;
|
|
198
|
+
mockupUrl?: string;
|
|
199
|
+
shop?: string;
|
|
200
|
+
initialArtwork?: Artwork;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function ProductPageProviderMinimal({
|
|
204
|
+
children,
|
|
205
|
+
productId,
|
|
206
|
+
productData,
|
|
207
|
+
endpoint,
|
|
208
|
+
mockupUrl,
|
|
209
|
+
shop,
|
|
210
|
+
initialArtwork,
|
|
211
|
+
}: ProductPageProviderMinimalProps) {
|
|
212
|
+
return (
|
|
213
|
+
<Shop
|
|
214
|
+
endpoint={endpoint}
|
|
215
|
+
mockupUrl={mockupUrl}
|
|
216
|
+
shop={shop}
|
|
217
|
+
initialArtwork={initialArtwork}
|
|
218
|
+
>
|
|
219
|
+
<Product productId={productId} productData={productData}>
|
|
220
|
+
{children}
|
|
221
|
+
</Product>
|
|
222
|
+
</Shop>
|
|
223
|
+
);
|
|
224
|
+
}
|