Skip to content

Commit

Permalink
feat(ui): add icon before title on PostLink component
Browse files Browse the repository at this point in the history
resolve #703
  • Loading branch information
mateusfg7 committed Nov 29, 2023
1 parent c6edf29 commit ecbf8b6
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/shared/components/post-list/post-link.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import React from 'react'
import Link from 'next/link'

import { Date } from '@/shared/components/date'
import { Post } from 'contentlayer/generated'
import { DraftBadge, PlannedBadge, TestBadge } from './post-badges'
import {
CompassTool,
ListBullets,
NoteBlank,
TextAlignLeft
} from '@/shared/wrappers/phosphor-icons'
import { Date } from '@/shared/components/date'
import { CalendarBlank, Clock } from '@/shared/components/icons'
import { DraftBadge, PlannedBadge, TestBadge } from './post-badges'

interface Props {
post: Post
hideYear?: boolean
}

const TitleIcon = ({ category }: { category: string }) => {
if (category === 'How To') return <CompassTool weight="duotone" />
if (category === 'Article') return <TextAlignLeft weight="duotone" />
if (category === 'Notes') return <NoteBlank weight="duotone" />
if (category === 'List') return <ListBullets weight="duotone" />

return <></>
}

export function PostLink({ post, hideYear = false }: Props) {
const showDate = !post.test
const showReadingTime = !post.test
Expand Down Expand Up @@ -61,8 +76,9 @@ export function PostLink({ post, hideYear = false }: Props) {
>
<section>
<div className="flex items-center justify-between gap-2 md:justify-start">
<h2 className="text-xl font-bold text-neutral-700 group-hover:text-blue-700 group-active:text-blue-700 dark:text-neutral-500 dark:group-hover:text-blue-500 group-active:dark:text-blue-500">
{post.title}
<h2 className="flex items-center gap-1 text-xl font-bold text-neutral-700 group-hover:text-blue-700 group-active:text-blue-700 dark:text-neutral-500 dark:group-hover:text-blue-500 group-active:dark:text-blue-500">
<TitleIcon category={post.category} />
<span>{post.title}</span>
</h2>
{post.test && <TestBadge />}
{post.status === 'draft' && !post.test && <DraftBadge />}
Expand Down

0 comments on commit ecbf8b6

Please sign in to comment.