Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ui-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './ui/checkbox';
export * from './ui/collapsible';
export * from './ui/color-picker';
export * from './ui/command';
export * from './ui/composing-card';
export * from './ui/context-menu';
export * from './ui/data-table';
export * from './ui/data-table-column-header';
Expand Down
44 changes: 44 additions & 0 deletions packages/ui-components/src/stories/composing-card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Meta, StoryObj } from '@storybook/react';

import { ComposingCard } from '@/ui/composing-card';
import { ThemeAwareDecorator } from '../../.storybook/decorators';

/**
* A responsive card wrapper that accepts children and supports transparent or solid background.
*/
const meta = {
title: 'ui/ComposingCard',
component: ComposingCard,
tags: ['autodocs'],
args: {
className: 'w-96 p-6',
transparent: false,
},
render: (args) => (
<ComposingCard {...args}>
<p className="text-sm text-foreground">Card content goes here.</p>
</ComposingCard>
),
parameters: {
layout: 'centered',
},
decorators: [ThemeAwareDecorator],
} satisfies Meta<typeof ComposingCard>;

export default meta;

type Story = StoryObj<typeof meta>;

/**
* Default card with the component's solid background.
*/
export const Default: Story = {};

/**
* Card with transparent background.
*/
export const Transparent: Story = {
args: {
transparent: true,
},
};
29 changes: 29 additions & 0 deletions packages/ui-components/src/ui/composing-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';

import { cn } from '../lib/cn';

type ComposingCardProps = React.HTMLAttributes<HTMLDivElement> & {
transparent?: boolean;
};

const ComposingCard = React.forwardRef<HTMLDivElement, ComposingCardProps>(
({ className, transparent = false, children, ...props }, ref) => (
<div
ref={ref}
className={cn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with cn you can do this, and not use the ternary

className={cn(
  'w-full rounded-2xl border',
  {
    'bg-transparent': transparent,
    'bg-neutral-50 dark:bg-background': !transparent,
  },
  className,
)}

'w-full rounded-2xl border',
{
'bg-transparent': transparent,
'bg-neutral-50 dark:bg-background': !transparent,
},
className,
)}
{...props}
>
{children}
</div>
),
);
ComposingCard.displayName = 'ComposingCard';

export { ComposingCard };
Loading