Skip to content

Commit

Permalink
Refactor/#27: BottomSheet IOS height 오류 수정 및 각 커스텀 훅 init 로직 추가 (#28)
Browse files Browse the repository at this point in the history
* fix: BottomSheet height이 IOS에서만 height: max-content가 적용되지 않는 오류를 수정

* feat: useCheckbox onReset 로직 추가

* feat: useRadio onReset 로직 추가

* chore: 0.4.10 버전 배포

* refactor: useRadio onResetRadio initId 옵셔널로 변경 및 resetId로 네이밍 변경

* chore: 0.4.11 버전 배포

* design: RadioContainer radio wrap 시 옵션간 상하 여백 조정

* chore: 0.4.12 버전 배포
  • Loading branch information
semnil5202 authored Mar 29, 2024
1 parent cb38821 commit 88d62cb
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 725 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "concept-be-design-system",
"description": "컨셉비 디자인 시스템",
"version": "0.4.9",
"version": "0.4.12",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
1 change: 0 additions & 1 deletion src/components/BottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const BottomSheetWrapper = styled.div<{ isOpen: boolean }>`
right: 0;
margin: 0 auto;
width: auto;
height: max-content;
max-width: 420px;
max-height: 90%;
min-height: 70%;
Expand Down
3 changes: 2 additions & 1 deletion src/components/RadioContainer/RadioContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const RadioContainer = <T extends string>({
}: Props<T>) => {
return (
<div {...attributes}>
<Flex alignItems="center" paddingBottom={12}>
<Flex alignItems="center" paddingBottom={4}>
<Text font="suit15m" color="b9" required={required}>
{label}
</Text>
Expand Down Expand Up @@ -75,6 +75,7 @@ const RadioLabel = styled.label<{ gap: GapType }>`
position: relative;
padding-left: 28px;
margin-right: ${({ gap }) => (gap === 'large' ? '30px' : '18px')};
margin-top: 8px;
cursor: pointer;
font-size: 15px;
font-weight: 500;
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useCheckbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const useCheckbox = <T extends Record<keyof T, CheckboxItem[]>>(
) => {
const [checkboxValue, setCheckboxValue] = useState<T>(initialValue);

const onResetCheckbox = useCallback((checkboxKey: keyof T) => {
setCheckboxValue((prev) => ({
...prev,
[checkboxKey]: prev[checkboxKey].map((checkbox) => ({
...checkbox,
checked: false,
})),
}));
}, []);

const onChangeCheckbox = useCallback(
(
e: ChangeEvent<HTMLInputElement>,
Expand Down Expand Up @@ -47,6 +57,7 @@ const useCheckbox = <T extends Record<keyof T, CheckboxItem[]>>(
return {
checkboxValue,
onChangeCheckbox,
onResetCheckbox,
};
};

Expand Down
19 changes: 19 additions & 0 deletions src/hooks/useRadio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ interface RadioItem {
checked: boolean;
}

interface OnResetRadioProps<T> {
radioKey: keyof T;
resetId?: number;
}

const useRadio = <T extends Record<keyof T, RadioItem[]>>(initialValue: T) => {
const [radioValue, setRadioValue] = useState<T>(initialValue);

const onResetRadio = useCallback(
({ radioKey, resetId }: OnResetRadioProps<T>) => {
setRadioValue((prev) => ({
...prev,
[radioKey]: prev[radioKey].map((radio) => ({
...radio,
checked: resetId ? radio.id === resetId : false,
})),
}));
},
[],
);

const onChangeRadio = useCallback(
(e: ChangeEvent<HTMLInputElement>, radioKey: keyof T) => {
const { value } = e.target;
Expand All @@ -27,6 +45,7 @@ const useRadio = <T extends Record<keyof T, RadioItem[]>>(initialValue: T) => {
return {
radioValue,
onChangeRadio,
onResetRadio,
};
};

Expand Down
Loading

0 comments on commit 88d62cb

Please sign in to comment.