feat: add sign in button with progress states
This commit is contained in:
parent
7e3f875f35
commit
02259df5d3
22
app/components/auth/form/sign-in-button.tsx
Normal file
22
app/components/auth/form/sign-in-button.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { ArrowRight, Loader2 } from 'lucide-react';
|
||||||
|
import { Button } from '~/components/ui/button';
|
||||||
|
import { BRAND } from '~/data/brand';
|
||||||
|
|
||||||
|
export type SignInState = 'idle' | 'busy' | 'done';
|
||||||
|
|
||||||
|
const LABELS: Record<SignInState, string> = {
|
||||||
|
idle: 'Sign in',
|
||||||
|
busy: 'Signing in…',
|
||||||
|
done: `Signed in. Opening ${BRAND.product}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function SignInButton({ state }: { state: SignInState }) {
|
||||||
|
const working = state !== 'idle';
|
||||||
|
return (
|
||||||
|
<Button type='submit' size='xl' variant={state === 'done' ? 'success' : 'default'} disabled={working} aria-busy={working} className='group w-full'>
|
||||||
|
{state === 'busy' && <Loader2 size={16} className='animate-spin' />}
|
||||||
|
{LABELS[state]}
|
||||||
|
{state === 'idle' && <ArrowRight size={15} className='transition-transform group-hover:translate-x-0.5' />}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user