Skip to content

Commit

Permalink
sdp-tech#77 fix: set overlap order between dropdowns at same level
Browse files Browse the repository at this point in the history
  • Loading branch information
eujin-shin committed Jun 22, 2024
1 parent 8fa5723 commit a85c7e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
18 changes: 14 additions & 4 deletions src/common/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ interface DropdownProps {
value: string | undefined;
setValue: (text: string) => void;
items: string[];
width: DimensionValue;
index?: number | undefined;
width?: DimensionValue;
style?: ViewStyle;
}
const ITEM_HEIGHT = 40;
Expand All @@ -27,7 +28,8 @@ export default function Dropdown({
setValue,
value,
items,
width,
index = undefined,
width = '90%',
}: DropdownProps) {
const [open, setOpen] = useState(false);

Expand All @@ -41,7 +43,14 @@ export default function Dropdown({
};

return (
<View>
<View
style={{
position: 'relative',
height: ITEM_HEIGHT + 4,
backgroundColor: 'red',
marginVertical: 8,
zIndex: index,
}}>
<View
style={{
width: width,
Expand Down Expand Up @@ -87,11 +96,12 @@ export default function Dropdown({

const Styles = StyleSheet.create({
container: {
marginVertical: 8,
position: 'absolute',
alignSelf: 'center',
borderWidth: 2,
borderRadius: 8,
borderColor: BLACK2,
backgroundColor: 'white',
},
item: {
height: ITEM_HEIGHT,
Expand Down
21 changes: 11 additions & 10 deletions src/pages/ComponentsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import Dropdown from '../common/Dropdown';
import { useState } from 'react';
import { Body16M } from '../styles/GlobalText';

const TestDropdown = () => {
const TestDropdown = ({ index }: { index: number }) => {
const [value, setValue] = useState<string | undefined>(undefined);
const [open, setOpen] = useState(false);
const items = ['a', 'b', 'c', 'd', 'e'];

return (
<View>
<Dropdown
title="서비스 선택하기"
setValue={t => setValue(t)}
value={value}
items={items}
width="90%"></Dropdown>
</View>
<Dropdown
title="서비스 선택하기"
setValue={t => setValue(t)}
value={value}
items={items}
index={index}
width="90%"></Dropdown>
);
};

Expand All @@ -25,7 +24,9 @@ export default function ComponentsTest() {
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<Body16M>테스트용 페이지</Body16M>
<TestDropdown />
<TestDropdown index={4} />
<Body16M>테스트용 페이지</Body16M>
<TestDropdown index={3} />
</View>
</SafeAreaView>
);
Expand Down

0 comments on commit a85c7e8

Please sign in to comment.