Skip to content

Commit 0fc9755

Browse files
committed
feat: 밈 상세화면 상단 이미지 비율 수정
1 parent 920ce28 commit 0fc9755

File tree

2 files changed

+51
-16
lines changed

2 files changed

+51
-16
lines changed

apps/web/src/pages/MemeDetailPage/MemeDetailPage.styles.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const ImageContainer = styled(motion.div)`
1515
position: sticky;
1616
top: 0;
1717
padding: 14px;
18+
max-height: 70vh;
19+
20+
@media (max-width: 768px) {
21+
padding: 10px;
22+
max-height: 50vh;
23+
}
1824
`;
1925

2026
const Image = styled.img`
@@ -38,18 +44,35 @@ const ShareButton = styled(motion.button)`
3844
cursor: pointer;
3945
color: ${({ theme }) => theme.palette.common.white};
4046
width: fit-content;
47+
min-width: 44px;
48+
min-height: 44px;
49+
justify-content: center;
50+
51+
@media (max-width: 768px) {
52+
bottom: 16px;
53+
padding: 8px 12px;
54+
}
55+
`;
56+
57+
const ShareTextWrapper = styled(motion.div)`
58+
display: flex;
59+
align-items: center;
4160
`;
4261

43-
const ShareButtonText = styled(motion.span)`
62+
const ShareButtonText = styled.span`
4463
${({ theme }) => theme.typography.body.body1};
4564
color: ${({ theme }) => theme.palette.common.white};
46-
overflow: hidden;
4765
white-space: nowrap;
4866
`;
4967

5068
const ContentContainer = styled.div`
5169
padding: 20px 14px;
5270
background-color: ${({ theme }) => theme.palette.gray['gray-10']};
71+
margin-top: 40px;
72+
73+
@media (max-width: 768px) {
74+
margin-top: 32px;
75+
}
5376
`;
5477

5578
const YearBadge = styled.div`
@@ -104,6 +127,7 @@ export {
104127
Image,
105128
ContentContainer,
106129
ShareButton,
130+
ShareTextWrapper,
107131
ShareButtonText,
108132
YearBadge,
109133
YearText,

apps/web/src/pages/MemeDetailPage/index.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { nativeBridge } from '@/utils/bridge';
44
import * as S from './MemeDetailPage.styles';
55
import { useTheme } from '@emotion/react';
66
import { useRef } from 'react';
7-
import { useScroll, useTransform, useSpring } from 'motion/react';
7+
import { useScroll, useTransform, useSpring, anticipate } from 'motion/react';
88

99
const DUMMY_DATA = {
1010
resultType: 'SUCCESS',
@@ -28,22 +28,27 @@ const MemeDetailPage = () => {
2828
const containerRef = useRef<HTMLDivElement>(null);
2929
const { scrollY } = useScroll({ container: containerRef });
3030

31-
const height = useTransform(scrollY, [0, 100], [400, 10]);
31+
const isMobile = window.innerWidth <= 768;
32+
const heightRange = isMobile ? [300, 150] : [400, 200];
33+
const scrollRange = isMobile ? [0, 50] : [0, 100];
34+
35+
const height = useTransform(scrollY, scrollRange, heightRange);
3236
const smoothHeight = useSpring(height, {
33-
stiffness: 150,
34-
damping: 50,
37+
stiffness: 200,
38+
damping: 30,
3539
});
3640

37-
const textWidth = useTransform(scrollY, [0, 10], [100, 0]);
38-
const smoothTextWidth = useSpring(textWidth, {
39-
stiffness: 150,
40-
damping: 50,
41+
const threshold = isMobile ? 15 : 30;
42+
43+
const isTextVisible = useTransform(scrollY, [0, threshold], [1, 0], {
44+
clamp: true,
45+
ease: anticipate,
4146
});
4247

43-
const padding = useTransform(scrollY, [0, 20], [10, 5]);
48+
const padding = useTransform(scrollY, [0, threshold], [10, 5]);
4449
const smoothPadding = useSpring(padding, {
45-
stiffness: 150,
46-
damping: 50,
50+
stiffness: 200,
51+
damping: 30,
4752
});
4853

4954
return (
@@ -68,9 +73,15 @@ const MemeDetailPage = () => {
6873
}}
6974
>
7075
<ShareIcon width={24} height={24} />
71-
<S.ShareButtonText style={{ maxWidth: smoothTextWidth }}>
72-
공유하기
73-
</S.ShareButtonText>
76+
<S.ShareTextWrapper
77+
style={{
78+
display: useTransform(isTextVisible, (v) =>
79+
v > 0.01 ? 'flex' : 'none',
80+
),
81+
}}
82+
>
83+
<S.ShareButtonText>공유하기</S.ShareButtonText>
84+
</S.ShareTextWrapper>
7485
</S.ShareButton>
7586
</S.ImageContainer>
7687
<S.ContentContainer>

0 commit comments

Comments
 (0)