mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-21 15:33:45 +00:00
🔘 refactor: Draw the Composer Controls With the Shared Button (#16953)
* refactor: Draw Composer Controls With the Shared Button * test: Pin the Composer Controls' Look Through the Shared Button
This commit is contained in:
parent
de3c828d85
commit
f8fea1e257
8 changed files with 310 additions and 77 deletions
|
|
@ -2,6 +2,7 @@ import { memo, useRef, useMemo, useState, useEffect, useCallback, useLayoutEffec
|
|||
import { CircleHelp } from 'lucide-react';
|
||||
import { Constants, reasoningOverrideSchema } from 'librechat-data-provider';
|
||||
import {
|
||||
Button,
|
||||
HoverCard,
|
||||
IconButton,
|
||||
HoverCardTrigger,
|
||||
|
|
@ -465,9 +466,9 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
|
|||
destructured here where `left`/`right` are visibly the only keys. */
|
||||
const { left, right } = hitArea(index);
|
||||
return (
|
||||
<button
|
||||
<Button
|
||||
key={value}
|
||||
type="button"
|
||||
variant="hit-area"
|
||||
role="radio"
|
||||
aria-checked={!isUngraded && index === activeIndex}
|
||||
aria-label={label(value)}
|
||||
|
|
@ -491,7 +492,7 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
|
|||
}}
|
||||
onClick={() => select(value)}
|
||||
style={{ left, right }}
|
||||
className="focus-visible:ring-text-primary absolute inset-y-0 rounded-full focus-visible:ring-2 focus-visible:outline-hidden focus-visible:ring-inset"
|
||||
className="absolute inset-y-0"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
|
@ -526,19 +527,13 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
|
|||
{/* Always present so the separate mode reads as something the user
|
||||
can turn on and off rather than as a one-way escape hatch. */}
|
||||
{ungradedValue != null && (
|
||||
<button
|
||||
type="button"
|
||||
<Button
|
||||
variant="pill-toggle"
|
||||
aria-pressed={isUngraded}
|
||||
onClick={() => select(isUngraded ? levels[restoreIndex] : ungradedValue)}
|
||||
className={cn(
|
||||
'rounded-full px-2 py-0.5 text-xs transition-colors',
|
||||
isUngraded
|
||||
? 'bg-accent-primary/15 text-accent-primary'
|
||||
: 'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
|
||||
)}
|
||||
>
|
||||
{label(ungradedValue)}
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
{descriptionText != null && descriptionText !== '' && (
|
||||
<HoverCard openDelay={200}>
|
||||
|
|
|
|||
|
|
@ -925,17 +925,13 @@ function Palette({
|
|||
aria-selected={isActive}
|
||||
className="min-w-0 flex-1"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
className="flex h-full w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-left"
|
||||
>
|
||||
<Button variant="row-content" tabIndex={-1} className="h-full w-full">
|
||||
<ChevronDown
|
||||
aria-hidden="true"
|
||||
className={cn('animate-composer-icon size-4 shrink-0', expanded && '-rotate-180')}
|
||||
/>
|
||||
<span className="truncate">{row.label}</span>
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
@ -967,11 +963,7 @@ function Palette({
|
|||
aria-selected={isActive}
|
||||
className="min-w-0 flex-1"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
className="flex h-full w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-left"
|
||||
>
|
||||
<Button variant="row-content" tabIndex={-1} className="h-full w-full">
|
||||
{/* The wrapper carries the fallback tile color; the image itself
|
||||
hides on error so an unreachable thumbnail (remote storage,
|
||||
expired links) degrades to an empty tile instead of a broken
|
||||
|
|
@ -1007,7 +999,7 @@ function Palette({
|
|||
{formatFileDate(file)}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
@ -1060,14 +1052,14 @@ function Palette({
|
|||
className="bg-text-primary absolute inset-y-1 left-0 w-0.5 rounded-full"
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
<Button
|
||||
variant="row-content"
|
||||
tabIndex={-1}
|
||||
aria-pressed={isEntry ? checked : undefined}
|
||||
aria-label={
|
||||
favorited ? `${label}, ${localize('com_ui_tools_view_favorites')}` : undefined
|
||||
}
|
||||
className="flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-lg px-2 text-left"
|
||||
className="h-full min-w-0 flex-1"
|
||||
>
|
||||
<span className="relative flex shrink-0" aria-hidden="true">
|
||||
{icon}
|
||||
|
|
@ -1091,7 +1083,7 @@ function Palette({
|
|||
<span className="text-text-secondary truncate text-xs">{description}</span>
|
||||
)}
|
||||
</span>
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
{modes != null && modes.length > 0 && (
|
||||
<div role="gridcell" className="flex shrink-0 items-center gap-1">
|
||||
|
|
@ -1118,23 +1110,17 @@ function Palette({
|
|||
</IconButton>
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
<Button
|
||||
key={mode.id}
|
||||
type="button"
|
||||
variant="chip-toggle"
|
||||
aria-pressed={mode.active}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
mode.onSelect();
|
||||
}}
|
||||
className={cn(
|
||||
'focus-visible:ring-text-primary min-h-6 shrink-0 rounded-full border px-2 py-0.5 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-hidden',
|
||||
mode.active
|
||||
? 'bg-surface-active-alt text-text-primary border-transparent'
|
||||
: 'border-border-medium text-text-secondary hover:bg-surface-hover hover:text-text-primary',
|
||||
)}
|
||||
>
|
||||
{mode.label}
|
||||
</button>
|
||||
</Button>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { memo, useRef, useMemo, useState, useLayoutEffect } from 'react';
|
||||
import * as Ariakit from '@ariakit/react';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import { TooltipAnchor, useMediaQuery } from '@librechat/client';
|
||||
import { Button, TooltipAnchor, useMediaQuery } from '@librechat/client';
|
||||
import type { SettingDefinition, TConversation, TReasoningOverride } from 'librechat-data-provider';
|
||||
import { ReasoningControl, useComposerReasoning } from '../Reasoning';
|
||||
import Effort, { effortRank, resolveEffortLabel } from './Effort';
|
||||
|
|
@ -124,19 +124,10 @@ function ThinkingControl({
|
|||
render={
|
||||
<TooltipAnchor
|
||||
description={localize('com_ui_composer_thinking')}
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
className={cn(
|
||||
'text-text-primary gap-1 rounded-full px-2.5 text-sm transition-colors',
|
||||
'hover:bg-surface-hover focus-visible:ring-text-primary focus-visible:ring-2 focus-visible:outline-hidden',
|
||||
open && 'bg-surface-hover',
|
||||
)}
|
||||
/>
|
||||
}
|
||||
render={<Button variant="composer-pill" />}
|
||||
/>
|
||||
}
|
||||
className="flex h-8 shrink-0 items-center"
|
||||
className="flex shrink-0"
|
||||
>
|
||||
{/* Closed, the button hugs its label so it takes no more room in the bar
|
||||
than it needs. Open, it widens to the longest label and the text
|
||||
|
|
|
|||
|
|
@ -114,19 +114,16 @@ export function ReasoningControl({
|
|||
return (
|
||||
<Popover.Root modal>
|
||||
<Popover.Trigger asChild>
|
||||
{/* Styled as the composer control it sits beside (the Thinking pill in
|
||||
`Composer/Thinking.tsx`) rather than as a restyled `Button`: the
|
||||
open state keeps it lit while its popover is up, which no `Button`
|
||||
variant expresses. */}
|
||||
<button
|
||||
type="button"
|
||||
{/* `composer-trigger` keeps it lit while its popover is up, through the
|
||||
`aria-expanded` the trigger carries. */}
|
||||
<Button
|
||||
variant="composer-trigger"
|
||||
disabled={disabled}
|
||||
aria-label={`${localize('com_ui_reasoning_for_next_message')} ${displayValue}`}
|
||||
className="text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-text-primary data-[state=open]:bg-surface-hover data-[state=open]:text-text-primary inline-flex h-8 items-center justify-center gap-1.5 rounded-xl px-2 text-sm font-medium whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
||||
>
|
||||
<BrainCircuit className="size-4" aria-hidden="true" />
|
||||
<ChevronDown className="size-3" aria-hidden="true" />
|
||||
</button>
|
||||
</Button>
|
||||
</Popover.Trigger>
|
||||
<Popover.Portal>
|
||||
<Popover.Content
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ import { useLatestMessage } from '~/hooks/Messages';
|
|||
import { useLocalize } from '~/hooks';
|
||||
import SteerPart from './SteerPart';
|
||||
|
||||
const ACTION_CLASS =
|
||||
'rounded text-xs font-medium text-text-secondary hover:text-text-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-xheavy';
|
||||
|
||||
/**
|
||||
* Steers that have not been confirmed by the server yet, rendered at the tail
|
||||
* of the streaming reply (the place the words will land) instead of in a
|
||||
|
|
@ -182,31 +179,27 @@ function PendingSteers({ conversationId, index = 0, fullWidth = false }: Pending
|
|||
)}
|
||||
</span>
|
||||
{retrySafe && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => retry(steer.steerId)}
|
||||
className={ACTION_CLASS}
|
||||
>
|
||||
<Button type="button" onClick={() => retry(steer.steerId)} variant="text-action">
|
||||
{localize('com_ui_retry')}
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
{!deliveryUncertain && (
|
||||
<button
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => editFailedSteer(steer)}
|
||||
className={ACTION_CLASS}
|
||||
variant="text-action"
|
||||
>
|
||||
{localize('com_ui_edit')}
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
{!deliveryUncertain && (
|
||||
<button
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => sendAsNew(steer.steerId)}
|
||||
className={ACTION_CLASS}
|
||||
variant="text-action"
|
||||
>
|
||||
{localize('com_ui_send_as_new')}
|
||||
</button>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
|
|
|
|||
235
e2e/specs/mock/scenarios/composer-buttons.spec.ts
Normal file
235
e2e/specs/mock/scenarios/composer-buttons.spec.ts
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import type { Locator, Page } from '@playwright/test';
|
||||
import {
|
||||
messagesView,
|
||||
MOCK_ENDPOINTS,
|
||||
NEW_CHAT_PATH,
|
||||
selectMockEndpoint,
|
||||
sendMessage,
|
||||
} from '../helpers';
|
||||
import { probeStyle } from './style.helpers';
|
||||
|
||||
/**
|
||||
* The composer's own controls (the Thinking pill and its effort rail, the palette rows and
|
||||
* their mode chips, the numeric reasoning trigger and the pending steer actions) are drawn by
|
||||
* the shared Button. Each keeps the box, ink and fill it had as a local recipe, so these
|
||||
* assertions hold on the base as well as on the change; the colors resolve through probes
|
||||
* of the semantic utilities, which keeps them true in light and dark mode.
|
||||
*/
|
||||
test.describe.configure({ timeout: 120_000 });
|
||||
|
||||
const box = (locator: Locator) =>
|
||||
locator.evaluate((node: HTMLElement) => {
|
||||
const style = getComputedStyle(node);
|
||||
return {
|
||||
height: node.offsetHeight,
|
||||
radius: parseFloat(style.borderTopLeftRadius) >= 9999 ? 'full' : style.borderTopLeftRadius,
|
||||
paddingLeft: style.paddingLeft,
|
||||
gap: style.columnGap,
|
||||
fontSize: style.fontSize,
|
||||
fontWeight: style.fontWeight,
|
||||
};
|
||||
});
|
||||
|
||||
const paint = (locator: Locator) =>
|
||||
locator.evaluate((node: HTMLElement) => {
|
||||
const style = getComputedStyle(node);
|
||||
return { color: style.color, background: style.backgroundColor };
|
||||
});
|
||||
|
||||
async function expectPaint(page: Page, locator: Locator, classes: string) {
|
||||
await page.mouse.move(0, 0);
|
||||
await expect
|
||||
.poll(() => paint(locator))
|
||||
.toEqual({
|
||||
color: await probeStyle(page, classes, 'color'),
|
||||
background: await probeStyle(page, classes, 'background-color'),
|
||||
});
|
||||
}
|
||||
|
||||
/** Paint of a pressed state whose classes exist only behind the `aria-pressed:` variant. */
|
||||
async function expectPressedPaint(page: Page, locator: Locator, classes: string) {
|
||||
const expected = await page.evaluate((className) => {
|
||||
const probe = document.createElement('button');
|
||||
probe.className = className;
|
||||
probe.setAttribute('aria-pressed', 'true');
|
||||
document.body.append(probe);
|
||||
const style = getComputedStyle(probe);
|
||||
const value = { color: style.color, background: style.backgroundColor };
|
||||
probe.remove();
|
||||
return value;
|
||||
}, classes);
|
||||
await page.mouse.move(0, 0);
|
||||
await expect.poll(() => paint(locator)).toEqual(expected);
|
||||
}
|
||||
|
||||
async function openComposer(page: Page) {
|
||||
await page.goto(NEW_CHAT_PATH, { timeout: 10000 });
|
||||
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
|
||||
}
|
||||
|
||||
test.describe('composer controls on the shared Button', () => {
|
||||
test('Thinking pill and effort rail keep their look and keyboard @scenario:thinking-pill-and-effort-rail-keep-their-look', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openComposer(page);
|
||||
const thinking = page.getByRole('button', { name: /^Thinking: / });
|
||||
await expect(thinking).toBeVisible();
|
||||
expect(await box(thinking)).toEqual({
|
||||
height: 32,
|
||||
radius: 'full',
|
||||
paddingLeft: '10px',
|
||||
gap: '4px',
|
||||
fontSize: '14px',
|
||||
fontWeight: '400',
|
||||
});
|
||||
await expectPaint(page, thinking, 'text-text-primary');
|
||||
|
||||
await thinking.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
const popover = page.getByRole('dialog', { name: /^Thinking: / });
|
||||
await expect(popover).toBeVisible();
|
||||
await expect(thinking).toHaveAttribute('aria-expanded', 'true');
|
||||
await expectPaint(page, thinking, 'bg-surface-hover text-text-primary');
|
||||
|
||||
const auto = popover.getByRole('button', { name: 'Auto', exact: true });
|
||||
await expect(auto).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(await box(auto)).toMatchObject({
|
||||
radius: 'full',
|
||||
paddingLeft: '8px',
|
||||
fontSize: '12px',
|
||||
fontWeight: '400',
|
||||
});
|
||||
await expectPressedPaint(
|
||||
page,
|
||||
auto,
|
||||
'aria-pressed:bg-accent-primary/15 aria-pressed:text-accent-primary',
|
||||
);
|
||||
|
||||
await auto.click();
|
||||
await expect(auto).toHaveAttribute('aria-pressed', 'false');
|
||||
await expectPaint(page, auto, 'text-text-secondary');
|
||||
|
||||
const checked = popover.getByRole('radio', { checked: true });
|
||||
await expect(checked).toHaveCount(1);
|
||||
const radios = popover.getByRole('radio');
|
||||
const count = await radios.count();
|
||||
const names = await radios.evaluateAll((nodes) =>
|
||||
nodes.map((node) => node.getAttribute('aria-label')),
|
||||
);
|
||||
const start = names.indexOf(await checked.getAttribute('aria-label'));
|
||||
const target = start === count - 1 ? start - 1 : start + 1;
|
||||
await checked.focus();
|
||||
await page.keyboard.press(target > start ? 'ArrowRight' : 'ArrowLeft');
|
||||
const moved = radios.nth(target);
|
||||
await expect(moved).toHaveAttribute('aria-checked', 'true');
|
||||
await expect(moved).toBeFocused();
|
||||
const ring = await moved.evaluate((node) => getComputedStyle(node).boxShadow);
|
||||
expect(ring).toContain('inset');
|
||||
await expect
|
||||
.poll(() => moved.evaluate((node) => getComputedStyle(node).backgroundColor))
|
||||
.toBe('rgba(0, 0, 0, 0)');
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(popover).toBeHidden();
|
||||
await expect(thinking).toBeFocused();
|
||||
await expect(thinking).toHaveAttribute('aria-expanded', 'false');
|
||||
await expectPaint(page, thinking, 'text-text-primary');
|
||||
});
|
||||
|
||||
test('Palette rows and mode chips keep their look and toggle @scenario:palette-rows-and-mode-chips-keep-their-look', async ({
|
||||
page,
|
||||
}) => {
|
||||
await openComposer(page);
|
||||
await page.getByRole('button', { name: 'Attach and tools' }).click();
|
||||
const palette = page.getByRole('dialog', { name: 'Attach and tools' });
|
||||
const runCode = palette.getByRole('button', { name: 'Run Code', exact: true });
|
||||
await expect(runCode).toBeVisible();
|
||||
expect(await box(runCode)).toMatchObject({
|
||||
radius: '8px',
|
||||
paddingLeft: '8px',
|
||||
gap: '10px',
|
||||
fontWeight: '400',
|
||||
});
|
||||
const inherited = await runCode.evaluate((node: HTMLElement) => ({
|
||||
own: getComputedStyle(node).color,
|
||||
cell: getComputedStyle(node.parentElement as HTMLElement).color,
|
||||
background: getComputedStyle(node).backgroundColor,
|
||||
}));
|
||||
expect(inherited.own).toBe(inherited.cell);
|
||||
expect(inherited.background).toBe('rgba(0, 0, 0, 0)');
|
||||
|
||||
const artifacts = palette.getByRole('button', { name: 'Artifacts', exact: true });
|
||||
await artifacts.click();
|
||||
await expect(artifacts).toHaveAttribute('aria-pressed', 'true');
|
||||
const standard = palette.getByRole('button', { name: 'Default', exact: true });
|
||||
const shadcn = palette.getByRole('button', { name: 'shadcn/ui', exact: true });
|
||||
await expect(standard).toHaveAttribute('aria-pressed', 'true');
|
||||
await expect(shadcn).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(await box(shadcn)).toMatchObject({
|
||||
height: 24,
|
||||
radius: 'full',
|
||||
paddingLeft: '8px',
|
||||
fontSize: '12px',
|
||||
fontWeight: '400',
|
||||
});
|
||||
await expectPaint(page, standard, 'bg-surface-active-alt text-text-primary');
|
||||
await expectPaint(page, shadcn, 'text-text-secondary');
|
||||
expect(await shadcn.evaluate((node) => getComputedStyle(node).borderTopColor)).toBe(
|
||||
await probeStyle(page, 'border border-border-medium', 'border-top-color'),
|
||||
);
|
||||
|
||||
await shadcn.click();
|
||||
await expect(shadcn).toHaveAttribute('aria-pressed', 'true');
|
||||
await expect(standard).toHaveAttribute('aria-pressed', 'false');
|
||||
await expectPaint(page, shadcn, 'bg-surface-active-alt text-text-primary');
|
||||
});
|
||||
|
||||
test('Reasoning trigger keeps its look @scenario:reasoning-trigger-keeps-its-look', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route('**/api/endpoints', async (route) => {
|
||||
const response = await route.fetch();
|
||||
const endpoints = await response.json();
|
||||
endpoints['Mock Provider A'].customParams = {
|
||||
defaultParamsEndpoint: 'google',
|
||||
paramDefinitions: [
|
||||
{
|
||||
key: 'thinkingBudget',
|
||||
type: 'number',
|
||||
default: -1,
|
||||
range: { min: -1, positiveMin: 128, max: 32768, step: 128 },
|
||||
},
|
||||
],
|
||||
};
|
||||
await route.fulfill({ response, json: endpoints });
|
||||
});
|
||||
await openComposer(page);
|
||||
const response = await sendMessage(page, `E2E_SLOW_REPLY:composer-buttons-${Date.now()}`);
|
||||
expect(response.ok()).toBeTruthy();
|
||||
await expect(messagesView(page).getByText('chunk-010')).toBeVisible({ timeout: 15000 });
|
||||
|
||||
/** The popover is modal, so Radix hides its trigger from the accessibility tree while open. */
|
||||
const reasoning = page.getByRole('button', {
|
||||
name: /Reasoning for next message/i,
|
||||
includeHidden: true,
|
||||
});
|
||||
await expect(reasoning).toBeVisible();
|
||||
expect(await box(reasoning)).toEqual({
|
||||
height: 32,
|
||||
radius: '12px',
|
||||
paddingLeft: '8px',
|
||||
gap: '6px',
|
||||
fontSize: '14px',
|
||||
fontWeight: '500',
|
||||
});
|
||||
await expectPaint(page, reasoning, 'text-text-secondary');
|
||||
await reasoning.click();
|
||||
await expect(page.getByRole('spinbutton')).toBeVisible();
|
||||
await expect(reasoning).toHaveAttribute('aria-expanded', 'true');
|
||||
await expectPaint(page, reasoning, 'bg-surface-hover text-text-primary');
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(reasoning).toBeFocused();
|
||||
await expectPaint(page, reasoning, 'text-text-secondary');
|
||||
});
|
||||
});
|
||||
|
|
@ -191,11 +191,6 @@
|
|||
"count": 1
|
||||
}
|
||||
},
|
||||
"client/src/components/Chat/Input/Reasoning.tsx": {
|
||||
"design/disabled-recipe": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"client/src/components/Chat/Input/TokenUsage/Breakdown.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 10
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ type ButtonVariantOptions =
|
|||
| 'card'
|
||||
| 'disclosure'
|
||||
| 'option'
|
||||
| 'text-action'
|
||||
| 'row-content'
|
||||
| 'chip-toggle'
|
||||
| 'pill-toggle'
|
||||
| 'composer-pill'
|
||||
| 'composer-trigger'
|
||||
| 'hit-area'
|
||||
| null
|
||||
| undefined;
|
||||
size?:
|
||||
|
|
@ -227,6 +234,32 @@ const buttonVariantRecipe = cva(
|
|||
option:
|
||||
'w-full select-none justify-start gap-2.5 whitespace-normal text-left font-normal text-text-primary transition-opacity enabled:duration-500 disabled:duration-500 disabled:transition-all motion-reduce:transition-none motion-reduce:disabled:transition-none hover:bg-surface-hover hover:active:bg-surface-pressed data-[selected=true]:bg-surface-active data-[selected=true]:hover:bg-surface-active',
|
||||
card: 'justify-start whitespace-normal rounded-2xl text-left font-normal hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',
|
||||
/** A small text action in the secondary ink beside a status line, such as a failed
|
||||
* steer's Retry or a pending one's Cancel; it rises to the primary ink under the pointer. */
|
||||
'text-action':
|
||||
'rounded text-xs text-text-secondary hover:text-text-primary focus-visible:ring-offset-0',
|
||||
/** The content of a list row whose row owns the highlight, such as a composer palette
|
||||
* entry: it lays the row out and takes the pointer, and leaves fill and ink to the row. */
|
||||
'row-content':
|
||||
'flex cursor-pointer justify-start gap-2.5 px-2 text-left font-normal transition-none',
|
||||
/** An outlined chip that toggles a mode, its pressed state marked with `aria-pressed`. */
|
||||
'chip-toggle':
|
||||
'min-h-theme-target shrink-0 rounded-full border border-border-medium text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-offset-0 aria-pressed:border-transparent aria-pressed:bg-surface-active-alt aria-pressed:text-text-primary aria-pressed:hover:bg-surface-active-alt',
|
||||
/** A borderless pill that toggles a mode, lit in the accent while `aria-pressed`. */
|
||||
'pill-toggle':
|
||||
'rounded-full text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-text-primary aria-pressed:bg-accent-primary/15 aria-pressed:text-accent-primary aria-pressed:hover:bg-accent-primary/15 aria-pressed:hover:text-accent-primary',
|
||||
/** A composer pill that opens a popover with its value, such as Thinking: primary ink,
|
||||
* and kept lit while the popover it controls is expanded. */
|
||||
'composer-pill':
|
||||
'gap-1 rounded-theme-control-round font-normal text-text-primary hover:bg-surface-hover focus-visible:ring-offset-0 aria-expanded:bg-surface-hover',
|
||||
/** A composer control that opens a popover from an icon, such as the reasoning menu: it
|
||||
* rests in the secondary ink and takes the primary one while hovered or expanded. */
|
||||
'composer-trigger':
|
||||
'gap-1.5 rounded-xl text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-offset-0 aria-expanded:bg-surface-hover aria-expanded:text-text-primary',
|
||||
/** An invisible target laid over a custom-drawn control, such as a stop on a slider rail:
|
||||
* it draws only its focus ring, inside its own box. */
|
||||
'hit-area':
|
||||
'rounded-full bg-transparent focus-visible:ring-inset focus-visible:ring-offset-0',
|
||||
},
|
||||
size: {
|
||||
default: 'h-theme-button px-theme-button-x py-2',
|
||||
|
|
@ -335,6 +368,14 @@ const buttonVariantRecipe = cva(
|
|||
shape: 'unset',
|
||||
class: 'rounded-xl',
|
||||
},
|
||||
/* These carry their own box, which the default size's height and padding would otherwise win. */
|
||||
{ variant: 'text-action', size: 'default', class: 'h-auto p-0' },
|
||||
{ variant: 'row-content', size: 'default', class: 'h-auto px-2 py-0' },
|
||||
{ variant: 'chip-toggle', size: 'default', class: 'h-auto px-2 py-0.5' },
|
||||
{ variant: 'pill-toggle', size: 'default', class: 'h-auto px-2 py-0.5' },
|
||||
{ variant: 'composer-pill', size: 'default', class: 'h-theme-button-compact px-2.5 py-0' },
|
||||
{ variant: 'composer-trigger', size: 'default', class: 'h-theme-button-compact px-2 py-0' },
|
||||
{ variant: 'hit-area', size: 'default', class: 'h-auto p-0' },
|
||||
],
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue