nexus/ui/src/components/SkillCard.tsx
Nexus Dev 3a41ec7b9c feat(nexus): design system phase 3 raw utility sweep
Third phase of the DESIGN.md migration. Removes every raw Tailwind
color palette utility (bg-red-*, text-amber-*, border-blue-*, etc.)
from component source and replaces them with the semantic tokens
introduced in phases 1 and 2.

Scope:
  - 84 files touched under ui/src/
  - ~420 raw palette utility instances replaced
  - 23 hardcoded hex fallbacks replaced with var(--token) refs
  - Zero raw palette utilities remain in component source
    (verified with rg '(bg|text|border|ring)-(red|blue|green|amber|
    yellow|cyan|violet|purple|pink|slate|zinc|neutral|sky|teal|
    emerald|indigo|rose|orange|fuchsia)-[0-9]+' ui/src)

Mapping rules applied:
  - red-* -> destructive
  - amber-/yellow-/orange-* -> warning
  - green-/emerald-* -> success
  - blue-/cyan-/sky-* -> primary (info/in-progress) or muted-foreground
  - slate-/gray-/zinc-/neutral-* -> muted / muted-foreground / border
  - violet-/purple-/pink-/indigo-/rose-/teal-* -> collapsed to
    primary or muted (most were one-off decorative choices, not
    role-bearing). Role-bearing uses go through lib/agent-role-colors
    which was rewritten in phase 2.
  - Opacity modifiers preserved (/10, /15, /20, etc.)
  - dark: variant duplicates removed (theme tokens auto-switch)

