Skip to content

Commit

Permalink
[ feat ] 공유하기 모달 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
myeongheonhong committed Nov 20, 2024
1 parent 5382aeb commit a74f606
Show file tree
Hide file tree
Showing 31 changed files with 457 additions and 499 deletions.
28 changes: 14 additions & 14 deletions public/assets/icons/closeSmallIc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions public/assets/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export { default as MainEndCakeImg } from '../images/mainEndCakeImg.png';
export { default as LinkBeefCakeImg } from '../images/linkBeefCakeImg.png';

// SNS share
export { default as KaKaoLogoImg } from '../images/sns/kakaoLogoImg.svg';
export { default as InstaLogoImg } from '../images/sns/instaLogoImg.svg';
export { default as FacebookLogoImg } from '../images/sns/facebookLogoImg.svg';
export { default as TwitterLogoImg } from '../images/sns/twitterLogoImg.svg';
export { default as ShareKaKaoLogoImg } from '../images/sns/kakaoLogoImg.svg';
export { default as ShareInstaLogoImg } from '../images/sns/instaLogoImg.svg';
export { default as ShareFacebookLogoImg } from '../images/sns/facebookLogoImg.svg';
export { default as ShareTwitterLogoImg } from '../images/sns/twitterLogoImg.svg';

//케이크 트리 관련 이미지
export { default as CakeDishTopRibbonImg } from '../images/cakeDishTopRibbonImg.png';
Expand Down
9 changes: 8 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { Metadata } from 'next';
import '../styles/global.css';
import { Suspense } from 'react';
import Loading from './loading';
import Script from 'next/script';

declare global {
interface Window {
Kakao: any;
}
}

