mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 13:33:45 +00:00
* feat: Animate background tasks and add tool navigation * fix: Focus background task navigation destinations directly * style: Refine background task controls and navigation icons * style: Place task stop controls after navigation * fix: Address background task navigation and rendering findings * fix: Fence task navigation and animate first detail reveal * fix: Prefer exact subagent thread navigation targets * fix: Preserve tool card hydration without navigation wrappers * fix: Scope task destinations and reveal event subagents * fix: Protect navigation focus and use theme focus roles
96 lines
3.5 KiB
TypeScript
96 lines
3.5 KiB
TypeScript
import * as React from 'react';
|
|
import { cva } from 'class-variance-authority';
|
|
import type { ClassProp } from 'class-variance-authority/types';
|
|
import { composerSubmitClasses } from '~/utils/composer';
|
|
import { disabledFillClasses } from '~/utils/theme';
|
|
import { cn } from '~/utils';
|
|
|
|
type IconButtonVariantProps = {
|
|
variant?:
|
|
| 'default'
|
|
| 'primary'
|
|
| 'secondary'
|
|
| 'ghost'
|
|
| 'row-action'
|
|
| 'destructive'
|
|
| 'submit'
|
|
| null;
|
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'theme' | null;
|
|
shape?: 'round' | 'square' | 'control' | 'theme' | 'composer' | 'inset' | null;
|
|
};
|
|
|
|
const iconButtonVariants: (props?: IconButtonVariantProps & ClassProp) => string = cva(
|
|
[
|
|
'inline-flex shrink-0 items-center justify-center text-text-primary transition-colors duration-theme-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control focus-visible:ring-offset-2 focus-visible:ring-offset-surface-primary disabled:pointer-events-none disabled:opacity-50',
|
|
disabledFillClasses,
|
|
],
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: 'bg-surface-secondary hover:bg-surface-hover hover:active:bg-surface-pressed',
|
|
primary:
|
|
'bg-surface-inverted text-text-inverted hover:bg-surface-inverted-hover hover:active:bg-surface-inverted-pressed',
|
|
secondary:
|
|
'border border-border-chrome bg-surface-secondary hover:bg-surface-hover hover:active:bg-surface-pressed',
|
|
ghost: 'bg-transparent hover:bg-surface-hover hover:active:bg-surface-pressed',
|
|
/** An action inside a list row whose highlight is already `surface-hover`,
|
|
* so its own hover takes the active fill to stay visible on top of it. */
|
|
'row-action': 'bg-transparent hover:bg-surface-active',
|
|
destructive:
|
|
'bg-surface-destructive text-text-on-status hover:bg-surface-destructive-hover',
|
|
/** The composer's submit slot: send, stop and the during-run send share it. */
|
|
submit: cn(
|
|
'hover:bg-surface-inverted-hover hover:active:bg-surface-inverted-pressed',
|
|
composerSubmitClasses(),
|
|
),
|
|
},
|
|
size: {
|
|
xs: 'size-6',
|
|
sm: 'size-8',
|
|
md: 'size-9',
|
|
lg: 'size-10',
|
|
theme: 'size-theme-control',
|
|
},
|
|
shape: {
|
|
round: 'rounded-full',
|
|
square: 'rounded-lg',
|
|
/** A compact control inset inside a rounded card, with a tighter inner corner. */
|
|
inset: 'rounded-md',
|
|
/** The theme's control corner: softer than `square`, short of the full circle of `round`. */
|
|
control: 'rounded-theme-control',
|
|
theme: 'rounded-theme-control-round',
|
|
/** The composer's send and stop slot, whose corner a theme sets apart from the other round controls. */
|
|
composer: 'rounded-theme-composer-action',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'ghost',
|
|
size: 'md',
|
|
shape: 'round',
|
|
},
|
|
},
|
|
);
|
|
|
|
export interface IconButtonProps
|
|
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'>,
|
|
IconButtonVariantProps {
|
|
label: string;
|
|
}
|
|
|
|
const IconButton: React.ForwardRefExoticComponent<
|
|
IconButtonProps & React.RefAttributes<HTMLButtonElement>
|
|
> = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
({ className, label, type = 'button', variant, size, shape, ...props }, ref) => (
|
|
<button
|
|
ref={ref}
|
|
type={type}
|
|
aria-label={label}
|
|
className={cn(iconButtonVariants({ variant, size, shape, className }))}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
|
|
IconButton.displayName = 'IconButton';
|
|
|
|
export { IconButton, iconButtonVariants };
|