Skip to content
Open
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
27,073 changes: 27,073 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/app/list/[listId]/_components/ListDetailInner/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { QUERY_KEYS } from '@/lib/constants/queryKeys';
import { AxiosError } from 'axios';
import reaction from '@/app/_api/reaction/Reaction';
import { ReactionType } from '@/lib/types/reactionType';
import SaveImageModal from './SaveImageModal';

interface BottomSheetOptionsProps {
key: string;
Expand All @@ -45,11 +46,14 @@ interface FooterProps {
items: ItemType[];
collaborators: UserProfileType[];
ownerNickname: string;
ownerProfileImageUrl: string;
isCollected: boolean;
viewCount: number;
collectCount: number;
isPublic: boolean;
reactions: Reaction[];
lastUpdatedDate: Date;
backgroundColor: string;
}

declare global {
Expand Down Expand Up @@ -90,6 +94,7 @@ function Footer({ data }: { data: FooterProps }) {
const path = usePathname();
const { user: loginUser } = useUser();
const { isOn, handleSetOff, handleSetOn } = useBooleanOutput();
const [isSavedImgModalOn, setIsSavedImgModalOn] = useState(false);
const [isSheetActive, setSheetActive] = useState<boolean>(false);
const [sheetOptionList, setSheetOptionList] = useState<BottomSheetOptionsProps[]>([]);
const listUrl = `https://listywave.com${path}`;
Expand Down Expand Up @@ -177,7 +182,15 @@ function Footer({ data }: { data: FooterProps }) {
};

const handleSheetActive = ({ type }: { type: 'share' | 'etc' }) => {
const optionList = getBottomSheetOptionList({ type, data, closeBottomSheet, listUrl, goToCreateList, language });
const optionList = getBottomSheetOptionList({
type,
data,
closeBottomSheet,
listUrl,
goToCreateList,
language,
openImageModal: () => setIsSavedImgModalOn(true),
});
setSheetOptionList(optionList);
setSheetActive((prev: boolean) => !prev);
};
Expand Down Expand Up @@ -228,6 +241,7 @@ function Footer({ data }: { data: FooterProps }) {
<LoginModal id="duplicateListLoginBtn" />
</Modal>
)}
{isSavedImgModalOn && <SaveImageModal data={data} onClose={() => setIsSavedImgModalOn(false)} />}
<div className={styles.container}>
<div className={styles.reactionContainer}>
{(['COOL', 'AGREE', 'THANKS'] as ReactionType[]).map((type) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { style } from '@vanilla-extract/css';
import { vars } from '@/styles/__theme.css';

export const modalOverlay = style({
position: 'fixed',
top: 0,
left: 0,
width: '100vw',
height: '100vh',
backgroundColor: 'rgba(0, 0, 0, 0.7)',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 1000,
});

export const modalContent = style({
backgroundColor: vars.color.white,
padding: '2rem',
borderRadius: '20px',
width: '375px',
textAlign: 'center',
});

export const captureContent = style({
backgroundColor: vars.color.white,
width: '100%',
borderRadius: '0px',
});

export const profileImageContainer = style({
width: '36px',
height: '36px',
position: 'relative',

cursor: 'pointer',
});

export const profileImage = style({
width: '40px',
height: '40px',
borderRadius: '50%',
marginRight: '12px',
});

export const header = style({
display: 'flex',
alignItems: 'center',
marginBottom: '15px',
});

export const headerContent = style({
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'flex-start',
marginLeft: '10px',
});

export const NicknameText = style({
color: vars.color.gray9,
fontSize: '1.4rem',
fontWeight: 'bold',
});

export const dateText = style({
fontSize: '1.4rem',
color: vars.color.gray7,
});

export const divider = style({
border: 'none',
height: '1px',
backgroundColor: vars.color.gray5,
marginBottom: '30px',
});

export const listContainer = style({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
padding: '30px 20px',
borderRadius: '10px',
});

export const title = style({
fontSize: '1.8rem',
fontWeight: 'bold',
});

export const itemContainer = style({
width: '100%',

display: 'flex',
flexDirection: 'column',
gap: '12px',
padding: '20px',
});

export const listItem = style({
height: '6rem',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '10px 0',
});

export const listIndex = style({
fontSize: '1.6rem',
fontWeight: 'bold',
marginRight: '8px',
});

export const listText = style({
fontSize: '1.6rem',
flexGrow: 1,
textAlign: 'left',
});

export const simpleImageWrapper = style({
width: '5rem',
height: '5rem',

display: 'flex',
justifyContent: 'center',
alignItems: 'center',

textAlign: 'center',
});

export const simpleImage = style({
width: '5rem',
height: '5rem',

borderRadius: '10px',
boxShadow: '0px 4px 10px rgba(0, 0, 0, 0.15)',

objectFit: 'cover',
});
126 changes: 126 additions & 0 deletions src/app/list/[listId]/_components/ListDetailInner/SaveImageModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
'use client';

import { useEffect, useRef } from 'react';
import { toPng } from 'html-to-image';
import toasting from '@/lib/utils/toasting';
import * as styles from './SaveImageModal.css';
import Image from 'next/image';
import fallbackProfile from '/public/images/fallback_profileImage.webp';
import { BACKGROUND_COLOR_READ } from '@/styles/Color';
import { ItemType } from '@/lib/types/listType';

interface SaveImageModalProps {
data: {
title: string;
ownerNickname: string;
ownerProfileImageUrl: string;
lastUpdatedDate: Date;
items: ItemType[];
backgroundColor: string;
};
onClose: () => void;
}

const SaveImageModal = ({ data, onClose }: SaveImageModalProps) => {
const captureRef = useRef<HTMLDivElement | null>(null);

useEffect(() => {
const timer = setTimeout(() => {
if (captureRef.current) {
const clonedCapture = captureRef.current.cloneNode(true) as HTMLDivElement;
clonedCapture.style.width = `${window.innerWidth}px`;
clonedCapture.style.height = `${window.innerHeight}px`;
clonedCapture.style.padding = '50px 30px';

document.body.appendChild(clonedCapture);

toPng(clonedCapture, { backgroundColor: '#fff' })
.then((dataUrl) => {
const link = document.createElement('a');
link.download = `listywave_${data.title}.png`;
link.href = dataUrl;
link.click();
toasting({ type: 'success', txt: '이미지를 저장하였습니다' });
})
.catch((err) => {
console.error('이미지 저장 오류:', err);
toasting({ type: 'error', txt: '이미지 저장을 실패했습니다.' });
})
.finally(() => {
document.body.removeChild(clonedCapture);
onClose();
});
}
}, 1000);

return () => clearTimeout(timer);
}, [data.title, onClose]);
Comment on lines +27 to +57
Copy link
Contributor

Choose a reason for hiding this comment

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

모달로 띄워지고 자동으로 닫히고 저장까지 너무 완벽하게 구현해주셔서 놀랐어요!!🥹 ver2때 만들어 둔 디자인은 있는데 ver3용은 없네요ㅠ, ver3에 맞게 어떻게 바꿀 수 있을지 고민해보겠습니다!!

Copy link
Contributor

Choose a reason for hiding this comment

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

참고로 ver2 디자인 후보가 아래와 같았는데요! 최대 10개까지 아이템이 있고, 아이템당 100자까지 작성 가능한 점을 고려하여 아래와 같은 조건을 세웠습니다.

[조건]

  • 제목/작성자/날짜/순위 포함하기
  • 이미지 제외, 텍스트로만 이루어져 행간 줄이기
  • 리스트에 맞게 높낮이 조정가능
Screenshot 2025-03-03 at 7 12 35 PM


return (
<div className={styles.modalOverlay}>
<div className={styles.modalContent}>
<div className={styles.captureContent} ref={captureRef}>
<div className={styles.header}>
<div className={styles.profileImageContainer}>
{data?.ownerProfileImageUrl !== '' ? (
<Image
src={data?.ownerProfileImageUrl}
className={styles.profileImage}
width={40}
height={40}
style={{ objectFit: 'cover', borderRadius: '50%' }}
alt="profile"
/>
) : (
<Image
src={fallbackProfile}
alt="profile"
className={styles.profileImage}
width={40}
height={40}
style={{ objectFit: 'cover', borderRadius: '50%' }}
/>
)}
</div>
<div className={styles.headerContent}>
<div className={styles.NicknameText}>{data.ownerNickname}</div>
<div className={styles.dateText}>{new Date(data.lastUpdatedDate).toLocaleString()}</div>
</div>
</div>
<hr className={styles.divider} />

<div
className={styles.listContainer}
style={{
backgroundColor: BACKGROUND_COLOR_READ[data?.backgroundColor as keyof typeof BACKGROUND_COLOR_READ],
}}
>
<div className={styles.title}>{data.title}</div>

<div className={styles.itemContainer}>
{data.items.map((item, idx) => (
<div key={idx} className={styles.listItem}>
<span className={styles.listIndex}>{idx + 1}.</span>
<span className={styles.listText}>{item.title}</span>
{item.imageUrl && (
<div className={styles.simpleImageWrapper}>
<Image
className={styles.simpleImage}
src={item.imageUrl}
alt={item.title}
width={70}
height={72}
/>
</div>
)}
</div>
))}
</div>
</div>
</div>
</div>
</div>
);
};

export default SaveImageModal;
Loading