Skip to content

Commit 4e5d498

Browse files
committed
feat(select): select style
1 parent 7ce2f19 commit 4e5d498

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import type { ComponentMeta, ComponentStory } from '@storybook/react';
1+
import type { Meta, StoryObj } from '@storybook/react';
22
import React from 'react';
33

44
import Select from '.';
55

6-
const componentMeta: ComponentMeta<typeof Select> = {
6+
const componentMeta: Meta<typeof Select> = {
77
title: 'Modern/Select',
88
component: Select,
99
};
1010

1111
export default componentMeta;
1212

13-
const Template: ComponentStory<typeof Select> = () => {
14-
return (
13+
export const Template: StoryObj<typeof Select> = {
14+
render: () => (
1515
<Select
1616
style={{
1717
width: 400,
@@ -23,7 +23,5 @@ const Template: ComponentStory<typeof Select> = () => {
2323
]}
2424
defaultValue='age'
2525
/>
26-
);
26+
),
2727
};
28-
29-
export const Default = Template.bind({});

packages/design/components/Select/index.tsx

+18-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,24 @@ const Select = ({ options, style, defaultValue, className, onChange }: SelectPro
3939
<span>{optionsMap[active]?.label}</span>
4040
<ArrowDown className='bgm-select-arrow' />
4141
</div>
42-
<select
43-
defaultValue={defaultValue}
44-
onChange={(e) => {
45-
handleOptionClick(e.target.value);
46-
}}
47-
>
48-
{options.map((option) => (
49-
<option key={option.value} value={option.value}>
50-
{option.label}
51-
</option>
52-
))}
53-
</select>
42+
{open ? (
43+
<ul className={cn('bgm-select__dropdown')} defaultValue={defaultValue}>
44+
{options.map((option) => (
45+
<li
46+
className={cn('bgm-select__dropdown-item')}
47+
key={option.value}
48+
value={option.value}
49+
onClick={() => {
50+
handleOptionClick(option.value);
51+
}}
52+
>
53+
{option.label}
54+
</li>
55+
))}
56+
</ul>
57+
) : (
58+
<></>
59+
)}
5460
</div>
5561
);
5662
};

packages/design/components/Select/style/index.less

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
top: 100%;
1919
border: 2px solid @gray-10;
2020
box-sizing: border-box;
21-
padding: 8px 12px;
21+
padding: 10px 0;
2222
width: 100%;
2323
left: 0;
2424
border-radius: 19px;
@@ -27,6 +27,16 @@
2727
> div {
2828
padding: 9px 0;
2929
}
30+
31+
&-item {
32+
height: 1em;
33+
padding: 10px;
34+
// padding: 0.5em 0;
35+
36+
&:hover {
37+
background-color: @gray-10;
38+
}
39+
}
3040
}
3141

3242
select {

0 commit comments

Comments
 (0)