export const metadata: Metadata = {
title: '조물주 보다 생일 선물주',
Expand All @@ -14,7 +21,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<html lang="en" className="bg-background">
<body>
<Suspense fallback={<Loading />}>{children}</Suspense>
{/* {children} */}
<Script src="https://developers.kakao.com/sdk/js/kakao.js" strategy="afterInteractive" />
</body>
</html>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default async function Home() {

return (
<>
<Header isLoggedIn={isLoggedIn} />
<Header />
<MainLayout>
<MainPageContainer />
<MainPageContainer isLoggedIn={isLoggedIn} />
</MainLayout>
</>
);
Expand Down
8 changes: 7 additions & 1 deletion src/app/wishes/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { getMainProgressWishesData } from '@/api/wishes';
import ErrorPage from '@/app/error';
import Header from '@/components/Common/Hedaer';
import ShareLinkModal from '@/components/Common/Modal/ShareLinkModal';
import { WishesCreateTitleText } from '@/domain/wishes/create/component';
import WishesCreatePageContainer from '@/domain/wishes/create/container';
import { AccountInputWithSavedAccountData, CenteredContent } from '@/domain/wishes/create/service';
import {
AccountInputWithSavedAccountData,
CenteredContent,
ShareWishesLinkModal,
} from '@/domain/wishes/create/service';
import WishesAccountInputForm from '@/domain/wishes/create/wishesAccountInputForm';
import WishesLinkInputForm from '@/domain/wishes/create/wishesLinkInputForm';
import MainLayout from '@/layouts/MainLayout';
Expand Down Expand Up @@ -51,6 +56,7 @@ export default async function WishesCreatePage({
done: (
<>
<CenteredContent />,
<ShareWishesLinkModal />
</>
),
}[step]
Expand Down
8 changes: 8 additions & 0 deletions src/app/wishes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { getMainProgressWishesData } from '@/api/wishes';
import { getLoginUserCookiesData } from '@/utils/common/cookies';
import WishesPageContainer, {
CakesTreeMessage,
WishesLinkSnsShareModal,
WishesPageFixedBottomButton,
} from '@/domain/wishes/container';
import { ReceivedCakePresentList, WishesMessageToCreateUser } from '@/domain/wishes/service';
import { MessageText } from '@/domain/wishes/component';
import { defaultCakeTreeDataArray } from '@/constant/model/cakesTreeData';
import GradientShadow from '@/components/UI/GradientShadow';
import ShareLinkModal from '@/components/Common/Modal/ShareLinkModal';

export default async function WishesPage() {
const progressWishesData = await getMainProgressWishesData();
Expand All @@ -27,6 +30,10 @@ export default async function WishesPage() {
nickName={loginUserData.nickName}
/>
<ReceivedCakePresentList wishId={progressWishesData.wishId} />
<WishesLinkSnsShareModal
wishId={progressWishesData.wishId}
nickName={loginUserData.nickName}
/>
</>
) : (
<>
Expand All @@ -39,6 +46,7 @@ export default async function WishesPage() {
)}
<WishesPageFixedBottomButton isWishProgress={!!progressWishesData} />
</WishesPageContainer>
<GradientShadow height={19} />
</MainLayout>
</>
);
Expand Down
27 changes: 0 additions & 27 deletions src/app/wishes/share/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Common/Hedaer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface HeaderProps {
}

export default function Header(props: HeaderProps) {
const { backBtn, mypageBtn, pathTo, isLoggedIn } = props;
const { backBtn, mypageBtn, pathTo } = props;
const pathname = usePathname();
const router = useRouter();

Expand Down
27 changes: 13 additions & 14 deletions src/components/Common/Modal/CloseIconInModal.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import { ColorsTypes } from '@/styles/styles';
import { PropsWithChildren } from 'react';
import Modal, { ModalProps } from '.';
import { CloseSmallIc } from '../../../../public/assets/icons';
import Image from 'next/image';
import { ColorsTypes } from '@/styles/styles';
import { VitaminCakeImg } from '../../../../public/assets/images';
import { CloseSmallIc } from '../../../../public/assets/icons';

export default function CloseIconInModal({
modalColor = 'main_blue',
modalTitle,
children,
...rest
}: { modalColor?: keyof ColorsTypes; modalTitle: string } & PropsWithChildren & ModalProps) {
}: { modalColor?: keyof ColorsTypes } & PropsWithChildren & ModalProps) {
return (
<Modal {...rest}>
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-[85%] h-314">
<div className={`bg-${modalColor} p-20 rounded-xl`}>
<div className="flex flex-row-reverse" onClick={rest.handleState}>
<Image src={CloseSmallIc} alt="닫기" width={16} height={16} />
</div>
<div className="flex flex-col items-center gap-20 w-full">
<div className="flex flex-col items-center w-full">
<Image src={VitaminCakeImg} alt="케이크 이미지" width={60} height={60} />
<h4 className="font-bitbit text-[24px] text-background">{modalTitle}</h4>
</div>
{children}
<div className="flex flex-row-reverse">
<Image
src={CloseSmallIc}
alt="닫기"
width={16}
height={16}
onClick={rest.handleState}
/>
</div>

{children}
</div>
</div>
</Modal>
Expand Down
25 changes: 25 additions & 0 deletions src/components/Common/Modal/CloseIconInModalWithVitaminCake.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PropsWithChildren } from 'react';
import { ModalProps } from '.';
import Image from 'next/image';
import { ColorsTypes } from '@/styles/styles';
import { VitaminCakeImg } from '../../../../public/assets/images';
import CloseIconInModal from './CloseIconInModal';

export default function CloseIconInModalWithVitaminCake({
modalColor = 'main_blue',
modalTitle,
children,
...rest
}: { modalColor?: keyof ColorsTypes; modalTitle: string } & PropsWithChildren & ModalProps) {
return (
<CloseIconInModal {...rest}>
<div className="flex flex-col items-center gap-20 w-full">
<div className="flex flex-col items-center w-full">
<Image src={VitaminCakeImg} alt="케이크 이미지" width={60} height={60} />
<h4 className="font-bitbit text-[24px] text-background">{modalTitle}</h4>
</div>
{children}
</div>
</CloseIconInModal>
);
}
57 changes: 57 additions & 0 deletions src/components/Common/Modal/ShareLinkModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Image from 'next/image';
import InputText from '../Input/inputText';
import CloseIconInModal from './CloseIconInModal';
import { LinkCopyIc } from '../../../../public/assets/icons';
import { snsShareListArray } from '@/constant/model/snsShareList';
import { useEffect } from 'react';

export default function ShareLinkModal({
modalState,
handleModalState,
wishId,
nickName,
}: {
modalState: boolean;
handleModalState: () => void;
wishId: string;
nickName: string;
}) {
const wishLink = `sunmulzu.com/wishes/${wishId}`;

useEffect(() => {
if (typeof window !== 'undefined') {
const { Kakao } = window;

if (!Kakao.isInitialized()) {
Kakao.init(process.env.NEXT_PUBLIC_KAKAO_JAVASCRIPT_KEY);
}
}
}, []);

async function handleAccountWishesLink() {
try {
await navigator.clipboard.writeText(wishLink);
alert('링크가 복사됐어요!');
} catch (error) {}
}

return (
<CloseIconInModal isOpen={modalState} handleState={handleModalState}>
<div className="flex gap-10 justify-center w-full p-10">
{snsShareListArray.map((snsItem) => (
<Image
src={snsItem.image}
alt="sns아이콘"
onClick={() => {
snsItem.onClick(wishLink, nickName);
}}
/>
))}
</div>

<InputText onClick={handleAccountWishesLink} value={wishLink} readOnly>
<Image src={LinkCopyIc} alt="" onClick={handleAccountWishesLink} />
</InputText>
</CloseIconInModal>
);
}
Loading

0 comments on commit a74f606

Please sign in to comment.