-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(processes/profile): add religion form
- Loading branch information
Showing
6 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"printWidth": 150, | ||
"printWidth": 120, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
|
9 changes: 9 additions & 0 deletions
9
src/processes/my_profile/ReligionForm/ReligionForm.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.Container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 40px; | ||
} | ||
|
||
.Label { | ||
margin-bottom: 16px; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/processes/my_profile/ReligionForm/ReligionForm.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { ReligionForm } from 'src/processes/my_profile/ReligionForm/ReligionForm'; | ||
|
||
const meta: Meta<typeof ReligionForm> = { | ||
component: ReligionForm, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ReligionForm>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Radio } from 'src/shared/ui/Radio/Radio'; | ||
import { RadioWithInput } from 'src/shared/ui/RadioWithInput/RadioWithInput'; | ||
import styles from './ReligionForm.module.css'; | ||
import { useState } from 'react'; | ||
|
||
const ReligionTypeList = ['NONE', 'CHRISTIAN', 'BUDDHISM', 'CATHOLIC', 'WON_BUDDHISM', 'ETC']; | ||
type ReligionType = (typeof ReligionTypeList)[number]; | ||
const ReligionMetaMap: Record<ReligionType, { name: string; allowInput: boolean; placeholder?: string }> = { | ||
NONE: { name: '무교', allowInput: false }, | ||
CHRISTIAN: { name: '기독교', allowInput: false }, | ||
BUDDHISM: { name: '불교', allowInput: false }, | ||
CATHOLIC: { name: '천주교', allowInput: false }, | ||
WON_BUDDHISM: { name: '원불교', allowInput: false }, | ||
ETC: { name: '기타(기타 선택 시 직접 입력)', allowInput: true, placeholder: '종교를 입력해주세요.' }, | ||
} as const; | ||
|
||
export const ReligionForm = () => { | ||
const [selected, setSelected] = useState<ReligionType | null>(null); | ||
return ( | ||
<section className={styles.Container} role={'radiogroup'}> | ||
<div> | ||
<p className={styles.Label}>아니오,</p> | ||
<Radio label={'무교'} checked={selected === 'NONE'} onChange={() => setSelected('NONE')} /> | ||
</div> | ||
<div> | ||
<p className={styles.Label}>네! 저는..</p> | ||
{ReligionTypeList.slice(1).map((type) => | ||
ReligionMetaMap[type].allowInput ? ( | ||
<RadioWithInput | ||
key={type} | ||
value={type} | ||
checked={selected === type} | ||
label={ReligionMetaMap[type].name} | ||
inputPlaceholder={ReligionMetaMap[type].placeholder} | ||
onChange={() => setSelected(type)} | ||
/> | ||
) : ( | ||
<Radio | ||
key={type} | ||
value={type} | ||
checked={selected === type} | ||
label={ReligionMetaMap[type].name} | ||
onChange={() => setSelected(type)} | ||
/> | ||
), | ||
)} | ||
</div> | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { RadioWithInput } from 'src/shared/ui/RadioWithInput/RadioWithInput'; | ||
|
||
const meta: Meta<typeof RadioWithInput> = { | ||
component: RadioWithInput, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof RadioWithInput>; | ||
|
||
export const Default: Story = { | ||
args: { label: '직장인', checked: true, inputPlaceholder: '직장을 입력해주세요' }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters