-
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.
Showing
4 changed files
with
48 additions
and
80 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
57 changes: 23 additions & 34 deletions
57
src/pages/Coop/components/DiningTypeSelect/DiningTypeSelect.module.scss
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
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,52 +1,29 @@ | ||
import { DiningType } from 'models/dinings'; | ||
import { DiningType, DINING_TYPES, DINING_TYPE_MAP } from 'models/dinings'; | ||
import cn from 'utils/className'; | ||
|
||
import styles from './DiningTypeSelect.module.scss'; | ||
|
||
interface MenuTypeProps { | ||
diningType: DiningType; | ||
setDiningType: (diningType: DiningType) => void; | ||
interface Props { | ||
selectedDiningType: DiningType; | ||
setSelectedDiningType: (diningType: DiningType) => void; | ||
} | ||
|
||
export default function DiningTypeSelect({ diningType, setDiningType }: MenuTypeProps) { | ||
export default function DiningTypeSelect({ selectedDiningType, setSelectedDiningType }: Props) { | ||
return ( | ||
<div className={styles.place__container}> | ||
<button | ||
className={cn({ | ||
[styles['place__button--selected']]: diningType === 'BREAKFAST', | ||
[styles.place__button]: diningType !== 'BREAKFAST', | ||
})} | ||
onClick={() => setDiningType('BREAKFAST')} | ||
onKeyDown={(e) => e.key === 'Enter' && setDiningType('BREAKFAST')} | ||
type="button" | ||
tabIndex={0} | ||
> | ||
아침 | ||
</button> | ||
<button | ||
className={cn({ | ||
[styles['place__button--selected']]: diningType === 'LUNCH', | ||
[styles.place__button]: diningType !== 'LUNCH', | ||
})} | ||
onClick={() => setDiningType('LUNCH')} | ||
onKeyDown={(e) => e.key === 'Enter' && setDiningType('LUNCH')} | ||
type="button" | ||
tabIndex={0} | ||
> | ||
점심 | ||
</button> | ||
<button | ||
className={cn({ | ||
[styles['place__button--selected']]: diningType === 'DINNER', | ||
[styles.place__button]: diningType !== 'DINNER', | ||
})} | ||
onClick={() => setDiningType('DINNER')} | ||
onKeyDown={(e) => e.key === 'Enter' && setDiningType('DINNER')} | ||
type="button" | ||
tabIndex={0} | ||
> | ||
저녁 | ||
</button> | ||
<div className={styles.container}> | ||
{DINING_TYPES.map((type: DiningType) => ( | ||
<button | ||
key={type} | ||
type="button" | ||
className={cn({ | ||
[styles.button]: true, | ||
[styles['button--selected']]: selectedDiningType === type, | ||
})} | ||
onClick={() => setSelectedDiningType(type)} | ||
> | ||
{DINING_TYPE_MAP[type]} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} |
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