headplane/app/components/Card.tsx

44 lines
983 B
TypeScript
Raw Normal View History

2024-12-31 10:31:50 +05:30
import type { HTMLProps } from 'react';
2024-12-31 10:30:14 +05:30
import { Heading as AriaHeading } from 'react-aria-components';
import { cn } from '~/utils/cn';
2024-12-31 10:30:14 +05:30
function Title(props: Parameters<typeof AriaHeading>[0]) {
return (
<AriaHeading
2024-12-31 10:30:14 +05:30
{...props}
slot="title"
className={cn('text-lg font-semibold leading-6 mb-5', props.className)}
/>
2024-12-31 10:30:14 +05:30
);
}
2024-12-31 10:30:14 +05:30
function Text(props: React.HTMLProps<HTMLParagraphElement>) {
return (
2024-12-31 10:30:14 +05:30
<p {...props} className={cn('text-base leading-6 my-0', props.className)} />
);
}
2024-12-31 10:30:14 +05:30
type Props = HTMLProps<HTMLDivElement> & {
variant?: 'raised' | 'flat';
2024-12-31 10:30:14 +05:30
};
2024-12-31 10:30:14 +05:30
function Card(props: Props) {
return (
<div
2024-12-31 10:30:14 +05:30
{...props}
className={cn(
'w-full max-w-md overflow-hidden rounded-xl p-4',
2024-12-31 10:30:14 +05:30
props.variant === 'flat'
? 'bg-transparent shadow-none'
: 'bg-ui-50 dark:bg-ui-900 shadow-sm',
'border border-ui-200 dark:border-ui-700',
2024-12-31 10:30:14 +05:30
props.className,
)}
>
2024-12-31 10:30:14 +05:30
{props.children}
</div>
2024-12-31 10:30:14 +05:30
);
}
2024-12-31 10:30:14 +05:30
export default Object.assign(Card, { Title, Text });