70 lines
2.6 KiB
TypeScript
70 lines
2.6 KiB
TypeScript
import type { VariantProps } from "class-variance-authority"
|
|
import { cva } from "class-variance-authority"
|
|
|
|
export { default as StatusBadge } from "./StatusBadge.vue"
|
|
|
|
export const statusBadgeVariants = cva(
|
|
"inline-flex items-center justify-center bg-gray-50 dark:bg-neutral-700 border-1 aspect-1/1 p-1 lg:aspect-auto lg:px-2 lg:py-0.5 rounded-full lg:rounded-sm text-xs lg:w-full whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
draft:
|
|
"border-dashed text-muted-foreground dark:bg-transparent",
|
|
issued:
|
|
"bg-transparent border-sky-200 text-sky-600 dark:bg-sky-800 dark:text-sky-300 dark:border-0",
|
|
paid:
|
|
"border-none bg-success text-success-foreground",
|
|
due:
|
|
"font-bold border-none bg-amber-300 text-amber-800 dark:bg-amber-900 dark:text-amber-500",
|
|
reminded:
|
|
"font-bold border-none bg-red-500 text-red-100 dark:bg-red-900 dark:text-red-200 dark:font-normal",
|
|
cancelled:
|
|
"bg-background text-foreground",
|
|
|
|
},
|
|
size: {
|
|
default: '',
|
|
sm: 'lg:aspect-1/1 lg:p-1, lg:rounded-full lg:w-auto lg:w-1 text-transparent dark:text-transparent',
|
|
lg: 'text-sm px-6!',
|
|
icon: '',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "draft",
|
|
},
|
|
},
|
|
)
|
|
export type StatusBadgeVariants = VariantProps<typeof statusBadgeVariants>
|
|
|
|
export const statusBadgeLabels: { [key: string]: string } = {
|
|
draft: 'Entwurf',
|
|
issued: 'Gestellt',
|
|
paid: 'Bezahlt',
|
|
due: 'Fällig',
|
|
reminded: 'Gemahnt',
|
|
cancelled: 'Storniert'
|
|
}
|
|
|
|
export function statusTextStyle(status: string): string {
|
|
if (status === 'draft') return 'text-muted-foreground'
|
|
if (status === 'due') return 'text-amber-600'
|
|
if (status === 'reminded') return 'text-red-600 dark:text-red-400'
|
|
if (status === 'cancelled') return 'line-through text-muted-foreground decoration-gray-300'
|
|
|
|
return (['due', 'reminded'].includes(status)) ?
|
|
'var(--color-destructive)' :
|
|
''
|
|
}
|
|
|
|
export const castToStatusVariant = (status: string): StatusBadgeVariants['variant'] => {
|
|
const statusMapping: Record<string, StatusBadgeVariants['variant']> = {
|
|
'draft': 'draft',
|
|
'issued': 'issued',
|
|
'paid': 'paid',
|
|
'due': 'due',
|
|
'reminded': 'reminded',
|
|
'cancelled': 'cancelled',
|
|
};
|
|
|
|
return statusMapping[status] || 'draft';
|
|
}; |