diff --git a/src/components/Card/Card.stories.tsx b/src/components/Card/Card.stories.tsx index 7e7848b56..118b5afa0 100644 --- a/src/components/Card/Card.stories.tsx +++ b/src/components/Card/Card.stories.tsx @@ -30,7 +30,6 @@ export const Default: Story = { } export const Clickable: Story = { args: { - as: 'button', clickable: true, onClick: () => console.log('Clicked!'), children: ( @@ -49,7 +48,6 @@ export const Clickable: Story = { } export const Disabled: Story = { args: { - as: 'button', clickable: true, disabled: true, children: ( diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx index 6e9506df2..fbab80a3a 100644 --- a/src/components/Card/Card.tsx +++ b/src/components/Card/Card.tsx @@ -1,48 +1,60 @@ -import { clsx } from 'clsx' -import { ElementType, forwardRef } from 'react' +import { Slot } from '@radix-ui/react-slot' +import { cva, VariantProps } from 'class-variance-authority' +import { HTMLAttributes } from 'react' -import { - Box, - PolymorphicComponent, - PolymorphicProps, - PolymorphicRef, -} from '../Box' +const cardVariants = cva(['overflow-hidden', 'rounded-md', 'p-4', 'w-full'], { + variants: { + clickable: { + true: 'hover:opacity-80 cursor-pointer focus:ring-2 focus:ring-focus focus:outline-none', + }, + disabled: { + true: 'opacity-50 cursor-default pointer-events-none', + }, + outlined: { + true: 'border border-border-normal bg-transparent', + false: 'bg-background-secondary', + }, + blur: { + true: 'backdrop-blur', + }, + }, + defaultVariants: { + outlined: false, + }, +}) -import * as styles from './styles.css' +interface CardProps + extends HTMLAttributes, + VariantProps { + asChild?: boolean +} -type CardProps = styles.CardVariants +export const Card = (props: CardProps) => { + const { + className, + children, + clickable, + outlined, + disabled, + blur, + asChild, + ...rest + } = props -export const Card: PolymorphicComponent = forwardRef( - ( - props: PolymorphicProps, - ref: PolymorphicRef - ) => { - const { - className, - children, - clickable, - outlined, - disabled, - blur, - width = 'full', - ...rest - } = props - return ( - - {children} - - ) - } -) + const Comp = asChild ? Slot : 'div' + + return ( + + {children} + + ) +} diff --git a/src/components/Scroll/Scroll.stories.tsx b/src/components/Scroll/Scroll.stories.tsx index 890ff6512..64bcebb13 100644 --- a/src/components/Scroll/Scroll.stories.tsx +++ b/src/components/Scroll/Scroll.stories.tsx @@ -16,12 +16,11 @@ type Story = StoryObj const StoryWrapper: StoryFn = args => ( diff --git a/src/components/Tabs/Tabs.stories.tsx b/src/components/Tabs/Tabs.stories.tsx index b104bc1ec..d029bef57 100644 --- a/src/components/Tabs/Tabs.stories.tsx +++ b/src/components/Tabs/Tabs.stories.tsx @@ -13,7 +13,7 @@ export default { type Story = StoryObj const Content = ({ children }: any) => ( - + {children} diff --git a/src/components/ThemeProvider/ThemeProvider.stories.tsx b/src/components/ThemeProvider/ThemeProvider.stories.tsx index b35485c06..217a3132a 100644 --- a/src/components/ThemeProvider/ThemeProvider.stories.tsx +++ b/src/components/ThemeProvider/ThemeProvider.stories.tsx @@ -32,7 +32,7 @@ export const Nested = () => {
- + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do @@ -50,7 +50,7 @@ export const Nested = () => {
- + Lorem ipsum dolor sit amet, consectetur adipiscing elit, @@ -84,7 +84,7 @@ export const Nested = () => { backgroundSecondary: 'navy', }} > - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, @@ -108,7 +108,7 @@ export const Nested = () => { scope="application4" prefersColorScheme > - + Lorem ipsum dolor sit amet, consectetur adipiscing elit, diff --git a/src/components/Toast/Toast.stories.tsx b/src/components/Toast/Toast.stories.tsx index f67aee133..4490f6014 100644 --- a/src/components/Toast/Toast.stories.tsx +++ b/src/components/Toast/Toast.stories.tsx @@ -25,7 +25,7 @@ const ToastStory = (args: ToastProps) => { const toast = useToast() return ( - +