Size Guide Modal
A size guide dialog driven by a table per product category.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/store-size-guide-modal.jsonUsage
store-size-guide-modal-example.tsx
"use client";
import { useState } from "react";
import { SizeGuideModal, type SizeGuideTable } from "@dbs/ui";
import { StoreScope, triggerClass } from "./_store";
type Kind = "shirts" | "shoes";
const TABLES: Record<Kind, SizeGuideTable> = {
shirts: {
title: "Shirt sizes",
head: ["Size", "Chest (cm)", "Length (cm)"],
rows: [
["S", "92 to 96", "70"],
["M", "97 to 102", "72"],
["L", "103 to 108", "74"],
["XL", "109 to 114", "76"],
],
note: "Measure a shirt that fits you well and compare. Between sizes, size up.",
},
shoes: {
title: "Shoe sizes",
head: ["EU", "UK", "Foot length (cm)"],
rows: [
["40", "6.5", "25.0"],
["41", "7.5", "25.7"],
["42", "8", "26.3"],
["43", "9", "27.0"],
],
note: "Stand on a sheet of paper and mark your longest toe and heel.",
},
};
export default function StoreSizeGuideModalExample() {
const [kind, setKind] = useState<Kind | null>(null);
return (
<StoreScope minHeight={600}>
<div className="flex gap-3">
<button type="button" className={triggerClass} onClick={() => setKind("shirts")}>
Shirt guide
</button>
<button type="button" className={triggerClass} onClick={() => setKind("shoes")}>
Shoe guide
</button>
</div>
<SizeGuideModal kind={kind} onClose={() => setKind(null)} tables={TABLES} />
</StoreScope>
);
}