mirror of
https://github.com/nextlevelbuilder/ui-ux-pro-max-skill.git
synced 2026-11-28 22:30:32 +00:00
This commit is contained in:
parent
e8b065f0f3
commit
f2f7266b07
@ -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}
|
||||
/>
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
<StyleStatusBadge status={style.status} />
|
||||
<span className="text-[10px] px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400">
|
||||
{style.type}
|
||||
</span>
|
||||
|
||||
@ -70,8 +70,8 @@ export function StylePreview({ style }: StylePreviewProps) {
|
||||
</div>
|
||||
|
||||
{/* Style name overlay */}
|
||||
<div className="absolute bottom-0 left-0 right-0 px-3 py-1.5 bg-gradient-to-t from-black/40 to-transparent">
|
||||
<span className="text-[10px] font-medium text-white/80">
|
||||
<div className="absolute bottom-0 left-0 right-0 px-3 py-1.5 bg-gradient-to-t from-black/60 to-transparent">
|
||||
<span className="text-[10px] font-semibold text-white/95">
|
||||
Preview
|
||||
</span>
|
||||
</div>
|
||||
|
||||
22
gallery/components/StyleStatusBadge.tsx
Normal file
22
gallery/components/StyleStatusBadge.tsx
Normal file
@ -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 (
|
||||
<span
|
||||
className={`text-[10px] px-2 py-0.5 rounded-full font-medium ${colorClass}`}
|
||||
>
|
||||
{status}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@ -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(<StyleStatusBadge status="active" />);
|
||||
assert.match(activeMarkup, /bg-green-100/);
|
||||
assert.match(activeMarkup, />active<\/span>/);
|
||||
|
||||
const supplementalMarkup = renderToStaticMarkup(<StyleStatusBadge status="supplemental" />);
|
||||
assert.match(supplementalMarkup, /bg-blue-100/);
|
||||
assert.match(supplementalMarkup, />supplemental<\/span>/);
|
||||
|
||||
const deprecatedMarkup = renderToStaticMarkup(<StyleStatusBadge status="deprecated" />);
|
||||
assert.match(deprecatedMarkup, /bg-red-100/);
|
||||
assert.match(deprecatedMarkup, />deprecated<\/span>/);
|
||||
|
||||
const emptyMarkup = renderToStaticMarkup(<StyleStatusBadge status="" />);
|
||||
assert.equal(emptyMarkup, "");
|
||||
});
|
||||
|
||||
@ -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"
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user