Skip to content

Commit afd8783

Browse files
authored
feat: dropdown 애니메이션과 elevation level을 변경한다 (#997)
1 parent ebb98e9 commit afd8783

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

packages/vibrant-components/src/lib/Dropdown/Dropdown.tsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const Dropdown = withDropdownVariation(
120120
});
121121
const [visible, setVisible] = useState(false);
122122
const [offset, setOffset] = useState<{ x?: number; y?: number }>({});
123+
const [direction, setDirection] = useState<'bottom' | 'top'>(position.startsWith('top') ? 'top' : 'bottom');
123124
const [containerHeight, setContainerHeight] = useState<number>();
124125
const [contentHeight, setContentHeight] = useState<number>();
125126

@@ -191,6 +192,14 @@ export const Dropdown = withDropdownVariation(
191192
);
192193

193194
setOffset({ x: offsetX, y: offsetY });
195+
196+
if (offsetY > 0) {
197+
setDirection('bottom');
198+
}
199+
200+
if (offsetY < 0) {
201+
setDirection('top');
202+
}
194203
}
195204

196205
setContentHeight(height);
@@ -236,8 +245,9 @@ export const Dropdown = withDropdownVariation(
236245
<Transition
237246
animation={{
238247
opacity: visible ? 1 : 0,
248+
scale: visible ? 1 : 0.95,
239249
}}
240-
duration={200}
250+
duration={150}
241251
>
242252
<OverlayBox
243253
open={isOpen}
@@ -251,7 +261,7 @@ export const Dropdown = withDropdownVariation(
251261
<Box
252262
backgroundColor="surface2"
253263
py={isDefined(py) ? py : CONTENT_PADDING}
254-
elevationLevel={4}
264+
elevationLevel={2}
255265
rounded="md"
256266
minWidth={[280, 280, 240]}
257267
pb={pb}
@@ -262,11 +272,14 @@ export const Dropdown = withDropdownVariation(
262272
animation={
263273
visible
264274
? {
275+
y: direction === 'bottom' ? 0 : 0,
265276
height: contentHeight,
266277
}
267-
: {}
278+
: {
279+
y: direction === 'bottom' ? -8 : 8,
280+
}
268281
}
269-
duration={200}
282+
duration={150}
270283
>
271284
<Box overflow="hidden" height={contentHeight}>
272285
<Box onLayout={handleContentResize} flexShrink={0} data-testid={testId}>
@@ -295,6 +308,7 @@ export const Dropdown = withDropdownVariation(
295308
pb={bottomSheetPaddingBottom}
296309
width="100%"
297310
maxHeight={viewportHeight - BOTTOM_SHEET_MIN_TOP_MARGIN}
311+
elevationLevel={3}
298312
backgroundColor="surface2"
299313
roundedTopLeft="xxl"
300314
roundedTopRight="xxl"

0 commit comments

Comments
 (0)