Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🔐 refactor: Give Sign-In Controls Button, Input and Alert Variants (#16828)
Marco Berettabcebe1d96a71
diff --git a/client/src/components/Auth/AuthLayout.tsx b/client/src/components/Auth/AuthLayout.tsxindex fdd43eaea2..b14b7653ec 100644--- a/client/src/components/Auth/AuthLayout.tsx+++ b/client/src/components/Auth/AuthLayout.tsx@@ -112,10 +112,7 @@ function AuthLayout({)}>{!hasStartupConfigError && !isFetching && header && (- <h1- className="text-text-primary mb-4 text-center text-3xl font-semibold"- style={{ userSelect: 'none' }}- >+ <h1 className="text-text-primary mb-4 text-center text-3xl font-semibold select-none">{header}</h1>)}diff --git a/client/src/components/Auth/ErrorMessage.tsx b/client/src/components/Auth/ErrorMessage.tsxindex 447e01c785..5434e0ebfd 100644--- a/client/src/components/Auth/ErrorMessage.tsx+++ b/client/src/components/Auth/ErrorMessage.tsx@@ -6,7 +6,8 @@ export const ErrorMessage = ({ children }: { children: React.ReactNode }) => (icon={false}aria-live="assertive"elevation="raised"- className="mt-6 px-6 py-4 transition-all"+ size="roomy"+ className="mt-6">{children}</Alert>diff --git a/client/src/components/Auth/LoginForm.tsx b/client/src/components/Auth/LoginForm.tsxindex 7a6879e85c..a3d3e7a9ba 100644--- a/client/src/components/Auth/LoginForm.tsx+++ b/client/src/components/Auth/LoginForm.tsx@@ -1,7 +1,15 @@import React, { useState, useEffect, useContext } from 'react';import { useForm } from 'react-hook-form';import { Turnstile } from '@marsidev/react-turnstile';-import { ThemeContext, SecretInput, Spinner, Button, Input, isDark } from '@librechat/client';+import {+ ThemeContext,+ SecretInput,+ Spinner,+ Button,+ Input,+ isDark,+ floatingLabel,+} from '@librechat/client';import type { TLoginUser, TStartupConfig } from 'librechat-data-provider';import type { TAuthContext } from '~/common';import { useResendVerificationEmail, useGetStartupConfig } from '~/data-provider';@@ -36,13 +44,6 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,const emailAutoComplete = startupConfig.passkeyLoginEnabled? `${baseAutoComplete} webauthn`: baseAutoComplete;- const authInputClassName =- 'webkit-dark-styles peer h-auto w-full rounded-2xl border px-3.5 pb-2.5 pt-3 text-text-primary duration-200 focus:border-accent-primary focus-visible:border-accent-primary';- const authSecretInputClassName = `${authInputClassName} pr-12`;- const authLabelClassName =- 'absolute start-3 top-1.5 z-10 origin-[0] -translate-y-4 scale-75 transform bg-surface-primary px-2 text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary rtl:peer-focus:left-auto rtl:peer-focus:translate-x-1/4';- const authSecretButtonClassName =- 'size-9 rounded-xl text-text-secondary-alt hover:bg-transparent hover:text-text-primary';useEffect(() => {if (error && error.includes('422') && !showResendLink) {@@ -115,10 +116,10 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,: (value) => validateEmail(value, localize('com_auth_email_pattern')),})}aria-invalid={!!errors.email}- className={authInputClassName}+ variant="floating"placeholder=" "/>- <label htmlFor="email" className={authLabelClassName}>+ <label htmlFor="email" className={floatingLabel}>{useUsernameLogin? localize('com_auth_username').replace(/ \(.*$/, ''): localize('com_auth_email_address')}@@ -142,12 +143,9 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,maxLength: { value: 128, message: localize('com_auth_password_max_length') },})}aria-invalid={!!errors.password}- className={authSecretInputClassName}+ variant="floating"placeholder=" "label={localize('com_auth_password')}- labelClassName={authLabelClassName}- controlsClassName="right-2"- buttonClassName={authSecretButtonClassName}/></div>{renderError('password')}@@ -183,7 +181,8 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,type="submit"disabled={(requireCaptcha && !turnstileToken) || isSubmitting}variant="submit"- className="h-12 w-full rounded-2xl"+ shape="soft"+ className="h-12 w-full">{isSubmitting ? <Spinner /> : localize('com_auth_continue')}</Button>diff --git a/client/src/components/Auth/Registration.tsx b/client/src/components/Auth/Registration.tsxindex d3c3c70aa8..c8d81d8f81 100644--- a/client/src/components/Auth/Registration.tsx+++ b/client/src/components/Auth/Registration.tsx@@ -4,7 +4,15 @@ import { loginPage } from 'librechat-data-provider';import { Turnstile } from '@marsidev/react-turnstile';import { useNavigate, useOutletContext, useLocation } from 'react-router-dom';import { useRegisterUserMutation } from 'librechat-data-provider/react-query';-import { ThemeContext, SecretInput, Spinner, Button, Input, isDark } from '@librechat/client';+import {+ ThemeContext,+ SecretInput,+ Spinner,+ Button,+ Input,+ isDark,+ floatingLabel,+} from '@librechat/client';import type { TRegisterUser, TError } from 'librechat-data-provider';import type { TLoginLayoutContext } from '~/common';import { useLocalize, TranslationKeys } from '~/hooks';@@ -37,13 +45,6 @@ const Registration: React.FC = () => {// only require captcha if we have a siteKeyconst requireCaptcha = Boolean(startupConfig?.turnstile?.siteKey);- const authInputClassName =- 'webkit-dark-styles peer h-auto w-full rounded-2xl border px-3.5 pb-2.5 pt-3 text-text-primary duration-200 focus:border-accent-primary focus-visible:border-accent-primary';- const authSecretInputClassName = `${authInputClassName} pr-12`;- const authLabelClassName =- 'absolute start-3 top-1.5 z-10 origin-[0] -translate-y-4 scale-75 transform bg-surface-primary px-2 text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary rtl:peer-focus:left-auto rtl:peer-focus:translate-x-1/4';- const authSecretButtonClassName =- 'size-9 rounded-xl text-text-secondary-alt hover:bg-transparent hover:text-text-primary';const registerUser = useRegisterUserMutation({onMutate: () => {@@ -90,13 +91,10 @@ const Registration: React.FC = () => {aria-label={fieldLabel}{...field}aria-invalid={!!errors[id]}- className={authSecretInputClassName}+ variant="floating"placeholder=" "data-testid={id}label={fieldLabel}- labelClassName={authLabelClassName}- controlsClassName="right-2"- buttonClassName={authSecretButtonClassName}/>) : (<>@@ -108,11 +106,11 @@ const Registration: React.FC = () => {aria-label={fieldLabel}{...field}aria-invalid={!!errors[id]}- className={authInputClassName}+ variant="floating"placeholder=" "data-testid={id}/>- <label htmlFor={id} className={authLabelClassName}>+ <label htmlFor={id} className={floatingLabel}>{fieldLabel}</label></>@@ -235,7 +233,8 @@ const Registration: React.FC = () => {type="submit"aria-label="Submit registration"variant="submit"- className="h-12 w-full rounded-2xl"+ shape="soft"+ className="h-12 w-full">{isSubmitting ? <Spinner /> : localize('com_auth_continue')}</Button>diff --git a/client/src/components/Auth/RequestPasswordReset.tsx b/client/src/components/Auth/RequestPasswordReset.tsxindex a1c6b6fe43..1fadf27aef 100644--- a/client/src/components/Auth/RequestPasswordReset.tsx+++ b/client/src/components/Auth/RequestPasswordReset.tsx@@ -11,12 +11,7 @@ import { useLocalize } from '~/hooks';const BodyTextWrapper: FC<{ children: ReactNode }> = ({ children }) => {return (- <Alert- variant="success"- icon={false}- elevation="raised"- className="mt-6 px-6 py-4 transition-all"- >+ <Alert variant="success" icon={false} elevation="raised" size="roomy" className="mt-6">{children}</Alert>);@@ -111,7 +106,7 @@ function RequestPasswordReset() {},})}aria-invalid={!!errors.email}- className="webkit-dark-styles peer text-text-primary focus:border-accent-primary h-auto w-full rounded-2xl border px-3.5 pt-3 pb-2.5 duration-200"+ variant="floating"placeholder=" "/><label@@ -133,7 +128,8 @@ function RequestPasswordReset() {type="submit"disabled={!!errors.email || isLoading}variant="submit"- className="h-12 w-full rounded-2xl"+ shape="soft"+ className="h-12 w-full">{isLoading ? <Spinner /> : localize('com_auth_continue')}</Button>diff --git a/client/src/components/Auth/ResetPassword.tsx b/client/src/components/Auth/ResetPassword.tsxindex e7ebfbcdc1..2a111b2a31 100644--- a/client/src/components/Auth/ResetPassword.tsx+++ b/client/src/components/Auth/ResetPassword.tsx@@ -20,12 +20,6 @@ function ResetPassword() {const password = watch('password');const resetPassword = useResetPasswordMutation();const { setError, setHeaderText, startupConfig } = useOutletContext<TLoginLayoutContext>();- const authInputClassName =- 'webkit-dark-styles peer h-auto w-full rounded-2xl border px-3.5 pb-2.5 pr-12 pt-3 text-text-primary duration-200 focus:border-accent-primary focus-visible:border-accent-primary';- const authLabelClassName =- 'absolute start-3 top-1.5 z-10 origin-[0] -translate-y-4 scale-75 transform bg-surface-primary px-2 text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary rtl:peer-focus:left-auto rtl:peer-focus:translate-x-1/4';- const authSecretButtonClassName =- 'size-9 rounded-xl text-text-secondary-alt hover:bg-transparent hover:text-text-primary';const onSubmit = (data: TResetPassword) => {resetPassword.mutate(data, {@@ -41,12 +35,7 @@ function ResetPassword() {if (resetPassword.isSuccess) {return (<>- <Alert- variant="success"- icon={false}- elevation="raised"- className="mt-6 px-6 py-4 transition-all"- >+ <Alert variant="success" icon={false} elevation="raised" size="roomy" className="mt-6"><div className="flex flex-col space-y-4"><p>{localize('com_auth_login_with_new_password')}</p><Button@@ -100,12 +89,9 @@ function ResetPassword() {},})}aria-invalid={!!errors.password}- className={authInputClassName}+ variant="floating"placeholder=" "label={localize('com_auth_password')}- labelClassName={authLabelClassName}- controlsClassName="right-2"- buttonClassName={authSecretButtonClassName}/></div>@@ -125,12 +111,9 @@ function ResetPassword() {validate: (value) => value === password || localize('com_auth_password_not_match'),})}aria-invalid={!!errors.confirm_password}- className={authInputClassName}+ variant="floating"placeholder=" "label={localize('com_auth_password_confirm')}- labelClassName={authLabelClassName}- controlsClassName="right-2"- buttonClassName={authSecretButtonClassName}/></div>{errors.confirm_password && (@@ -155,7 +138,8 @@ function ResetPassword() {aria-label={localize('com_auth_submit_registration')}disabled={!!errors.password || !!errors.confirm_password || isSubmitting}variant="submit"- className="h-12 w-full rounded-2xl"+ shape="soft"+ className="h-12 w-full">{isSubmitting ? <Spinner /> : localize('com_auth_continue')}</Button>diff --git a/client/src/components/Auth/TwoFactorScreen.tsx b/client/src/components/Auth/TwoFactorScreen.tsxindex 32dd7929b2..034394ad83 100644--- a/client/src/components/Auth/TwoFactorScreen.tsx+++ b/client/src/components/Auth/TwoFactorScreen.tsx@@ -87,7 +87,7 @@ const TwoFactorScreen: React.FC = React.memo(() => {return (<div className="mt-4"><form onSubmit={handleSubmit(onSubmit)}>- <Label className="text-text-primary flex justify-center text-center text-sm break-keep">+ <Label className="flex justify-center text-center text-sm break-keep">{localize('com_auth_two_factor')}</Label>{!useBackup && (@@ -142,7 +142,8 @@ const TwoFactorScreen: React.FC = React.memo(() => {variant="submit"data-testid="login-button"disabled={isLoading}- className="w-full rounded-2xl px-4 py-3 text-sm font-medium disabled:opacity-80"+ shape="soft"+ className="w-full disabled:opacity-80">{isLoading ? localize('com_auth_email_verifying_ellipsis') : localize('com_ui_verify')}</Button>@@ -151,18 +152,20 @@ const TwoFactorScreen: React.FC = React.memo(() => {{!useBackup ? (<Buttontype="button"- variant="link"+ variant="link-accent"onClick={toggleBackupOn}- className="text-accent-primary hover:text-accent-primary-hover inline-flex p-1 text-sm font-medium transition-colors"+ size="snug"+ className="inline-flex">{localize('com_ui_use_backup_code')}</Button>) : (<Buttontype="button"- variant="link"+ variant="link-accent"onClick={toggleBackupOff}- className="text-accent-primary hover:text-accent-primary-hover inline-flex p-1 text-sm font-medium transition-colors"+ size="snug"+ className="inline-flex">{localize('com_ui_use_2fa_code')}</Button>diff --git a/client/src/components/Auth/VerifyEmail.tsx b/client/src/components/Auth/VerifyEmail.tsxindex 3a46df7d6e..b47ca6b1fe 100644--- a/client/src/components/Auth/VerifyEmail.tsx+++ b/client/src/components/Auth/VerifyEmail.tsx@@ -139,8 +139,8 @@ function RequestPasswordReset() {{statusText}</h1>{!verificationStatus && (- <div className="mt-4 flex justify-center">- <Spinner className="text-accent-primary h-8 w-8" />+ <div className="text-accent-primary mt-4 flex justify-center">+ <Spinner className="h-8 w-8" /></div>)}{verificationStatus && countdown > 0 && (@@ -153,8 +153,9 @@ function RequestPasswordReset() {{localize('com_auth_email_verification_resend_prompt')}<Buttontype="button"- variant="link"- className="text-link ml-2 inline h-auto p-0"+ variant="hyperlink"+ size="bare"+ className="ml-2 inline"onClick={handleResendEmail}disabled={resendEmailMutation.isLoading}>diff --git a/client/src/style.css b/client/src/style.cssindex 5a486a370d..d479ecb8d7 100644--- a/client/src/style.css+++ b/client/src/style.css@@ -1740,19 +1740,6 @@ html {}}-.webkit-dark-styles,-.webkit-dark-styles:focus {- background-clip: content-box;- -webkit-box-shadow: 0 0 0 50vh rgb(var(--field-fill, var(--surface-primary))) inset;-}--.dark .webkit-dark-styles,-.dark .webkit-dark-styles:focus {- -webkit-text-fill-color: rgb(var(--field-text, var(--text-primary)));- background-clip: content-box;- -webkit-box-shadow: 0 0 0 50vh rgb(var(--field-fill, var(--surface-primary))) inset;-}-/* Ordered Listing */.prose :where(ol[type='A']):not(:where([class~='not-prose'] *)) {list-style-type: upper-alpha;diff --git a/e2e/specs/mock/scenarios/signin-controls.spec.ts b/e2e/specs/mock/scenarios/signin-controls.spec.tsnew file mode 100644index 0000000000..7428bd3fdf--- /dev/null+++ b/e2e/specs/mock/scenarios/signin-controls.spec.ts@@ -0,0 +1,104 @@+import { expect, test } from '@playwright/test';++/**+ * The sign-in screens compose the shared `Input`, `SecretInput`, `Button` and `Alert` through+ * named roles (`variant="floating"`, `size="xl"` with `shape="soft"`, `size="roomy"`) instead of+ * restating classes per screen. These scenarios read what the browser paints in the default theme,+ * so the roles have to reproduce the look the local class strings drew.+ */+test.use({ storageState: { cookies: [], origins: [] } });++const MODES = ['light', 'dark'] as const;++for (const mode of MODES) {+ test.describe(`${mode} mode`, () => {+ test.use({ colorScheme: mode });++ test(`a sign-in field keeps its rounded edge and its label rests inside it until it has a value (${mode}) @scenario:signin-floating-field`, async ({+ page,+ }) => {+ await page.goto('/login', { timeout: 15_000 });+ const email = page.locator('#email');+ await expect(email).toBeVisible({ timeout: 15_000 });++ const field = await email.evaluate((el) => {+ const style = getComputedStyle(el);+ return {+ radius: style.borderTopLeftRadius,+ padLeft: style.paddingLeft,+ width: el.getBoundingClientRect().width,+ wrapperWidth: el.parentElement?.getBoundingClientRect().width ?? 0,+ };+ });+ expect(field.radius).toBe('16px');+ expect(field.padLeft).toBe('14px');+ expect(field.width).toBe(field.wrapperWidth);++ const label = page.locator('label[for="email"]');+ const resting = await label.evaluate((el) =>+ Number.parseFloat(getComputedStyle(el).scale === 'none' ? '1' : getComputedStyle(el).scale),+ );+ expect(resting).toBe(1);++ await email.fill('[email protected]');+ await expect+ .poll(() =>+ label.evaluate((el) =>+ Number.parseFloat(+ getComputedStyle(el).scale === 'none' ? '1' : getComputedStyle(el).scale,+ ),+ ),+ )+ .toBeCloseTo(0.75, 2);++ const password = page.locator('#password');+ await expect(password).toHaveAttribute('placeholder', ' ');+ expect(await password.evaluate((el) => getComputedStyle(el).borderTopLeftRadius)).toBe(+ '16px',+ );+ await expect(page.getByRole('button', { name: /show/i })).toBeVisible();+ });++ test(`the sign-in submit is a 48px control with a 16px corner (${mode}) @scenario:signin-submit-shape`, async ({+ page,+ }) => {+ await page.goto('/login', { timeout: 15_000 });+ const submit = page.getByTestId('login-button');+ await expect(submit).toBeVisible({ timeout: 15_000 });++ const box = await submit.evaluate((el) => {+ const style = getComputedStyle(el);+ return {+ height: el.getBoundingClientRect().height,+ radius: style.borderTopLeftRadius,+ wrapperWidth: el.parentElement?.getBoundingClientRect().width ?? 0,+ width: el.getBoundingClientRect().width,+ };+ });+ expect(box.height).toBe(48);+ expect(box.radius).toBe('16px');+ expect(box.width).toBe(box.wrapperWidth);+ });++ test(`a failed sign-in shows its error with the roomy alert padding (${mode}) @scenario:signin-error-alert`, async ({+ page,+ }) => {+ await page.route(+ (url) => url.pathname === '/api/auth/login',+ (route) => route.fulfill({ status: 401, json: { message: 'Invalid email or password' } }),+ );+ await page.goto('/login', { timeout: 15_000 });+ await page.locator('#email').fill('[email protected]');+ await page.locator('#password').fill('not-the-password');+ await page.getByTestId('login-button').click();++ const alert = page.getByRole('alert').filter({ hasText: /./ }).first();+ await expect(alert).toBeVisible({ timeout: 15_000 });+ const padding = await alert.evaluate((el) => {+ const style = getComputedStyle(el);+ return [style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft];+ });+ expect(padding).toEqual(['16px', '24px', '16px', '24px']);+ });+ });+}diff --git a/eslint-suppressions.json b/eslint-suppressions.jsonindex 5f21c7d7f9..ff8557a183 100644--- a/eslint-suppressions.json+++ b/eslint-suppressions.json@@ -68,16 +68,6 @@"count": 6}},- "client/src/components/Auth/AuthLayout.tsx": {- "shadcn/no-inline-styles": {- "count": 1- }- },- "client/src/components/Auth/ErrorMessage.tsx": {- "shadcn/no-restyle": {- "count": 3- }- },"client/src/components/Auth/Footer.tsx": {"shadcn/no-arbitrary-values": {"count": 1@@ -86,34 +76,9 @@"count": 1}},- "client/src/components/Auth/LoginForm.tsx": {- "shadcn/no-restyle": {- "count": 33- }- },- "client/src/components/Auth/Registration.tsx": {- "shadcn/no-restyle": {- "count": 33- }- },- "client/src/components/Auth/RequestPasswordReset.tsx": {- "shadcn/no-restyle": {- "count": 13- }- },- "client/src/components/Auth/ResetPassword.tsx": {- "shadcn/no-restyle": {- "count": 48- }- },"client/src/components/Auth/TwoFactorScreen.tsx": {"shadcn/no-restyle": {- "count": 19- }- },- "client/src/components/Auth/VerifyEmail.tsx": {- "shadcn/no-restyle": {- "count": 3+ "count": 1}},"client/src/components/Bookmarks/BookmarkForm.tsx": {diff --git a/packages/client/src/components/Alert.spec.tsx b/packages/client/src/components/Alert.spec.tsxnew file mode 100644index 0000000000..b83557fe67--- /dev/null+++ b/packages/client/src/components/Alert.spec.tsx@@ -0,0 +1,15 @@+import '@testing-library/jest-dom';+import { render, screen } from '@testing-library/react';+import { Alert } from './Alert';++describe('Alert', () => {+ it('keeps the inline padding by default and gives a standalone notice more air when roomy', () => {+ const { rerender } = render(<Alert>Saved</Alert>);+ expect(screen.getByRole('alert')).toHaveClass('px-4', 'py-3');++ rerender(<Alert size="roomy">Saved</Alert>);+ const roomy = screen.getByRole('alert');+ expect(roomy).toHaveClass('px-6', 'py-4');+ expect(roomy).not.toHaveClass('px-4');+ });+});diff --git a/packages/client/src/components/Alert.tsx b/packages/client/src/components/Alert.tsxindex d10fbba1ac..fe0c41f4c5 100644--- a/packages/client/src/components/Alert.tsx+++ b/packages/client/src/components/Alert.tsx@@ -9,6 +9,7 @@ const alertVariants: (| ({variant?: 'info' | 'success' | 'warning' | 'error' | 'neutral' | null | undefined;elevation?: 'flat' | 'raised' | null | undefined;+ size?: 'default' | 'roomy' | null | undefined;} & ClassProp)| undefined,) => string = cva('relative flex gap-3 rounded-xl border border-border-light px-4 py-3 text-sm', {@@ -25,10 +26,16 @@ const alertVariants: (flat: '',raised: 'shadow-xs',},+ /** `roomy` gives a standalone notice, such as a form's outcome, more air than an inline one. */+ size: {+ default: '',+ roomy: 'px-6 py-4',+ },},defaultVariants: {variant: 'info',elevation: 'flat',+ size: 'default',},});@@ -51,14 +58,17 @@ export interface AlertPropsconst Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>> =React.forwardRef<HTMLDivElement, AlertProps>(- ({ className, variant = 'info', elevation, icon, role = 'alert', children, ...props }, ref) => {+ (+ { className, variant = 'info', elevation, size, icon, role = 'alert', children, ...props },+ ref,+ ) => {const resolvedVariant = (variant ?? 'info') as AlertVariant;const DefaultIcon = defaultIcons[resolvedVariant];return (<divref={ref}role={role}- className={cn(alertVariants({ variant, elevation }), className)}+ className={cn(alertVariants({ variant, elevation, size }), className)}{...props}>{icon !== false && (diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsxindex b14db9eef9..190a5bab90 100644--- a/packages/client/src/components/Button.spec.tsx+++ b/packages/client/src/components/Button.spec.tsx@@ -357,4 +357,12 @@ describe('Button', () => {?.querySelectorAll('circle').forEach((circle) => expect(circle).toHaveAttribute('stroke', 'currentColor'));});++ it('offers the sign-in sizes, shape and link variants as roles rather than caller classes', () => {+ expect(cn(buttonVariants({ shape: 'soft' }))).toContain('rounded-2xl');+ expect(cn(buttonVariants({ size: 'snug' }))).toContain('p-1');+ expect(cn(buttonVariants({ size: 'bare' }))).toContain('p-0');+ expect(cn(buttonVariants({ variant: 'link-accent' }))).toContain('text-accent-primary');+ expect(cn(buttonVariants({ variant: 'hyperlink' }))).toContain('text-link');+ });});diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsxindex eca8e6dabd..60cae516ee 100644--- a/packages/client/src/components/Button.tsx+++ b/packages/client/src/components/Button.tsx@@ -10,6 +10,8 @@ type ButtonVariantOptions =variant?:| 'default'| 'link'+ | 'link-accent'+ | 'hyperlink'| 'submit'| 'outline'| 'outline-toggle'@@ -41,12 +43,14 @@ type ButtonVariantOptions =| 'xs'| 'sm'| 'lg'+ | 'snug'+ | 'bare'| 'theme'| 'row'| 'tile'| null| undefined;- shape?: 'default' | 'theme' | 'round' | null | undefined;+ shape?: 'default' | 'soft' | 'theme' | 'round' | null | undefined;} & ClassProp)| undefined;@@ -100,6 +104,11 @@ const buttonVariantRecipe = cva('row-action-reveal':'shrink-0 rounded-md text-text-secondary transition-opacity hover:bg-surface-hover-alt hover:text-text-primary data-[open]:bg-surface-active data-[open]:text-text-primary data-[open]:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:focus-visible:opacity-100 [@media(hover:hover)]:group-focus-within:opacity-100 [@media(hover:hover)]:group-hover:opacity-100',link: 'text-text-primary underline-offset-4 hover:underline',+ /** A link-weight action in the accent color, such as the alternate way to confirm a sign-in. */+ 'link-accent':+ 'text-accent-primary underline-offset-4 hover:text-accent-primary-hover hover:underline',+ /** An action set inside a sentence in the hyperlink color, sized by its own text. */+ hyperlink: 'text-link underline-offset-4 hover:underline',submit: 'bg-surface-submit text-text-on-status hover:bg-surface-submit-hover',/*** The toggle that heads a collapsible sidebar section, such as Chats,@@ -187,6 +196,10 @@ const buttonVariantRecipe = cva(xs: 'h-theme-button-xs rounded-md px-2.5 text-xs',sm: 'h-theme-button-sm rounded-lg px-3',lg: 'h-theme-button-lg rounded-lg px-8',+ /** Default height with a snug pad, for a text action that sits close to its neighbors. */+ 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',icon: 'size-theme-button','icon-sm': 'size-theme-icon-button-sm p-0','icon-xs': 'size-theme-button-xs',@@ -204,6 +217,8 @@ const buttonVariantRecipe = cva(},shape: {default: 'rounded-lg',+ /** The generous corner of a sign-in form's controls. */+ soft: 'rounded-2xl',theme: 'rounded-theme-control',round: 'rounded-theme-control-round',unset: '',diff --git a/packages/client/src/components/Field.css b/packages/client/src/components/Field.cssindex c67fd3fd19..b3c89d88f2 100644--- a/packages/client/src/components/Field.css+++ b/packages/client/src/components/Field.css@@ -35,3 +35,18 @@ html[data-input-modality='pointer'] .lc-field:focus-visible {}}}++/* The floating-label field (`floatingField`) paints its own fill over the browser's autofill, so+ an autofilled sign-in field keeps the theme's field color instead of the UA's yellow. */+.webkit-dark-styles,+.webkit-dark-styles:focus {+ background-clip: content-box;+ -webkit-box-shadow: 0 0 0 50vh rgb(var(--field-fill, var(--surface-primary))) inset;+}++.dark .webkit-dark-styles,+.dark .webkit-dark-styles:focus {+ -webkit-text-fill-color: rgb(var(--field-text, var(--text-primary)));+ background-clip: content-box;+ -webkit-box-shadow: 0 0 0 50vh rgb(var(--field-fill, var(--surface-primary))) inset;+}diff --git a/packages/client/src/components/Input.tsx b/packages/client/src/components/Input.tsxindex e57d9be873..c74e1b1c3a 100644--- a/packages/client/src/components/Input.tsx+++ b/packages/client/src/components/Input.tsx@@ -1,17 +1,20 @@import * as React from 'react';+import { floatingField } from './floating';import { fieldControl } from './Field';import { cn } from '~/utils';import './Field.css';/** `title` edits a heading in place, so the field takes the heading's type scale. `inline` shares* a row with icon Buttons, so it takes their height role and the row stays one height when a- * theme sizes fields and buttons apart. */-const INPUT_VARIANTS = {+ * theme sizes fields and buttons apart. `floating` is the sign-in form field whose label rests+ * inside it and lifts on focus. */+const INPUT_VARIANTS: Record<'default' | 'inline' | 'title' | 'title-sm' | 'floating', string> = {default: '',inline: 'h-theme-button',title: 'h-theme-field-lg text-2xl font-semibold tracking-tight','title-sm': 'text-base font-semibold tracking-tight',-} as const;+ floating: floatingField,+};export type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {colorTransition?: boolean;@@ -31,6 +34,7 @@ const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTclassName ?? '',)}ref={ref}+ placeholder={variant === 'floating' ? ' ' : undefined}{...props}/>);diff --git a/packages/client/src/components/SecretInput.spec.tsx b/packages/client/src/components/SecretInput.spec.tsxindex ca5688f6d8..05c132945d 100644--- a/packages/client/src/components/SecretInput.spec.tsx+++ b/packages/client/src/components/SecretInput.spec.tsx@@ -64,4 +64,16 @@ describe('SecretInput', () => {);expect(field).not.toHaveClass('h-10');});++ /** The sign-in form's field carries its edge, label and controls with it, so a form names the+ * variant rather than restating them. */+ it('draws the floating variant with its label and show control', () => {+ render(<SecretInput id="pw" variant="floating" label="Password" />);+ const field = document.getElementById('pw');++ expect(field).toHaveClass('peer', 'rounded-2xl', 'pr-11');+ expect(field).toHaveAttribute('placeholder', ' ');+ expect(screen.getByText('Password')).toHaveClass('peer-placeholder-shown:top-1/2');+ expect(screen.getByRole('button', { name: 'Show secret' })).toHaveClass('size-9', 'rounded-xl');+ });});diff --git a/packages/client/src/components/SecretInput.tsx b/packages/client/src/components/SecretInput.tsxindex 847abf9785..c6514d5a50 100644--- a/packages/client/src/components/SecretInput.tsx+++ b/packages/client/src/components/SecretInput.tsx@@ -1,13 +1,17 @@import * as React from 'react';import { useState, useCallback } from 'react';import { Eye, EyeOff, Copy, Check } from 'lucide';+import { floatingField, floatingLabel, floatingSecretButton } from './floating';import { cn, disabledInkClasses } from '~/utils';import { MorphIcon } from './MorphIcon';+import './Field.css';import { fieldControl } from './Field';export interface SecretInputPropsextends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {colorTransition?: boolean;+ /** `floating` is the sign-in form field whose label rests inside it and lifts on focus. */+ variant?: 'default' | 'floating';/** Show the built-in copy button */showCopy?: boolean;/** Custom copy control rendered inside the input, in place of the built-in one */@@ -32,6 +36,7 @@ const SecretInput: React.ForwardRefExoticComponent<id,label,className,+ variant = 'default',colorTransition,showCopy = false,copyButton,@@ -48,6 +53,7 @@ const SecretInput: React.ForwardRefExoticComponent<},ref,) => {+ const isFloating = variant === 'floating';const [isVisible, setIsVisible] = useState(false);const [isCopied, setIsCopied] = useState(false);@@ -86,6 +92,7 @@ const SecretInput: React.ForwardRefExoticComponent<className={cn(fieldControl,colorTransition && 'transition-colors',+ isFloating && floatingField,className ?? '',copyButton != null || showCopy ? 'pr-20' : 'pr-11',)}@@ -93,17 +100,19 @@ const SecretInput: React.ForwardRefExoticComponent<disabled={disabled}value={value}autoComplete="off"+ placeholder={isFloating ? ' ' : undefined}spellCheck={false}{...props}/>{label != null && (- <label htmlFor={id} className={cn(labelClassName ?? '')}>+ <label htmlFor={id} className={cn(isFloating && floatingLabel, labelClassName)}>{label}</label>)}<divclassName={cn('pointer-events-none absolute inset-y-0 right-1.5 flex items-center gap-0.5 [&_button]:pointer-events-auto',+ isFloating && 'right-2',controlsOnHover &&'opacity-0 transition-opacity duration-150 group-focus-within/secret-input:opacity-100 group-hover/secret-input:opacity-100',controlsClassName,@@ -121,6 +130,7 @@ const SecretInput: React.ForwardRefExoticComponent<? 'cursor-not-allowed opacity-50': 'hover:bg-surface-hover hover:text-text-primary',disabledInkClasses,+ isFloating && floatingSecretButton,buttonClassName,)}aria-label={isCopied ? 'Copied' : 'Copy to clipboard'}@@ -138,6 +148,7 @@ const SecretInput: React.ForwardRefExoticComponent<? 'cursor-not-allowed opacity-50': 'hover:bg-surface-hover hover:text-text-primary',disabledInkClasses,+ isFloating && floatingSecretButton,buttonClassName,)}aria-label={isVisible ? 'Hide secret' : 'Show secret'}diff --git a/packages/client/src/components/floating.ts b/packages/client/src/components/floating.tsnew file mode 100644index 0000000000..6ede8b17fa--- /dev/null+++ b/packages/client/src/components/floating.ts@@ -0,0 +1,14 @@+/**+ * The floating-label field of a sign-in form: a generous corner and edge, with the label resting+ * inside the field until the field is focused or filled, then lifting onto its top edge. The+ * label is the field's `peer`, so it follows the field's placeholder and focus state in CSS.+ * `webkit-dark-styles` keeps a browser's autofill from repainting the field.+ */+export const floatingField: string =+ 'webkit-dark-styles peer h-auto w-full rounded-2xl border px-3.5 pb-2.5 pt-3 text-text-primary duration-200 motion-reduce:transition-none focus:border-accent-primary focus-visible:border-accent-primary';++export const floatingLabel: string =+ 'absolute start-3 top-1.5 z-10 origin-[0] -translate-y-4 scale-75 transform bg-surface-primary px-2 text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary motion-reduce:transition-none rtl:peer-focus:left-auto rtl:peer-focus:translate-x-1/4';++export const floatingSecretButton: string =+ 'size-9 rounded-xl text-text-secondary-alt hover:bg-transparent hover:text-text-primary';diff --git a/packages/client/src/components/index.ts b/packages/client/src/components/index.tsindex fbe6c4c163..37f6c2b3f5 100644--- a/packages/client/src/components/index.ts+++ b/packages/client/src/components/index.ts@@ -96,3 +96,4 @@ export type {DataTableSearchProps,DataTableProps as VirtualizedDataTableProps,} from './DataTable/DataTable.types';+export { floatingLabel } from './floating';