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

feat: 메뉴 토글 기능 구현한다 #898

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/src/components/ui/Navigator/NavigationBar/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useNavigationBar } from './hooks/useNavigationBar';
// TODO: 모바일 오류 (미디어 쿼리) 개선

const Menu = () => {
const { openBasePanel } = useNavigationBar();
const { toggleBasePanel } = useNavigationBar();

const memberToken = useExternalValue(memberTokenStore);
const isSignIn = memberToken !== EMPTY_MEMBER_TOKEN;
Expand Down Expand Up @@ -66,7 +66,7 @@ const Menu = () => {
noRadius="all"
css={displayNoneInMobile}
aria-label="주변 충전소 목록 열기"
onClick={() => openBasePanel(<StationSearchWindow />)}
onClick={() => toggleBasePanel(<StationSearchWindow key="base-panel-list" />)}
>
<Bars3Icon width="2.8rem" stroke="#555" />
<Text mt={0.5} variant="caption">
Expand All @@ -77,7 +77,7 @@ const Menu = () => {
<Button
noRadius="all"
aria-label="필터링 메뉴 열기"
onClick={() => openBasePanel(<ServerStationFilters />)}
onClick={() => toggleBasePanel(<ServerStationFilters key="base-panel-filter" />)}
>
<AdjustmentsHorizontalIcon width="2.8rem" stroke="#555" />
<Text mt={0.5} variant="caption">
Expand All @@ -100,7 +100,7 @@ const Menu = () => {
noRadius="all"
css={displayNoneInWeb}
aria-label="충전소 리스트 열기"
onClick={() => openBasePanel(<StationListWindow />)}
onClick={() => toggleBasePanel(<StationListWindow key="base-panel-list" />)}
>
<Bars3Icon width="2.8rem" stroke="#555" />
<Text mt={0.5} variant="caption">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { navigationBarPanelStore } from '@stores/layout/navigationBarPanelStore'
export const useNavigationBar = () => {
const [navigationBarPanel, setNavigationBarPanel] = useExternalState(navigationBarPanelStore);

const openBasePanel = (basePanel: ReactElement) => {
const toggleBasePanel = (basePanel: ReactElement) => {
const isAlreadyOpen = navigationBarPanel.basePanel?.key === basePanel.key;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBasePanelOpen와 같이 basePanel이라는 단어가 포함되는건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toggleBasePanel 안에 있어서 생략할까 말까 했는데 'isBasePanelAlreadyOpen'으로 변경하겠습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


setNavigationBarPanel((prev) => ({
...prev,
basePanel,
basePanel: isAlreadyOpen ? null : basePanel,
}));
};

Expand Down Expand Up @@ -44,7 +46,7 @@ export const useNavigationBar = () => {
};

return {
openBasePanel,
toggleBasePanel,
openLastPanel,
closeBasePanel,
closeLastPanel,
Expand Down
Loading