🎚️ refactor: Use Primitive Tones, Variants and Shapes in Remaining Components (#16872)

* refactor: Use Spinner Tones, Label Variants and Shared Button Props in Remaining Components

Replaces text colour, round shape and size overrides with the primitives' own tone, variant, shape and size props where the merged classes are identical, drops redundant field overrides, and removes the prose and arbitrary transition classes that generated no CSS or have a token form.

* test: Cover the Quiet Ink of the Marketplace Search Clear Button

* test: Assert the Clear Button Hover Ink Only Where Hover Exists
This commit is contained in:
Marco Beretta 2026-10-08 12:27:15 +02:00 • committed by GitHub
parent 0a3e9e0468
commit f26b60dd23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 108 additions and 113 deletions

View file

@ -431,7 +431,7 @@ const AgentGrid: React.FC<AgentGridProps> = ({
aria-live="polite"
aria-label={localize('com_agents_loading')}
>
<Spinner className="text-text-primary h-6 w-6" />
<Spinner tone="primary" className="h-6 w-6" />
<span className="sr-only">{localize('com_agents_loading')}</span>
</div>
)}

View file

@ -89,13 +89,11 @@ const SearchBar: React.FC<SearchBarProps> = ({ value, onSearch, className = '' }
{/* Show clear button only when search has value - Google style */}
{searchTerm && (
<Button
variant="ghost"
variant="quiet"
size="icon-sm"
type="button"
onClick={handleClear}
/* `ghost` only colours its hover state, so the glyph would inherit the
document's colour and disappear against a dark surface. */
className="text-text-secondary absolute end-0.5 top-1/2 -translate-y-1/2 rounded-md transition-none"
className="absolute end-0.5 top-1/2 -translate-y-1/2 rounded-md transition-none"
aria-label={localize('com_agents_clear_search')}
>
<X className="size-4" aria-hidden="true" />

View file

@ -56,7 +56,7 @@ const DeleteBookmarkButton: FC<{
onFocus={onFocus}
onBlur={onBlur}
onClick={() => setOpen(!open)}
className="h-8 w-8 p-0"
size="icon-sm"
>
<TrashIcon />
</Button>

View file

@ -32,7 +32,7 @@ const EditBookmarkButton: FC<{
onFocus={onFocus}
onBlur={onBlur}
onClick={() => setOpen(!open)}
className="h-8 w-8 p-0"
size="icon-sm"
>
<EditIcon />
</Button>

View file

@ -157,10 +157,10 @@ const ConvoLink: React.FC<ConvoLinkProps> = ({
ref={titleRef}
className={cn(
isUnseen && !isGenerating && 'font-semibold',
'min-w-0 flex-1 overflow-hidden [mask-size:100%_100%] [mask-position:left] [mask-repeat:no-repeat] [text-align:start] whitespace-nowrap [transition-property:mask-size] [transition-duration:0ms] [transition-timing-function:linear] [--convo-title-fade-width:24px] [--convo-title-reveal-duration:800ms] [&:dir(rtl)]:[mask-position:right]',
'min-w-0 flex-1 overflow-hidden [mask-size:100%_100%] [mask-position:left] [mask-repeat:no-repeat] [text-align:start] whitespace-nowrap [transition-property:mask-size] duration-0 ease-linear [--convo-title-fade-width:24px] [--convo-title-reveal-duration:800ms] [&:dir(rtl)]:[mask-position:right]',
isOverflowing &&
'[mask-image:linear-gradient(to_right,currentColor_calc(100%_-_var(--convo-title-fade-width)),transparent)] [&:dir(rtl)]:[mask-image:linear-gradient(to_left,currentColor_calc(100%_-_var(--convo-title-fade-width)),transparent)]',
'data-[title-revealed=true]:[mask-size:calc(100%_+_var(--convo-title-fade-width))_100%] data-[title-revealed=true]:[transition-duration:var(--convo-title-reveal-duration)]',
'data-[title-revealed=true]:[mask-size:calc(100%_+_var(--convo-title-fade-width))_100%] data-[title-revealed=true]:duration-(--convo-title-reveal-duration)',
)}
onDoubleClick={(e) => {
if (isSmallScreen) {

View file

@ -155,10 +155,10 @@ const ProjectChatsInline = memo(function ProjectChatsInline({
{hasMore && (
<Button
type="button"
variant="ghost"
variant="quiet"
size="sm"
onClick={onShowAll}
className="text-text-secondary mt-0.5 ml-1 h-auto rounded-md px-2 py-1 text-xs font-medium"
className="mt-0.5 ml-1 h-auto rounded-md px-2 py-1 text-xs font-medium"
>
{localize('com_ui_show_all')}
</Button>
@ -455,7 +455,7 @@ const ProjectsSection = ({ toggleNav, isAuthenticated }: ProjectsSectionProps) =
if (isLoading && projects.length === 0) {
return (
<div className="flex justify-start py-2 pl-2">
<Spinner className="text-text-secondary h-4 w-4" />
<Spinner tone="secondary" className="h-4 w-4" />
</div>
);
}

View file

@ -28,7 +28,7 @@ const GoogleConfig = ({ userKey, setUserKey }: Pick<TConfigProps, 'userKey' | 's
<Label htmlFor={AuthKeys.GOOGLE_SERVICE_KEY} className="text-left text-sm font-medium">
{localize('com_endpoint_config_google_service_key')}
</Label>
<Label className="mx-1 text-right text-sm text-text-secondary">
<Label variant="secondary" className="mx-1 text-right text-sm">
{localize('com_endpoint_config_google_cloud_platform')}
</Label>
<br />

View file

@ -1,8 +1,8 @@
import { forwardRef } from 'react';
import { Input, Label, SecretInput } from '@librechat/client';
import type { ChangeEvent, FC, Ref } from 'react';
import { cn } from '~/utils/';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils/';
interface InputWithLabelProps {
id: string;
@ -35,7 +35,9 @@ const InputWithLabel: FC<InputWithLabelProps> = forwardRef((props, ref) => {
{label}
</Label>
{subLabel && (
<Label className="mx-1 text-right text-sm text-text-secondary">{subLabel}</Label>
<Label variant="secondary" className="mx-1 text-right text-sm">
{subLabel}
</Label>
)}
<br />
</div>

View file

@ -129,7 +129,7 @@ function EmptyState({ message }: { message: string }) {
function LoadingState({ message }: { message: string }) {
return (
<Panel className="flex min-h-52 flex-col items-center justify-center gap-3">
<Spinner className="text-text-secondary size-7" />
<Spinner tone="secondary" className="size-7" />
<span className="text-text-secondary text-sm">{message}</span>
</Panel>
);
@ -448,7 +448,7 @@ function LatestConversations({
<h2 className="text-base font-semibold">
{localize('com_insights_latest_conversations')}
</h2>
{isFetching && <Spinner className="text-text-secondary size-4" />}
{isFetching && <Spinner tone="secondary" className="size-4" />}
</div>
<div className="relative w-full sm:max-w-md">
<Search
@ -825,7 +825,7 @@ export default function InsightsView() {
variant="ghost"
aria-pressed={!customDateRange && range === item.value}
className={cn(
'h-8 rounded-md px-3',
'h-8 rounded-md',
!customDateRange && range === item.value && 'bg-surface-active-alt',
)}
onClick={() => {

View file

@ -77,8 +77,7 @@ function AuthField({ name, config, hasValue, control, errors, autoFocus }: AuthF
const placeholder = hasValue
? localize('com_ui_mcp_update_var', { 0: config.title })
: localize('com_ui_mcp_enter_var', { 0: config.title });
const className =
'w-full rounded border border-border-medium bg-transparent px-2 py-1 text-text-primary placeholder:text-text-secondary sm:text-sm';
const className = 'w-full rounded border border-border-medium px-2 py-1 sm:text-sm';
// Prevent autofill: browser DOM mutations bypass React's synthetic
// onChange, silently emptying react-hook-form state on submit.
const sharedProps = {

View file

@ -57,16 +57,16 @@ export default function MCPServerMenuItem({
)}
>
{/* Server Icon with Status Dot */}
<div className="relative shrink-0">
<div className="text-text-primary relative shrink-0">
{server.config?.iconPath ? (
<CustomIcon
src={server.config.iconPath}
className="text-text-primary h-8 w-8 rounded-lg object-cover"
className="h-8 w-8 rounded-lg object-cover"
alt=""
/>
) : (
<div className="bg-surface-tertiary flex h-8 w-8 items-center justify-center rounded-lg">
<MCPIcon className="text-text-secondary h-5 w-5" />
<div className="bg-surface-tertiary text-text-secondary flex h-8 w-8 items-center justify-center rounded-lg">
<MCPIcon className="h-5 w-5" />
</div>
)}
{/* Status dot - decorative, status is announced via aria-label on MenuItem */}

View file

@ -167,7 +167,7 @@ function LoadingStatusIcon({ serverName, onCancel, canCancel }: InitializingStat
aria-label={localize('com_ui_cancel')}
>
<div className="relative size-4">
<Spinner className="text-text-primary size-4 group-hover:opacity-0" />
<Spinner tone="primary" className="size-4 group-hover:opacity-0" />
<X className="text-text-destructive absolute inset-0 size-4 opacity-0 group-hover:opacity-100" />
</div>
</Button>
@ -179,7 +179,8 @@ function LoadingStatusIcon({ serverName, onCancel, canCancel }: InitializingStat
return (
<div className="flex size-6 items-center justify-center rounded p-1">
<Spinner
className="text-text-primary size-4"
tone="primary"
className="size-4"
aria-label={localize('com_nav_mcp_status_connecting', { 0: serverName })}
/>
</div>
@ -190,7 +191,8 @@ function ConnectingSpinner({ serverName }: { serverName: string }) {
return (
<div className="flex size-6 items-center justify-center rounded p-1">
<Spinner
className="text-text-primary size-4"
tone="primary"
className="size-4"
aria-label={localize('com_nav_mcp_status_connecting', { 0: serverName })}
/>
</div>

View file

@ -77,7 +77,7 @@ export default function McpOAuthDialog({
* open smoothly without a hardcoded height, matching MCPToolItem. */}
<div
className={cn(
'grid transition-[grid-template-rows] [transition-duration:var(--resize-dur)] [transition-timing-function:var(--resize-ease)] motion-reduce:transition-none',
'grid transition-all duration-(--resize-dur) ease-(--resize-ease) motion-reduce:transition-none',
showQR ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
)}
>

View file

@ -66,7 +66,7 @@ export default function StackedMCPIcons({
key={icon.key}
title={icon.displayName}
className={cn(
'relative flex items-center justify-center rounded-full border',
'text-text-primary relative flex items-center justify-center rounded-full border',
colors.border,
colors.bg,
sizes.container,
@ -78,10 +78,10 @@ export default function StackedMCPIcons({
<CustomIcon
src={icon.iconPath}
alt={icon.displayName}
className={cn('text-text-primary rounded-full object-cover', sizes.icon)}
className={cn('rounded-full object-cover', sizes.icon)}
/>
) : (
<MCPIcon className={cn('text-text-primary', sizes.icon)} />
<MCPIcon className={sizes.icon} />
)}
</div>
))}

View file

@ -139,7 +139,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({
{allowExecution === true && toolCalls && toolCalls.length > 0 && (
<>
<div className="border-border-inset bg-surface-code border-t p-4 text-xs">
<div className="text-text-secondary mb-1 text-[10px] font-medium tracking-wide uppercase">
<div className="text-text-secondary text-3xs mb-1 font-medium tracking-wide uppercase">
{localize('com_ui_output')}
</div>
<div className="text-text-primary flex flex-col-reverse">

View file

@ -156,7 +156,7 @@ function PluginAuthForm({
};
return (
<div key={`${authField}-${i}`} className="flex w-full flex-col gap-1.5">
<Label htmlFor={authField} className="text-sm font-medium text-text-secondary">
<Label htmlFor={authField} variant="secondary" className="text-sm font-medium">
{config.label}
</Label>
<HoverCard openDelay={300}>

View file

@ -150,9 +150,7 @@ export function ShareArtifactsContainer({
>
{mainContent}
</ResizablePanel>
{showDockedPanel && (
<ResizableHandleAlt withHandle className="bg-border-medium text-text-primary" />
)}
{showDockedPanel && <ResizableHandleAlt withHandle className="text-text-primary" />}
{showDockedPanel && (
<ResizablePanel
defaultSize={`${normalizedArtifactSize}`}

View file

@ -376,7 +376,7 @@ export function ShareHeader({
<div className="flex flex-wrap items-center justify-end gap-2 md:flex-nowrap md:self-start">
{langfuseSessionUrl && (
<Button asChild variant="outline" className="border-border-medium rounded-full">
<Button asChild variant="outline" shape="round" className="border-border-medium">
<a href={langfuseSessionUrl} target="_blank" rel="noopener noreferrer">
<span>{langfuseSessionLabel}</span>
<ExternalLink className="size-4 shrink-0" aria-hidden="true" />
@ -388,7 +388,7 @@ export function ShareHeader({
variant="submit"
onClick={onContinue}
disabled={isContinuing}
className="rounded-full"
shape="round"
>
{isContinuing ? (
<Spinner className="size-4" />
@ -403,9 +403,10 @@ export function ShareHeader({
size={isMobile ? 'icon' : 'default'}
type="button"
variant="outline"
shape="round"
aria-label={settingsLabel}
className={cn(
'border-border-medium text-text-primary rounded-full text-sm transition-colors',
'border-border-medium transition-colors',
isMobile
? 'absolute right-4 bottom-4 justify-center p-0 shadow-lg'
: 'gap-2 self-start px-4 py-2',

View file

@ -303,7 +303,7 @@ export default function GenericGrantAccessDialog({
<Share2Icon className="icon-md h-4 w-4" />
</span>
{totalCurrentShares > 0 && (
<Label className="text-text-secondary cursor-pointer text-sm font-medium">
<Label variant="secondary" className="cursor-pointer text-sm font-medium">
{totalCurrentShares}
</Label>
)}
@ -449,7 +449,7 @@ export default function GenericGrantAccessDialog({
});
}}
disabled={isCopying}
className={cn('shrink-0 gap-2', isCopying ? 'cursor-default' : '')}
className={cn('shrink-0', isCopying ? 'cursor-default' : '')}
aria-label={localize('com_ui_copy_url_to_clipboard')}
>
<MorphIcon icon={isCopying ? CopyCheck : Link} className="size-4" />

View file

@ -161,7 +161,7 @@ function AssistantToolsDialog({
style={{ minHeight: 'min(38.125rem, 90vh)' }}
>
<div>
<div className="border-border-medium flex items-center justify-between border-b-[1px] px-4 pt-5 pb-4 sm:p-6">
<div className="border-border-medium flex items-center justify-between border-b px-4 pt-5 pb-4 sm:p-6">
<div className="flex items-center">
<div className="text-center sm:text-left">
<OGDialogTitle className="text-lg leading-6 font-medium">
@ -199,7 +199,7 @@ function AssistantToolsDialog({
onChange={handleSearch}
placeholder={localize('com_nav_tool_search')}
aria-label={localize('com_nav_tool_search')}
className="border-border-medium text-text-primary max-w-64 min-w-0 flex-1 rounded border px-2 py-1"
className="border-border-medium max-w-64 min-w-0 flex-1 rounded border px-2 py-1"
/>
</div>
<div

View file

@ -73,8 +73,9 @@ function FileHovercardContent({
<FileText className="text-text-secondary size-4 shrink-0" aria-hidden="true" />
<Button
variant="link"
size="bare"
onClick={onClick}
className="h-auto min-w-0 justify-start truncate p-0 font-medium"
className="min-w-0 justify-start truncate font-medium"
>
{fileName}
</Button>

View file

@ -59,7 +59,7 @@ function SourceItem({ source, expanded = false }: SourceItemProps) {
}
return (
<span className="not-prose relative inline-block h-full w-full">
<span className="relative inline-block h-full w-full">
<Ariakit.HovercardProvider showTimeout={150} hideTimeout={150}>
<div className="flex h-full items-center">
<Ariakit.HovercardAnchor

View file

@ -33,7 +33,7 @@ export default function Collapse({
aria-hidden={!open || undefined}
inert={!open ? '' : undefined}
className={cn(
'grid transition-[grid-template-rows] [transition-duration:var(--resize-dur)] [transition-timing-function:var(--resize-ease)] motion-reduce:transition-none',
'grid transition-all duration-(--resize-dur) ease-(--resize-ease) motion-reduce:transition-none',
open ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
)}
>

View file

@ -76,7 +76,7 @@ const TermsAndConditionsModal = ({
className="max-h-[60vh] overflow-y-auto p-4"
aria-label={localize('com_ui_terms_and_conditions')}
>
<div className="prose dark:prose-invert !text-text-primary w-full max-w-none">
<div className="prose !text-text-primary w-full max-w-none">
{content !== '' ? (
<MarkdownLite content={content} />
) : (

View file

@ -344,7 +344,7 @@ export default function ChatRoute() {
if (endpointsQuery.isLoading || modelsQuery.isLoading) {
return (
<div className="flex h-screen items-center justify-center" aria-live="polite" role="status">
<Spinner className="text-text-primary" />
<Spinner tone="primary" />
</div>
);
}
@ -378,7 +378,7 @@ export default function ChatRoute() {
</Button>
</div>
) : (
<Spinner className="text-text-primary" />
<Spinner tone="primary" />
)}
</div>
)}

View file

@ -0,0 +1,43 @@
import { expect, test } from '@playwright/test';
import type { Locator } from '@playwright/test';
/** The ink a control draws, resolved to the colour the browser paints. */
const readInk = (locator: Locator) =>
locator.evaluate((element) => getComputedStyle(element).color);
test.describe('agent search clear button', () => {
test('@scenario:agent-search-clear-quiet-ink the clear button rests in the secondary ink and rises to the primary ink on hover', async ({
page,
}) => {
await page.goto('/agents/all', { timeout: 10000 });
const search = page.locator('#agent-search');
await expect(search).toBeVisible({ timeout: 30000 });
await search.fill('clear me');
const clear = page.getByRole('button', { name: 'Clear search', exact: true });
await expect(clear).toBeVisible();
const probe = await page.evaluate(() => {
const paint = (variable: string) => {
const element = document.createElement('span');
element.style.color = `rgb(var(${variable}))`;
document.body.appendChild(element);
const color = getComputedStyle(element).color;
element.remove();
return color;
};
return { secondary: paint('--text-secondary'), primary: paint('--text-primary') };
});
expect(await readInk(clear)).toBe(probe.secondary);
const hasHover = await page.evaluate(() => matchMedia('(hover: hover)').matches);
if (hasHover) {
await clear.hover();
await expect.poll(() => readInk(clear)).toBe(probe.primary);
}
await clear.click();
await expect(search).toHaveValue('');
await expect(clear).toBeHidden();
});
});

View file

@ -12,11 +12,6 @@
"count": 10
}
},
"client/src/components/Agents/AgentGrid.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/Agents/Marketplace.tsx": {
"shadcn/no-restyle": {
"count": 1
@ -29,7 +24,7 @@
},
"client/src/components/Agents/SearchBar.tsx": {
"shadcn/no-restyle": {
"count": 7
"count": 6
}
},
"client/src/components/Artifacts/ArtifactCodeEditor.tsx": {
@ -55,16 +50,6 @@
"count": 11
}
},
"client/src/components/Bookmarks/DeleteBookmarkButton.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/Bookmarks/EditBookmarkButton.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/Chat/ChatView.tsx": {
"shadcn/no-restyle": {
"count": 1
@ -563,7 +548,7 @@
},
"client/src/components/Conversations/ConvoLink.tsx": {
"shadcn/no-arbitrary-values": {
"count": 4
"count": 1
}
},
"client/src/components/Conversations/ConvoOptions/ShareButton.tsx": {
@ -583,7 +568,7 @@
},
"client/src/components/Conversations/ProjectsSection.tsx": {
"shadcn/no-restyle": {
"count": 9
"count": 7
}
},
"client/src/components/Conversations/RenameForm.tsx": {
@ -657,14 +642,9 @@
"count": 1
}
},
"client/src/components/Input/SetKeyDialog/GoogleConfig.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/Input/SetKeyDialog/InputWithLabel.tsx": {
"shadcn/no-restyle": {
"count": 5
"count": 4
},
"shadcn/require-static-classes": {
"count": 2
@ -677,45 +657,37 @@
},
"client/src/components/Insights/InsightsView.tsx": {
"shadcn/no-restyle": {
"count": 28
"count": 25
}
},
"client/src/components/MCP/CustomUserVarsSection.tsx": {
"shadcn/no-restyle": {
"count": 18
"count": 12
}
},
"client/src/components/MCP/MCPServerMenuItem.tsx": {
"shadcn/no-restyle": {
"count": 3
"count": 1
}
},
"client/src/components/MCP/MCPServerStatusIcon.tsx": {
"shadcn/no-restyle": {
"count": 13
"count": 10
}
},
"client/src/components/MCP/McpOAuthDialog.tsx": {
"shadcn/no-arbitrary-values": {
"count": 3
},
"shadcn/no-restyle": {
"count": 3
}
},
"client/src/components/MCP/StackedMCPIcons.tsx": {
"shadcn/no-restyle": {
"count": 4
"count": 2
},
"shadcn/require-static-classes": {
"count": 3
}
},
"client/src/components/Messages/Content/CodeBlock.tsx": {
"shadcn/no-arbitrary-values": {
"count": 1
}
},
"client/src/components/Messages/Content/Error/parts.tsx": {
"shadcn/no-arbitrary-values": {
"count": 1
@ -861,7 +833,7 @@
},
"client/src/components/Plugins/Store/PluginAuthForm.tsx": {
"shadcn/no-restyle": {
"count": 9
"count": 8
}
},
"client/src/components/Projects/ProjectChatOptions.tsx": {
@ -960,12 +932,12 @@
},
"client/src/components/Share/ShareArtifacts.tsx": {
"shadcn/no-restyle": {
"count": 2
"count": 1
}
},
"client/src/components/Share/ShareView.tsx": {
"shadcn/no-restyle": {
"count": 14
"count": 9
}
},
"client/src/components/SharePoint/SharePointPickerDialog.tsx": {
@ -975,7 +947,7 @@
},
"client/src/components/Sharing/GenericGrantAccessDialog.tsx": {
"shadcn/no-restyle": {
"count": 3
"count": 1
},
"shadcn/require-static-classes": {
"count": 2
@ -1300,11 +1272,8 @@
}
},
"client/src/components/Tools/AssistantToolsDialog.tsx": {
"shadcn/no-arbitrary-values": {
"count": 1
},
"shadcn/no-restyle": {
"count": 6
"count": 5
}
},
"client/src/components/Tools/ToolItem.tsx": {
@ -1353,7 +1322,7 @@
"count": 1
},
"shadcn/no-restyle": {
"count": 3
"count": 2
}
},
"client/src/components/Web/Sources.tsx": {
@ -1362,9 +1331,6 @@
},
"shadcn/no-restyle": {
"count": 44
},
"shadcn/no-unknown-classes": {
"count": 1
}
},
"client/src/components/ui/AdminSettingsDialog.tsx": {
@ -1375,26 +1341,11 @@
"count": 1
}
},
"client/src/components/ui/Collapse.tsx": {
"shadcn/no-arbitrary-values": {
"count": 3
}
},
"client/src/components/ui/LocalizedDateRangePicker.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/ui/TermsAndConditionsModal.tsx": {
"shadcn/no-unknown-classes": {
"count": 1
}
},
"client/src/routes/ChatRoute.tsx": {
"shadcn/no-restyle": {
"count": 2
}
},
"client/src/routes/Root.tsx": {
"shadcn/no-inline-styles": {
"count": 2