import { colors, space, type } from '@atiraui/foundations/tokens.stylex' import { Spinner } from '@atiraui/primitives' import * as stylex from '@stylexjs/stylex' import { Check } from 'lucide-react' import type { ComponentPropsWithRef, ReactNode } from 'react' export type LoaderState = | { status: 'pending' } | { status: 'streaming' } | { status: 'complete' } type NativeDivProps = Omit< ComponentPropsWithRef<'div'>, 'children' | 'className' | 'style' > export type LoaderProps = NativeDivProps & { label?: ReactNode state: LoaderState } const stateLabels: Record = { complete: 'Complete', pending: 'Waiting', streaming: 'Generating', } export function Loader({ label, ref, state, ...props }: LoaderProps) { const active = state.status === 'pending' || state.status === 'streaming' return (
{active ? ( ) : (
) } const styles = stylex.create({ root: { alignItems: 'center', color: colors.textMuted, display: 'inline-flex', fontFamily: type.family, fontSize: type.sizeSmall, gap: space.x2, lineHeight: type.lineCompact, minBlockSize: '1.5rem', }, icon: { blockSize: '0.875rem', color: colors.textMuted, flexShrink: 0, inlineSize: '0.875rem', }, })