Skip to content

Commit 482a2f5

Browse files
authored
TIL > refactor: 피드 컨텐츠와 주간 TOP5 layout 사용성 개선 (#451)
* refactor: 비로그인 상태 시 content를 figma와 동일하게 수정 * refactor: post feed의 layout을 full-width로 수정 * refactor: 각 영역이 독립적으로 scroll 되도록 수정 * refactor: 주간 TOP5가 영역에 맞게 card style이 조정되도록 수정 * refactor: PostCard의 style 수정 * feat: Layout mobile 대응 * feat: hover 시 title color 변경 * refactor: 게시글 상세의 주간 sidebar layout 수정
1 parent bf39d03 commit 482a2f5

File tree

8 files changed

+189
-210
lines changed

8 files changed

+189
-210
lines changed
Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
11
import { useAuth } from "@/contexts/AuthContext";
22
import { Button } from "@/components/shared/ui/Button";
3+
import { css } from "@styled-system/css";
34

45
export function UnauthenticatedState() {
56
const { login } = useAuth();
67

78
return (
8-
<div className="flex flex-col items-center justify-center px-6 py-8 gap-4 w-full rounded-2xl bg-white">
9-
{/* 메인 텍스트 */}
10-
<h1 className="text-xl font-bold text-center text-black/80 tracking-tight leading-[130%]">
11-
매일 한 줄, 오늘 배운 내용을 기록해봐요!
12-
</h1>
9+
<div className={container}>
10+
<span className={title}>오늘 배운 내용을 기록하려면 로그인해 주세요</span>
1311

14-
{/* 버튼 */}
15-
<Button
16-
onClick={login}
17-
variant="primary"
18-
size="lg"
19-
className="px-8 py-3 text-base font-bold"
20-
>
12+
<Button onClick={login} variant="primary" size="lg" className={button}>
2113
로그인하기
2214
</Button>
2315
</div>
2416
);
2517
}
18+
19+
const container = css({
20+
display: "flex",
21+
flexDirection: "column",
22+
alignItems: "center",
23+
justifyContent: "center",
24+
paddingX: "2rem",
25+
paddingY: "3rem",
26+
gap: "1.5rem"
27+
});
28+
29+
const title = css({
30+
fontFamily: "Toss Product Sans OTF",
31+
fontSize: "1.125rem",
32+
fontWeight: "700",
33+
fontStyle: "bold",
34+
lineHeight: "130%",
35+
letterSpacing: "-0.025em"
36+
});
37+
38+
const button = css({
39+
maxHeight: "2.5rem",
40+
paddingX: "1rem",
41+
42+
fontFamily: "Toss Product Sans OTF",
43+
fontSize: "1rem",
44+
fontWeight: "700",
45+
fontStyle: "bold",
46+
lineHeight: "130%",
47+
letterSpacing: "-0.025em"
48+
});

fundamentals/today-i-learned/src/components/features/discussions/PostCard.tsx

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,15 @@ export function PostCard({
113113
)}
114114
</div>
115115

116-
{/* 본문 */}
117-
<div className={contentSection}>
118-
{/* 제목과 내용 */}
119-
<div className={contentContainer}>
120-
{/* 제목 */}
121-
<h2 className={postTitle}>{discussion.title}</h2>
116+
{/* 제목 */}
117+
<h2 className={postTitle}>{discussion.title}</h2>
122118

123-
{/* 내용 미리보기 */}
124-
<div className={contentPreview}>
125-
<MarkdownRenderer
126-
content={discussion.body}
127-
className={markdownContent}
128-
/>
129-
</div>
130-
</div>
119+
{/* 내용 미리보기 */}
120+
<div className={contentPreview}>
121+
<MarkdownRenderer
122+
content={discussion.body}
123+
className={markdownContent}
124+
/>
131125
</div>
132126

133127
<InteractionButtons
@@ -141,6 +135,7 @@ export function PostCard({
141135
variant="card"
142136
/>
143137
</div>
138+
144139
{EditPostModal}
145140
</Card>
146141
);
@@ -162,14 +157,21 @@ const cardContent = css({
162157
display: "flex",
163158
flexDirection: "column",
164159
padding: "1.5rem",
165-
gap: "1.5rem"
160+
transition: "all 0.2s",
161+
_hover: {
162+
"& h2": {
163+
color: "#0064FF",
164+
opacity: 0.8
165+
}
166+
}
166167
});
167168

168169
const headerSection = css({
169170
display: "flex",
170171
alignItems: "center",
171172
justifyContent: "space-between",
172-
height: "2.5rem"
173+
height: "2.5rem",
174+
marginBottom: "1rem"
173175
});
174176

175177
const userInfoContainer = css({
@@ -231,35 +233,22 @@ const timeStamp = css({
231233
color: "#979797"
232234
});
233235

234-
const contentSection = css({
235-
display: "flex",
236-
flexDirection: "column",
237-
gap: "1.25rem"
238-
});
239-
240-
const contentContainer = css({
241-
display: "flex",
242-
flexDirection: "column",
243-
gap: "1.25rem"
244-
});
245-
246236
const postTitle = css({
237+
marginBottom: "0.5rem",
247238
fontWeight: "700",
248239
fontSize: "22px",
249240
lineHeight: "130%",
250241
letterSpacing: "-0.4px",
251242
color: "#0F0F0F",
252-
transition: "colors 0.15s ease-in-out",
253243
overflow: "hidden",
254244
textOverflow: "ellipsis",
255245
whiteSpace: "nowrap",
256-
_hover: {
257-
color: "rgb(55, 65, 81)"
258-
}
246+
transition: "color 0.2s"
259247
});
260248

261249
const contentPreview = css({
262250
display: "-webkit-box",
251+
marginBottom: "1rem",
263252
WebkitLineClamp: "3",
264253
// @ts-ignore
265254
WebkitBoxOrient: "vertical",

fundamentals/today-i-learned/src/components/features/discussions/WeeklyTop5.tsx

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ function PopularPostItem({ post, rank }: { post: any; rank: number }) {
5454
</div>
5555

5656
<h4 className={postTitle}>{post.title}</h4>
57-
58-
<div className={postPreview}>
59-
<MarkdownRenderer
60-
content={truncateMarkdown(post.body, 100)}
61-
className={markdownContent}
62-
/>
63-
</div>
57+
<p className={contentPreview}>{post.body}</p>
6458
</button>
6559
</div>
6660
);
@@ -125,6 +119,7 @@ export function WeeklyTop5() {
125119
const weeklyTop5Container = css({
126120
display: "flex",
127121
flexDirection: "column",
122+
padding: "1rem",
128123
gap: "1.5rem"
129124
});
130125

@@ -176,23 +171,24 @@ const rankNumber = css({
176171
});
177172

178173
const postButton = css({
179-
flex: 1,
174+
position: "relative",
180175
display: "flex",
181176
flexDirection: "column",
182-
justifyContent: "flex-end",
177+
justifyContent: "space-between",
178+
width: "100%",
183179
paddingY: "1.25rem",
184180
paddingX: "1.5rem",
185181
backgroundColor: "white",
186182
border: "1px solid rgba(209, 213, 219, 0.5)",
187183
borderRadius: "1rem",
188-
transition: "all 0.2s",
189184
textAlign: "left",
190-
minHeight: "136px",
191-
position: "relative",
185+
transition: "all 0.2s",
186+
overflow: "hidden",
192187
cursor: "pointer",
193188
_hover: {
194189
"& h4": {
195-
color: "rgb(55, 65, 81)"
190+
color: "#0064FF",
191+
opacity: 0.8
196192
}
197193
}
198194
});
@@ -201,7 +197,7 @@ const authorSection = css({
201197
display: "flex",
202198
alignItems: "center",
203199
gap: "0.375rem",
204-
marginBottom: "0.75rem"
200+
marginBottom: "1rem"
205201
});
206202

207203
const avatarStyle = css({
@@ -211,38 +207,41 @@ const avatarStyle = css({
211207
const authorName = css({
212208
fontSize: "16px",
213209
fontWeight: "bold",
214-
color: "rgba(0, 0, 0, 0.6)",
210+
color: "rgba(0, 0, 0, 0.8)",
215211
letterSpacing: "-0.025em",
216212
overflow: "hidden",
217213
textOverflow: "ellipsis",
218214
whiteSpace: "nowrap"
219215
});
220216

221217
const postTitle = css({
218+
marginBottom: "0.5rem",
219+
overflow: "hidden",
220+
222221
fontWeight: "bold",
223222
fontSize: "18px",
224223
color: "#0F0F0F",
225224
lineHeight: "tight",
226225
letterSpacing: "-0.025em",
227-
transition: "color 0.2s",
228-
overflow: "hidden",
229226
textOverflow: "ellipsis",
230227
whiteSpace: "nowrap",
231-
marginBottom: "0.75rem"
228+
229+
transition: "color 0.2s"
232230
});
233231

234-
const postPreview = css({
232+
const contentPreview = css({
233+
display: "-webkit-box",
235234
overflow: "hidden",
236-
textOverflow: "ellipsis",
237-
whiteSpace: "nowrap"
238-
});
239235

240-
const markdownContent = css({
241236
fontSize: "16px",
242237
fontWeight: "medium",
243238
color: "rgba(0, 0, 0, 0.8)",
244239
lineHeight: "relaxed",
245-
letterSpacing: "-0.025em"
240+
letterSpacing: "-0.025em",
241+
WebkitLineClamp: 2,
242+
// @ts-ignore
243+
WebkitBoxOrient: "vertical",
244+
whiteSpace: "normal"
246245
});
247246

248247
// Loading and Empty States

fundamentals/today-i-learned/src/components/shared/ShareLinkButton.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Link } from "lucide-react";
1+
import { Check, Link } from "lucide-react";
22
import { useToast } from "@/contexts/ToastContext";
33
import { css, cx } from "@styled-system/css";
4+
import { useState } from "react";
45

56
const shareButton = {
67
display: "flex",
@@ -21,8 +22,6 @@ const shareIconContainer = {
2122
const shareIcon = {
2223
width: "100%",
2324
height: "100%",
24-
stroke: "#979797",
25-
strokeWidth: "1.67px",
2625
fill: "none"
2726
};
2827

@@ -35,14 +34,25 @@ export function ShareLinkButton({
3534
discussionId,
3635
className = ""
3736
}: ShareLinkButtonProps) {
38-
const { success: showSuccessToast } = useToast();
37+
const [isCopied, setIsCopied] = useState(false);
38+
const { addToast } = useToast();
3939

4040
const handleCopyLink = (e: React.MouseEvent) => {
41+
setIsCopied(true);
4142
e.stopPropagation();
43+
4244
const origin = typeof window !== "undefined" ? window.location.origin : "";
4345
const url = `${origin}/today-i-learned/post/${discussionId}`;
4446
navigator.clipboard.writeText(url);
45-
showSuccessToast("링크가 복사되었습니다!");
47+
addToast({
48+
type: "success",
49+
title: "링크가 복사되었습니다!",
50+
duration: 3000
51+
});
52+
53+
setTimeout(() => {
54+
setIsCopied(false);
55+
}, 3000);
4656
};
4757

4858
return (
@@ -52,7 +62,11 @@ export function ShareLinkButton({
5262
aria-label="링크 복사"
5363
>
5464
<div className={css(shareIconContainer)}>
55-
<Link className={css(shareIcon)} />
65+
{isCopied ? (
66+
<Check className={css(shareIcon)} stroke="#10b981" />
67+
) : (
68+
<Link className={css(shareIcon)} stroke="#979797" />
69+
)}
5670
</div>
5771
</button>
5872
);

fundamentals/today-i-learned/src/components/shared/layout/Layout.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ const layoutContainer = css({
1717
minHeight: "100vh",
1818
backgroundColor: "white",
1919
fontFamily: "sans-serif",
20-
fontSmoothing: "antialiased"
20+
fontSmoothing: "antialiased",
21+
overflow: "hidden"
2122
});
2223

2324
const mainContent = css({
24-
paddingTop: "81px",
25-
marginX: "auto",
26-
minWidth: "48rem",
27-
maxWidth: "1440px",
28-
"@media (min-width: 1024px)": {
29-
paddingLeft: "50px"
30-
}
25+
height: "100vh",
26+
paddingTop: "4.6875rem",
27+
paddingLeft: { base: 0, lg: "3.125rem" },
28+
overflow: "hidden"
3129
});

0 commit comments

Comments
 (0)