|
| 1 | +import type { ReactNode } from 'react' |
| 2 | +import { cn, Skeleton } from '@sim/emcn' |
| 3 | +import { cva, type VariantProps } from 'class-variance-authority' |
| 4 | + |
| 5 | +const authLoadingSkeletonVariants = cva('', { |
| 6 | + variants: { |
| 7 | + shape: { |
| 8 | + title: 'h-[38px] rounded-[4px]', |
| 9 | + label: 'h-[14px] rounded-[4px]', |
| 10 | + control: 'h-[44px] rounded-[10px]', |
| 11 | + divider: 'h-[1px] rounded-[1px]', |
| 12 | + }, |
| 13 | + }, |
| 14 | +}) |
| 15 | + |
| 16 | +interface AuthLoadingSkeletonProps extends VariantProps<typeof authLoadingSkeletonVariants> { |
| 17 | + className?: string |
| 18 | +} |
| 19 | + |
| 20 | +/** Placeholder geometry shared by the auth route loading states. */ |
| 21 | +export function AuthLoadingSkeleton({ shape, className }: AuthLoadingSkeletonProps) { |
| 22 | + return <Skeleton className={cn(authLoadingSkeletonVariants({ shape }), className)} /> |
| 23 | +} |
| 24 | + |
| 25 | +interface AuthLoadingFrameProps { |
| 26 | + children: ReactNode |
| 27 | +} |
| 28 | + |
| 29 | +export function AuthLoadingFrame({ children }: AuthLoadingFrameProps) { |
| 30 | + return <div className='flex flex-col items-center'>{children}</div> |
| 31 | +} |
| 32 | + |
| 33 | +interface AuthLoadingFieldProps { |
| 34 | + labelWidthClassName: string |
| 35 | + className?: string |
| 36 | +} |
| 37 | + |
| 38 | +export function AuthLoadingField({ labelWidthClassName, className }: AuthLoadingFieldProps) { |
| 39 | + return ( |
| 40 | + <div className={cn('w-full space-y-2', className)}> |
| 41 | + <AuthLoadingSkeleton shape='label' className={labelWidthClassName} /> |
| 42 | + <AuthLoadingSkeleton shape='control' className='w-full' /> |
| 43 | + </div> |
| 44 | + ) |
| 45 | +} |
| 46 | + |
| 47 | +/** The divider and paired provider-action placeholders on login and signup. */ |
| 48 | +export function AuthLoadingAlternateActions() { |
| 49 | + return ( |
| 50 | + <> |
| 51 | + <AuthLoadingSkeleton shape='divider' className='mt-6 w-full' /> |
| 52 | + <div className='mt-6 flex w-full gap-3'> |
| 53 | + <AuthLoadingSkeleton shape='control' className='flex-1' /> |
| 54 | + <AuthLoadingSkeleton shape='control' className='flex-1' /> |
| 55 | + </div> |
| 56 | + </> |
| 57 | + ) |
| 58 | +} |
0 commit comments