Skip to content
Merged
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
45 changes: 36 additions & 9 deletions components/Threads/desktop/Skeleton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

.preview {
position: relative;
padding: 2rem;
padding: 1.5rem;
box-sizing: border-box;
height: var(--thread-height);
width: 100%;
Expand All @@ -41,12 +41,10 @@
width: auto;
display: flex;
flex-direction: initial;

margin-bottom: 0.3rem;

.user {
width: 3rem;

position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand All @@ -69,13 +67,12 @@
}
}

>span {
> span {
padding: 0 0.1rem;
}

.sig {
width: 5rem;

position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand Down Expand Up @@ -107,7 +104,6 @@

.title {
width: 50%;

position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand All @@ -134,8 +130,8 @@
}

.content {
height: 4rem;

height: 3rem; // 改為兩行的高度 (對應 min-height: calc(1em * 1.5 * 2))
margin-bottom: 0.5rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand All @@ -158,9 +154,40 @@
}
}

// 新增 hashtag skeleton
.hashtags {
display: flex;
gap: 0.5rem;
margin-top: 0.3rem;
}

.hashtag {
width: 3rem;
height: 1.5rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
border-radius: 0.75rem;

&::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateX(-100%);
background-image: linear-gradient(90deg,
rgba(#fff, 0) 0,
rgba(#fff, 0.2) 20%,
rgba(#fff, 0.5) 60%,
rgba(#fff, 0));
animation: shimmer 2s infinite;
content: '';
}
}

.cover {
min-width: 25%;

position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand Down
38 changes: 32 additions & 6 deletions components/Threads/desktop/ThreadsList.module.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "@/app/styles/variables.scss";

.threads {
--thread-height: 10rem;
--thread-height: 12rem;
position: relative;
width: 100%;
border-radius: $border-radius;
Expand All @@ -10,7 +10,7 @@
gap: $gap;
overflow-y: auto;

>p {
> p {
width: 100%;
text-align: center;
padding-bottom: 0.5rem;
Expand Down Expand Up @@ -58,10 +58,36 @@

.previewContent {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
color: black;
margin-bottom: 0.5rem;
line-height: 1.5; // 行高倍數
min-height: calc(1em * 1.5 * 2); // 1em * line-height * 行數
}

.hashtags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.3rem;
}

.hashtag {
padding: 0.25rem 0.6rem;
background: rgba(95, 205, 245, 1);
color: #ffffff;
border-radius: 0.75rem;
font-size: 0.75rem;
font-weight: 600;
transition: all 0.2s ease;
white-space: nowrap;

&:hover {
background: #5FCDF5;
color: white;
}
}

.cover {
Expand Down Expand Up @@ -101,7 +127,7 @@
opacity: 60%;
}

&>span {
& > span {
padding: 0 0.1rem;
}
}
Expand All @@ -115,7 +141,7 @@
justify-content: flex-end;
flex: content;

&>span {
& > span {
padding: 0 0.1rem;
}

Expand All @@ -141,7 +167,7 @@
align-items: center;
justify-content: center;

>h1 {
> h1 {
font-size: $info-title-font-size;
}
}
44 changes: 29 additions & 15 deletions components/Threads/desktop/ThreadsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Thread = ({ threadData }: { threadData: TThread }) => {
return (
<Link
href={`/post/${threadData._id}`}
className={style.thread + " cursor-pointer select-none "}
className={style.thread + " cursor-pointer select-none"}
style={{
backgroundColor: isAnnouncement ? "white" : "",
}}
Expand All @@ -62,11 +62,7 @@ export const Thread = ({ threadData }: { threadData: TThread }) => {
</div>
<div className={style.statist}>
<p className={style.date}>
{
new Date(threadData.createdAt!)
.toLocaleString("zh-TW")
.split(" ")[0]
}
{new Date(threadData.createdAt!).toLocaleString("zh-TW").split(" ")[0]}
</p>
<div className={style.likes}>
<Image
Expand All @@ -90,11 +86,11 @@ export const Thread = ({ threadData }: { threadData: TThread }) => {
</div>
</div>
</div>

<div className={style.title_bar}>
<h1 className={style.previewTitle}>
{isAnnouncement && "🔔 公告 - "}
{threadData.title}
{/* {threadData.pinned && " • 已置頂"} */}
</h1>
</div>

Expand All @@ -106,21 +102,34 @@ export const Thread = ({ threadData }: { threadData: TThread }) => {
>
{markdownToPlainText(threadData.content)}
</p>

{threadData.hashtag && threadData.hashtag.length > 0 && !isAnnouncement && (
<div className={style.hashtags}>
{threadData.hashtag.slice(0, 3).map((tag, index) => (
<span key={index} className={style.hashtag}>
#{tag}
</span>
))}
</div>
)}
</div>

<div
className={style.cover}
style={{
display: isAnnouncement ? "none" : "",
}}
>
<Image
src={fixCoverUrl(threadData.cover!)}
alt="cover image"
style={{ objectFit: "cover" }}
priority
sizes="100%"
fill
></Image>
{threadData.cover && (
<Image
src={fixCoverUrl(threadData.cover)}
alt="cover image"
style={{ objectFit: "cover" }}
priority
sizes="100%"
fill
/>
)}
</div>
</Link>
);
Expand All @@ -137,6 +146,11 @@ const ThreadSkeleton = () => {
</div>
<div className={skeleton.title}></div>
<p className={skeleton.content}></p>
<div className={skeleton.hashtags}>
<div className={skeleton.hashtag}></div>
<div className={skeleton.hashtag}></div>
<div className={skeleton.hashtag}></div>
</div>
</div>
<div className={skeleton.cover}></div>
</div>
Expand Down
44 changes: 22 additions & 22 deletions components/Threads/mobile/Skeleton.module.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
@import "@/app/styles/variables.scss";

.thread {
--thread-height: 12rem;
--thread-height: 8rem;
background: $panel-background-color;
border-radius: $border-radius;
border-radius: $mobile-border-radius;
max-height: var(--thread-height);
height: var(--thread-height);
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 0.5rem;

animation-name: breath;
animation-duration: 0.8s;
Expand All @@ -20,7 +18,6 @@
from {
background-color: rgba(255, 255, 255, 0.5);
}

to {
background-color: rgba(255, 255, 255, 0.2);
}
Expand All @@ -29,24 +26,23 @@

.preview {
position: relative;
padding: 2rem;
padding: 1rem;
box-sizing: border-box;
height: var(--thread-height);
width: 100%;
overflow: hidden;
}

.info {
font-size: 0.85rem;
font-size: 0.75rem;
width: auto;
display: flex;
flex-direction: initial;

margin-bottom: 0.3rem;

.user {
width: 3rem;

height: 0.75rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand All @@ -69,13 +65,13 @@
}
}

>span {
> span {
padding: 0 0.1rem;
}

.sig {
width: 5rem;

width: 4rem;
height: 0.75rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand Down Expand Up @@ -106,15 +102,13 @@
}

.title {
width: 50%;

width: 60%;
height: 1rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
border-radius: 0.3rem;
margin-bottom: 0.5rem;
height: 1.75rem;
flex: 1;

&::after {
position: absolute;
Expand All @@ -134,8 +128,8 @@
}

.content {
height: 4rem;

height: 0.9rem;
margin-bottom: 0.5rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
Expand All @@ -158,13 +152,19 @@
}
}

.cover {
min-width: 25%;
.hashtags {
display: flex;
gap: 0.4rem;
margin-top: 1rem;
}

.hashtag {
width: 2.5rem;
height: 1.1rem;
position: relative;
background-color: $skeleton-background-color;
overflow: hidden;
border-radius: $border-radius;
border-radius: 0.6rem;

&::after {
position: absolute;
Expand Down
Loading