From 2801f949ff0ace2fbbcfec61bcaf09b2b2643659 Mon Sep 17 00:00:00 2001 From: "(hoooooony)" <(cjh41820@gmail.com)> Date: Wed, 10 Apr 2024 21:06:51 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=EC=82=AC=EC=9E=A5=EB=8B=98=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=BD=94=EC=9D=B8=EA=B3=BC=20?= =?UTF-8?q?=EB=98=91=EA=B0=99=EC=9D=B4=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shop/index.ts | 2 + src/assets/svg/mystore/hidden-info-arrow.svg | 3 + src/assets/svg/mystore/see-info-arrow.svg | 3 + .../Modal/ImageModal/ImageModal.module.scss | 108 +++++++++++++++ .../ImageModal/hooks/useModalKeyboardEvent.ts | 26 ++++ .../common/Modal/ImageModal/index.tsx | 69 ++++++++++ src/component/common/Modal/PortalProvider.tsx | 73 ++++++++++ src/index.tsx | 9 +- src/model/shopInfo/myShopInfo.ts | 14 ++ src/page/MyShopPage/MyShopPage.module.scss | 27 ++++ .../EventTable/EventTable.module.scss | 3 + .../components/EventCard.module.scss | 80 +++++++++++ .../EventTable/components/index.tsx | 65 +++++++++ .../components/EventTable/index.tsx | 44 ++++++ .../MenuTable/MenuTable.module.scss | 125 ++++++++++++++++++ .../MyShopPage/components/MenuTable/index.tsx | 125 ++++++++++++++++++ src/page/MyShopPage/index.tsx | 52 +++++++- src/utils/constant/menu.ts | 25 ++++ src/utils/hooks/useModalPortal.ts | 14 ++ src/utils/hooks/useMoveScroll.ts | 19 +++ 20 files changed, 878 insertions(+), 8 deletions(-) create mode 100644 src/assets/svg/mystore/hidden-info-arrow.svg create mode 100644 src/assets/svg/mystore/see-info-arrow.svg create mode 100644 src/component/common/Modal/ImageModal/ImageModal.module.scss create mode 100644 src/component/common/Modal/ImageModal/hooks/useModalKeyboardEvent.ts create mode 100644 src/component/common/Modal/ImageModal/index.tsx create mode 100644 src/component/common/Modal/PortalProvider.tsx create mode 100644 src/page/MyShopPage/components/EventTable/EventTable.module.scss create mode 100644 src/page/MyShopPage/components/EventTable/components/EventCard.module.scss create mode 100644 src/page/MyShopPage/components/EventTable/components/index.tsx create mode 100644 src/page/MyShopPage/components/EventTable/index.tsx create mode 100644 src/page/MyShopPage/components/MenuTable/MenuTable.module.scss create mode 100644 src/page/MyShopPage/components/MenuTable/index.tsx create mode 100644 src/utils/constant/menu.ts create mode 100644 src/utils/hooks/useModalPortal.ts create mode 100644 src/utils/hooks/useMoveScroll.ts diff --git a/src/api/shop/index.ts b/src/api/shop/index.ts index 8c01cb54..590ce3a7 100644 --- a/src/api/shop/index.ts +++ b/src/api/shop/index.ts @@ -39,3 +39,5 @@ export const modifyMenu = (menuId:number, param:NewMenu) => accessClient.put(`/o export const putShop = (id: number, data: OwnerShop) => accessClient.put(`/owner/shops/${id}`, data); export const deleteMenu = (menuId:number) => accessClient.delete(`/owner/shops/menus/${menuId}`); + +export const getStoreEventList = (id : string) => accessClient.get(`금방 만들어준데요./${id}`); diff --git a/src/assets/svg/mystore/hidden-info-arrow.svg b/src/assets/svg/mystore/hidden-info-arrow.svg new file mode 100644 index 00000000..6b3cc1e5 --- /dev/null +++ b/src/assets/svg/mystore/hidden-info-arrow.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/assets/svg/mystore/see-info-arrow.svg b/src/assets/svg/mystore/see-info-arrow.svg new file mode 100644 index 00000000..5826e6b6 --- /dev/null +++ b/src/assets/svg/mystore/see-info-arrow.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/component/common/Modal/ImageModal/ImageModal.module.scss b/src/component/common/Modal/ImageModal/ImageModal.module.scss new file mode 100644 index 00000000..bde5f372 --- /dev/null +++ b/src/component/common/Modal/ImageModal/ImageModal.module.scss @@ -0,0 +1,108 @@ +@use "src/utils/styles/mediaQuery" as media; + +.background { + position: fixed; + display: flex; + justify-content: center; + align-items: center; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0 0 0 / 70%); + z-index: 21; +} + +.image { + max-width: 574px; + max-height: 100%; + position: fixed; + margin: auto; + + @include media.media-breakpoint-down(mobile) { + & { + max-width: calc(100% - 68px); + max-height: calc(100% - 100px); + } + } +} + +.arrow-button { + width: 60px; + height: 60px; + outline: none; + border: 0; + z-index: 23; + background-size: 24px 24px; + background-position: 50% 50%; + background-repeat: no-repeat; + background-color: #252525; + border-radius: 50%; + box-sizing: border-box; + position: fixed; + top: calc((100vh - 60px) / 2); + cursor: pointer; + + &:hover { + background-color: #f7941e; + } + + @include media.media-breakpoint-down(mobile) { + & { + width: 24px; + height: 24px; + background-color: transparent; + top: calc((100vh - 24px) / 2); + } + + &:hover { + background-color: transparent; + } + } + + &--next { + background-image: url("https://static.koreatech.in/assets/img/next-arrow.png"); + right: 50px; + + @include media.media-breakpoint-down(mobile) { + right: 10px; + } + } + + &--prev { + background-image: url("https://static.koreatech.in/assets/img/prev-arrow.png"); + left: 50px; + + @include media.media-breakpoint-down(mobile) { + left: 10px; + } + } +} + +.close { + border: 0; + outline: 0; + position: fixed; + background-color: rgba(0 0 0 / 0%); + top: 33px; + right: 62px; + width: 33px; + height: 41px; + cursor: pointer; + background-image: url("https://static.koreatech.in/assets/img/close.png"); + + @include media.media-breakpoint-down(mobile) { + & { + top: 20px; + right: 20px; + width: 24px; + height: 24px; + background-size: 24px; + background-color: transparent; + } + + &:hover { + background-color: transparent; + } + } +} diff --git a/src/component/common/Modal/ImageModal/hooks/useModalKeyboardEvent.ts b/src/component/common/Modal/ImageModal/hooks/useModalKeyboardEvent.ts new file mode 100644 index 00000000..3070f309 --- /dev/null +++ b/src/component/common/Modal/ImageModal/hooks/useModalKeyboardEvent.ts @@ -0,0 +1,26 @@ +import React from 'react'; + +interface KeyboardEventProps { + onClose: () => void + onChangeImageIndex: (move: number) => void +} + +function useModalKeyboardEvent({ onClose, onChangeImageIndex }: KeyboardEventProps) { + React.useEffect(() => { + function pressKey(event: KeyboardEvent) { + if (event.code === 'Escape') { + onClose(); + } else if (event.code === 'ArrowLeft') { + onChangeImageIndex(-1); + } else if (event.code === 'ArrowRight') { + onChangeImageIndex(1); + } + } + window.addEventListener('keydown', pressKey, true); + return () => { + window.removeEventListener('keydown', pressKey, true); + }; + }, [onClose, onChangeImageIndex]); +} + +export default useModalKeyboardEvent; diff --git a/src/component/common/Modal/ImageModal/index.tsx b/src/component/common/Modal/ImageModal/index.tsx new file mode 100644 index 00000000..2eeefae3 --- /dev/null +++ b/src/component/common/Modal/ImageModal/index.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import cn from 'utils/ts/className'; +import styles from './ImageModal.module.scss'; +import useModalKeyboardEvent from './hooks/useModalKeyboardEvent'; + +export interface ImageModalProps { + imageList: string[] + imageIndex: number + onClose: () => void +} + +function ImageModal({ + imageList, + imageIndex, + onClose, +}: ImageModalProps) { + const [selectedIndex, setSelectedIndex] = React.useState(imageIndex); + const onChangeImageIndex = React.useCallback((move: number) => { + if (move < 0) { + return (selectedIndex !== 0 && ( + setSelectedIndex(selectedIndex + move) + )); + } + return (selectedIndex !== imageList.length - 1 && ( + setSelectedIndex(selectedIndex + move) + )); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [selectedIndex]); // imageList 의존성 불필요 + + useModalKeyboardEvent({ onClose, onChangeImageIndex }); + + React.useEffect(() => { + const body = document.querySelector('body'); + body!.style.overflow = 'hidden'; + + return () => { body!.style.overflow = 'auto'; }; + }, []); + + return ( +
원