diff --git a/frontend/components.json b/frontend/components.json index e24d4934..57039a23 100644 --- a/frontend/components.json +++ b/frontend/components.json @@ -13,4 +13,4 @@ "components": "@/components", "utils": "@/lib/utils" } -} \ No newline at end of file +} diff --git a/frontend/src/components/blog-feed.tsx b/frontend/src/components/blog-feed.tsx index f09bad8c..6bf45131 100644 --- a/frontend/src/components/blog-feed.tsx +++ b/frontend/src/components/blog-feed.tsx @@ -2,10 +2,10 @@ import axios from 'axios'; import { useEffect, useState } from 'react'; import FeaturedPostCard from '@/components/featured-post-card'; import LatestPostCard from '@/components/latest-post-card'; -import { CATEGORIES } from '@/constants/categories'; -import { categoryProps } from '@/utils/category-props'; import { FeaturedPostCardSkeleton } from '@/components/skeletons/featured-post-card-skeleton'; import { LatestPostCardSkeleton } from '@/components/skeletons/latest-post-card-skeleton'; +import CategoryPill from '@/components/category-pill'; +import { categories } from '@/utils/category-colors'; export default function BlogFeed() { const [selectedCategory, setSelectedCategory] = useState('featured'); @@ -40,15 +40,18 @@ export default function BlogFeed() { }, []); return ( -
+
-

+
+ What's hot? +
+

{selectedCategory === 'featured' ? 'Featured Posts' : `Posts related to "${selectedCategory}"`}

-
+
{posts.length === 0 ? Array(5) .fill(0) @@ -60,30 +63,29 @@ export default function BlogFeed() {
-
Discover by topic
-

Categories

-
- {CATEGORIES.map((category) => ( +
+ Discover by topic +
+

Categories

+
+ {categories.map((category) => ( ))}
-
What's new ?
-

Latest Posts

-
+
+ What's new? +
+

Latest Posts

+
{latestPosts.length === 0 ? Array(5) .fill(0) diff --git a/frontend/src/components/category-pill.tsx b/frontend/src/components/category-pill.tsx new file mode 100644 index 00000000..69ab7af7 --- /dev/null +++ b/frontend/src/components/category-pill.tsx @@ -0,0 +1,22 @@ +import { getCategoryColors } from '@/utils/category-colors'; +import { twMerge } from 'tailwind-merge'; + +interface CategoryPillProps extends React.HTMLAttributes { + category: string; + selected?: boolean; +} + +export default function CategoryPill({ category, selected = false }: CategoryPillProps) { + const [defaultColor, selectedColor]: [string, string] = getCategoryColors(category); + + return ( + + {category} + + ); +} diff --git a/frontend/src/components/featured-post-card.tsx b/frontend/src/components/featured-post-card.tsx index caaf8407..c75f3c30 100644 --- a/frontend/src/components/featured-post-card.tsx +++ b/frontend/src/components/featured-post-card.tsx @@ -1,35 +1,37 @@ import { useNavigate } from 'react-router-dom'; import Post from '@/types/post-type'; import formatPostTime from '@/utils/format-post-time'; -import { categoryProps } from '@/utils/category-props'; +import CategoryPill from '@/components/category-pill'; export default function FeaturedPostCard({ post }: { post: Post }) { const navigate = useNavigate(); return (
navigate('/details-page', { state: { post } })} >
{post.title}
-
-
{post.title}
+
+
+ {post.title} +
{post.categories.map((category, index) => ( - - {category} - + ))}
-
-

{post.description}

+
+

+ {post.description} +

-
+
{post.authorName} • {formatPostTime(post.timeOfPost)}
diff --git a/frontend/src/components/latest-post-card.tsx b/frontend/src/components/latest-post-card.tsx index 934048a8..e6b0dc3c 100644 --- a/frontend/src/components/latest-post-card.tsx +++ b/frontend/src/components/latest-post-card.tsx @@ -1,27 +1,27 @@ import { useNavigate } from 'react-router-dom'; import linkIcon from '@/assets/svg/link.svg'; import Post from '@/types/post-type'; -import { categoryProps } from '@/utils/category-props'; import formatPostTime from '@/utils/format-post-time'; +import CategoryPill from '@/components/category-pill'; export default function LatestPostCard({ post }: { post: Post }) { const navigate = useNavigate(); return (
navigate('/details-page', { state: { post } })} >
-
+
{post.categories.map((category, index) => ( - - {category} - + ))}
navigate(-1)} />
-
{post.title}
-
+
+ {post.title} +
+
{post.authorName} • {formatPostTime(post.timeOfPost)}
diff --git a/frontend/src/components/modal.tsx b/frontend/src/components/modal.tsx index 18e38e7b..8ab05028 100644 --- a/frontend/src/components/modal.tsx +++ b/frontend/src/components/modal.tsx @@ -24,27 +24,29 @@ const ModalComponent: React.FC = ({ role="dialog" aria-modal="false" > -
+
-
-
+
+
-
+
{imageUrls.map((imageUrl) => (
handleImageSelect(imageUrl)} > @@ -60,18 +62,18 @@ const ModalComponent: React.FC = ({
-
+
-
-
-