Skip to content

Commit 877ca0b

Browse files
committed
optimize: optimize command-item
1 parent a722b77 commit 877ca0b

File tree

3 files changed

+25
-45
lines changed

3 files changed

+25
-45
lines changed

packages/ui/src/components/command/CommandItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const CommandItem = (props: CommandItemProps) => {
2323
>
2424
{isValidElement(leading) ? withClassName(leading, itemIcon()) : leading}
2525

26-
<span>{children}</span>
26+
{children}
2727

2828
{trailing}
2929

playground/src/app/(demo)/combobox/modules/ComboboxDemo.tsx

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,38 @@ const ComboboxDemo = () => {
99

1010
const frameworks = [
1111
{
12-
label: (
13-
<div className="flex items-center gap-2">
14-
<span>Vue</span>
15-
<Check className={cn('ml-auto', value === 'vue' ? 'opacity-100' : 'opacity-0')} />
16-
</div>
17-
),
12+
label: 'Vue',
13+
trailing: <Check className={cn('ml-auto', value === 'vue' ? 'opacity-100' : 'opacity-0')} />,
1814
value: 'vue'
1915
},
2016
{
21-
label: (
22-
<div className="flex items-center gap-2">
23-
<span>React</span>
24-
<Check className={cn('ml-auto', value === 'react' ? 'opacity-100' : 'opacity-0')} />
25-
</div>
26-
),
17+
label: 'React',
18+
trailing: <Check className={cn('ml-auto', value === 'react' ? 'opacity-100' : 'opacity-0')} />,
2719
value: 'react'
2820
},
2921
{
30-
label: (
31-
<div className="flex items-center gap-2">
32-
<span>Next.js</span>
33-
<Check className={cn('ml-auto', value === 'nextjs' ? 'opacity-100' : 'opacity-0')} />
34-
</div>
35-
),
22+
label: 'Next.js',
23+
trailing: <Check className={cn('ml-auto', value === 'nextjs' ? 'opacity-100' : 'opacity-0')} />,
3624
value: 'nextjs'
3725
},
3826
{
39-
label: (
40-
<div className="flex items-center gap-2">
41-
<span>SvelteKit</span>
42-
<Check className={cn('ml-auto', value === 'sveltekit' ? 'opacity-100' : 'opacity-0')} />
43-
</div>
44-
),
27+
label: 'SvelteKit',
28+
trailing: <Check className={cn('ml-auto', value === 'sveltekit' ? 'opacity-100' : 'opacity-0')} />,
4529
value: 'sveltekit'
4630
},
4731
{
48-
label: (
49-
<div className="flex items-center gap-2">
50-
<span>Nuxt</span>
51-
<Check className={cn('ml-auto', value === 'nuxt' ? 'opacity-100' : 'opacity-0')} />
52-
</div>
53-
),
32+
label: 'Nuxt',
33+
trailing: <Check className={cn('ml-auto', value === 'nuxt' ? 'opacity-100' : 'opacity-0')} />,
5434
value: 'nuxt'
5535
},
5636
{
57-
label: (
58-
<div className="flex items-center gap-2">
59-
<span>Remix</span>
60-
<Check className={cn('ml-auto', value === 'remix' ? 'opacity-100' : 'opacity-0')} />
61-
</div>
62-
),
37+
label: 'Remix',
38+
trailing: <Check className={cn('ml-auto', value === 'remix' ? 'opacity-100' : 'opacity-0')} />,
6339
value: 'remix'
6440
},
6541
{
66-
label: (
67-
<div className="flex items-center gap-2">
68-
<span>Astro</span>
69-
<Check className={cn('ml-auto', value === 'astro' ? 'opacity-100' : 'opacity-0')} />
70-
</div>
71-
),
42+
label: 'Astro',
43+
trailing: <Check className={cn('ml-auto', value === 'astro' ? 'opacity-100' : 'opacity-0')} />,
7244
value: 'astro'
7345
}
7446
];

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

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

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

99
import DemoTabs from './modules/DemoTabs';
1010
import DemoTitle from './modules/DemoTitle';
1111

12+
const extensions = [
13+
{
14+
children: null,
15+
label: 'Combobox',
16+
value: 'combobox'
17+
}
18+
];
19+
1220
// 动态读取组件目录的函数
1321
function getComponentDirectories() {
1422
try {
@@ -28,7 +36,7 @@ function getComponentDirectories() {
2836
value: dir.name
2937
}));
3038

31-
return componentDirs;
39+
return [...componentDirs, ...extensions];
3240
} catch (error) {
3341
console.error('读取组件目录失败:', error);
3442
// 如果读取失败,返回默认值

0 commit comments

Comments
 (0)