diff --git a/gallery/components/StyleCard.tsx b/gallery/components/StyleCard.tsx index ae62dfc..0122782 100644 --- a/gallery/components/StyleCard.tsx +++ b/gallery/components/StyleCard.tsx @@ -3,6 +3,7 @@ import { StyleData } from "@/lib/types"; import { hasTextSelectionIn, isNestedControlClick } from "@/lib/nestedControl"; import { StyleCardTitle } from "./StyleCardTitle"; +import { StyleStatusBadge } from "./StyleStatusBadge"; import { StylePreview } from "./StylePreview"; import { ColorPalette } from "./ColorPalette"; import { MetadataBadges } from "./MetadataBadges"; @@ -33,6 +34,7 @@ export function StyleCard({ style, onSelect }: StyleCardProps) { onOpen={onSelect ? () => onSelect(style) : undefined} />
+ {style.type} diff --git a/gallery/components/StylePreview.tsx b/gallery/components/StylePreview.tsx index 32f88db..04e2598 100644 --- a/gallery/components/StylePreview.tsx +++ b/gallery/components/StylePreview.tsx @@ -70,8 +70,8 @@ export function StylePreview({ style }: StylePreviewProps) {
{/* Style name overlay */} -
- +
+ Preview
diff --git a/gallery/components/StyleStatusBadge.tsx b/gallery/components/StyleStatusBadge.tsx new file mode 100644 index 0000000..c917540 --- /dev/null +++ b/gallery/components/StyleStatusBadge.tsx @@ -0,0 +1,22 @@ +interface StyleStatusBadgeProps { + status: string; +} + +export function StyleStatusBadge({ status }: StyleStatusBadgeProps) { + if (!status) return null; + + const colorClass = + status === "deprecated" + ? "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400" + : status === "supplemental" + ? "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400" + : "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"; + + return ( + + {status} + + ); +} diff --git a/gallery/components/style-card.test.tsx b/gallery/components/style-card.test.tsx index a79a167..d9abc9a 100644 --- a/gallery/components/style-card.test.tsx +++ b/gallery/components/style-card.test.tsx @@ -4,6 +4,7 @@ import { renderToStaticMarkup } from "react-dom/server"; import { hasTextSelectionIn, isNestedControlClick } from "../lib/nestedControl"; import { StyleCardTitle } from "./StyleCardTitle"; +import { StyleStatusBadge } from "./StyleStatusBadge"; // Stands in for a DOM element: closest() returns a marker node when the // element itself, or one of the ancestors listed in `path`, matches one of the @@ -70,3 +71,20 @@ test("a click that ends a text selection does not open the detail dialog", () => assert.equal(hasTextSelectionIn({ isCollapsed: false, anchorNode: elsewhere }, card), false); assert.equal(hasTextSelectionIn(null, card), false); }); + +test("style status badge renders corresponding semantic colors for status types", () => { + const activeMarkup = renderToStaticMarkup(); + assert.match(activeMarkup, /bg-green-100/); + assert.match(activeMarkup, />active<\/span>/); + + const supplementalMarkup = renderToStaticMarkup(); + assert.match(supplementalMarkup, /bg-blue-100/); + assert.match(supplementalMarkup, />supplemental<\/span>/); + + const deprecatedMarkup = renderToStaticMarkup(); + assert.match(deprecatedMarkup, /bg-red-100/); + assert.match(deprecatedMarkup, />deprecated<\/span>/); + + const emptyMarkup = renderToStaticMarkup(); + assert.equal(emptyMarkup, ""); +}); diff --git a/gallery/tsconfig.test.json b/gallery/tsconfig.test.json index af88742..f434817 100644 --- a/gallery/tsconfig.test.json +++ b/gallery/tsconfig.test.json @@ -24,6 +24,7 @@ "components/MetadataBadges.tsx", "components/FilterBar.tsx", "components/StyleCardTitle.tsx", + "components/StyleStatusBadge.tsx", "components/metadata-badges.test.tsx", "components/style-card.test.tsx" ]