Skip to content

Commit

Permalink
feat: add nav on post meta bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Sep 8, 2023
1 parent ec023c9 commit 6adae54
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
46 changes: 44 additions & 2 deletions src/components/widgets/post/PostMetaBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client'

import Link from 'next/link'
import type { PostModel } from '@mx-space/api-client'

import { MdiClockOutline } from '~/components/icons/clock'
Expand All @@ -9,12 +10,17 @@ import { FloatPopover } from '~/components/ui/float-popover'
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
import { RelativeTime } from '~/components/ui/relative-time'
import { clsxm } from '~/lib/helper'
import { routeBuilder, Routes } from '~/lib/route-builder'
import { useModalStack } from '~/providers/root/modal-stack-provider'

import { TagDetailModal } from './fab/PostTagsFAB'

export const PostMetaBar: Component<{
meta: Partial<
Pick<PostModel, 'created' | 'modified' | 'category' | 'tags' | 'count'>
>
}> = ({ className, meta }) => {
const { present } = useModalStack()
return (
<div
className={clsxm(
Expand Down Expand Up @@ -46,8 +52,44 @@ export const PostMetaBar: Component<{
<div className="flex min-w-0 items-center space-x-1">
<FeHash className="translate-y-[0.5px]" />
<span className="min-w-0 truncate">
{meta.category?.name}
{meta.tags?.length ? ` / ${meta.tags.join(', ')}` : ''}
<Link
href={routeBuilder(Routes.Category, {
slug: meta.category.slug,
})}
className="shiro-link--underline font-normal"
>
{meta.category?.name}
</Link>

{meta.tags?.length ? (
<>
{' '}
/{' '}
{meta.tags.map((tag, index) => {
const isLast = index === meta.tags!.length - 1

return (
<>
<button
className="shiro-link--underline"
onClick={() =>
present({
content: () => <TagDetailModal name={tag} />,
title: `Tag: ${tag}`,
})
}
key={tag}
>
{tag}
</button>
{!isLast && <span>, </span>}
</>
)
})}
</>
) : (
''
)}
</span>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/post/fab/PostTagsFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const TagInternal = memo(function TagInternal(
)
})

const TagDetailModal = (props: TagModel) => {
export const TagDetailModal = (props: { name: string }) => {
const { name } = props
const { data, isLoading } = useQuery({
queryKey: [name, 'tag'],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Manrope, Noto_Serif_SC } from 'next/font/google'

const sansFont = Manrope({
subsets: ['latin'],
weight: ['400', '500'],
weight: ['300', '400', '500'],
variable: '--font-sans',
display: 'swap',
})
Expand Down

1 comment on commit 6adae54

@vercel
Copy link

@vercel vercel bot commented on 6adae54 Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

springtide.vercel.app
shiro-git-main-innei.vercel.app
shiro-innei.vercel.app
innei.in

Please sign in to comment.