Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Match the media tiles and show a full-size preview when editing
Damian Legawiec3decc4c5a582
diff --git a/packages/dashboard-ui/src/styles.css b/packages/dashboard-ui/src/styles.cssindex feabe61ba7..037b3ac3f3 100644--- a/packages/dashboard-ui/src/styles.css+++ b/packages/dashboard-ui/src/styles.css@@ -43,7 +43,7 @@--brand-blue: oklch(0.5967 0.2212 258); /* #0077ff — site accent */--brand-blue-strong: oklch(0.5106 0.1868 257.7); /* #0060ce — site link hover */- --background: oklch(0.97 0 0); /* neutral-100 */+ --background: oklch(98.5% 0 none); /* neutral-100 */--foreground: oklch(0.145 0 0); /* neutral-950 */--card: oklch(1 0 0); /* white cards, one step above the page */--card-foreground: oklch(0.145 0 0);@@ -89,7 +89,7 @@--radius: 0.75rem;/* Sidebar — one step off the page, so it reads as its own surface. */- --sidebar: oklch(0.97 0 0); /* neutral-100 */+ --sidebar: oklch(98.5% 0 none); /* neutral-100 */--sidebar-foreground: oklch(0.145 0 0);--sidebar-primary: oklch(0.145 0 0);--sidebar-primary-foreground: oklch(1 0 0);diff --git a/packages/dashboard/src/components/spree/products/media-edit-sheet.tsx b/packages/dashboard/src/components/spree/products/media-edit-sheet.tsxindex 7fc144dfae..3d6b0a72a0 100644--- a/packages/dashboard/src/components/spree/products/media-edit-sheet.tsx+++ b/packages/dashboard/src/components/spree/products/media-edit-sheet.tsx@@ -93,7 +93,9 @@ export function MediaEditSheet({ form, mediaIndex, variants, open, onOpenChange// For an image this is the picture itself; for a hosted video it is the file// the merchant just picked (a blob URL) or the URL the API serves it at.- const previewUrl = entry.previewUrl ?? null+ // The sheet is far wider than a grid cell, so it wants the large rendition.+ // A pre-save row has no server URL yet, but its blob URL is the original.+ const previewUrl = entry.fullPreviewUrl ?? entry.previewUrl ?? nullconst alt = entry.alt ?? ''const selectedVariantIds = new Set(entry.variant_ids ?? [])diff --git a/packages/dashboard/src/components/spree/products/product-form-cards.tsx b/packages/dashboard/src/components/spree/products/product-form-cards.tsxindex 8be723cd19..9ea2d89631 100644--- a/packages/dashboard/src/components/spree/products/product-form-cards.tsx+++ b/packages/dashboard/src/components/spree/products/product-form-cards.tsx@@ -609,7 +609,7 @@ function SortableMediaThumbnail({onEdit()}}}- className={`group relative aspect-square cursor-pointer overflow-hidden rounded-md border border-border bg-muted focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 ${+ className={`group relative aspect-square cursor-pointer bg-muted overflow-hidden rounded-md border border-border transition-colors hover:border-muted-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 ${isDragging ? 'opacity-40 ring-2 ring-primary/40' : ''}`}/>diff --git a/packages/dashboard/src/hooks/use-media-library.ts b/packages/dashboard/src/hooks/use-media-library.tsindex 326a9cf62b..a5b7497ee8 100644--- a/packages/dashboard/src/hooks/use-media-library.ts+++ b/packages/dashboard/src/hooks/use-media-library.ts@@ -99,7 +99,11 @@ export function mediaThumbnailUrl(media: Media): string | null {/*** A larger rendition for surfaces that show one file at a time — the detail- * panel, the edit sheet. The grid's 256px thumbnail pixelates at that width.+ * panel, the picker. The grid's 256px thumbnail pixelates at that width.+ *+ * Falls back to the uncropped original, which is fine here: nothing in the+ * library picks a focal point against this image. The product edit sheet does,+ * so it stays on the square renditions.*/export function mediaPreviewUrl(media: Media): string | null {return media.large_url ?? media.poster_url ?? media.original_url ?? mediaThumbnailUrl(media)diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsxindex 9b20a221a6..0a8be799a4 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx@@ -126,6 +126,10 @@ function mediaToFormValues(media: Media, index: number) {// Video rows have no image of their own, so the poster is the preview.previewUrl:media.small_url ?? media.mini_url ?? media.poster_url ?? media.original_url ?? undefined,+ // Only the square renditions: the focal point is picked against the+ // rendered box, and original_url is uncropped, so mixing them in would+ // move the point the merchant set.+ fullPreviewUrl: media.large_url ?? media.xlarge_url ?? media.poster_url ?? null,posterUrl: media.poster_url,// The file itself, so an uploaded video can actually play. Every sized URL// on a video row resolves to its poster, so none of them work here.@@ -360,7 +364,10 @@ function ProductForm({ product }: { product: Product }) {// before removing an entry from form state.if (media && media.length > 0) {payload.media = media.map(- ({ previewUrl, posterUrl, videoUrl, downloadUrl, uploadId, ...rest }, i) => ({+ (+ { previewUrl, fullPreviewUrl, posterUrl, videoUrl, downloadUrl, uploadId, ...rest },+ i,+ ) => ({...rest,position: i + 1,}),@@ -390,6 +397,7 @@ function ProductForm({ product }: { product: Product }) {source_media_id: _smid,poster_signed_id: _psid,previewUrl: _p,+ fullPreviewUrl: _fp,posterUrl: _pu,videoUrl: _vu,downloadUrl: _du,diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsxindex 7d4b011c3f..3aa60024df 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx@@ -315,7 +315,7 @@ function MediaLibraryPage() {<buttontype="button"onClick={() => setSelected(media)}- className="block w-full overflow-hidden rounded-md border border-border text-left transition-colors hover:border-muted-foreground"+ className="block w-full cursor-pointer text-left overflow-hidden rounded-md border border-border transition-colors hover:border-muted-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2"/>}>diff --git a/packages/dashboard/src/schemas/product.ts b/packages/dashboard/src/schemas/product.tsindex 52c7fae2b0..b07c16c11a 100644--- a/packages/dashboard/src/schemas/product.ts+++ b/packages/dashboard/src/schemas/product.ts@@ -102,6 +102,10 @@ export const mediaFormSchema = zfocal_point_y: z.number().min(0).max(1).nullable().optional(),// UI-only — strip at submit.previewUrl: z.string().optional(),+ // Larger rendition for the edit sheet; previewUrl is grid-sized and+ // visibly pixelates when blown up. Absent before save, where the blob URL+ // in previewUrl is full resolution anyway.+ fullPreviewUrl: z.string().nullable().optional(),// Server URL for downloading the original; absent until the row is saved.downloadUrl: z.string().nullable().optional(),uploadId: z.string().optional(),