Skip to content

Commit ee66ac7

Browse files
committed
optimize: optimize code
1 parent cbf9622 commit ee66ac7

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

packages/ui/src/components/card/card-variants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const cardVariants = tv({
66
size: 'md'
77
},
88
slots: {
9-
content: 'flex-grow',
9+
content: 'flex-grow overflow-auto',
1010
footer: 'flex items-center justify-between',
1111
header: 'flex items-center justify-between',
1212
root: 'flex flex-col items-stretch rounded-md border bg-card text-card-foreground shadow-sm',

packages/ui/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export * from './components/breadcrumb';
1515
export * from './components/button';
1616

1717
export * from './components/card';
18-
1918
export * from './components/carousel';
2019

2120
export * from './components/checkbox';
@@ -38,6 +37,8 @@ export * from './components/scroll-area';
3837

3938
export * from './components/sonner';
4039

40+
export * from './components/switch';
41+
4142
export * from './components/tabs';
4243

4344
export * from './lib';

playground/src/app/(demo)/card/page.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Rocket, X } from 'lucide-react';
22
import React from 'react';
3-
import { Badge, Button, Card } from 'soybean-react-ui'; // 假设这些是你自己封装的 React 组件
3+
import { Badge, ButtonIcon, Card } from 'soybean-react-ui'; // 假设这些是你自己封装的 React 组件
44
import type { ThemeSize } from 'soybean-react-ui';
55

66
const sizes: ThemeSize[] = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
@@ -37,13 +37,9 @@ const DemoCard: React.FC = () => {
3737
size={size}
3838
title={`Size: ${size}`}
3939
extra={
40-
<Button
41-
asIconButton
42-
fitContent
43-
size={size}
44-
>
40+
<ButtonIcon size={size}>
4541
<X />
46-
</Button>
42+
</ButtonIcon>
4743
}
4844
>
4945
<p className="text-gray-500 dark:text-neutral-400">Content</p>

playground/src/app/(demo)/layout.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import process from 'node:process';
44

55
import Link from 'next/link';
66
import React from 'react';
7-
import { ScrollArea } from 'soybean-react-ui';
7+
import { Card, ScrollArea } from 'soybean-react-ui';
88

99
import DemoTabs from './modules/DemoTabs';
1010
import DemoTitle from './modules/DemoTitle';
@@ -43,15 +43,13 @@ function DemoLayout({ children }: { children: React.ReactNode }) {
4343
<>
4444
<DemoTabs items={componentTabs} />
4545

46-
<div className="h-full p-[18px]">
47-
<div className="h-full mb-8 border border-gray-200 rounded-xl bg-white p-6 shadow-lg transition-all dark:border-neutral-700 dark:bg-neutral-800 hover:shadow-xl">
48-
<h3 className="border-gray-200 text-xl dark:border-neutral-700 mb-4 border-b pb-2 text-gray-800 font-bold dark:text-gray-100">
49-
Demo <DemoTitle />
50-
</h3>
51-
52-
<ScrollArea className="h-full pb-20">{children}</ScrollArea>
53-
</div>
54-
</div>
46+
<Card
47+
className="h-full"
48+
classNames={{ content: 'flex-c gap-3 ' }}
49+
title={<DemoTitle />}
50+
>
51+
{children}
52+
</Card>
5553
</>
5654
);
5755
}

playground/src/app/(demo)/modules/DemoTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const DemoTitle = () => {
1010

1111
const title = currentTab.charAt(0).toUpperCase() + currentTab.slice(1);
1212

13-
return title;
13+
return <h3 className="font-semibold tracking-tight text-base">{title} Demo</h3>;
1414
};
1515

1616
export default DemoTitle;

0 commit comments

Comments
 (0)