|
| 1 | +import type { CardProps, HeadingProps, TextProps } from '@fuels/ui'; |
| 2 | +import { Card, Heading, createComponent, Text, withNamespace } from '@fuels/ui'; |
| 3 | +import { tv } from 'tailwind-variants'; |
| 4 | + |
| 5 | +import { ReactComponent as EmptySvg } from './empty.svg'; |
| 6 | + |
| 7 | +export type EmptyCardProps = CardProps; |
| 8 | +export type EmptyCardTitleProps = HeadingProps; |
| 9 | +export type EmptyCardDescriptionProps = TextProps; |
| 10 | + |
| 11 | +export const EmptyCardRoot = createComponent<EmptyCardProps, typeof Card>({ |
| 12 | + id: 'EmptyCard', |
| 13 | + render: (_, { children, className, ...props }) => { |
| 14 | + const classes = styles({ className }); |
| 15 | + return ( |
| 16 | + <Card {...props} className={classes.root({ className })}> |
| 17 | + <EmptySvg |
| 18 | + width={80} |
| 19 | + height={80} |
| 20 | + viewBox="0 0 682.66 682.66" |
| 21 | + className={classes.image({ |
| 22 | + className: '[&_path]:stroke-[8] text-muted', |
| 23 | + })} |
| 24 | + /> |
| 25 | + {children} |
| 26 | + </Card> |
| 27 | + ); |
| 28 | + }, |
| 29 | +}); |
| 30 | + |
| 31 | +export const EmptyCardTitle = createComponent< |
| 32 | + EmptyCardTitleProps, |
| 33 | + typeof Card.Title |
| 34 | +>({ |
| 35 | + id: 'EmptyCardTitle', |
| 36 | + render: (_, { className, ...props }) => { |
| 37 | + const classes = styles({ className }); |
| 38 | + return <Heading {...props} as="h4" size="5" className={classes.title()} />; |
| 39 | + }, |
| 40 | +}); |
| 41 | + |
| 42 | +export const EmptyCardDescription = createComponent< |
| 43 | + EmptyCardDescriptionProps, |
| 44 | + typeof Text |
| 45 | +>({ |
| 46 | + id: 'EmptyCardDescription', |
| 47 | + render: (_, { className, ...props }) => { |
| 48 | + const classes = styles({ className }); |
| 49 | + return <Text {...props} className={classes.description()} />; |
| 50 | + }, |
| 51 | +}); |
| 52 | + |
| 53 | +export const EmptyCard = withNamespace(EmptyCardRoot, { |
| 54 | + Title: EmptyCardTitle, |
| 55 | + Description: EmptyCardDescription, |
| 56 | +}); |
| 57 | + |
| 58 | +const styles = tv({ |
| 59 | + slots: { |
| 60 | + root: 'p-6 text-center flex flex-col items-center gap-0', |
| 61 | + image: 'mb-6', |
| 62 | + title: 'font-semibold text-heading', |
| 63 | + description: 'text-sm text-secondary mt-2', |
| 64 | + }, |
| 65 | +}); |
0 commit comments