diff --git a/src/processes/my_profile/JobForm/JobForm.module.css b/src/processes/my_profile/JobForm/JobForm.module.css new file mode 100644 index 0000000..f046add --- /dev/null +++ b/src/processes/my_profile/JobForm/JobForm.module.css @@ -0,0 +1,7 @@ +.Container { + +} + +.Input { + margin-left: 32px; +} \ No newline at end of file diff --git a/src/processes/my_profile/JobForm/JobForm.stories.ts b/src/processes/my_profile/JobForm/JobForm.stories.ts new file mode 100644 index 0000000..75bc281 --- /dev/null +++ b/src/processes/my_profile/JobForm/JobForm.stories.ts @@ -0,0 +1,13 @@ +import { Meta, StoryObj } from '@storybook/react'; +import { JobForm } from 'src/processes/my_profile/JobForm/JobForm'; + +const meta: Meta = { + component: JobForm, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: {}, +}; diff --git a/src/processes/my_profile/JobForm/JobForm.tsx b/src/processes/my_profile/JobForm/JobForm.tsx new file mode 100644 index 0000000..affedd6 --- /dev/null +++ b/src/processes/my_profile/JobForm/JobForm.tsx @@ -0,0 +1,51 @@ +import { useState } from 'react'; +import styles from './JobForm.module.css'; +import { RadioWithInput } from 'src/shared/ui/RadioWithInput/RadioWithInput'; + +const JobTypeList = ['STUDENT', 'OFFICE_WORKER', 'FREELANCER', 'ETC']; +type JobType = (typeof JobTypeList)[number]; + +const JobMetaMap: Record = { + STUDENT: { + name: '학생(대학원생)', + inputPlaceHolder: '학과나 학교를 입력해주세요.', + }, + OFFICE_WORKER: { + name: '직장인', + inputPlaceHolder: '직무나 회사를 입력해주세요.', + }, + FREELANCER: { + name: '자영업자, 프리랜서', + inputPlaceHolder: '어떤 사업을 하는지 입력해주세요.', + }, + ETC: { + name: '기타', + inputPlaceHolder: '기타 하시는 일을 입력해주세요.', + }, +}; + +export const JobForm = () => { + const [selected, setSelected] = useState(null); + const [inputValue, setInputValue] = useState(''); + + const onSelect = (job: JobType) => { + setSelected(job); + setInputValue(''); + }; + + return ( +
+ {JobTypeList.map((job) => ( + onSelect(job)} + inputPlaceholder={JobMetaMap[job].inputPlaceHolder} + inputValue={inputValue} + onChangeInputValue={setInputValue} + /> + ))} +
+ ); +}; diff --git a/src/shared/ui/Input/Input.tsx b/src/shared/ui/Input/Input.tsx index 56bf386..3cc9ec8 100644 --- a/src/shared/ui/Input/Input.tsx +++ b/src/shared/ui/Input/Input.tsx @@ -1,15 +1,15 @@ -import { DetailedHTMLProps, InputHTMLAttributes, ReactNode } from 'react'; +import { DetailedHTMLProps, forwardRef, InputHTMLAttributes, ReactNode } from 'react'; import styles from './Input.module.css'; type InputProps = DetailedHTMLProps, HTMLInputElement> & { suffixSlot?: ReactNode; }; -export const Input = ({ suffixSlot, ...props }: InputProps) => { +export const Input = forwardRef(function InputComponent({ className, suffixSlot, ...props }: InputProps, ref) { return ( -
- +
+ {suffixSlot && {suffixSlot}}
); -}; +}); diff --git a/src/shared/ui/Radio/Radio.module.css b/src/shared/ui/Radio/Radio.module.css index c80d34f..b9fc2ff 100644 --- a/src/shared/ui/Radio/Radio.module.css +++ b/src/shared/ui/Radio/Radio.module.css @@ -4,6 +4,7 @@ font-weight: 500; font-size: 16px; line-height: 16px; + padding: 12px 0; color: var(--color-neutral-90); } diff --git a/src/shared/ui/Radio/Radio.tsx b/src/shared/ui/Radio/Radio.tsx index ba0131b..4e9547d 100644 --- a/src/shared/ui/Radio/Radio.tsx +++ b/src/shared/ui/Radio/Radio.tsx @@ -1,7 +1,7 @@ import styles from './Radio.module.css'; import { DetailedHTMLProps, InputHTMLAttributes } from 'react'; -type RadioProps = Exclude, HTMLInputElement>, 'type'> & { +export type RadioProps = Exclude, HTMLInputElement>, 'type'> & { label: string; }; diff --git a/src/shared/ui/RadioWithInput/RadioWithInput.tsx b/src/shared/ui/RadioWithInput/RadioWithInput.tsx new file mode 100644 index 0000000..1a89e33 --- /dev/null +++ b/src/shared/ui/RadioWithInput/RadioWithInput.tsx @@ -0,0 +1,28 @@ +import { Radio, RadioProps } from 'src/shared/ui/Radio/Radio'; +import { Input } from 'src/shared/ui/Input/Input'; +import styles from 'src/processes/my_profile/JobForm/JobForm.module.css'; +import { useRef } from 'react'; + +type RadioWithInputProps = RadioProps & { + inputPlaceholder: string; + inputValue: string; + onChangeInputValue: (value: string) => void; +}; + +export const RadioWithInput = ({ inputPlaceholder, inputValue, onChangeInputValue, ...props }: RadioWithInputProps) => { + const inputRef = useRef(null); + return ( + <> + + {props.checked && ( + onChangeInputValue(e.target.value)} + /> + )} + + ); +};