Skip to content

Commit

Permalink
feat(select): select style
Browse files Browse the repository at this point in the history
  • Loading branch information
Gypsophyllite committed May 18, 2023
1 parent 7ce2f19 commit c73c8d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
12 changes: 5 additions & 7 deletions packages/design/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { ComponentMeta, ComponentStory } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';

import Select from '.';

const componentMeta: ComponentMeta<typeof Select> = {
const componentMeta: Meta<typeof Select> = {
title: 'Modern/Select',
component: Select,
};

export default componentMeta;

const Template: ComponentStory<typeof Select> = () => {
return (
export const Template: StoryObj<typeof Select> = {
render: () => (
<Select
style={{
width: 400,
Expand All @@ -23,7 +23,5 @@ const Template: ComponentStory<typeof Select> = () => {
]}
defaultValue='age'
/>
);
),
};

export const Default = Template.bind({});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions packages/design/components/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@ const Select = ({ options, style, defaultValue, className, onChange }: SelectPro
<span>{optionsMap[active]?.label}</span>
<ArrowDown className='bgm-select-arrow' />
</div>
<select
defaultValue={defaultValue}
onChange={(e) => {
handleOptionClick(e.target.value);
}}
>
{options.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
{open ? (
<ul className={cn('bgm-select__dropdown')} defaultValue={defaultValue}>
{options.map((option) => (
<li
className={cn('bgm-select__dropdown-item')}
key={option.value}
value={option.value}
onClick={() => {
handleOptionClick(option.value);
}}
>
{option.label}
</li>
))}
</ul>
) : (
<></>
)}
</div>
);
};
Expand Down
12 changes: 11 additions & 1 deletion packages/design/components/Select/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
top: 100%;
border: 2px solid @gray-10;
box-sizing: border-box;
padding: 8px 12px;
padding: 10px 0;
width: 100%;
left: 0;
border-radius: 19px;
Expand All @@ -27,6 +27,16 @@
> div {
padding: 9px 0;
}

&-item {
height: 1em;
padding: 10px;
// padding: 0.5em 0;

&:hover {
background-color: @gray-10;
}
}
}

select {
Expand Down

0 comments on commit c73c8d8

Please sign in to comment.