Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/#27: BottomSheet IOS height 오류 수정 및 각 커스텀 훅 init 로직 추가 #28

Merged
merged 8 commits into from
Mar 29, 2024
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