Skip to content

Commit e4fdcf7

Browse files
authored
Merge pull request #74 from techknowledge-blog/feature/article-levels-label
Article Level Label
2 parents 23bff0e + c771904 commit e4fdcf7

2 files changed

Lines changed: 49 additions & 14 deletions

File tree

src/components/posts/post/Post.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface PostProps {
1717
content: string;
1818
slug: string;
1919
createdAt: string;
20+
article_level: string;
2021
}
2122

2223
export function Post() {
@@ -42,13 +43,29 @@ export function Post() {
4243
return <div>carregando...</div>;
4344
}
4445

46+
const levelColors: Record<string, string> = {
47+
Iniciante: "bg-[#B4CB3F]",
48+
Intermediário: "bg-[#408EEB]",
49+
Avançado: "bg-[#7B66D4]",
50+
};
51+
4552
return (
46-
<div className="px-4 sm:px-6 lg:px-8 mt-12 w-full md:w-[46rem] lg:w-[62rem]">
47-
<div className="flex items-center">
48-
<div className="h-6 w-1 dark:bg-blue-300 bg-blue-500 mr-4"></div>
49-
<p className="font-bold text-sm sm:text-base dark:text-white text-[#62748E]">
50-
{formatDateToCustomFormat(post.createdAt)}
51-
</p>
53+
<div className="px-6 mt-12 w-full md:w-[46rem] lg:w-[62rem]">
54+
<div className="flex items-center justify-between">
55+
<div className="flex items-center">
56+
<div className="h-6 w-1 dark:bg-blue-300 bg-blue-500 mr-4"></div>
57+
<p className="font-bold text-sm sm:text-base dark:text-white text-[#62748E]">
58+
{formatDateToCustomFormat(post.createdAt)}
59+
</p>
60+
</div>
61+
62+
<span
63+
className={`w-[6.5rem] h-[1.625rem] rounded-full text-xs text-black font-semibold flex items-center justify-center ${
64+
levelColors[post.article_level] || "bg-gray-200 text-gray-700"
65+
}`}
66+
>
67+
<p>{post.article_level}</p>
68+
</span>
5269
</div>
5370

5471
<div className="prose prose-invert max-w-none mt-8">
@@ -59,7 +76,7 @@ export function Post() {
5976
<div className="mt-8">
6077
<ReactMarkdown
6178
className=" prose dark:prose-invert prose-h1:text-black dark:prose-h1:text-white max-w-full
62-
prose-pre:overflow-x-auto prose-pre:max-w-full md:prose-pre:w-full sm-custom:prose-pre:w-[18rem] sm-extended:prose-pre:w-[30rem] xs-custom:prose-pre:w-[21rem] prose-pre:p-4
79+
prose-pre:overflow-x-auto prose-pre:max-w-full md:prose-pre:w-full sm-custom:prose-pre:w-full sm-extended:prose-pre:w-full xs-custom:prose-pre:w-full prose-pre:p-4
6380
prose-pre:bg-gray-800 dark:prose-pre:bg-slate-800 prose-pre:text-white prose-pre:rounded-lg
6481
prose-code:break-words prose-code:whitespace-pre-wrap"
6582
rehypePlugins={[rehypeHighlight]}

src/components/posts/postlist/PostList.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface PostType {
1515
};
1616
slug: string;
1717
estimated_time: number;
18+
article_level: string;
1819
}
1920

2021
export function PostList() {
@@ -47,6 +48,12 @@ export function PostList() {
4748
}, {});
4849
}
4950

51+
const levelColors: Record<string, string> = {
52+
Iniciante: "bg-[#B4CB3F]",
53+
Intermediário: "bg-[#408EEB]",
54+
Avançado: "bg-[#7B66D4]",
55+
};
56+
5057
const postsByCategory = groupPostsByCategory(posts);
5158

5259
return (
@@ -65,7 +72,7 @@ export function PostList() {
6572
{posts.map((post) => (
6673
<li
6774
key={post.id}
68-
className="dark:bg-[#1E293B] bg-[#93C5FD] p-6 rounded-lg dark:hover:bg-[#334155] hover:bg-[#71b4ff] transition w-[20rem] md:w-full h-full flex flex-col"
75+
className="dark:bg-[#1E293B] bg-[#93C5FD] p-4 rounded-lg dark:hover:bg-[#334155] hover:bg-[#71b4ff] transition w-[20rem] md:w-full h-full flex flex-col"
6976
>
7077
<div className="flex flex-col gap-4 flex-grow">
7178
<Link to={`/posts/${post.slug}`} className="no-underline">
@@ -86,7 +93,7 @@ export function PostList() {
8693
</p>
8794
</div>
8895

89-
<div className="flex items-center justify-between">
96+
<div className="flex items-center justify-between gap-4">
9097
<Link
9198
to={`/posts/${post.slug}`}
9299
className="flex items-center gap-2 font-bold mt-auto min-h-14 text-sm dark:text-white text-black dark:hover:text-blue-400 hover:underline"
@@ -95,11 +102,22 @@ export function PostList() {
95102
<ArrowRight size={16} />
96103
</Link>
97104

98-
<div className="flex items-center gap-2">
99-
<Clock size={20} weight="bold" color="#8ec5ff" />
100-
<p className="text-sm font-semibold text-blue-400">
101-
{post.estimated_time}min
102-
</p>
105+
<div className="flex items-center gap-2 lg:gap-4">
106+
<span
107+
className={`w-[6rem] h-[1.5rem] lg:w-[6.5rem] lg:h-[1.625rem] rounded-full text-xs text-black font-semibold flex items-center justify-center ${
108+
levelColors[post.article_level] ||
109+
"bg-gray-200 text-gray-700"
110+
}`}
111+
>
112+
<p>{post.article_level}</p>
113+
</span>
114+
115+
<div className="flex items-center gap-2">
116+
<Clock size={20} weight="bold" color="#8ec5ff" />
117+
<p className="text-sm font-semibold text-blue-400">
118+
{post.estimated_time}min
119+
</p>
120+
</div>
103121
</div>
104122
</div>
105123
</li>

0 commit comments

Comments
 (0)