Skip to content

Commit b44c695

Browse files
authored
Merge pull request #79 from COW-dev/fix/#78-select
[FIX] Select width 수정, TextArea/Input/Select padding 조절
2 parents 755b5e0 + 5691fb1 commit b44c695

File tree

9 files changed

+41
-56
lines changed

9 files changed

+41
-56
lines changed

src/shared/ui/Input/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function Input({ value, onClickReset, ...props }: InputProps) {
1515
<Flex gap={8} alignItems="center" className="relative w-full">
1616
<input
1717
value={value}
18-
className="w-full rounded-xl border-none bg-white px-4 py-3 outline-1 outline-gray-200 focus:ring-4 focus:ring-blue-200 focus:outline-blue-500 md:py-3.5"
18+
className="w-full rounded-xl border-none bg-white px-4 py-3.5 outline-1 outline-gray-200 focus:ring-4 focus:ring-blue-200 focus:outline-blue-500"
1919
{...props}
2020
/>
2121
{value && (

src/shared/ui/Select/Option.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { cn } from '@/shared/lib/core';
55
import { useSelectContext } from './Select.context';
66

77
const optionVariants = cva(
8-
'font-semibold text- cursor-pointer first:rounded-t-md last:rounded-b-md hover:bg-gray-50',
8+
'font-semibold text- cursor-pointer first:rounded-t-md last:rounded-b-md hover:bg-gray-100',
99
{
1010
variants: {
1111
size: {
1212
md: 'px-3 py-1 text-sm',
13-
lg: 'px-5 py-2 md:py-2.5',
13+
lg: 'px-4 py-3.5',
1414
},
1515
},
1616
defaultVariants: {

src/shared/ui/Select/OptionGroupName.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@ type Props = {
33
};
44

55
export function OptionGroupName({ name }: Props) {
6-
return (
7-
<div className="border-b-2 border-gray-100 px-5 py-2 text-base text-gray-300 md:text-lg">
8-
{name}
9-
</div>
10-
);
6+
return <div className="border-b-2 border-gray-100 px-4 py-3.5 text-lg text-gray-300">{name}</div>;
117
}

src/shared/ui/Select/OptionList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { cn } from '@/shared/lib/core';
55
import { useSelectContext } from './Select.context';
66

77
const optionListVariants = cva(
8-
'absolute top-full left-0 z-50 mt-1 max-h-60 w-full overflow-y-auto rounded-md border border-gray-200 bg-white font-semibold text-gray-400 shadow-lg',
8+
'relative z-50 mt-1 max-h-60 w-full overflow-y-auto rounded-md border border-gray-200 bg-white font-semibold text-gray-400 shadow-lg',
99
{
1010
variants: {
1111
size: {
1212
md: 'text-sm min-w-24',
13-
lg: 'text-base md:text-lg',
13+
lg: 'md:text-lg',
1414
},
1515
},
1616
defaultVariants: {

src/shared/ui/Select/Select.stories.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ const meta = {
77
title: 'components/Select',
88
component: Select,
99
tags: ['autodocs'],
10-
argTypes: {
11-
size: {
12-
control: { type: 'radio' },
13-
options: ['md', 'lg'],
14-
description: 'Select 컴포넌트의 크기 옵션입니다.',
15-
},
16-
defaultValue: {
17-
control: 'text',
18-
description: '기본 선택값입니다.',
10+
parameters: {
11+
docs: {
12+
description: {
13+
component:
14+
'Select 컴포넌트는 드롭다운 메뉴를 통해 여러 옵션 중 하나를 선택할 수 있는 UI 요소입니다. 사용자는 버튼을 클릭하여 옵션 목록을 열고, 원하는 옵션을 선택할 수 있습니다. 선택된 옵션은 버튼에 표시되며, 사용자는 언제든지 다른 옵션으로 변경할 수 있습니다.',
15+
},
1916
},
2017
},
2118
} satisfies Meta<typeof Select>;
@@ -26,18 +23,22 @@ type Story = StoryObj<typeof Select>;
2623
const defaultContents = ['객관식', '단답형', '체크박스', '드롭다운', '파일'];
2724

2825
export const Basic: Story = {
29-
parameters: {
30-
docs: {
31-
description: {
32-
component: '드롭다운 선택 컴포넌트로, 기본 선택과 그룹화된 선택을 지원합니다.',
33-
},
34-
},
35-
},
3626
args: {
3727
value: '유형을 선택해주세요',
3828
size: 'md',
3929
defaultValue: '유형을 선택해주세요',
4030
},
31+
argTypes: {
32+
size: {
33+
control: { type: 'radio' },
34+
options: ['md', 'lg'],
35+
description: 'Select 컴포넌트의 크기 옵션입니다.',
36+
},
37+
defaultValue: {
38+
control: 'text',
39+
description: '기본 선택값입니다.',
40+
},
41+
},
4142
render: (args) => {
4243
const [value, setValue] = useState(args.defaultValue);
4344
return (

src/shared/ui/Select/SelectButton.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cn } from '@/shared/lib/core';
22

3+
import { Flex } from '../Flex';
34
import { Icon } from '../Icon';
45

56
type Props = {
@@ -23,22 +24,24 @@ type Props = {
2324
};
2425

2526
const sizeVariants = {
26-
md: 'px-3 py-1 text-sm w-fit min-w-24',
27-
lg: 'px-5 py-1.5 md:py-2.5 min-w-64 md:w-72 text-base md:text-lg',
27+
md: 'px-3 py-1 text-sm min-w-24',
28+
lg: 'px-4 py-3.5 min-w-64 text-lg',
2829
} as const;
2930

3031
export function SelectButton({ selected, onClick, isOpen, size = 'lg' }: Props) {
3132
return (
32-
<div
33+
<Flex
34+
alignItems="center"
3335
onClick={onClick}
3436
className={cn(
3537
sizeVariants[size],
36-
'flex cursor-pointer items-center rounded-lg border border-gray-200 bg-white text-start font-semibold text-gray-400'
38+
'w-full rounded-lg border border-gray-200 bg-white font-semibold text-gray-400'
3739
)}
3840
>
3941
<button
42+
type="button"
4043
className={cn(
41-
'flex w-full items-center justify-between rounded-lg align-middle hover:rounded-lg',
44+
'flex w-full cursor-pointer items-center justify-between rounded-lg align-middle',
4245
isOpen && 'hover:rounded-b-none'
4346
)}
4447
>
@@ -52,6 +55,6 @@ export function SelectButton({ selected, onClick, isOpen, size = 'lg' }: Props)
5255
)}
5356
/>
5457
</button>
55-
</div>
58+
</Flex>
5659
);
5760
}

src/shared/ui/Select/SelectMain.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Props = {
2828
children: ReactNode;
2929
} & Omit<ComponentProps<'select'>, 'value' | 'onChange' | 'size'>;
3030

31-
export function SelectMain({ value, onChange, size = 'lg', children }: Props) {
31+
export function SelectMain({ value, onChange, size = 'lg', defaultValue, children }: Props) {
3232
const [isOpen, setIsOpen] = useState(false);
3333

3434
const handleSelect = (option: string) => {
@@ -44,15 +44,13 @@ export function SelectMain({ value, onChange, size = 'lg', children }: Props) {
4444
size: size,
4545
}}
4646
>
47-
<div className="relative w-fit">
48-
<SelectButton
49-
selected={value}
50-
onClick={() => setIsOpen(!isOpen)}
51-
size={size}
52-
isOpen={isOpen}
53-
/>
54-
{isOpen && <OptionList>{children}</OptionList>}
55-
</div>
47+
<SelectButton
48+
selected={value || defaultValue}
49+
onClick={() => setIsOpen(!isOpen)}
50+
size={size}
51+
isOpen={isOpen}
52+
/>
53+
{isOpen && <OptionList>{children}</OptionList>}
5654
</SelectContext.Provider>
5755
);
5856
}

src/shared/ui/TextArea/TextArea.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ type Story = StoryObj<typeof TextArea>;
2323
export const Basic: Story = {
2424
args: {
2525
value: '',
26-
variant: 'gray',
2726
maxLength: 500,
2827
showCounter: true,
2928
},

src/shared/ui/TextArea/TextArea.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ type TextAreaProps = {
1010
* Current value of the textarea
1111
*/
1212
value: string;
13-
/**
14-
* Background color of the textarea
15-
* @default 'gray'
16-
*/
17-
variant: 'gray' | 'white';
1813
/**
1914
* Default height in number of rows
2015
* @default 3
@@ -31,14 +26,8 @@ type TextAreaProps = {
3126
className?: string;
3227
} & Omit<ComponentProps<'textarea'>, 'rows'>;
3328

34-
const variantStyle = {
35-
gray: 'bg-gray-50',
36-
white: 'bg-white',
37-
} as const;
38-
3929
export function TextArea({
4030
value,
41-
variant = 'gray',
4231
rows = 3,
4332
showCounter = false,
4433
className,
@@ -49,8 +38,7 @@ export function TextArea({
4938
<textarea
5039
rows={rows}
5140
className={cn(
52-
'focus:border-primary-100 w-full resize-none rounded-xl border-none px-4 py-3 text-gray-900 outline-1 outline-gray-200 transition-colors placeholder:text-gray-400 focus:border-1',
53-
variantStyle[variant],
41+
'w-full resize-none rounded-xl border-none bg-white px-4 py-3.5 text-gray-900 outline-1 outline-gray-200 transition-colors placeholder:text-gray-400 focus:ring-4 focus:ring-blue-200 focus:outline-blue-500',
5442
className
5543
)}
5644
{...props}

0 commit comments

Comments
 (0)