mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-21 07:23:11 +00:00
🪄 refactor: Compose Chat Package Styles From Shared Primitive Variants (#17760)
* refactor: Compose Message Toolbar Styles From Shared Button and Label Variants * test: Cover an Open Fork Menu Holding the Message Toolbar Visible * refactor: Compose Composer File Styles From Shared Primitives * refactor: Compose Summary, Collapsible Text and Subagent Activity Styles From Shared Button Presets * fix: Draw the New Button Variants From Theme Radius and Height Roles * test: Find the Held-Open Scenario's Replies Inside the Message List * fix: Restore the Feedback Note and Fork Checkbox Looks Through Primitive Variants * refactor: Compose the Message Nav Chevrons With the Disabled Ink Recipe
This commit is contained in:
parent
6adb4899c7
commit
03f1b76db5
39 changed files with 369 additions and 438 deletions
|
|
@ -36,7 +36,6 @@ const GoogleConfig = ({ userKey, setUserKey }: Pick<TConfigProps, 'userKey' | 's
|
|||
<FileUpload
|
||||
id={AuthKeys.GOOGLE_SERVICE_KEY}
|
||||
className="w-full"
|
||||
containerClassName="bg-surface-secondary h-10 max-h-10 w-full resize-none py-2"
|
||||
text={localize('com_endpoint_config_key_import_json_key')}
|
||||
successText={localize('com_endpoint_config_key_import_json_key_success')}
|
||||
invalidText={localize('com_endpoint_config_key_import_json_key_invalid')}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ export const AssistantAvatar = ({
|
|||
|
||||
// Calculate the offset based on the loading progress
|
||||
const offset = circumference - progress * circumference;
|
||||
const circleCSSProperties = {
|
||||
transition: 'stroke-dashoffset 0.3s linear',
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -48,13 +45,7 @@ export const AssistantAvatar = ({
|
|||
width="80"
|
||||
height="80"
|
||||
/>
|
||||
{progress < 1 && (
|
||||
<ProgressCircle
|
||||
circumference={circumference}
|
||||
offset={offset}
|
||||
circleCSSProperties={circleCSSProperties}
|
||||
/>
|
||||
)}
|
||||
{progress < 1 && <ProgressCircle circumference={circumference} offset={offset} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,6 @@
|
|||
* emitting its CSS a second time. */
|
||||
@reference './style.css';
|
||||
|
||||
.hover-button.active {
|
||||
display: block;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.nav {
|
||||
position: fixed;
|
||||
z-index: 110;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
import { randomUUID } from 'crypto';
|
||||
import { expect, test } from '@playwright/test';
|
||||
import {
|
||||
MOCK_ENDPOINTS,
|
||||
NEW_CHAT_PATH,
|
||||
messagesView,
|
||||
sendMessage,
|
||||
selectMockEndpoint,
|
||||
} from '../helpers';
|
||||
import {
|
||||
REPLY_TEXT,
|
||||
createProject,
|
||||
|
|
@ -57,6 +64,48 @@ test('a mouse desktop reveals message actions on hover and keyboard focus @scena
|
|||
}
|
||||
});
|
||||
|
||||
test("an open fork menu holds an earlier reply's actions visible after the pointer leaves @scenario:mouse-desktop-open-menu-holds-actions", async ({
|
||||
page,
|
||||
}) => {
|
||||
const label = `held-${randomUUID().slice(0, 8)}`;
|
||||
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
|
||||
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
|
||||
for (const turn of ['first', 'second']) {
|
||||
expect((await sendMessage(page, `E2E_REPLY:${label}-${turn}`)).ok()).toBeTruthy();
|
||||
await expect(messagesView(page).getByText(`E2E reply ${label}-${turn}`)).toBeVisible({
|
||||
timeout: 30000,
|
||||
});
|
||||
}
|
||||
const row = page
|
||||
.locator('.message-render')
|
||||
.filter({ hasText: `E2E reply ${label}-first` })
|
||||
.last();
|
||||
const latest = page
|
||||
.locator('.message-render')
|
||||
.filter({ hasText: `E2E reply ${label}-second` })
|
||||
.last();
|
||||
const copy = row.getByTestId('copy-response-button');
|
||||
const fork = row.getByRole('button', { name: 'Open Fork Menu' });
|
||||
|
||||
await page.mouse.move(0, 0);
|
||||
await expect.poll(() => paintedOpacity(copy)).toBe(0);
|
||||
/** The latest reply's actions never fade. */
|
||||
await expect.poll(() => paintedOpacity(latest.getByTestId('copy-response-button'))).toBe(1);
|
||||
|
||||
await row.hover();
|
||||
await fork.click();
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Visible messages only', exact: true }),
|
||||
).toBeVisible();
|
||||
await page.mouse.move(0, 0);
|
||||
/** The open menu lights its trigger and keeps every action in the row opaque. */
|
||||
await expect.poll(() => paintedOpacity(copy)).toBe(1);
|
||||
await expect(fork).toHaveAttribute('data-hover-active', 'true');
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(fork).not.toHaveAttribute('data-hover-active');
|
||||
});
|
||||
|
||||
test('a mouse desktop reveals project row actions on hover and keyboard focus @scenario:mouse-desktop-project-row-actions-reveal', async ({
|
||||
page,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -1254,146 +1254,6 @@
|
|||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/CollapsibleText.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/Summary.tsx": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
},
|
||||
"shadcn/no-inline-styles": {
|
||||
"count": 1
|
||||
},
|
||||
"shadcn/no-restyle": {
|
||||
"count": 9
|
||||
},
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/EscalateNowButton.tsx": {
|
||||
"design/disabled-recipe": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/QuoteButton.tsx": {
|
||||
"shadcn/no-inline-styles": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/DragDropOverlay.tsx": {
|
||||
"shadcn/no-inline-styles": {
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/FileUpload.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 11
|
||||
},
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/ImagePreview.tsx": {
|
||||
"shadcn/no-inline-styles": {
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/PastedTextDialog.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/ProgressCircle.tsx": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
},
|
||||
"shadcn/no-inline-styles": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/composer/files/SourceIcon.tsx": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/Feedback.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 10
|
||||
},
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 3
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/Fork.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 4
|
||||
},
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/HeaderLabel.tsx": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 5
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/HoverButtons.tsx": {
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/MessageNav.tsx": {
|
||||
"design/disabled-recipe": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/MessageRow.tsx": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/MinimalHoverButtons.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 2
|
||||
},
|
||||
"shadcn/require-static-classes": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/ScrollToBottom.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/SiblingSwitch.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/messages/styles.ts": {
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/subagents/activity.tsx": {
|
||||
"design/disabled-recipe": {
|
||||
"count": 1
|
||||
},
|
||||
"shadcn/no-arbitrary-values": {
|
||||
"count": 1
|
||||
},
|
||||
"shadcn/no-restyle": {
|
||||
"count": 4
|
||||
}
|
||||
},
|
||||
"packages/chat/src/components/subagents/transcript.tsx": {
|
||||
"shadcn/no-restyle": {
|
||||
"count": 12
|
||||
}
|
||||
},
|
||||
"packages/client/src/components/Badge.tsx": {
|
||||
"design/disabled-recipe": {
|
||||
"count": 1
|
||||
|
|
|
|||
|
|
@ -84,11 +84,7 @@ export {
|
|||
getHeaderModelName,
|
||||
getHeaderHoverLabel,
|
||||
} from './components/messages/HeaderLabel';
|
||||
export {
|
||||
hoverButtonClasses,
|
||||
messageFooterClasses,
|
||||
revealOnRowHoverClasses,
|
||||
} from './components/messages/styles';
|
||||
export { messageFooterClasses, revealOnRowHoverClasses } from './components/messages/styles';
|
||||
export { getRunStepDurationLabels, getElapsedDurationLabels } from './components/messages/duration';
|
||||
export type { RunStepDurationLabels } from './components/messages/duration';
|
||||
export { default as MessageRow } from './components/messages/MessageRow';
|
||||
|
|
|
|||
|
|
@ -118,14 +118,14 @@ const CollapsibleText: NamedExoticComponent<CollapsibleTextProps> = memo(functio
|
|||
<Button
|
||||
type="button"
|
||||
variant="link"
|
||||
size="bare"
|
||||
size="bare-xs"
|
||||
onClick={() => {
|
||||
if (!expanded) onExpand?.();
|
||||
setExpanded((prev) => !prev);
|
||||
}}
|
||||
aria-expanded={expanded}
|
||||
aria-controls={contentId}
|
||||
className="mt-1 gap-1 text-xs"
|
||||
className="mt-1"
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
|
|
|
|||
|
|
@ -75,14 +75,11 @@ const SummaryButton = memo(
|
|||
return (
|
||||
<div className="group/summary flex w-full items-center justify-between gap-2">
|
||||
<Button
|
||||
variant="disclosure"
|
||||
variant="disclosure-line"
|
||||
onClick={onClick}
|
||||
aria-expanded={isExpanded}
|
||||
aria-controls={contentId}
|
||||
className={cn(
|
||||
'group/button flex-1 gap-0 rounded-lg leading-[18px] font-normal',
|
||||
fontSize,
|
||||
)}
|
||||
className="group/button flex-1"
|
||||
>
|
||||
<span className="relative mr-1.5 inline-flex h-[1.125rem] w-[1.125rem] items-center justify-center">
|
||||
<ScrollText
|
||||
|
|
@ -97,27 +94,33 @@ const SummaryButton = memo(
|
|||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
<span>{label}</span>
|
||||
<span className={fontSize}>{label}</span>
|
||||
</Button>
|
||||
{content && showCopyButton && (
|
||||
<Button
|
||||
variant="message-action"
|
||||
onClick={onCopy}
|
||||
aria-label={
|
||||
isCopied ? localize('com_ui_copied_to_clipboard') : localize('com_ui_copy_summary')
|
||||
}
|
||||
/** Revealed with the expanded summary on hover or focus, and by keyboard focus alone
|
||||
* while collapsed. */
|
||||
<span
|
||||
className={cn(
|
||||
isExpanded
|
||||
? 'opacity-0 group-focus-within/summary-container:opacity-100 group-hover/summary-container:opacity-100'
|
||||
: 'opacity-0',
|
||||
'focus-visible:opacity-100',
|
||||
'inline-flex opacity-0 has-[:focus-visible]:opacity-100',
|
||||
isExpanded &&
|
||||
'group-focus-within/summary-container:opacity-100 group-hover/summary-container:opacity-100',
|
||||
)}
|
||||
>
|
||||
<span className="sr-only">
|
||||
{isCopied ? localize('com_ui_copied_to_clipboard') : localize('com_ui_copy_summary')}
|
||||
</span>
|
||||
<MorphIcon icon={isCopied ? Check : Copy} className="h-[1.125rem] w-[1.125rem]" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="message-action"
|
||||
onClick={onCopy}
|
||||
aria-label={
|
||||
isCopied ? localize('com_ui_copied_to_clipboard') : localize('com_ui_copy_summary')
|
||||
}
|
||||
>
|
||||
<span className="sr-only">
|
||||
{isCopied
|
||||
? localize('com_ui_copied_to_clipboard')
|
||||
: localize('com_ui_copy_summary')}
|
||||
</span>
|
||||
<MorphIcon icon={isCopied ? Check : Copy} className="h-[1.125rem] w-[1.125rem]" />
|
||||
</Button>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
|
@ -294,10 +297,10 @@ const Summary: NamedExoticComponent<SummaryProps> = memo(
|
|||
role="region"
|
||||
aria-label={label}
|
||||
aria-hidden={!isExpanded || undefined}
|
||||
className={cn('grid transition-all duration-300 ease-out', isExpanded && 'mb-4')}
|
||||
style={{
|
||||
gridTemplateRows: isExpanded ? '1fr' : '0fr',
|
||||
}}
|
||||
className={cn(
|
||||
'grid transition-all duration-300 ease-out',
|
||||
isExpanded ? 'mb-4 grid-rows-[1fr]' : 'grid-rows-[0fr]',
|
||||
)}
|
||||
>
|
||||
<div className="relative overflow-hidden">
|
||||
<SummaryContent meta={meta}>{text}</SummaryContent>
|
||||
|
|
|
|||
|
|
@ -163,8 +163,14 @@ export default function EscalateNowButton({
|
|||
return (
|
||||
<Ariakit.TooltipProvider placement="top" timeout={300}>
|
||||
{/* The disabled IconButton already renders at half opacity; 70% of that
|
||||
is the 35% this control has always dimmed to. */}
|
||||
<span className={cn('transition-opacity', disabled && 'opacity-70')}>
|
||||
is the 35% this control has always dimmed to. A theme that paints a disabled
|
||||
fill draws the control at full opacity, so the wrapper stops dimming it too. */}
|
||||
<span
|
||||
className={cn(
|
||||
'theme-disabled-within:opacity-100 transition-opacity',
|
||||
disabled && 'opacity-70',
|
||||
)}
|
||||
>
|
||||
<Ariakit.TooltipAnchor
|
||||
render={
|
||||
surface === 'bubble' ? (
|
||||
|
|
|
|||
|
|
@ -343,15 +343,15 @@ function QuoteButton({ conversationId }: QuoteButtonProps): React.ReactPortal |
|
|||
return;
|
||||
}
|
||||
if (!next) {
|
||||
button.style.display = 'none';
|
||||
button.hidden = true;
|
||||
return;
|
||||
}
|
||||
const touch = String(next.viaTouch);
|
||||
if (button.dataset.touch !== touch) {
|
||||
button.dataset.touch = touch;
|
||||
}
|
||||
if (button.style.display === 'none') {
|
||||
button.style.display = 'inline-flex';
|
||||
if (button.hidden) {
|
||||
button.hidden = false;
|
||||
}
|
||||
const { width, height } = button.getBoundingClientRect();
|
||||
const maxLeft = Math.max(EDGE_MARGIN, window.innerWidth - width - EDGE_MARGIN);
|
||||
|
|
@ -629,10 +629,10 @@ function QuoteButton({ conversationId }: QuoteButtonProps): React.ReactPortal |
|
|||
onClick={addQuote}
|
||||
aria-label={localize('com_ui_add_to_chat')}
|
||||
data-testid="add-to-chat-button"
|
||||
hidden
|
||||
style={{
|
||||
top: 0,
|
||||
left: 0,
|
||||
display: 'none',
|
||||
}}
|
||||
className={cn(
|
||||
'border-border-chrome bg-surface-secondary text-text-primary hover:bg-surface-tertiary fixed z-50 inline-flex items-center gap-1.5 rounded-full border text-sm font-medium shadow-lg transition-colors',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ const DragDropOverlay: NamedExoticComponent<DragDropOverlayProps> = memo(({ isAc
|
|||
? 'pointer-events-auto visible opacity-100'
|
||||
: 'pointer-events-none invisible opacity-0'
|
||||
} `}
|
||||
style={{ willChange: 'opacity' }}
|
||||
/>
|
||||
{/** Main content overlay */}
|
||||
<div
|
||||
|
|
@ -28,8 +27,6 @@ const DragDropOverlay: NamedExoticComponent<DragDropOverlayProps> = memo(({ isAc
|
|||
} `}
|
||||
style={{
|
||||
transform: isActive ? 'scale(1)' : 'scale(0.95)',
|
||||
/** Use will-change to hint browser about upcoming changes */
|
||||
willChange: 'opacity, transform',
|
||||
}}
|
||||
>
|
||||
{/** Content area with subtle background */}
|
||||
|
|
@ -40,9 +37,9 @@ const DragDropOverlay: NamedExoticComponent<DragDropOverlayProps> = memo(({ isAc
|
|||
fill="none"
|
||||
width="132"
|
||||
height="108"
|
||||
className="transition-transform duration-200 ease-in-out"
|
||||
style={{
|
||||
transform: isActive ? 'translateY(0)' : 'translateY(-10px)',
|
||||
transition: 'transform 0.2s ease-in-out',
|
||||
}}
|
||||
>
|
||||
<g clipPath="url(#clip0_3605_64419)">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { cn, Button, useLocalize } from '@librechat/client';
|
|||
type FileUploadProps = {
|
||||
onFileSelected: (jsonData: Record<string, unknown>) => void;
|
||||
className?: string;
|
||||
containerClassName?: string;
|
||||
successText?: string;
|
||||
invalidText?: string;
|
||||
validator?: ((data: Record<string, unknown>) => boolean) | null;
|
||||
|
|
@ -16,15 +15,13 @@ type FileUploadProps = {
|
|||
const FileUpload: React.FC<FileUploadProps> = ({
|
||||
onFileSelected,
|
||||
className = '',
|
||||
containerClassName = '',
|
||||
successText = null,
|
||||
invalidText = null,
|
||||
validator = null,
|
||||
text = null,
|
||||
id = '1',
|
||||
}) => {
|
||||
const [statusColor, setStatusColor] = useState<string>('text-text-secondary');
|
||||
const [status, setStatus] = useState<null | string>(null);
|
||||
const [status, setStatus] = useState<null | 'success' | 'invalid'>(null);
|
||||
const localize = useLocalize();
|
||||
|
||||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
||||
|
|
@ -38,13 +35,11 @@ const FileUpload: React.FC<FileUploadProps> = ({
|
|||
const jsonData = JSON.parse(e.target?.result as string);
|
||||
if (validator && !validator(jsonData)) {
|
||||
setStatus('invalid');
|
||||
setStatusColor('text-text-destructive');
|
||||
return;
|
||||
}
|
||||
|
||||
if (validator) {
|
||||
setStatus('success');
|
||||
setStatusColor('text-status-success');
|
||||
}
|
||||
|
||||
onFileSelected(jsonData);
|
||||
|
|
@ -72,14 +67,10 @@ const FileUpload: React.FC<FileUploadProps> = ({
|
|||
<>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
variant="field-import"
|
||||
onClick={handleClick}
|
||||
className={cn(
|
||||
'text-text-secondary hover:bg-surface-hover hover:text-status-success focus:ring-text-primary me-1 flex h-auto cursor-pointer items-center rounded bg-transparent px-2 py-1 text-xs font-normal transition-colors',
|
||||
statusColor,
|
||||
containerClassName,
|
||||
)}
|
||||
data-status={status ?? undefined}
|
||||
className="me-1 flex w-full cursor-pointer items-center"
|
||||
aria-label={statusText}
|
||||
>
|
||||
<FileUp className="me-1 flex size-5.5 items-center stroke-1" aria-hidden="true" />
|
||||
|
|
|
|||
|
|
@ -6,13 +6,6 @@ import { cn, Button, useLocalize } from '@librechat/client';
|
|||
import ProgressCircle from './ProgressCircle';
|
||||
import SourceIcon from './SourceIcon';
|
||||
|
||||
type styleProps = {
|
||||
backgroundImage?: string;
|
||||
backgroundSize?: string;
|
||||
backgroundPosition?: string;
|
||||
backgroundRepeat?: string;
|
||||
};
|
||||
|
||||
const ImagePreview = ({
|
||||
imageBase64,
|
||||
url,
|
||||
|
|
@ -83,32 +76,15 @@ const ImagePreview = ({
|
|||
return () => document.removeEventListener('keydown', onKey);
|
||||
}, [isModalOpen, handleOpenChange]);
|
||||
|
||||
const baseStyle: styleProps = {
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
};
|
||||
|
||||
const imageUrl = imageBase64 ?? url ?? '';
|
||||
|
||||
const style: styleProps = imageUrl
|
||||
? {
|
||||
...baseStyle,
|
||||
backgroundImage: `url(${imageUrl})`,
|
||||
}
|
||||
: baseStyle;
|
||||
|
||||
if (typeof style.backgroundImage !== 'string' || style.backgroundImage.length === 0) {
|
||||
if (imageUrl.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const radius = 55;
|
||||
const circumference = 2 * Math.PI * radius;
|
||||
const offset = circumference - progress * circumference;
|
||||
const circleCSSProperties = {
|
||||
transition: 'stroke-dashoffset 0.3s linear',
|
||||
};
|
||||
|
||||
/** Keyboard users need the same expand affordance the pointer gets on hover. */
|
||||
const showExpandAffordance = isHovered || isFocused;
|
||||
|
||||
|
|
@ -122,7 +98,6 @@ const ImagePreview = ({
|
|||
'focus-visible:ring-text-primary focus-visible:ring-offset-surface-primary focus:outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',
|
||||
className,
|
||||
)}
|
||||
style={style}
|
||||
aria-label={`View ${alt} in full size`}
|
||||
aria-haspopup="dialog"
|
||||
onClick={(e) => {
|
||||
|
|
@ -135,11 +110,16 @@ const ImagePreview = ({
|
|||
onFocus={() => setIsFocused(true)}
|
||||
onBlur={() => setIsFocused(false)}
|
||||
>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt=""
|
||||
draggable={false}
|
||||
className="absolute inset-0 size-full object-cover object-center"
|
||||
/>
|
||||
{progress < 1 ? (
|
||||
<ProgressCircle
|
||||
circumference={circumference}
|
||||
offset={offset}
|
||||
circleCSSProperties={circleCSSProperties}
|
||||
aria-label={`Loading progress: ${Math.round(progress * 100)}%`}
|
||||
/>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ export default function PastedTextDialog({
|
|||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
aria-label={localize('com_ui_pasted_text_edit')}
|
||||
className="h-[65vh] max-h-[70vh] min-h-[20rem] font-mono text-xs"
|
||||
variant="code"
|
||||
className="h-[65vh] max-h-[70vh] min-h-[20rem]"
|
||||
/>
|
||||
<div className="flex justify-end gap-2 pt-4">
|
||||
<OGDialogClose asChild>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
export default function ProgressCircle({
|
||||
circumference,
|
||||
offset,
|
||||
circleCSSProperties,
|
||||
}: {
|
||||
circumference: number;
|
||||
offset: number;
|
||||
circleCSSProperties: React.CSSProperties;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className="bg-surface-media-overlay/5 text-text-on-media absolute inset-0 flex items-center justify-center">
|
||||
|
|
@ -19,7 +17,7 @@ export default function ProgressCircle({
|
|||
cy="60"
|
||||
/>
|
||||
<circle
|
||||
className="origin-[50%_50%] -rotate-90 transition-[stroke-dashoffset]"
|
||||
className="transition-stroke-dashoffset origin-[50%_50%] -rotate-90 duration-300 ease-linear"
|
||||
stroke="currentColor"
|
||||
strokeWidth="10"
|
||||
strokeDasharray={`${circumference} ${circumference}`}
|
||||
|
|
@ -28,7 +26,6 @@ export default function ProgressCircle({
|
|||
r="55"
|
||||
cx="60"
|
||||
cy="60"
|
||||
style={circleCSSProperties}
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const sourceToClassname = (): Partial<Record<string, string>> => ({
|
|||
});
|
||||
|
||||
const defaultClassName =
|
||||
'absolute inset-e-0 bottom-0 rounded-full p-[0.15rem] text-text-secondary transition-colors';
|
||||
'absolute inset-e-0 bottom-0 rounded-full p-0.5 text-text-secondary transition-colors';
|
||||
|
||||
export default function SourceIcon({
|
||||
source,
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ import {
|
|||
TooltipAnchor,
|
||||
ThumbUpIcon,
|
||||
ThumbDownIcon,
|
||||
cn,
|
||||
useLocalize,
|
||||
} from '@librechat/client';
|
||||
import type { TFeedback, TFeedbackTag } from 'librechat-data-provider';
|
||||
import type { NamedExoticComponent } from 'react';
|
||||
import { hoverButtonClasses } from './styles';
|
||||
|
||||
interface FeedbackProps {
|
||||
handleFeedback: ({ feedback }: { feedback: TFeedback | undefined }) => void;
|
||||
|
|
@ -60,16 +58,7 @@ function FeedbackOptionButton({
|
|||
const label = localize(tag.label as Parameters<typeof localize>[0]);
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="quiet"
|
||||
className={cn(
|
||||
'h-auto w-full justify-start gap-3 rounded-xl p-2 transition-colors duration-200',
|
||||
active && 'bg-surface-hover text-text-primary font-semibold',
|
||||
)}
|
||||
onClick={onClick}
|
||||
aria-label={label}
|
||||
aria-pressed={active}
|
||||
>
|
||||
<Button variant="popover-option" onClick={onClick} aria-label={label} aria-pressed={active}>
|
||||
<Icon size="1.1875rem" bold={active} aria-hidden="true" />
|
||||
<span>{label}</span>
|
||||
</Button>
|
||||
|
|
@ -152,9 +141,8 @@ function FeedbackButtons({
|
|||
store={upStore}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={buttonClasses(feedback?.rating === 'thumbsUp', isLast)}
|
||||
variant={isLast ? 'message-hover' : 'message-hover-reveal'}
|
||||
data-hover-active={feedback?.rating === 'thumbsUp' || undefined}
|
||||
onClick={handleThumbsUpClick}
|
||||
title={localize('com_ui_feedback_positive')}
|
||||
aria-pressed={feedback?.rating === 'thumbsUp'}
|
||||
|
|
@ -187,9 +175,8 @@ function FeedbackButtons({
|
|||
store={downStore}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={buttonClasses(feedback?.rating === 'thumbsDown', isLast)}
|
||||
variant={isLast ? 'message-hover' : 'message-hover-reveal'}
|
||||
data-hover-active={feedback?.rating === 'thumbsDown' || undefined}
|
||||
onClick={handleThumbsDownClick}
|
||||
title={localize('com_ui_feedback_negative')}
|
||||
aria-pressed={feedback?.rating === 'thumbsDown'}
|
||||
|
|
@ -221,9 +208,6 @@ function FeedbackButtons({
|
|||
);
|
||||
}
|
||||
|
||||
const buttonClasses = (isActive: boolean, isLast: boolean) =>
|
||||
hoverButtonClasses({ isActive, isLast });
|
||||
|
||||
function Feedback({ isLast = false, handleFeedback, feedback: initialFeedback }: FeedbackProps) {
|
||||
const localize = useLocalize();
|
||||
const [openDialog, setOpenDialog] = useState(false);
|
||||
|
|
@ -282,9 +266,8 @@ function Feedback({ isLast = false, handleFeedback, feedback: initialFeedback }:
|
|||
description={label}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={buttonClasses(true, isLast)}
|
||||
variant={isLast ? 'message-hover' : 'message-hover-reveal'}
|
||||
data-hover-active
|
||||
onClick={() => {
|
||||
if (isThumbsUp) {
|
||||
handleButtonFeedback(undefined);
|
||||
|
|
@ -320,7 +303,7 @@ function Feedback({ isLast = false, handleFeedback, feedback: initialFeedback }:
|
|||
{localize('com_ui_feedback_more_information')}
|
||||
</OGDialogTitle>
|
||||
<Textarea
|
||||
className="h-auto w-full rounded-xl p-2"
|
||||
variant="note"
|
||||
value={feedback?.text || ''}
|
||||
onChange={handleTextChange}
|
||||
rows={4}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import type { TForkConvoRequest } from 'librechat-data-provider';
|
|||
import type { TranslationKeys } from '@librechat/client';
|
||||
import type { NamedExoticComponent } from 'react';
|
||||
import { useMessagesHost } from '../../react/messages/host';
|
||||
import { hoverButtonClasses } from './styles';
|
||||
|
||||
interface PopoverButtonProps {
|
||||
children: React.ReactNode;
|
||||
|
|
@ -173,13 +172,13 @@ const CheckboxOption: React.FC<CheckboxOptionProps> = ({
|
|||
}
|
||||
onToggle(isChecked);
|
||||
}}
|
||||
className="transition duration-300 ease-in-out"
|
||||
variant="fade"
|
||||
aria-label={localize(labelKey)}
|
||||
/>
|
||||
<Label
|
||||
htmlFor={id}
|
||||
variant="secondary"
|
||||
className="hover:text-text-primary ms-2 w-auto cursor-pointer text-sm break-normal select-none"
|
||||
variant="option"
|
||||
className="ms-2 w-auto cursor-pointer text-sm break-normal select-none"
|
||||
>
|
||||
{localize(labelKey)}
|
||||
</Label>
|
||||
|
|
@ -261,8 +260,6 @@ function Fork({
|
|||
* hand-kept copy would leave the button reading as active forever. */
|
||||
const isActive = Ariakit.useStoreState(popoverStore, 'open');
|
||||
|
||||
const buttonStyle = hoverButtonClasses({ isActive, isLast });
|
||||
|
||||
const startFork = (request: TForkConvoRequest) => {
|
||||
if (forkConversation == null) {
|
||||
return;
|
||||
|
|
@ -346,9 +343,8 @@ function Fork({
|
|||
store={popoverStore}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={buttonStyle}
|
||||
variant={isLast ? 'message-hover' : 'message-hover-reveal'}
|
||||
data-hover-active={isActive || undefined}
|
||||
onClick={(e) => {
|
||||
if (rememberGlobal) {
|
||||
e.preventDefault();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export function getHeaderHoverLabel(
|
|||
* keyboard focus that reveals all three lands them together instead of staggering
|
||||
* across the card-resize spring this used to borrow. */
|
||||
const labelSlot =
|
||||
'[grid-area:1/1] truncate transition-[opacity,transform,filter] duration-theme-normal ease-out motion-reduce:transition-none motion-reduce:transform-none motion-reduce:blur-none';
|
||||
'[grid-area:1/1] truncate transition-crossfade duration-theme-normal ease-out motion-reduce:transition-none motion-reduce:transform-none motion-reduce:blur-none';
|
||||
|
||||
/** Provider name that crossfades to the model name. A pointer swaps it on the
|
||||
* label itself; keyboard focus landing on the message row swaps it too, so a
|
||||
|
|
@ -49,7 +49,7 @@ const labelSlot =
|
|||
* screen readers that never move the visual focus at all.
|
||||
*
|
||||
* The focus condition is the row-wide one documented on
|
||||
* `revealOnRowHoverClasses` in `../styles`: the row itself or a descendant
|
||||
* `revealOnRowHoverClasses` in `@librechat/client`: the row itself or a descendant
|
||||
* that is not a text-entry control. Both halves matter here for the same
|
||||
* reasons they matter to the timestamp and the footer actions. */
|
||||
export default function HeaderLabel({ label, hoverLabel }: HeaderLabelProps): ReactElement {
|
||||
|
|
@ -64,10 +64,10 @@ export default function HeaderLabel({ label, hoverLabel }: HeaderLabelProps): Re
|
|||
<span
|
||||
className={cn(
|
||||
labelSlot,
|
||||
'group-hover/label:-translate-y-1 group-hover/label:opacity-0 group-hover/label:blur-[2px]',
|
||||
'group-hover/label:blur-crossfade group-hover/label:-translate-y-1 group-hover/label:opacity-0',
|
||||
'group-focus-visible:-translate-y-1 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:-translate-y-1',
|
||||
'group-focus-visible:opacity-0 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:opacity-0',
|
||||
'group-focus-visible:blur-[2px] group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:blur-[2px]',
|
||||
'group-focus-visible:blur-crossfade group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:blur-crossfade',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
|
|
@ -76,7 +76,7 @@ export default function HeaderLabel({ label, hoverLabel }: HeaderLabelProps): Re
|
|||
aria-hidden="true"
|
||||
className={cn(
|
||||
labelSlot,
|
||||
'translate-y-1 opacity-0 blur-[2px]',
|
||||
'blur-crossfade translate-y-1 opacity-0',
|
||||
'group-hover/label:translate-y-0 group-hover/label:opacity-100 group-hover/label:blur-none',
|
||||
'group-focus-visible:translate-y-0 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:translate-y-0',
|
||||
'group-focus-visible:opacity-100 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:opacity-100',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import React, { useState, useMemo, useCallback, useContext, memo } from 'react';
|
|||
import { Copy, Check } from 'lucide';
|
||||
import { getSpeechText, findMessageById, isUserInitiatedCompaction } from 'librechat-data-provider';
|
||||
import {
|
||||
cn,
|
||||
Button,
|
||||
EditIcon,
|
||||
MorphIcon,
|
||||
|
|
@ -17,7 +16,6 @@ import { MessageAudioSlot, useMessagesHost } from '../../react/messages/host';
|
|||
import useGenerationsByLatest from '../../react/messages/generations';
|
||||
import { hasEditablePart } from '../../core/parts/editableParts';
|
||||
import { ChatContext } from '../../react/chat/context';
|
||||
import { hoverButtonClasses } from './styles';
|
||||
import Feedback from './Feedback';
|
||||
import Fork from './Fork';
|
||||
|
||||
|
|
@ -47,8 +45,8 @@ type HoverButtonProps = {
|
|||
icon: React.ReactNode;
|
||||
isActive?: boolean;
|
||||
isLast?: boolean;
|
||||
className?: string;
|
||||
buttonStyle?: string;
|
||||
/** Fades the button in with its row; the latest message's toolbar stays visible. */
|
||||
reveal?: boolean;
|
||||
dataTestId?: string;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
|
@ -61,23 +59,20 @@ const HoverButton = memo(
|
|||
icon,
|
||||
isActive = false,
|
||||
isLast = false,
|
||||
className = '',
|
||||
reveal = !isLast,
|
||||
dataTestId,
|
||||
disabled = false,
|
||||
}: HoverButtonProps) => {
|
||||
const buttonStyle = hoverButtonClasses({ isActive, isLast, className });
|
||||
|
||||
return (
|
||||
<TooltipAnchor
|
||||
description={title}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
variant={reveal ? 'message-hover-reveal' : 'message-hover'}
|
||||
id={id}
|
||||
data-testid={dataTestId}
|
||||
data-hover-active={isActive || undefined}
|
||||
aria-label={title}
|
||||
className={buttonStyle}
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
>
|
||||
|
|
@ -226,10 +221,7 @@ const HoverButtons = ({
|
|||
icon={<MorphIcon icon={isCopied ? Check : Copy} size="1.1875rem" />}
|
||||
isLast={isLast}
|
||||
disabled={!canCopy}
|
||||
className={cn(
|
||||
'ms-0 flex items-center gap-1.5 text-xs',
|
||||
isSubmitting && isCreatedByUser ? 'no-touch:opacity-0 group-hover:opacity-100' : '',
|
||||
)}
|
||||
reveal={!isLast || (isSubmitting && isCreatedByUser)}
|
||||
dataTestId={!isCreatedByUser ? 'copy-response-button' : undefined}
|
||||
/>
|
||||
)}
|
||||
|
|
@ -243,7 +235,6 @@ const HoverButtons = ({
|
|||
icon={<EditIcon size="19" />}
|
||||
isActive={isEditing}
|
||||
isLast={isLast}
|
||||
className={isCreatedByUser ? '' : 'active'}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
@ -272,7 +263,6 @@ const HoverButtons = ({
|
|||
icon={<RegenerateIcon size="19" />}
|
||||
isLast={isLast}
|
||||
dataTestId={isLast ? 'regenerate-generation-button' : undefined}
|
||||
className="active"
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
@ -284,7 +274,6 @@ const HoverButtons = ({
|
|||
icon={<ContinueIcon className="size-4.75" />}
|
||||
isLast={isLast}
|
||||
dataTestId={isLast ? 'continue-generation-button' : undefined}
|
||||
className="active"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { memo, useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|||
import { createPortal } from 'react-dom';
|
||||
import { ChevronUp, ChevronDown } from 'lucide-react';
|
||||
import { ContentTypes } from 'librechat-data-provider';
|
||||
import { cn, pxToRem, useLocalize, useRemScale } from '@librechat/client';
|
||||
import { cn, pxToRem, useLocalize, useRemScale, disabledInkClasses } from '@librechat/client';
|
||||
import type { TMessage, TMessageContentParts } from 'librechat-data-provider';
|
||||
import type { TranslationKeys } from '@librechat/client';
|
||||
import { parseWakeupMessage } from '../../core/parts/wakeup';
|
||||
|
|
@ -356,14 +356,17 @@ const MessageIndicator = memo(function MessageIndicator({
|
|||
);
|
||||
});
|
||||
|
||||
const chevronButtonClasses = [
|
||||
'-me-1 rounded-md p-0.5 text-text-tertiary opacity-40 transition-[color,opacity] duration-300 high-contrast:opacity-50',
|
||||
'group-hover/nav:text-text-secondary group-hover/nav:opacity-100',
|
||||
'group-focus-within/nav:text-text-secondary group-focus-within/nav:opacity-100',
|
||||
'group-hover/nav:hover:text-text-primary',
|
||||
'group-hover/nav:disabled:opacity-30 group-focus-within/nav:disabled:opacity-30',
|
||||
'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-xheavy',
|
||||
].join(' ');
|
||||
/** Built on call: this module must not read `@librechat/client` while it loads. */
|
||||
const chevronButtonClasses = (): string =>
|
||||
cn(
|
||||
'-me-1 rounded-md p-0.5 text-text-tertiary opacity-40 transition-reveal duration-300 high-contrast:opacity-50',
|
||||
'group-hover/nav:text-text-secondary group-hover/nav:opacity-100',
|
||||
'group-focus-within/nav:text-text-secondary group-focus-within/nav:opacity-100',
|
||||
'group-hover/nav:hover:text-text-primary',
|
||||
'group-hover/nav:disabled:opacity-30 group-focus-within/nav:disabled:opacity-30',
|
||||
'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-xheavy',
|
||||
disabledInkClasses,
|
||||
);
|
||||
|
||||
function MessageNav({
|
||||
scrollableRef,
|
||||
|
|
@ -1625,7 +1628,7 @@ function MessageNav({
|
|||
type="button"
|
||||
onClick={jumpToPrevious}
|
||||
disabled={!canGoUp}
|
||||
className={chevronButtonClasses}
|
||||
className={chevronButtonClasses()}
|
||||
aria-label={localize('com_ui_message_nav_previous')}
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
|
|
@ -1715,7 +1718,7 @@ function MessageNav({
|
|||
type="button"
|
||||
onClick={jumpToNext}
|
||||
disabled={!canGoDown}
|
||||
className={chevronButtonClasses}
|
||||
className={chevronButtonClasses()}
|
||||
aria-label={localize('com_ui_message_nav_next')}
|
||||
>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ export default function MessageRow({
|
|||
role="group"
|
||||
aria-label={ariaLabel}
|
||||
className={cn(
|
||||
'message-render group font-theme-ui duration-theme-normal mx-auto flex min-w-0 flex-1 transition-[max-width] motion-reduce:transition-none',
|
||||
'message-render group font-theme-ui duration-theme-normal transition-max-width mx-auto flex min-w-0 flex-1 motion-reduce:transition-none',
|
||||
'focus-visible:ring-text-primary focus-visible:ring-2 focus-visible:outline-hidden',
|
||||
isUserSide ? 'justify-end' : 'items-start',
|
||||
widthClass,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { useState } from 'react';
|
||||
import { Copy, Check } from 'lucide';
|
||||
import { cn, Button, MorphIcon, useLocalize, TooltipAnchor } from '@librechat/client';
|
||||
import { Button, MorphIcon, useLocalize, TooltipAnchor } from '@librechat/client';
|
||||
import type { TMessage, SearchResultData } from 'librechat-data-provider';
|
||||
import type { ReactNode } from 'react';
|
||||
import type { MarkdownVariant } from '../../react/messages/host';
|
||||
import { useMessagesHost } from '../../react/messages/host';
|
||||
import { revealOnRowHoverClasses } from './styles';
|
||||
|
||||
type THoverButtons = {
|
||||
message: TMessage;
|
||||
|
|
@ -32,13 +31,12 @@ export default function MinimalHoverButtons({
|
|||
}
|
||||
render={
|
||||
<Button
|
||||
variant="message-action"
|
||||
variant="message-hover-reveal"
|
||||
aria-label={
|
||||
isCopied
|
||||
? localize('com_ui_copied_to_clipboard')
|
||||
: localize('com_ui_copy_to_clipboard')
|
||||
}
|
||||
className={cn('ms-0 flex items-center gap-1.5 text-xs', revealOnRowHoverClasses)}
|
||||
disabled={!canCopy}
|
||||
onClick={() => copyToClipboard(setIsCopied)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ const ScrollToBottom: ForwardRefExoticComponent<Props & RefAttributes<HTMLDivEle
|
|||
aria-label={localize('com_ui_scroll_to_bottom')}
|
||||
className={cn(
|
||||
'me-2 active:scale-[0.96] motion-reduce:active:scale-100',
|
||||
/* The wrapper owns the fade, so being briefly unreachable must not
|
||||
dim the control on its way in on top of it. */
|
||||
'disabled:opacity-100',
|
||||
interactive ? 'pointer-events-auto' : 'pointer-events-none',
|
||||
)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ export default function SiblingSwitch({
|
|||
setSiblingIdx?.(siblingIdx + 1);
|
||||
};
|
||||
|
||||
const buttonStyle = cn(
|
||||
'hover-button',
|
||||
'group-hover:visible group-focus-visible:visible group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:visible group-[.final-completion]:visible',
|
||||
);
|
||||
|
||||
return siblingCount > 1 ? (
|
||||
<nav
|
||||
className={cn(
|
||||
|
|
@ -46,7 +41,6 @@ export default function SiblingSwitch({
|
|||
>
|
||||
<Button
|
||||
variant="message-action"
|
||||
className={buttonStyle}
|
||||
onClick={previous}
|
||||
disabled={siblingIdx == 0}
|
||||
aria-label={localize('com_ui_previous_sibling')}
|
||||
|
|
@ -66,7 +60,6 @@ export default function SiblingSwitch({
|
|||
</span>
|
||||
<Button
|
||||
variant="message-action"
|
||||
className={buttonStyle}
|
||||
onClick={next}
|
||||
disabled={siblingIdx == siblingCount - 1}
|
||||
aria-label={localize('com_ui_next_sibling')}
|
||||
|
|
|
|||
|
|
@ -838,6 +838,8 @@ describe('MessageNav', () => {
|
|||
'button[aria-label="com_ui_message_nav_previous"]',
|
||||
) as HTMLButtonElement;
|
||||
expect(prev.disabled).toBe(true);
|
||||
/** A theme that paints disabled controls draws it in the disabled ink at full opacity. */
|
||||
expect(prev).toHaveClass('theme-disabled:opacity-100', 'theme-disabled:text-text-disabled');
|
||||
/** And the origin rib reads as reached, not as somewhere still to go. */
|
||||
const origin = container.querySelector('[data-msg-id="messages-start"] span');
|
||||
expect(origin?.className).not.toContain('bg-text-tertiary');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { hoverButtonClasses, revealOnRowHoverClasses } from '../styles';
|
||||
import { cn, buttonVariants } from '@librechat/client';
|
||||
import { revealOnRowHoverClasses } from '../styles';
|
||||
|
||||
const FADE = 'no-touch:opacity-0';
|
||||
|
||||
|
|
@ -49,46 +50,52 @@ describe('revealOnRowHoverClasses', () => {
|
|||
would replace the `transition-colors` a `Button` contributes and the hover
|
||||
tint would snap. The colour properties have to ride along explicitly. */
|
||||
it('names the colour properties alongside opacity', () => {
|
||||
expect(revealOnRowHoverClasses).toContain('transition-[opacity,color,background-color]');
|
||||
expect(revealOnRowHoverClasses).toContain('transition-reveal');
|
||||
expect(revealOnRowHoverClasses).not.toContain('transition-opacity');
|
||||
});
|
||||
|
||||
it('keeps the colour fade when merged onto a Button', () => {
|
||||
const merged = cn(buttonVariants({ variant: 'message-hover-reveal' }));
|
||||
expect(merged).toContain('transition-reveal');
|
||||
expect(merged).not.toContain('transition-colors');
|
||||
});
|
||||
});
|
||||
|
||||
describe('hoverButtonClasses', () => {
|
||||
describe('message hover buttons', () => {
|
||||
const idle = buttonVariants({ variant: 'message-hover-reveal' });
|
||||
const last = buttonVariants({ variant: 'message-hover' });
|
||||
|
||||
it('fades an idle action out until the row is hovered', () => {
|
||||
expect(hoverButtonClasses()).toContain(FADE);
|
||||
expect(hoverButtonClasses()).toContain('group-hover:opacity-100');
|
||||
expect(idle).toContain(FADE);
|
||||
expect(idle).toContain('group-hover:opacity-100');
|
||||
});
|
||||
|
||||
it('reveals an idle action on keyboard focus, not on a click parking focus in the row', () => {
|
||||
expect(hoverButtonClasses()).toContain(`${FOCUS_DESCENDANT}:opacity-100`);
|
||||
expect(hoverButtonClasses()).not.toContain('group-focus-within:');
|
||||
expect(idle).toContain(`${FOCUS_DESCENDANT}:opacity-100`);
|
||||
expect(idle).not.toContain('group-focus-within:');
|
||||
});
|
||||
|
||||
it('marks an active action so the toolbar can key off it', () => {
|
||||
expect(hoverButtonClasses({ isActive: true })).toContain('hover-button-active');
|
||||
expect(hoverButtonClasses({ isActive: true })).toContain('active');
|
||||
expect(idle).toContain('data-[hover-active]:bg-surface-hover');
|
||||
expect(idle).toContain('data-[hover-active]:text-text-primary');
|
||||
});
|
||||
|
||||
it('keeps every action opaque while any of them is active', () => {
|
||||
expect(hoverButtonClasses()).toContain('group-has-[.hover-button-active]:opacity-100');
|
||||
expect(hoverButtonClasses({ isActive: true })).toContain(
|
||||
'group-has-[.hover-button-active]:opacity-100',
|
||||
);
|
||||
expect(hoverButtonClasses({ isLast: true })).toContain(
|
||||
'group-has-[.hover-button-active]:opacity-100',
|
||||
);
|
||||
expect(idle).toContain('group-has-[[data-hover-active]]:opacity-100');
|
||||
expect(last).toContain('group-has-[[data-hover-active]]:opacity-100');
|
||||
});
|
||||
|
||||
it('does not use the legacy active class as the marker', () => {
|
||||
expect(hoverButtonClasses()).not.toContain('group-has-[.active]');
|
||||
expect(idle).not.toContain('group-has-[.active]');
|
||||
expect(last).not.toContain('group-has-[.active]');
|
||||
});
|
||||
|
||||
it('never fades the actions on the last row', () => {
|
||||
expect(hoverButtonClasses({ isLast: true })).not.toContain(FADE);
|
||||
expect(last).not.toContain(FADE);
|
||||
});
|
||||
|
||||
it('appends caller classes', () => {
|
||||
expect(hoverButtonClasses({ className: 'ml-0' })).toContain('ml-0');
|
||||
it('keeps the marker the narrow-screen stylesheet reads', () => {
|
||||
expect(idle).toContain('hover-button');
|
||||
expect(last).toContain('hover-button');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,41 +1,5 @@
|
|||
import { cn } from '@librechat/client';
|
||||
/**
|
||||
* Reveal-on-hover for a control that shares the message footer with the hover actions.
|
||||
*
|
||||
* Pointer devices fade it out until the row is hovered or keyboard focus lands inside
|
||||
* it. Touch devices, which cannot hover, keep it visible.
|
||||
*
|
||||
* The focus half is `:focus-visible`, not `:focus-within`: clicking a tool card or an
|
||||
* expand toggle in the message body leaves focus parked there, and `:focus-within`
|
||||
* would hold the whole footer open with the pointer nowhere near the row. An action
|
||||
* that opens a surface keeps the toolbar up through `hover-button-active` instead.
|
||||
*
|
||||
* That focus half reads
|
||||
* `:is(:focus-visible, :has(:focus-visible:not(:is(input, textarea, [contenteditable]))))`
|
||||
* on the row, and both halves earn their keep:
|
||||
*
|
||||
* - The row itself has to be tested, not only its descendants. `MessageNav` moves the
|
||||
* reader by setting `tabindex="-1"` on the row and focusing it, and `:has()` never
|
||||
* matches its own subject, so a plain `:has(:focus-visible)` leaves a focused row
|
||||
* showing its focus ring with its metadata and its actions still hidden.
|
||||
* - Text-entry controls are excluded from the descendant half, because they match
|
||||
* `:focus-visible` even when a mouse clicks them. `ToolApproval` and
|
||||
* `AskUserQuestion` both render textareas inside a row, and without the exclusion
|
||||
* clicking one pins the row open with the pointer somewhere else entirely. Every
|
||||
* toolbar action is a button, so a keyboard user still never focuses a hidden one.
|
||||
*
|
||||
* The two halves stay two variants on purpose. Folding them into a single
|
||||
* `group-[&:is(...)]` makes Tailwind emit a bare `.group$ { opacity: 1 }` rule, which
|
||||
* lightningcss rejects and which fails the production CSS build while leaving `jest`
|
||||
* and `tsc` perfectly green.
|
||||
*
|
||||
* The transition names `color` and `background-color` alongside `opacity` rather than
|
||||
* naming opacity alone: `cn` merges the whole `transition-*` group, so a bare
|
||||
* `transition-opacity` here would replace the `transition-colors` a `Button` brings and
|
||||
* the hover tint would snap instead of fading.
|
||||
*/
|
||||
export const revealOnRowHoverClasses =
|
||||
'transition-[opacity,color,background-color] duration-theme-normal ease-out group-hover:opacity-100 group-focus-visible:opacity-100 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:opacity-100 motion-reduce:transition-none no-touch:opacity-0';
|
||||
/** The shared reveal recipe; its reasoning is documented where it is defined. */
|
||||
export { revealOnRowHoverClasses } from '@librechat/client';
|
||||
|
||||
/**
|
||||
* The message footer, holding the height of its action row.
|
||||
|
|
@ -48,38 +12,3 @@ export const revealOnRowHoverClasses =
|
|||
* 19px icon.
|
||||
*/
|
||||
export const messageFooterClasses = 'min-h-[1.9375rem] text-xs';
|
||||
|
||||
type HoverButtonStyleOptions = {
|
||||
isActive?: boolean;
|
||||
isLast?: boolean;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shared appearance for the message hover actions.
|
||||
*
|
||||
* The actions fade in with the row on pointer devices. When a button opens a
|
||||
* surface (the editor, the fork popover, a submitted rating) it reports
|
||||
* `isActive`, and the whole toolbar stays opaque for as long as that surface is
|
||||
* open, so the pointer can leave the row without the actions vanishing out from
|
||||
* under whatever it opened.
|
||||
*
|
||||
* The marker is deliberately not the legacy `active` class: `HoverButtons`
|
||||
* pins that one to the edit button of every assistant message, which would
|
||||
* hold the entire toolbar open on every assistant row.
|
||||
*/
|
||||
export const hoverButtonClasses = ({
|
||||
isActive = false,
|
||||
isLast = false,
|
||||
className,
|
||||
}: HoverButtonStyleOptions = {}): string =>
|
||||
cn(
|
||||
'hover-button size-auto rounded-lg p-1.5 text-text-secondary-alt',
|
||||
'hover:text-text-primary hover:bg-surface-hover',
|
||||
'group-hover:visible group-focus-visible:visible group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:visible group-[.final-completion]:visible',
|
||||
!isLast && revealOnRowHoverClasses,
|
||||
'group-has-[.hover-button-active]:visible group-has-[.hover-button-active]:opacity-100',
|
||||
'focus-visible:ring-2 focus-visible:ring-text-primary focus-visible:outline-hidden',
|
||||
isActive && 'hover-button-active active text-text-primary bg-surface-hover',
|
||||
className,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useCallback, useId, useMemo, useState } from 'react';
|
||||
import { Bot, ChevronDown } from 'lucide-react';
|
||||
import { Button, cn, useLocalize } from '@librechat/client';
|
||||
import { Button, cn, useLocalize, disabledInkClasses } from '@librechat/client';
|
||||
import type { ParentSubagentSummary } from 'librechat-data-provider';
|
||||
import type { ReactNode } from 'react';
|
||||
import {
|
||||
|
|
@ -71,7 +71,7 @@ export function EventSubagentActivityGroup({
|
|||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'duration-theme-normal mx-auto min-w-0 flex-1 px-4 transition-[max-width] motion-reduce:transition-none sm:px-0',
|
||||
'duration-theme-normal transition-max-width mx-auto min-w-0 flex-1 px-4 motion-reduce:transition-none sm:px-0',
|
||||
getMessageRowWidthClass({ fullWidth, hasParallelContent }),
|
||||
)}
|
||||
>
|
||||
|
|
@ -155,13 +155,13 @@ function EventSubagentRows({
|
|||
data-event-subagent-conversation={conversationId}
|
||||
>
|
||||
<Button
|
||||
variant="quiet"
|
||||
variant="disclosure-panel"
|
||||
type="button"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
aria-expanded={expanded}
|
||||
aria-controls={panelId}
|
||||
aria-label={`${localize('com_ui_subagent_activity')}: ${summary}`}
|
||||
className="focus-visible:ring-ring-primary flex h-auto min-h-10 w-full items-center justify-start px-3 text-start focus-visible:ring-offset-0 focus-visible:ring-inset"
|
||||
className="flex min-h-10 items-center"
|
||||
>
|
||||
<Bot size={15} className="shrink-0" aria-hidden="true" />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium">{summary}</span>
|
||||
|
|
@ -207,7 +207,7 @@ function EventSubagentRow({
|
|||
data-subagent-part-index="0"
|
||||
className={cn(
|
||||
'focus-visible:ring-ring-primary flex w-full items-center gap-2 px-3 py-2 text-start text-sm focus-visible:ring-2 focus-visible:outline-hidden focus-visible:ring-inset',
|
||||
canOpen ? 'hover:bg-surface-hover' : 'cursor-default opacity-70',
|
||||
canOpen ? 'hover:bg-surface-hover' : cn('cursor-default opacity-70', disabledInkClasses),
|
||||
)}
|
||||
>
|
||||
<span className="flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-full">
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ function SubagentControlHistory({
|
|||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 shrink-0 px-2 text-xs"
|
||||
size="xs"
|
||||
className="shrink-0"
|
||||
onClick={() => onCancelControl(control.controlId as string)}
|
||||
>
|
||||
{localize('com_ui_subagent_control_withdraw')}
|
||||
|
|
@ -390,14 +390,13 @@ function SubagentPrompt({ prompt }: { prompt: string }) {
|
|||
{localize('com_ui_prompt')}
|
||||
</h3>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
variant="quiet"
|
||||
size="compact"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
aria-controls={contentId}
|
||||
aria-expanded={expanded}
|
||||
aria-label={toggleLabel}
|
||||
title={toggleLabel}
|
||||
className="text-text-secondary hover:bg-surface-tertiary focus:ring-text-primary h-8 gap-1.5 rounded-md px-2 text-xs font-medium transition focus:ring-2"
|
||||
>
|
||||
{expanded ? <Minimize2 size={14} aria-hidden /> : <Maximize2 size={14} aria-hidden />}
|
||||
<span className="hidden sm:inline">{toggleLabel}</span>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { ClassProp } from 'class-variance-authority/types';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { disabledFillClasses } from '~/utils/theme';
|
||||
import { disabledFillClasses, revealOnRowHoverClasses } from '~/utils/theme';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
type ButtonVariantOptions =
|
||||
|
|
@ -24,6 +24,9 @@ type ButtonVariantOptions =
|
|||
| 'ghost'
|
||||
| 'quiet'
|
||||
| 'message-action'
|
||||
| 'message-hover'
|
||||
| 'message-hover-reveal'
|
||||
| 'popover-option'
|
||||
| 'inline-link'
|
||||
| 'carousel-nav'
|
||||
| 'toolbar'
|
||||
|
|
@ -37,6 +40,8 @@ type ButtonVariantOptions =
|
|||
| 'inline-edit'
|
||||
| 'card'
|
||||
| 'disclosure'
|
||||
| 'disclosure-line'
|
||||
| 'disclosure-panel'
|
||||
| 'option'
|
||||
| 'text-action'
|
||||
| 'hint'
|
||||
|
|
@ -46,6 +51,7 @@ type ButtonVariantOptions =
|
|||
| 'composer-pill'
|
||||
| 'composer-trigger'
|
||||
| 'hit-area'
|
||||
| 'field-import'
|
||||
| null
|
||||
| undefined;
|
||||
size?:
|
||||
|
|
@ -64,6 +70,7 @@ type ButtonVariantOptions =
|
|||
| 'wide'
|
||||
| 'snug'
|
||||
| 'bare'
|
||||
| 'bare-xs'
|
||||
| 'theme'
|
||||
| 'row'
|
||||
| 'tile'
|
||||
|
|
@ -73,6 +80,17 @@ type ButtonVariantOptions =
|
|||
} & ClassProp)
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* A button in the hover toolbar under a message (copy, edit, fork, rate): a small padded square in
|
||||
* the alt secondary ink. `data-hover-active` marks a button whose surface (the editor, the fork
|
||||
* popover, a rating) is open; it lights that button and holds the whole toolbar opaque until the
|
||||
* surface closes, so the pointer can leave the row without the actions vanishing from under it.
|
||||
* The marker is not the legacy `active` class, which other toolbar buttons carry at rest.
|
||||
* `hover-button` is the marker the app's narrow-screen stylesheet keeps visible.
|
||||
*/
|
||||
const messageHoverClasses =
|
||||
'hover-button size-auto rounded-lg p-1.5 text-text-secondary-alt hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary focus-visible:ring-text-primary group-has-[[data-hover-active]]:opacity-100 data-[hover-active]:bg-surface-hover data-[hover-active]:text-text-primary';
|
||||
|
||||
const buttonVariantRecipe = cva(
|
||||
[
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-theme-control ring-offset-surface-primary transition-colors duration-theme-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
||||
|
|
@ -97,10 +115,11 @@ const buttonVariantRecipe = cva(
|
|||
/**
|
||||
* A control floating over scrolling content, such as the scroll-to-bottom chip. A theme that
|
||||
* draws no chrome outline gives it an opaque fill and a lift instead, so it never reads as a
|
||||
* bare glyph over the thread.
|
||||
* bare glyph over the thread. Its own enter and exit own its visibility, and it is
|
||||
* disabled only while that runs, so being disabled never dims it on top of the fade.
|
||||
*/
|
||||
floating:
|
||||
'border border-border-chrome bg-surface-chat/90 text-text-primary hover:bg-surface-hover hover:active:bg-surface-pressed theme-chrome-quiet:bg-surface-chat theme-chrome-quiet:shadow-md theme-chrome-quiet:hover:bg-surface-hover theme-chrome-quiet:hover:active:bg-surface-pressed',
|
||||
'disabled:opacity-100 border border-border-chrome bg-surface-chat/90 text-text-primary hover:bg-surface-hover hover:active:bg-surface-pressed theme-chrome-quiet:bg-surface-chat theme-chrome-quiet:shadow-md theme-chrome-quiet:hover:bg-surface-hover theme-chrome-quiet:hover:active:bg-surface-pressed',
|
||||
/** An outlined filter whose pressed state stays visible between activations. */
|
||||
'outline-toggle':
|
||||
'text-text-primary border border-border-control bg-transparent transition-none hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary aria-pressed:border-border-heavy aria-pressed:bg-surface-active-alt aria-pressed:hover:bg-surface-active-alt',
|
||||
|
|
@ -126,6 +145,15 @@ const buttonVariantRecipe = cva(
|
|||
/** An icon action under a message: a small padded square that rests in the alt secondary ink. */
|
||||
'message-action':
|
||||
'size-auto rounded-lg p-1.5 text-text-secondary-alt hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary',
|
||||
/** A message toolbar action that stays visible, such as the latest message's. */
|
||||
'message-hover': messageHoverClasses,
|
||||
/** A message toolbar action that fades in with its row; see `revealOnRowHoverClasses`. */
|
||||
'message-hover-reveal': `${messageHoverClasses} ${revealOnRowHoverClasses}`,
|
||||
/** An entry in a small action popover, such as a rating's reasons: it rests in the
|
||||
* secondary ink, and the chosen entry, marked with `aria-pressed`, keeps the hover fill
|
||||
* in the primary ink at semibold weight. */
|
||||
'popover-option':
|
||||
'w-full justify-start gap-3 rounded-xl text-text-secondary duration-theme-normal hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary aria-pressed:bg-surface-hover aria-pressed:font-semibold aria-pressed:text-text-primary',
|
||||
/** A text action that reads as a link in a list or footer: no fill at rest or under the pointer,
|
||||
* and a ring flush against the control. */
|
||||
'inline-link':
|
||||
|
|
@ -221,6 +249,16 @@ const buttonVariantRecipe = cva(
|
|||
*/
|
||||
disclosure:
|
||||
'w-full justify-start focus-visible:ring-focus-subtle focus-visible:ring-offset-0 disabled:opacity-100',
|
||||
/** A disclosure that reads as one line of body text, such as a compacted summary's
|
||||
* header: normal weight on an 18px line, its glyph slot spacing itself, and the default
|
||||
* corner so its focus ring stays rounded. */
|
||||
/** The header row of a bordered panel that folds the panel's body open, such as a turn's
|
||||
* subagent activity: the quiet ink rising to primary with a hover fill, and the control
|
||||
* focus ring inset in the row because it sits flush against the panel's edge. */
|
||||
'disclosure-panel':
|
||||
'w-full justify-start text-start text-text-secondary hover:bg-surface-hover hover:active:bg-surface-pressed hover:text-text-primary focus-visible:ring-focus-control focus-visible:ring-inset focus-visible:ring-offset-0',
|
||||
'disclosure-line':
|
||||
'w-full justify-start gap-0 font-normal leading-4.5 focus-visible:ring-focus-subtle focus-visible:ring-offset-0 disabled:opacity-100',
|
||||
/**
|
||||
* A full-width answer row in an option list, such as the choices of an
|
||||
* `ask_user_question`. The fill follows the pointer instantly rather than
|
||||
|
|
@ -265,6 +303,11 @@ const buttonVariantRecipe = cva(
|
|||
* 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',
|
||||
/** A field-height control that fills a value by importing a file, such as a service
|
||||
* account key: a quiet field in the secondary ink that turns to the success ink under the
|
||||
* pointer, and reports the import's outcome through `data-status`. */
|
||||
'field-import':
|
||||
'rounded-sm bg-surface-secondary text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-status-success focus-visible:ring-text-primary data-[status=invalid]:text-text-destructive data-[status=success]:text-status-success',
|
||||
},
|
||||
size: {
|
||||
default: 'h-theme-button px-theme-button-x py-2',
|
||||
|
|
@ -290,6 +333,9 @@ const buttonVariantRecipe = cva(
|
|||
snug: 'h-theme-button p-1',
|
||||
/** Sized by its own text with no pad, for an action set inside a sentence. */
|
||||
bare: 'h-auto p-0',
|
||||
/** `bare` at the small text size with a tight gap, for an inline toggle beside its glyph
|
||||
* such as a clipped text's Show more. */
|
||||
'bare-xs': 'h-auto gap-1 p-0 text-xs',
|
||||
icon: 'size-theme-button',
|
||||
'icon-sm': 'size-theme-icon-button-sm p-0',
|
||||
'icon-xs': 'size-theme-button-xs',
|
||||
|
|
@ -339,6 +385,12 @@ const buttonVariantRecipe = cva(
|
|||
},
|
||||
/* These carry their own box, which the default size's height and padding would otherwise win. */
|
||||
{ variant: 'message-action', size: 'default', class: 'size-auto p-1.5' },
|
||||
{
|
||||
variant: ['message-hover', 'message-hover-reveal'],
|
||||
size: 'default',
|
||||
class: 'size-auto p-1.5',
|
||||
},
|
||||
{ variant: 'popover-option', size: 'default', class: 'h-auto p-2' },
|
||||
{ variant: 'inline-link', size: 'default', class: 'h-auto p-0' },
|
||||
{ variant: 'carousel-nav', size: 'default', class: 'h-auto p-2' },
|
||||
{ variant: 'toolbar', size: 'default', class: 'h-auto px-2 py-1' },
|
||||
|
|
@ -382,6 +434,9 @@ const buttonVariantRecipe = cva(
|
|||
{ 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' },
|
||||
{ variant: 'disclosure-line', size: 'default', class: 'h-auto p-0' },
|
||||
{ variant: 'disclosure-panel', size: 'default', class: 'h-auto px-3' },
|
||||
{ variant: 'field-import', size: 'default', class: 'h-theme-field px-2 py-2' },
|
||||
],
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
|
|
|
|||
|
|
@ -24,6 +24,25 @@ describe('Checkbox', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Checkbox fade variant', () => {
|
||||
it('eases the check fill over 300ms and snaps under reduced motion', () => {
|
||||
render(<Checkbox aria-label="Fading" variant="fade" />);
|
||||
|
||||
expect(screen.getByRole('checkbox', { name: 'Fading' })).toHaveClass(
|
||||
'transition',
|
||||
'duration-300',
|
||||
'ease-in-out',
|
||||
'motion-reduce:transition-none',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps the default checkbox free of motion', () => {
|
||||
render(<Checkbox aria-label="Plain" />);
|
||||
|
||||
expect(screen.getByRole('checkbox', { name: 'Plain' })).not.toHaveClass('transition');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CheckboxGlyph', () => {
|
||||
it('paints the unchecked fill role only while unchecked', () => {
|
||||
const { container, rerender } = render(<CheckboxGlyph checked={false} />);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,19 @@ import { Check } from 'lucide-react';
|
|||
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
||||
import { cn, disabledFillClasses } from '~/utils';
|
||||
|
||||
/** `fade` eases the check fill in and out over 300ms, for a checkbox that sits in running
|
||||
* prose such as the fork menu's options; reduced motion snaps it like the default. */
|
||||
const CHECKBOX_VARIANTS: Record<'default' | 'fade', string> = {
|
||||
default: '',
|
||||
fade: 'transition duration-300 ease-in-out motion-reduce:transition-none',
|
||||
};
|
||||
|
||||
type BaseCheckboxProps = Omit<
|
||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
|
||||
'aria-label' | 'aria-labelledby'
|
||||
> & {
|
||||
asChild?: boolean;
|
||||
variant?: keyof typeof CHECKBOX_VARIANTS;
|
||||
};
|
||||
|
||||
export type CheckboxProps =
|
||||
|
|
@ -23,12 +31,13 @@ export type CheckboxProps =
|
|||
const Checkbox: React.ForwardRefExoticComponent<
|
||||
CheckboxProps & React.RefAttributes<HTMLButtonElement>
|
||||
> = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(
|
||||
({ className = '', ...props }, ref) => (
|
||||
({ className = '', variant = 'default', ...props }, ref) => (
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'peer border-border-xheavy ring-offset-surface-primary focus-visible:ring-focus-control theme-checkbox-fill:bg-checkbox-fill data-[state=checked]:bg-surface-inverted data-[state=checked]:text-text-inverted size-theme-checkbox rounded-theme-checkbox shrink-0 border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
|
||||
disabledFillClasses,
|
||||
CHECKBOX_VARIANTS[variant],
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|||
import { cn, peerDisabledInkClasses } from '~/utils';
|
||||
|
||||
type LabelVariantOptions =
|
||||
| ({ variant?: 'default' | 'secondary' | 'section' | null | undefined } & ClassProp)
|
||||
| ({ variant?: 'default' | 'secondary' | 'option' | 'section' | null | undefined } & ClassProp)
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
|
|
@ -25,6 +25,10 @@ const labelVariants: (props?: LabelVariantOptions) => string = cva('', {
|
|||
/** The default metrics in the secondary ink, for a label that annotates rather than names. */
|
||||
secondary:
|
||||
'text-(length:--theme-label-size) leading-(--theme-label-leading) font-theme-label text-text-secondary',
|
||||
/** The secondary metrics rising to the primary ink under the pointer, for the label of a
|
||||
* checkbox or radio that is itself a click target for its control. */
|
||||
option:
|
||||
'text-(length:--theme-label-size) leading-(--theme-label-leading) font-theme-label text-text-secondary hover:text-text-primary',
|
||||
/** Eyebrow above a field or settings group. */
|
||||
section: 'text-[11px] font-medium uppercase tracking-wide text-text-secondary',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,16 +3,21 @@ import { fieldBase, fieldEmbedded, fieldFlush, fieldInvalid, fieldFillTransparen
|
|||
import { cn } from '~/utils';
|
||||
import './Field.css';
|
||||
|
||||
/** `document` is a long-form editor that reads like the text it will become. `flush` draws no
|
||||
* border or ring because the surrounding frame owns the indicator, and `embedded` fills a row
|
||||
* edge to edge. */
|
||||
/** `document` is a long-form editor that reads like the text it will become, `code` an editor
|
||||
* for raw text whose spacing matters, in a small monospace, and `note` a short free-text note.
|
||||
* `flush` draws no border or ring because the surrounding frame owns the indicator, and
|
||||
* `embedded` fills a row edge to edge. */
|
||||
const TEXTAREA_VARIANTS: Record<
|
||||
'default' | 'transparent' | 'document' | 'flush' | 'embedded',
|
||||
'default' | 'transparent' | 'document' | 'code' | 'note' | 'flush' | 'embedded',
|
||||
string
|
||||
> = {
|
||||
default: 'bg-surface-secondary',
|
||||
transparent: fieldFillTransparent,
|
||||
document: `${fieldFillTransparent} text-base leading-relaxed`,
|
||||
code: 'bg-surface-secondary font-mono text-xs',
|
||||
/** A short free-text note inside a dialog, such as a rating's extra feedback: the larger corner
|
||||
* and an even, tighter pad. */
|
||||
note: 'bg-surface-secondary rounded-xl p-2',
|
||||
flush: fieldFlush,
|
||||
embedded: fieldEmbedded,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -115,6 +115,28 @@ describe('LibreChat Tailwind preset', () => {
|
|||
expect(fallback).toContain('--theme-switch-width');
|
||||
});
|
||||
|
||||
it('publishes the chat motion roles the package components write', async () => {
|
||||
const css = await generate([
|
||||
'transition-reveal',
|
||||
'transition-crossfade',
|
||||
'transition-max-width',
|
||||
'transition-stroke-dashoffset',
|
||||
'blur-crossfade',
|
||||
]);
|
||||
|
||||
expect(rule(css, 'transition-reveal')).toContain(
|
||||
'transition-property: opacity, color, background-color',
|
||||
);
|
||||
expect(rule(css, 'transition-crossfade')).toContain(
|
||||
'transition-property: opacity, transform, filter',
|
||||
);
|
||||
expect(rule(css, 'transition-max-width')).toContain('transition-property: max-width');
|
||||
expect(rule(css, 'transition-stroke-dashoffset')).toContain(
|
||||
'transition-property: stroke-dashoffset',
|
||||
);
|
||||
expect(rule(css, 'blur-crossfade')).toContain('blur(2px)');
|
||||
});
|
||||
|
||||
it('generates every component animation and its keyframes together', async () => {
|
||||
const names = ['loading-dot', 'accordion-down', 'accordion-up', 'caret-blink'];
|
||||
const css = await generate(names.map((name) => `animate-${name}`));
|
||||
|
|
|
|||
|
|
@ -20,6 +20,45 @@ export const disabledFillClasses =
|
|||
*/
|
||||
export const disabledInkClasses =
|
||||
'theme-disabled:text-text-disabled theme-disabled:opacity-100 theme-disabled:[&_*]:text-text-disabled';
|
||||
/**
|
||||
* Reveal-on-hover for a control that shares a chat message's footer with its hover actions.
|
||||
*
|
||||
* Pointer devices fade it out until the row (the nearest `group`) is hovered or keyboard
|
||||
* focus lands inside it. Touch devices, which cannot hover, keep it visible.
|
||||
*
|
||||
* The focus half is `:focus-visible`, not `:focus-within`: clicking a tool card or an
|
||||
* expand toggle in the message body leaves focus parked there, and `:focus-within`
|
||||
* would hold the whole footer open with the pointer nowhere near the row. An action
|
||||
* that opens a surface keeps the toolbar up through the `message-hover` button's
|
||||
* `data-hover-active` instead.
|
||||
*
|
||||
* That focus half reads
|
||||
* `:is(:focus-visible, :has(:focus-visible:not(:is(input, textarea, [contenteditable]))))`
|
||||
* on the row, and both halves earn their keep:
|
||||
*
|
||||
* - The row itself has to be tested, not only its descendants. `MessageNav` moves the
|
||||
* reader by setting `tabindex="-1"` on the row and focusing it, and `:has()` never
|
||||
* matches its own subject, so a plain `:has(:focus-visible)` leaves a focused row
|
||||
* showing its focus ring with its metadata and its actions still hidden.
|
||||
* - Text-entry controls are excluded from the descendant half, because they match
|
||||
* `:focus-visible` even when a mouse clicks them. `ToolApproval` and
|
||||
* `AskUserQuestion` both render textareas inside a row, and without the exclusion
|
||||
* clicking one pins the row open with the pointer somewhere else entirely. Every
|
||||
* toolbar action is a button, so a keyboard user still never focuses a hidden one.
|
||||
*
|
||||
* The two halves stay two variants on purpose. Folding them into a single
|
||||
* `group-[&:is(...)]` makes Tailwind emit a bare `.group$ { opacity: 1 }` rule, which
|
||||
* lightningcss rejects and which fails the production CSS build while leaving `jest`
|
||||
* and `tsc` perfectly green.
|
||||
*
|
||||
* The transition is `transition-reveal` (opacity, color and background-color) rather
|
||||
* than `transition-opacity`: `cn` merges the whole `transition-*` group, so a bare
|
||||
* `transition-opacity` would replace the `transition-colors` a `Button` brings and
|
||||
* the hover tint would snap instead of fading.
|
||||
*/
|
||||
export const revealOnRowHoverClasses =
|
||||
'transition-reveal duration-theme-normal ease-out group-hover:opacity-100 group-focus-visible:opacity-100 group-has-[:focus-visible:not(:is(input,textarea,[contenteditable]))]:opacity-100 motion-reduce:transition-none no-touch:opacity-0';
|
||||
|
||||
export const peerDisabledInkClasses =
|
||||
'peer-theme-disabled:text-text-disabled peer-theme-disabled:opacity-100 peer-theme-disabled:[&_svg]:text-text-disabled';
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ const twMerge = extendTailwindMerge({
|
|||
'font-size': [{ text: [...TYPE_STEPS] }],
|
||||
'outline-w': [{ outline: ['theme-focus'] }],
|
||||
'outline-offset': [{ 'outline-offset': ['theme-focus'] }],
|
||||
transition: [{ transition: ['reveal', 'crossfade', 'max-width', 'stroke-dashoffset'] }],
|
||||
blur: [{ blur: ['crossfade'] }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -180,6 +180,21 @@ module.exports = {
|
|||
'theme-fast': 'var(--theme-motion-fast, 150ms)',
|
||||
'theme-normal': 'var(--theme-motion-normal, 200ms)',
|
||||
},
|
||||
transitionProperty: {
|
||||
/** A control that fades in with its row and keeps a hover tint: naming opacity alone
|
||||
* would drop the color fade a `Button` brings. */
|
||||
reveal: 'opacity, color, background-color',
|
||||
/** Two labels sharing one slot that swap by fading, sliding and blurring. */
|
||||
crossfade: 'opacity, transform, filter',
|
||||
/** A column that widens or narrows with the chat-width preference. */
|
||||
'max-width': 'max-width',
|
||||
/** A progress ring filling as its dash offset falls. */
|
||||
'stroke-dashoffset': 'stroke-dashoffset',
|
||||
},
|
||||
blur: {
|
||||
/** The soft blur a crossfading label passes through on its way out or in. */
|
||||
crossfade: '2px',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue