Skip to content

Commit 006b386

Browse files
committed
feat(Select): 기본 제공되는 컴포넌트에 className 주입할 수 있게 변경 및 Menu에 zindex 추가 (#185(
1 parent 8a103ee commit 006b386

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

apps/docs/src/App.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ChangeEvent, useState } from 'react';
44

55
import '@sopt-makers/ui/dist/index.css';
66

7-
import { FieldBox, SearchField, Test, TextArea, TextField } from '@sopt-makers/ui';
7+
import { FieldBox, SearchField, Test, TextArea, TextField, SelectV2 } from '@sopt-makers/ui';
88
import { colors } from '@sopt-makers/colors';
99

1010
function App() {
@@ -46,6 +46,11 @@ function App() {
4646
setSearch('');
4747
};
4848

49+
const options = [
50+
{ label: 'Option 1', value: 'option1' },
51+
{ label: 'Option 2', value: 'option2' },
52+
];
53+
4954
return (
5055
<>
5156
<Test text='Test Component' size='big' color='blue' />
@@ -88,6 +93,30 @@ function App() {
8893
>
8994
<span style={{ color: colors.white }}>여긴 본문</span>
9095
</FieldBox>
96+
<div>
97+
<SelectV2.Root
98+
visibleOptions={2}
99+
onChange={() => {
100+
console.log('dsad');
101+
}}
102+
type='text'
103+
>
104+
<SelectV2.Trigger>
105+
<SelectV2.TriggerContent placeholder='새로운 SelectV2' />
106+
</SelectV2.Trigger>
107+
<SelectV2.Menu>
108+
{options.map((option) => (
109+
<SelectV2.MenuItem
110+
key={option.value}
111+
option={option}
112+
onClick={() => {
113+
console.log('custom logic');
114+
}}
115+
/>
116+
))}
117+
</SelectV2.Menu>
118+
</SelectV2.Root>
119+
</div>
91120
</>
92121
);
93122
}

packages/ui/Input/Select.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,18 @@ function SelectTrigger({ children }: SelectTriggerProps) {
144144
}
145145

146146
interface SelectTriggerContentProps {
147-
className?: string;
148147
placeholder?: string;
148+
className?: string;
149149
}
150150

151151
// Select.TriggerContent 컴포넌트: trigger의 미리 정의된 UI
152-
function SelectTriggerContent({ className, placeholder }: SelectTriggerContentProps) {
152+
function SelectTriggerContent({ placeholder, className }: SelectTriggerContentProps) {
153153
const { open, selected } = useSelectContext();
154154

155155
const selectedLabel = selected ? selected.label : placeholder;
156156

157157
return (
158-
<div className={`${S.select} ${open ? S.focus : ''} ${className ? className : ''}`}>
158+
<div className={`${S.select} ${open ? S.focus : ''} ${className}`}>
159159
<p className={!selected ? S.selectPlaceholder : ''}>{selectedLabel}</p>
160160
<IconChevronDown
161161
style={{
@@ -171,18 +171,19 @@ function SelectTriggerContent({ className, placeholder }: SelectTriggerContentPr
171171

172172
interface SelectMenuProps {
173173
children: React.ReactNode;
174+
className?: string;
174175
}
175176

176177
// SelectMenu 컴포넌트: 옵션 목록을 렌더링
177-
function SelectMenu({ children }: SelectMenuProps) {
178+
function SelectMenu({ children, className }: SelectMenuProps) {
178179
const { open, optionsRef, calcMaxHeight } = useSelectContext();
179180

180181
if (!open) {
181182
return null;
182183
}
183184

184185
return (
185-
<ul className={S.optionList} ref={optionsRef} style={{ maxHeight: calcMaxHeight() }}>
186+
<ul className={`${S.optionList} ${className}`} ref={optionsRef} style={{ maxHeight: calcMaxHeight() }}>
186187
{children}
187188
</ul>
188189
);
@@ -191,10 +192,11 @@ function SelectMenu({ children }: SelectMenuProps) {
191192
interface SelectMenuItemProps<T> {
192193
option: Option<T>;
193194
onClick?: () => void;
195+
className?: string;
194196
}
195197

196198
// SelectMenuItem 컴포넌트: 옵션 목록 하나의 UI
197-
function SelectMenuItem<T>({ option, onClick }: SelectMenuItemProps<T>) {
199+
function SelectMenuItem<T>({ option, onClick, className }: SelectMenuItemProps<T>) {
198200
const { open, type, handleOptionClick } = useSelectContext();
199201

200202
const handleClick = () => {
@@ -211,7 +213,7 @@ function SelectMenuItem<T>({ option, onClick }: SelectMenuItemProps<T>) {
211213

212214
return (
213215
<li>
214-
<button className={S.option} onClick={handleClick} type='button'>
216+
<button className={`${S.option} ${className}`} onClick={handleClick} type='button'>
215217
{type === 'textIcon' && option.icon}
216218
{(type === 'userList' || type === 'userListDesc') &&
217219
(option.profileUrl ? (

packages/ui/Input/style.css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export const optionList = style({
193193
'transformOrigin': 'top',
194194
'animation': `${fadeIn} 0.5s forwards`,
195195
'overflowX': 'hidden',
196+
'zIndex': 24,
196197

197198
'::-webkit-scrollbar-thumb': {
198199
background: theme.colors.gray500,

0 commit comments

Comments
 (0)