TypeScript
refactor(web): add a label variant to Badge (#13029)
Julius Marminge8d02447c36df
diff --git a/apps/web/src/components/chat/TraitsPicker.tsx b/apps/web/src/components/chat/TraitsPicker.tsxindex 13606e75c87..07ca60cedcc 100644--- a/apps/web/src/components/chat/TraitsPicker.tsx+++ b/apps/web/src/components/chat/TraitsPicker.tsx@@ -95,10 +95,7 @@ const ULTRATHINK_PROMPT_PREFIX = "Ultrathink:\n";function DefaultBadge() {return (- <Badge- variant="outline"- className="inline-flex h-4 w-fit min-w-0 items-center justify-center gap-0 border-border/70 bg-muted/60 px-1.5 py-0 font-semibold text-[10px] text-muted-foreground leading-none sm:h-4"- >+ <Badge variant="outline" size="sm" className="min-w-0">Default</Badge>);diff --git a/apps/web/src/components/pullRequest/pullRequestPresentation.tsx b/apps/web/src/components/pullRequest/pullRequestPresentation.tsxindex d46cad36622..6c3506a9321 100644--- a/apps/web/src/components/pullRequest/pullRequestPresentation.tsx+++ b/apps/web/src/components/pullRequest/pullRequestPresentation.tsx@@ -57,14 +57,8 @@ export function PullRequestLabelChip({return (<Badgesize={size}- variant="secondary"- className={cn(- "min-w-0 max-w-40 shrink justify-start gap-1 rounded-full px-2",- size === "sm" && "h-4 text-[.625rem]",- color &&- "bg-[color-mix(in_srgb,var(--label)_8%,transparent)] text-[color-mix(in_srgb,var(--label)_30%,var(--color-foreground))] dark:bg-[color-mix(in_srgb,var(--label)_12%,transparent)] dark:text-[color-mix(in_srgb,var(--label)_45%,var(--color-foreground))]",- className,- )}+ variant={color ? "label" : "secondary"}+ className={cn("min-w-0 max-w-40 shrink justify-start", className)}{...(color ? { style: { "--label": color } as CSSProperties } : {})}><span className="truncate">{label.name}</span>@@ -411,7 +405,7 @@ export function PullRequestReviewOutcomeBadge({}) {const presentation = REVIEW_OUTCOME_PRESENTATION[outcome];return (- <Badge size="sm" variant={presentation.badgeVariant} className={cn("gap-1", className)}>+ <Badge size="sm" variant={presentation.badgeVariant} className={className}><presentation.Icon aria-hidden className="size-3" />{presentation.label}</Badge>diff --git a/apps/web/src/components/settings/KeybindingsSettings.tsx b/apps/web/src/components/settings/KeybindingsSettings.tsxindex 8371d0d9cdf..7c5bbfa65fb 100644--- a/apps/web/src/components/settings/KeybindingsSettings.tsx+++ b/apps/web/src/components/settings/KeybindingsSettings.tsx@@ -977,7 +977,7 @@ function KeybindingRowMenu({function KeybindingSourceBadge({ source }: { source: KeybindingRow["source"] }) {if (source === "Default") return null;return (- <Badge variant="outline" size="sm" className="font-normal text-muted-foreground">+ <Badge variant="outline" size="sm">{source}</Badge>);diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsxindex 8ab05b166f5..0bcc8e07c2b 100644--- a/apps/web/src/components/sidebar/SidebarChrome.tsx+++ b/apps/web/src/components/sidebar/SidebarChrome.tsx@@ -66,7 +66,7 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({<SidebarBrand onBackdrop={backdropVariant !== null} />{pillLabel ? (<Badge- className="relative z-10 ml-1 hidden rounded-full px-1.5 text-muted-foreground @[15rem]/sidebar-header:inline-flex"+ className="relative z-10 ml-1 hidden @[15rem]/sidebar-header:inline-flex"data-environment-identification="pill"size="sm"variant="secondary"diff --git a/apps/web/src/components/ui/badge.tsx b/apps/web/src/components/ui/badge.tsxindex 32275cc4161..d5d7a47eb98 100644--- a/apps/web/src/components/ui/badge.tsx+++ b/apps/web/src/components/ui/badge.tsx@@ -34,6 +34,9 @@ const badgeVariants = cva(secondary: "bg-secondary text-secondary-foreground [button&,a&]:hover:bg-secondary/90",success: "bg-success/8 text-success-foreground dark:bg-success/16",warning: "bg-warning/8 text-warning-foreground dark:bg-warning/16",+ // A code-host label tinted from the --label color the consumer sets in style.+ label:+ "bg-[color-mix(in_srgb,var(--label)_8%,transparent)] text-[color-mix(in_srgb,var(--label)_30%,var(--color-foreground))] dark:bg-[color-mix(in_srgb,var(--label)_12%,transparent)] dark:text-[color-mix(in_srgb,var(--label)_45%,var(--color-foreground))]",},},},diff --git a/scripts/lint-restyle-ceiling.ts b/scripts/lint-restyle-ceiling.tsindex 35592ebc17f..bdf34708ecd 100644--- a/scripts/lint-restyle-ceiling.ts+++ b/scripts/lint-restyle-ceiling.ts@@ -8,7 +8,7 @@ import * as NodeURL from "node:url";// components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the// count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you// migrate a file, and delete this script when the rule becomes an error.-export const RESTYLE_CEILING = 1031;+export const RESTYLE_CEILING = 1008;const RULE = "shadcn(no-restyle)";