Skip to content

Commit

Permalink
Merge pull request #144 from ASAP-Lettering/feat/#141
Browse files Browse the repository at this point in the history
[Design] 편지지 반응형 수정 및 이미지 압축 해제
  • Loading branch information
yyypearl authored Feb 5, 2025
2 parents 87e01af + b9365ab commit 7e56c30
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 57 deletions.
58 changes: 35 additions & 23 deletions src/app/independent/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,25 @@ const IndependentLetterPage = () => {
const [isDelete, setIsDelete] = useState(false);

const [maxLinesPerPage, setMaxLinesPerPage] = useState(12);
const [fontSize, setFontSize] = useState<string>('16px');

useEffect(() => {
const updateMaxLines = () => {
if (window.innerHeight > 800) {
setMaxLinesPerPage(10);
} else if (window.innerHeight > 680) {
if (window.innerHeight > 780) {
setMaxLinesPerPage(11);
setFontSize('16px');
} else if (window.innerHeight > 660) {
setMaxLinesPerPage(9);
setFontSize('16px');
} else if (window.innerHeight > 628) {
setMaxLinesPerPage(8);
} else if (window.innerHeight > 600) {
setMaxLinesPerPage(6);
setFontSize('16px');
} else if (window.innerHeight > 580) {
setMaxLinesPerPage(7);
setFontSize('16px');
} else {
setMaxLinesPerPage(5);
setMaxLinesPerPage(8);
setFontSize('11px');
}
};

Expand Down Expand Up @@ -143,7 +151,11 @@ const IndependentLetterPage = () => {
)}
</IconWrapper>
<MainWrapper>
<LetterContainer>
<LetterContainer
$hasChangeButton={
letterData.content.length > 0 && letterData.images.length > 0
}
>
<Letter
key={`${key}-${maxLinesPerPage}`}
showType="receive"
Expand All @@ -158,6 +170,7 @@ const IndependentLetterPage = () => {
width="100%"
height="100%"
maxLines={maxLinesPerPage}
fontSize={fontSize}
/>
</LetterContainer>
{letterData.images.length > 0 && letterData.content.length > 0 ? (
Expand Down Expand Up @@ -332,42 +345,41 @@ const PopupBtn = styled.button`
}
`;

const LetterContainer = styled.div`
const LetterContainer = styled.div<{ $hasChangeButton: boolean }>`
display: flex;
justify-content: center;
align-items: center;
width: 100%;
max-width: 345px;
min-height: 398px;
max-height: 398px;
margin-bottom: ${({ $hasChangeButton }) => ($hasChangeButton ? '0' : '80px')};
@media (max-height: 824px) {
max-width: 320px;
@media (max-height: 780px) {
min-height: 350px;
max-height: 350px;
}
@media (max-height: 780px) {
max-width: 300px;
@media (max-height: 660px) {
min-height: 330px;
max-height: 330px;
}
@media (max-height: 680px) {
max-width: 300px;
min-height: 300px;
max-height: 300px;
@media (max-height: 628px) {
min-height: 310px;
max-height: 310px;
}
@media (max-height: 600px) {
max-width: 250px;
min-height: 250px;
max-height: 250px;
@media (max-height: 580px) {
min-height: 280px;
max-height: 280px;
}
@media (max-height: 550px) {
max-width: 250px;
min-height: 250px;
max-height: 250px;
min-height: 260px;
max-height: 260px;
margin-bottom: ${({ $hasChangeButton }) =>
$hasChangeButton ? '0' : '55px'};
}
`;

Expand Down
58 changes: 35 additions & 23 deletions src/app/letter/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,25 @@ const LetterPage = () => {
const { showToast } = useToast();

const [maxLinesPerPage, setMaxLinesPerPage] = useState(12);
const [fontSize, setFontSize] = useState<string>('16px');

useEffect(() => {
const updateMaxLines = () => {
if (window.innerHeight > 800) {
setMaxLinesPerPage(10);
} else if (window.innerHeight > 680) {
if (window.innerHeight > 780) {
setMaxLinesPerPage(11);
setFontSize('16px');
} else if (window.innerHeight > 660) {
setMaxLinesPerPage(9);
setFontSize('16px');
} else if (window.innerHeight > 628) {
setMaxLinesPerPage(8);
} else if (window.innerHeight > 600) {
setMaxLinesPerPage(6);
setFontSize('16px');
} else if (window.innerHeight > 580) {
setMaxLinesPerPage(7);
setFontSize('16px');
} else {
setMaxLinesPerPage(5);
setMaxLinesPerPage(8);
setFontSize('11px');
}
};

Expand Down Expand Up @@ -196,7 +204,11 @@ const LetterPage = () => {
)}
</IconWrapper>
<MainWrapper>
<LetterContainer>
<LetterContainer
$hasChangeButton={
letterData.content.length > 0 && letterData.images.length > 0
}
>
<Letter
key={`${key}-${maxLinesPerPage}`}
showType="receive"
Expand All @@ -213,6 +225,7 @@ const LetterPage = () => {
width="100%"
height="100%"
maxLines={maxLinesPerPage}
fontSize={fontSize}
/>
</LetterContainer>
{letterData.images.length > 0 && letterData.content.length > 0 ? (
Expand Down Expand Up @@ -392,42 +405,41 @@ const PopupBtn = styled.button`
}
`;

const LetterContainer = styled.div`
const LetterContainer = styled.div<{ $hasChangeButton: boolean }>`
display: flex;
justify-content: center;
align-items: center;
width: 100%;
max-width: 345px;
min-height: 398px;
max-height: 398px;
margin-bottom: ${({ $hasChangeButton }) => ($hasChangeButton ? '0' : '80px')};
@media (max-height: 824px) {
max-width: 320px;
@media (max-height: 780px) {
min-height: 350px;
max-height: 350px;
}
@media (max-height: 780px) {
max-width: 300px;
@media (max-height: 660px) {
min-height: 330px;
max-height: 330px;
}
@media (max-height: 680px) {
max-width: 300px;
min-height: 300px;
max-height: 300px;
@media (max-height: 628px) {
min-height: 310px;
max-height: 310px;
}
@media (max-height: 600px) {
max-width: 250px;
min-height: 250px;
max-height: 250px;
@media (max-height: 580px) {
min-height: 280px;
max-height: 280px;
}
@media (max-height: 550px) {
max-width: 250px;
min-height: 250px;
max-height: 250px;
min-height: 260px;
max-height: 260px;
margin-bottom: ${({ $hasChangeButton }) =>
$hasChangeButton ? '0' : '55px'};
}
`;

Expand Down
8 changes: 1 addition & 7 deletions src/app/send/(process)/content/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,10 @@ const SendContentPage = () => {

const imageUrls: string[] = [];
for (const file of validImages) {
const compressedFile = await imageCompression(file, {
maxSizeMB: 500,
maxWidthOrHeight: 512,
useWebWorker: true
});

try {
setImageUploadLoading(true);

const response = await postImage(compressedFile);
const response = await postImage(file);
console.log('이미지 업로드 성공', response.data);
imageUrls.push(response.data.imageUrl);
} catch (error) {
Expand Down
9 changes: 8 additions & 1 deletion src/app/send/(process)/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@ const SendPreviewPage = () => {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [isSharing, setIsSharing] = useState<boolean>(false);
const [maxLinesPerPage, setMaxLinesPerPage] = useState(12);
const [fontSize, setFontSize] = useState<string>('16px');

useEffect(() => {
setIsImage(!!!(content.length > 0));
}, []);

useEffect(() => {
const updateMaxLines = () => {
if (window.innerHeight > 670) {
if (window.innerHeight > 660) {
setMaxLinesPerPage(12);
setFontSize('16px');
} else if (window.innerHeight > 628) {
setMaxLinesPerPage(8);
setFontSize('16px');
} else if (window.innerHeight > 580) {
setMaxLinesPerPage(7);
setFontSize('16px');
} else {
setMaxLinesPerPage(9);
setFontSize('11px');
}
};

Expand Down Expand Up @@ -155,6 +160,7 @@ const SendPreviewPage = () => {
padding="38px 28px"
nameSize="18px"
maxLines={maxLinesPerPage}
fontSize={fontSize}
/>
</LetterContainer>
{content.length > 0 && images.length > 0 && (
Expand Down Expand Up @@ -248,6 +254,7 @@ const LetterContainer = styled.div<{ $hasChangeButton: boolean }>`
@media (max-height: 660px) {
min-height: 350px;
max-height: 350px;
}
@media (max-height: 628px) {
Expand Down
11 changes: 9 additions & 2 deletions src/app/store/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@ const LetterPreviewPage = () => {
const [isImage, setIsImage] = useState<boolean>(false);
const resetLetterState = useResetRecoilState(registerLetterState);
const [maxLinesPerPage, setMaxLinesPerPage] = useState(12);
const [fontSize, setFontSize] = useState<string>('16px');

useEffect(() => {
setIsImage(!!!(content.length > 0));
}, []);

useEffect(() => {
const updateMaxLines = () => {
if (window.innerHeight > 670) {
if (window.innerHeight > 660) {
setMaxLinesPerPage(12);
setFontSize('16px');
} else if (window.innerHeight > 628) {
setMaxLinesPerPage(8);
setFontSize('16px');
} else if (window.innerHeight > 580) {
setMaxLinesPerPage(7);
setFontSize('16px');
} else {
setMaxLinesPerPage(9);
setFontSize('11px');
}
};

Expand Down Expand Up @@ -135,6 +140,7 @@ const LetterPreviewPage = () => {
padding="38px 28px"
nameSize="18px"
maxLines={maxLinesPerPage}
fontSize={fontSize}
/>
</LetterContainer>
{content.length > 0 && images.length > 0 && (
Expand Down Expand Up @@ -224,13 +230,14 @@ const LetterWrapper = styled.div`
const LetterContainer = styled.div<{ $hasChangeButton: boolean }>`
display: flex;
justify-content: center;
align-items: center;
width: 100%;
max-width: 345px;
min-height: 443px;
max-height: 443px;
margin-bottom: ${({ $hasChangeButton }) => ($hasChangeButton ? '0' : '80px')};
@media (max-height: 670px) {
@media (max-height: 660px) {
min-height: 350px;
max-height: 350px;
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/draft/DraftList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ const DraftList = (props: DraftListProps) => {
<>
<Container onClick={handleConfirmModal}>
<Top>
{name.length > 0 ? <Name>{name}</Name> : <Blank>이름 없음</Blank>}|
{name && name.length > 0 ? (
<Name>{name}</Name>
) : (
<Blank>이름 없음</Blank>
)}
|
{content && content.length > 0 ? (
<Content>{content}</Content>
) : (
Expand Down

0 comments on commit 7e56c30

Please sign in to comment.