mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
Final batch of the design-token extraction: mints tokens for every remaining value-bearing arbitrary Tailwind bracket in ui/src/components/** and ui/src/pages/**, then adds a gate script so the "zero hardcoded value" rule is enforced going forward instead of re-audited by hand each time. Codemod: scripts/codemod-extract-misc.mjs (198 sites, 84 files, 96 new tokens: 58 --gtc-*/3 --gtr-* grid track lists, 19 --tp-* transition-property lists, 6 --z-* z-index values, --s-*/--e-*/--va-*/ --sw-* scale/ease/vertical-align/stroke-width, 2 --blur-*, 1 --drop-shadow-extract-*, 4 *-resolved wrapper tokens resolving FileViewerSheet.tsx's half-migrated var(x, fallback) sites Batch 1 deferred, and 2 --gradient-extract-* continuing Batch 1's counter for 2 hsl(var())/color-mix() gradient sites its color-literal audit didn't catch). Mandatory Step 0 syntax spike confirmed every paren form byte-equivalent via scratch stories + built-CSS grep, and confirmed the tw-animate-css plugin utilities (zoom-in-[0.97] etc.) are currently dead/no-op classes (plugin not installed) — allowlisted, not rewritten, since there's no visual behavior to preserve or change. Gate script: scripts/check-token-gates.mjs (new, wired as `pnpm check:token-gates`) implements the three DONE-WHEN gates (hex/color-literal, arbitrary-bracket-value, raw-font-size) over ui/src/components/** and ui/src/pages/**, parsing a new machine-readable ALLOWLIST block appended to ui/src/index.css that consolidates Batches 1-3's free-form allowlist prose into `* allow <path> — <reason>` lines. Resolved TOKEN-AUDIT.md's open "test file policy" question by allowlisting 43 test-fixture hex-literal sites across 18 *.test.tsx files (mock prop/API-response data, not rendered CSS). Gate exits 0 clean. AGENTS.md's existing Design system section now names the gate command. TOKEN-AUDIT.md gets a Batch 4 log appendix with counts, allowlist rationale, and the remaining out-of-scope debt (36 hex sites in ui/src/lib|context|plugins; the ~3,115-site Tailwind-palette-class scope question is still unresolved and flagged for a human decision). Verify: node scripts/check-token-gates.mjs exit 0 (all 3 gates clean); pnpm build-storybook exit 0; Storybook visual suite 510/510 (Playwright, tests/storybook-visual); pnpm typecheck (ui/) exit 0; codemod idempotent on re-run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
95 lines
3.3 KiB
TypeScript
95 lines
3.3 KiB
TypeScript
import type {
|
|
ExternalObjectLivenessState,
|
|
ExternalObjectStatusCategory,
|
|
} from "@paperclipai/shared";
|
|
import { Clock } from "lucide-react";
|
|
import {
|
|
externalObjectStatusIcon,
|
|
externalObjectStatusIconDefault,
|
|
} from "../lib/status-colors";
|
|
import {
|
|
externalObjectCategoryLabel,
|
|
externalObjectIconForCategory,
|
|
externalObjectIconForKey,
|
|
externalObjectLivenessLabel,
|
|
} from "../lib/external-objects";
|
|
import { usePrefersReducedMotion } from "../hooks/usePrefersReducedMotion";
|
|
import { cn } from "../lib/utils";
|
|
|
|
interface ExternalObjectStatusIconProps {
|
|
category: ExternalObjectStatusCategory;
|
|
liveness: ExternalObjectLivenessState;
|
|
statusIconKey?: string | null;
|
|
/** Optional override label used in `aria-label` (e.g. provider-specific copy). */
|
|
label?: string | null;
|
|
className?: string;
|
|
/** Tailwind size class — defaults to `h-3.5 w-3.5` (compact pill use). */
|
|
sizeClassName?: string;
|
|
/**
|
|
* When true the icon renders inline at 12 px with the `mr-1`/`align`
|
|
* adjustments used by `MarkdownIssueLink`. Used by the markdown decorator.
|
|
*/
|
|
inline?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Pure presentational icon for an external object's status. Combines:
|
|
*
|
|
* - A category icon (lucide) from `externalObjectIconForCategory`.
|
|
* - Tone classes (text + border) from `externalObjectStatusIcon`.
|
|
* - An overlaid clock micro-mark when liveness is `stale`.
|
|
* - Reduced-motion-aware spinner for the `running` category.
|
|
*
|
|
* Never mounts plugin React; the host is the sole renderer of identity glyphs.
|
|
*/
|
|
export function ExternalObjectStatusIcon({
|
|
category,
|
|
liveness,
|
|
statusIconKey,
|
|
label,
|
|
className,
|
|
sizeClassName = "h-3.5 w-3.5",
|
|
inline = false,
|
|
}: ExternalObjectStatusIconProps) {
|
|
const reducedMotion = usePrefersReducedMotion();
|
|
const Icon = externalObjectIconForKey(statusIconKey) ?? externalObjectIconForCategory(category);
|
|
const tone = statusIconKey === "git-merge"
|
|
? "text-violet-600 border-violet-600 dark:text-violet-400 dark:border-violet-400"
|
|
: externalObjectStatusIcon[category] ?? externalObjectStatusIconDefault;
|
|
const livenessSuffix = liveness === "fresh" || liveness === "unknown"
|
|
? ""
|
|
: ` (${externalObjectLivenessLabel(liveness)})`;
|
|
const ariaLabel = `${label ?? externalObjectCategoryLabel(category)}${livenessSuffix}`;
|
|
|
|
// The clock overlay needs a positioned wrapper. Inline mode keeps the icon
|
|
// tight to the surrounding text; pill mode expects to size by sizeClassName.
|
|
const wrapperBase = inline
|
|
? "relative mr-1 inline-flex shrink-0 align-(--va-0_125em)"
|
|
: "relative inline-flex shrink-0";
|
|
const iconSize = inline ? "h-3 w-3" : sizeClassName;
|
|
const isSpinner = category === "running";
|
|
const animateClass = isSpinner && !reducedMotion ? "animate-spin" : "";
|
|
|
|
return (
|
|
<span
|
|
role="img"
|
|
aria-label={ariaLabel}
|
|
className={cn(wrapperBase, className)}
|
|
>
|
|
<Icon
|
|
aria-hidden="true"
|
|
className={cn(iconSize, tone.split(" ").filter((c) => c.startsWith("text-")).join(" "), animateClass)}
|
|
/>
|
|
{liveness === "stale" ? (
|
|
<Clock
|
|
aria-hidden="true"
|
|
className={cn(
|
|
"absolute -bottom-0.5 -right-0.5 h-2 w-2 rounded-full bg-background text-muted-foreground",
|
|
inline ? "" : "p-px",
|
|
)}
|
|
/>
|
|
) : null}
|
|
</span>
|
|
);
|
|
}
|