Hardcoded hex fallbacks fixed:
  - #6366f1 (indigo) -> var(--primary) / var(--volt)
  - #64748b (slate) -> var(--muted-foreground) / var(--silver)
  - #4f46e5 (indigo) -> var(--primary)
  - #89b4fa (old Catppuccin blue) -> var(--primary) / #faff69
  - OrgChart status dots (#22d3ee/#4ade80/#facc15/#f87171/#a3a3a3)
    -> var(--primary) / var(--success) / var(--warning) /
    var(--destructive) / var(--muted-foreground) per status
  - VoiceWaveform fallback #89b4fa -> #faff69 (volt)

Legitimate hex values left untouched (12 total):
  - lib/color-contrast.ts WCAG reference constants
  - lib/worktree-branding.ts contrast fallback references
  - lib/mention-chips.ts runtime-generated SVG fills
  - context/ThemeContext.tsx theme metadata brand hexes
  - components/ThemeSeedInput.tsx user-facing hex picker

Ambiguous decisions (flagged for visual QA):
  - AgentDetail.tsx invocation-source badges (timer/assignment/
    on_demand) collapsed to primary/muted — visual distinction
    is reduced, labels still differ. Consider chart-role slots
    if differentiation matters.
  - AgentDetail.tsx mixed-opacity amber banners: bg-warning/60
    against new warning base reads heavier than original amber-50
    base.
  - Live-state dots in KanbanBoard/AgentDetail: bg-blue-* ->
    bg-primary — will glow volt in dark mode, probably desirable.

Verification:
  - npx tsc --noEmit in ui/ — zero errors introduced. Pre-existing
    errors in AgentConfigForm, command.tsx, useKeyboardShortcuts,
    usePiperTts, useVadRecorder, PersonalAssistant remain, all
    unrelated to color work.
  - Dev server on :6100 returns 200.

Not changed in this commit:
  - ui/src/lib/company-routes.ts — separate routing fix for broken
    Assistant/ContentStudio/Convert links, committed next.
  - Test files — a few will need assertion updates but are out of
    phase 3 scope.

Phase 4 follow-ups (rounded-xl/2xl collapse, soft shadow removal,
gradient removal) noted in .planning/AUDIT-RADIUS-SHADOWS.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 17:40:32 +00:00

151 lines
4.9 KiB
TypeScript

import { Check, Download, RotateCcw, Star } from "lucide-react";
import { Link } from "@/lib/router";
import { cn } from "@/lib/utils";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { SkillListItem } from "@/api/skillRegistry";
// TODO: hasUpdate detection requires backend enhancement — SkillListItem needs
// a hasUpdate field or the UI needs to compare activeVersionId against latest version.
// For now, hasUpdate is always passed as false from parent components.
export interface SkillCardProps {
skill: SkillListItem;
isInstalled?: boolean;
hasUpdate?: boolean;
onInstall?: () => void;
onUpdate?: () => void;
onRollback?: () => void;
onUninstall?: () => void;
isLoading?: boolean;
isReadOnly?: boolean;
source?: "managed" | "native";
className?: string;
compatibleAdapters?: string[];
}
export function SkillCard({
skill,
isInstalled = false,
hasUpdate = false,
onInstall,
onUpdate,
onRollback,
onUninstall,
isLoading = false,
isReadOnly = false,
source,
className,
compatibleAdapters,
}: SkillCardProps) {
return (
<Card className={cn("flex flex-col", className)}>
<CardContent className="p-4 flex flex-col gap-2">
{/* Row 1: name link (primary visual anchor) + update badge + native badge */}
<div className="flex items-start justify-between gap-2">
<Link
to={`/skills/detail/${encodeURIComponent(skill.id)}`}
className="text-sm font-medium hover:underline"
>
{skill.name}
</Link>
<div className="flex shrink-0 gap-1">
{(isReadOnly || source === "native") && (
<Badge
variant="secondary"
className="text-xs text-muted-foreground"
aria-label="Native skill"
>
Native
</Badge>
)}
{hasUpdate && !isReadOnly && (
<Badge
variant="outline"
className="text-xs text-warning border-warning/30"
aria-label="Update available"
>
Update
</Badge>
)}
</div>
</div>
{/* Row 2: description (2-line clamp) */}
{skill.description && (
<p className="text-xs text-muted-foreground line-clamp-2">{skill.description}</p>
)}
{/* Row 2b: compatible adapters (Browse/Trending only) */}
{compatibleAdapters && compatibleAdapters.length > 0 && (
<p className="text-[10px] text-muted-foreground mt-1">
Works with: {compatibleAdapters.join(", ")}
</p>
)}
{/* Row 3: source badge + rating + actions (push right) */}
<div className="flex items-center gap-2 mt-auto pt-2">
<Badge variant="secondary" className="text-xs">{skill.sourceId}</Badge>
{skill.averageRating != null && (
<span className="flex items-center gap-1 text-xs text-muted-foreground">
<Star className="h-3 w-3 fill-amber-400 text-warning" />
{skill.averageRating.toFixed(1)}
</span>
)}
<div className="ml-auto flex gap-1">
{!isReadOnly && isInstalled && onRollback && (
<Tooltip>
<TooltipTrigger asChild>
<Button
size="icon-sm"
variant="ghost"
onClick={onRollback}
disabled={isLoading}
>
<RotateCcw className="h-3.5 w-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>Rollback</TooltipContent>
</Tooltip>
)}
{!isReadOnly && !isInstalled && (
<Button
size="sm"
variant="outline"
onClick={onInstall}
disabled={isLoading}
>
<Download className="h-3.5 w-3.5 mr-1" />
{isLoading ? "Installing\u2026" : "Install skill"}
</Button>
)}
{!isReadOnly && isInstalled && hasUpdate && (
<Button
size="sm"
variant="outline"
onClick={onUpdate}
disabled={isLoading}
>
{isLoading ? "Updating\u2026" : "Update skill"}
</Button>
)}
{isInstalled && !hasUpdate && (
<Button
size="icon-sm"
variant="ghost"
disabled
title="Installed"
>
<Check className="h-3.5 w-3.5 text-muted-foreground" />
</Button>
)}
</div>
</div>
</CardContent>
</Card>
);
}