From f5179c385d6ac784ffc9d5b1b6bc0a62cad4eb3b Mon Sep 17 00:00:00 2001 From: soonki-98 Date: Tue, 29 Nov 2022 23:34:12 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20=ED=95=84=ED=84=B0=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=EC=97=90=EC=84=9C=20=ED=95=84=ED=84=B0=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=20=ED=81=B4=EB=A6=AD=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80=20#32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pages/map/FilterMenu.tsx | 116 +++++++++++++++++++----- src/recoil/map/filterAtom.ts | 8 +- 2 files changed, 99 insertions(+), 25 deletions(-) diff --git a/src/components/pages/map/FilterMenu.tsx b/src/components/pages/map/FilterMenu.tsx index 9c9ed08..0049dd1 100644 --- a/src/components/pages/map/FilterMenu.tsx +++ b/src/components/pages/map/FilterMenu.tsx @@ -1,3 +1,4 @@ +import { uuid } from '@lib/utils'; import { filterAtom } from '@recoil/map'; import Image from 'next/image'; import { useEffect, useRef } from 'react'; @@ -9,6 +10,8 @@ import FilterSection from './FilterSection'; function FilterMenu() { const [filterState, setFilterState] = useRecoilState(filterAtom); const filterRef = useRef(null); + const moodList = ['시끌벅적한', '고급스러운', '격식있는', '이색적인', '깔끔한', '조용한', '뷰가 이쁜']; + const drinkList = ['소주', '맥주', '와인', '칵테일', '샴페인', '위스키', '사케', '기타']; const closeClickOutSide = (e: MouseEvent) => { if (!filterRef.current) return; @@ -18,13 +21,14 @@ function FilterMenu() { }; const closeFilter = () => { - setFilterState({ ...filterState, isOpen: false }); + setFilterState({ drinkTag: null, moodTag: null, isOpen: false }); }; useEffect(() => { document.addEventListener('click', closeClickOutSide); return () => document.removeEventListener('click', closeClickOutSide); }, [filterState.isOpen]); + return ( @@ -35,27 +39,47 @@ function FilterMenu() { - 시끌벅적한 - 고급스러운 - 격식있는 - 이색적인 - 깔끔한 - 조용한 - 뷰가 예쁜 + {moodList.map((mood) => { + return ( + + + + ); + })} - - - - - + {drinkList.map((drink) => { + return ( + + + + ); + })} - + ); @@ -124,22 +148,66 @@ const SectionWrapper = styled.div` padding: 16px; `; -const DrinkFilter = styled.li` +const DrinkFilter = styled.li<{ isActive: boolean }>` aspect-ratio: 1/1; background-color: #fff; border: 1px solid #f0f0f0; border-radius: 50%; + button { + width: 100%; + height: 100%; + border-radius: 50%; + background-color: #fff; + border: 1px solid #fff; + color: #000; + cursor: pointer; + &:hover { + color: #715ae4; + border: 1px solid #715ae4; + } + ${({ isActive }) => { + if (isActive) { + return css` + border: 1px solid #715ae4; + color: #715ae4; + `; + } else { + return css` + border: 1px solid #f0f0f0; + color: #000; + `; + } + }} + } `; -const MoodFilter = styled.li` - padding: 8px 16px; - border: 1px solid #f0f0f0; - background-color: #fff; - border-radius: 24px; - color: #000; - font-weight: 500; - font-size: 12px; - line-height: 16px; +const MoodFilter = styled.li<{ isActive: boolean }>` + button { + padding: 8px 16px; + background-color: #fff; + border-radius: 24px; + font-weight: 500; + font-size: 12px; + line-height: 16px; + cursor: pointer; + &:hover { + border: 1px solid #715ae4; + color: #715ae4; + } + ${({ isActive }) => { + if (isActive) { + return css` + border: 1px solid #715ae4; + color: #715ae4; + `; + } else { + return css` + border: 1px solid #f0f0f0; + color: #000; + `; + } + }} + } `; const ButtonWrapper = styled.div` diff --git a/src/recoil/map/filterAtom.ts b/src/recoil/map/filterAtom.ts index 68eac50..d66a559 100644 --- a/src/recoil/map/filterAtom.ts +++ b/src/recoil/map/filterAtom.ts @@ -1,6 +1,12 @@ import { atom } from 'recoil'; -const filterAtom = atom({ +interface filterType { + isOpen: boolean; + moodTag: string | null; + drinkTag: string | null; +} + +const filterAtom = atom({ key: 'filterAtom', default: { isOpen: false,