mirror of
https://github.com/nextlevelbuilder/ui-ux-pro-max-skill.git
synced 2026-11-19 09:00:32 +00:00
The style card was a <div onClick> with no focusable control, so keyboard and screen reader users could not open the detail modal (#573, item D1). The card title is now a real <button aria-haspopup="dialog">; making the whole card a button would nest its section toggles, copy buttons, color swatches and checklist inside it. The focus mark is an outline, which forced-colors mode keeps. The detail modal now behaves as a dialog for those users: it has role="dialog", aria-modal and its title as label, moves focus to Close on open, keeps Tab and Shift+Tab inside, and returns focus to the element that opened it when it closes. The card's click handler also fired for every control inside it, so expanding "CSS Code", copying a color or ticking a checklist item opened the detail modal too, by mouse or keyboard. Clicks that start on a control inside the card, or that end a text selection inside it, now leave the modal closed; any other click on the card still opens it. The code copy button was reachable with Tab but stayed at opacity 0 unless hovered; it now shows while focused.
134 lines
4.5 KiB
TypeScript
134 lines
4.5 KiB
TypeScript
"use client";
|
|
|
|
import { StyleData } from "@/lib/types";
|
|
import { hasTextSelectionIn, isNestedControlClick } from "@/lib/nestedControl";
|
|
import { StyleCardTitle } from "./StyleCardTitle";
|
|
import { StylePreview } from "./StylePreview";
|
|
import { ColorPalette } from "./ColorPalette";
|
|
import { MetadataBadges } from "./MetadataBadges";
|
|
import { ExpandableSection } from "./ExpandableSection";
|
|
import { CodeSnippet } from "./CodeSnippet";
|
|
import { InteractiveChecklist } from "./InteractiveChecklist";
|
|
|
|
interface StyleCardProps {
|
|
style: StyleData;
|
|
onSelect?: (style: StyleData) => void;
|
|
}
|
|
|
|
export function StyleCard({ style, onSelect }: StyleCardProps) {
|
|
return (
|
|
<div
|
|
className="bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-800 overflow-hidden hover:shadow-lg dark:hover:shadow-gray-900/50 transition-shadow cursor-pointer"
|
|
onClick={(e) => {
|
|
if (isNestedControlClick(e.target, e.currentTarget)) return;
|
|
if (hasTextSelectionIn(window.getSelection(), e.currentTarget)) return;
|
|
onSelect?.(style);
|
|
}}
|
|
>
|
|
{/* Header */}
|
|
<div className="px-4 pt-4 pb-2">
|
|
<div className="flex items-start justify-between gap-2">
|
|
<StyleCardTitle
|
|
name={style.styleCategory}
|
|
onOpen={onSelect ? () => onSelect(style) : undefined}
|
|
/>
|
|
<div className="flex items-center gap-1.5 shrink-0">
|
|
<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>
|
|
<span className="text-[10px] text-gray-400">{style.eraOrigin}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Preview */}
|
|
<div className="px-4">
|
|
<StylePreview style={style} />
|
|
</div>
|
|
|
|
{/* Color Palette */}
|
|
<div className="px-4 py-3">
|
|
<ColorPalette colors={style.extractedColors} />
|
|
</div>
|
|
|
|
{/* Metadata Badges */}
|
|
<div className="px-4 pb-3">
|
|
<MetadataBadges style={style} />
|
|
</div>
|
|
|
|
{/* Expandable Sections */}
|
|
<div className="px-4 pb-2">
|
|
<ExpandableSection title="CSS Code">
|
|
<CodeSnippet code={style.cssTechnicalKeywords} label="CSS/Technical" />
|
|
{style.designSystemVariables && (
|
|
<div className="mt-2">
|
|
<CodeSnippet
|
|
code={style.designSystemVariables}
|
|
label="Design Variables"
|
|
/>
|
|
</div>
|
|
)}
|
|
</ExpandableSection>
|
|
|
|
<ExpandableSection title="AI Prompt">
|
|
<CodeSnippet code={style.aiPromptKeywords} />
|
|
</ExpandableSection>
|
|
|
|
<ExpandableSection title="Implementation Checklist">
|
|
<InteractiveChecklist checklist={style.implementationChecklist} />
|
|
</ExpandableSection>
|
|
|
|
<ExpandableSection title="Details">
|
|
<div className="space-y-2 text-xs">
|
|
{style.bestFor && (
|
|
<div>
|
|
<span className="font-medium text-gray-500 dark:text-gray-400">
|
|
Best for:{" "}
|
|
</span>
|
|
<span className="text-gray-700 dark:text-gray-300">
|
|
{style.bestFor}
|
|
</span>
|
|
</div>
|
|
)}
|
|
{style.doNotUseFor && (
|
|
<div>
|
|
<span className="font-medium text-gray-500 dark:text-gray-400">
|
|
Avoid for:{" "}
|
|
</span>
|
|
<span className="text-gray-700 dark:text-gray-300">
|
|
{style.doNotUseFor}
|
|
</span>
|
|
</div>
|
|
)}
|
|
{style.frameworkCompatibility && (
|
|
<div>
|
|
<span className="font-medium text-gray-500 dark:text-gray-400">
|
|
Frameworks:{" "}
|
|
</span>
|
|
<span className="text-gray-700 dark:text-gray-300">
|
|
{style.frameworkCompatibility}
|
|
</span>
|
|
</div>
|
|
)}
|
|
{style.keywords && (
|
|
<div className="flex flex-wrap gap-1 mt-1">
|
|
{style.keywords
|
|
.split(",")
|
|
.slice(0, 6)
|
|
.map((kw, i) => (
|
|
<span
|
|
key={i}
|
|
className="px-1.5 py-0.5 text-[10px] bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded"
|
|
>
|
|
{kw.trim()}
|
|
</span>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</ExpandableSection>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|