Skip to content

Commit 9b9d573

Browse files
author
Roman Snapko
authored
Add ComposingCard component with Storybook documentation (#2149)
<!-- Ensure the title clearly reflects what was changed. Provide a clear and concise description of the changes made. The PR should only contain the changes related to the issue, and no other unrelated changes. --> Fixes OPS-3926
1 parent 6eab4a8 commit 9b9d573

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

packages/ui-components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export * from './ui/checkbox';
1515
export * from './ui/collapsible';
1616
export * from './ui/color-picker';
1717
export * from './ui/command';
18+
export * from './ui/composing-card';
1819
export * from './ui/context-menu';
1920
export * from './ui/data-table';
2021
export * from './ui/data-table-column-header';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { ComposingCard } from '@/ui/composing-card';
4+
import { ThemeAwareDecorator } from '../../.storybook/decorators';
5+
6+
/**
7+
* A responsive card wrapper that accepts children and supports transparent or solid background.
8+
*/
9+
const meta = {
10+
title: 'ui/ComposingCard',
11+
component: ComposingCard,
12+
tags: ['autodocs'],
13+
args: {
14+
className: 'w-96 p-6',
15+
transparent: false,
16+
},
17+
render: (args) => (
18+
<ComposingCard {...args}>
19+
<p className="text-sm text-foreground">Card content goes here.</p>
20+
</ComposingCard>
21+
),
22+
parameters: {
23+
layout: 'centered',
24+
},
25+
decorators: [ThemeAwareDecorator],
26+
} satisfies Meta<typeof ComposingCard>;
27+
28+
export default meta;
29+
30+
type Story = StoryObj<typeof meta>;
31+
32+
/**
33+
* Default card with the component's solid background.
34+
*/
35+
export const Default: Story = {};
36+
37+
/**
38+
* Card with transparent background.
39+
*/
40+
export const Transparent: Story = {
41+
args: {
42+
transparent: true,
43+
},
44+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as React from 'react';
2+
3+
import { cn } from '../lib/cn';
4+
5+
type ComposingCardProps = React.HTMLAttributes<HTMLDivElement> & {
6+
transparent?: boolean;
7+
};
8+
9+
const ComposingCard = React.forwardRef<HTMLDivElement, ComposingCardProps>(
10+
({ className, transparent = false, children, ...props }, ref) => (
11+
<div
12+
ref={ref}
13+
className={cn(
14+
'w-full rounded-2xl border',
15+
{
16+
'bg-transparent': transparent,
17+
'bg-neutral-50 dark:bg-background': !transparent,
18+
},
19+
className,
20+
)}
21+
{...props}
22+
>
23+
{children}
24+
</div>
25+
),
26+
);
27+
ComposingCard.displayName = 'ComposingCard';
28+
29+
export { ComposingCard };

0 commit comments

Comments
 (0)