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

#277 업데이트 알림 뷰 #281

Merged
merged 4 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/@components/@common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ interface ModalContents {
closeHandler: () => void;
closeOpacityClassName?: string;
closeBtnClassName?: string;
isNoCloseBtn?: boolean;
}

export default function Modal(props: PropsWithChildren<ModalContents>) {
const { theme = "DEFAULT", closeHandler, closeOpacityClassName, closeBtnClassName, children } = props;
const { theme = "DEFAULT", closeHandler, closeOpacityClassName, closeBtnClassName, isNoCloseBtn, children } = props;
Copy link
Contributor

Choose a reason for hiding this comment

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

왐마야 반영을 안했네 이고..ㅎ 거마워용>,<

const outClickCloserRef = useOutClickCloser(closeHandler, true);

if (theme === "GRAY_CENTER")
Expand All @@ -37,7 +38,7 @@ export default function Modal(props: PropsWithChildren<ModalContents>) {
<ModalPortal>
<St.GrayRoot className={closeOpacityClassName}>
<St.GrayModal ref={outClickCloserRef}>
{closeBtnClassName && (
{isNoCloseBtn || (
<St.CloseBtn type="button" className={closeBtnClassName} onClick={closeHandler}>
<IcModalCloseBtn closeBtnClassName={closeBtnClassName} />
</St.CloseBtn>
Expand Down
21 changes: 10 additions & 11 deletions src/@components/MainPage/UpdateModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { versionUpdateList } from "../../../util/main/versionUpdateList";
import { VERSION_UPDATES } from "../../../util/main/versionUpdateList";
import Modal from "../../@common/Modal";
import useUpdateModal from "../hooks/useUpdateModal";
import * as St from "./style";

interface UpdateModalProps {
closeHandler: () => void;
}
export default function UpdateModal() {
const { isOpened, handleCloseModal } = useUpdateModal();
Copy link
Member Author

Choose a reason for hiding this comment

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

훅을 컴포넌트 내에 위치시켰습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

오왓 이런 방법이,,!
if (!isOpened) return null; 짱짱+-+!!!!!


export default function UpdateModal(props: UpdateModalProps) {
const { closeHandler } = props;
if (!isOpened) return null;

return (
<Modal theme="GRAY_BOTTOM" closeHandler={closeHandler}>
<Modal theme="GRAY_BOTTOM" closeHandler={handleCloseModal} isNoCloseBtn={true}>
<St.Container>
<St.Tag>23.04.20 업데이트</St.Tag>
<St.Title>피클 업데이트 안내</St.Title>
Expand All @@ -20,13 +19,13 @@ export default function UpdateModal(props: UpdateModalProps) {
지금 하는 안내는 1주일 정도만 유지되니 이해 부탁드릴게요!
</St.Description>
<St.UpdateLists>
{versionUpdateList.map((versionUpdateList) => (
<St.ContentsWrapper key={versionUpdateList.id}>
✅<St.Content>{versionUpdateList.content}</St.Content>
{VERSION_UPDATES.map((versionUpdate) => (
<St.ContentsWrapper key={versionUpdate.id}>
✅<St.Content>{versionUpdate.content}</St.Content>
</St.ContentsWrapper>
))}
</St.UpdateLists>
<St.CheckBtn onClick={closeHandler}>확인했어요</St.CheckBtn>
<St.CheckBtn onClick={handleCloseModal}>확인했어요</St.CheckBtn>
</St.Container>
</Modal>
);
Expand Down
6 changes: 4 additions & 2 deletions src/@components/MainPage/hooks/useUpdateModal.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { useEffect, useState } from "react";

const POPUP_SESSION_KEY = "popup-shown";

export default function useUpdateModal() {
const [isOpened, setIsOpened] = useState(false);

useEffect(() => {
const isPopupShown = sessionStorage.getItem("popup-shown");
const isPopupShown = sessionStorage.getItem(POPUP_SESSION_KEY);
if (!isPopupShown) {
setIsOpened(true);
sessionStorage.setItem("popup-shown", "true");
sessionStorage.setItem(POPUP_SESSION_KEY, "true");
}
}, []);

Expand Down
9 changes: 5 additions & 4 deletions src/@components/MainPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { lazy } from "react";

import Footer from "../@common/Footer";
import Header from "../@common/Header";
import useGTMPage from "../@common/hooks/useGTMPage";
import Banner from "./Banner";
import BestPiickle from "./BestPiickle";
import CTABtn from "./CTABtn";
import useUpdateModal from "./hooks/useUpdateModal";
import Medley from "./Medley";
import MoodPiickle from "./MoodPiickle";
import PiickleMe from "./PiickleMe";
import StripBanner from "./StripBanner";
import { St } from "./style";
import UpdateModal from "./UpdateModal";

const UpdateModal = lazy(() => import("./UpdateModal"));
Copy link
Member Author

Choose a reason for hiding this comment

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

전체 UI가 나온 이후에, 업데이트 모달창을 띄우고 싶었습니다.!

Copy link
Contributor

Choose a reason for hiding this comment

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

오오오오옹 새로운 거 배워갑니다:)


export default function MainPage() {
const { isOpened, handleCloseModal } = useUpdateModal();
useGTMPage();

return (
Expand All @@ -27,7 +28,7 @@ export default function MainPage() {
<PiickleMe />
<Footer />
<CTABtn />
{isOpened && <UpdateModal closeHandler={handleCloseModal} />}
<UpdateModal />
</St.MainPage>
);
}
4 changes: 2 additions & 2 deletions src/util/main/versionUpdateList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type VersionUpdateList = {
type VersionUpdate = {
id: number;
content: string;
};

export const versionUpdateList: VersionUpdateList[] = [
export const VERSION_UPDATES: VersionUpdate[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 하눈거구나~ 이거 넘나 헷갈리는고!-!

util 폴더의 비슷한 다른 파일들 참고했는데, Upper Case로 바꾸면 좋을 것들이 많을 것 같네용:)

변수명을 다 바꿨길래 궁금한건데용 파일명은 일부러 안바꾸신거겠죠?

Copy link
Member Author

Choose a reason for hiding this comment

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

@NYeonK 생각 못했어요 하하하 바꾸셔도 좋습니다 !!!!!!!!!

{ id: 1, content: "카드 넘기기가 세로 스크롤로 변경 되었어요!" },
{ id: 2, content: "북마크 이모티콘이 변경 되었어요!" },
{ id: 3, content: "19금 대화주제 필터를 오픈했어요!" },
Expand Down