-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from route06inc/feat/nav-post-component
feat: Add NavPrevPost, NavNextPost
- Loading branch information
Showing
25 changed files
with
417 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { fallbackLang } from '@/features/i18n' | ||
import { TopPage } from '@/features/top' | ||
|
||
export default function Page() { | ||
return <TopPage lang={fallbackLang} /> | ||
return <TopPage /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { fallbackLang } from '@/features/i18n' | ||
import { PostListPage } from '@/features/posts' | ||
|
||
export default function Page() { | ||
return <PostListPage lang={fallbackLang} /> | ||
return <PostListPage /> | ||
} |
5 changes: 3 additions & 2 deletions
5
frontend/apps/service-site/src/components/TopCards/TopCards.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/apps/service-site/src/features/posts/components/NavNextPost/NavNextPost.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.wrapper { | ||
display: grid; | ||
grid-auto-flow: row; | ||
gap: var(--spacing-2); | ||
} | ||
|
||
.label { | ||
color: var(--global-body-text); | ||
font-family: var(--main-font); | ||
font-size: var(--font-size-2); | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .label { | ||
color: var(--global-foreground); | ||
} | ||
|
||
.titleWrapper { | ||
display: grid; | ||
grid-auto-flow: column; | ||
gap: var(--spacing-half); | ||
justify-content: space-between; | ||
} | ||
|
||
.icon { | ||
width: 1.25rem; | ||
height: 1.25rem; | ||
color: var(--global-foreground); | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .icon { | ||
color: var(--primary-color); | ||
} | ||
|
||
.title { | ||
display: -webkit-box; | ||
overflow: hidden; | ||
color: var(--global-foreground); | ||
text-overflow: ellipsis; | ||
font-family: var(--message-font); | ||
font-size: var(--font-size-7); | ||
line-height: 120%; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 3; | ||
line-clamp: 3; | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .title { | ||
color: var(--primary-color); | ||
} |
16 changes: 16 additions & 0 deletions
16
frontend/apps/service-site/src/features/posts/components/NavNextPost/NavNextPost.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import { aPost } from '../../factories' | ||
import { NavNextPost } from './' | ||
|
||
const meta = { | ||
component: NavNextPost, | ||
args: { | ||
post: aPost(), | ||
}, | ||
} satisfies Meta<typeof NavNextPost> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} |
27 changes: 27 additions & 0 deletions
27
frontend/apps/service-site/src/features/posts/components/NavNextPost/NavNextPost.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Lang } from '@/features/i18n' | ||
import type { Post } from 'contentlayer/generated' | ||
import { ChevronRight } from 'lucide-react' | ||
import Link from 'next/link' | ||
import type { FC } from 'react' | ||
import { createPostDetailLink } from '../../utils' | ||
import styles from './NavNextPost.module.css' | ||
|
||
type Props = { | ||
lang?: Lang | undefined | ||
post: Post | ||
} | ||
|
||
export const NavNextPost: FC<Props> = ({ lang, post }) => { | ||
return ( | ||
<Link | ||
href={createPostDetailLink({ lang, slug: post.slug })} | ||
className={styles.wrapper} | ||
> | ||
<span className={styles.label}>Next</span> | ||
<div className={styles.titleWrapper}> | ||
<span className={styles.title}>{post.title}</span> | ||
<ChevronRight className={styles.icon} /> | ||
</div> | ||
</Link> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/apps/service-site/src/features/posts/components/NavNextPost/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './NavNextPost' |
56 changes: 56 additions & 0 deletions
56
...pps/service-site/src/features/posts/components/NavPreviousPost/NavPreviousPost.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.wrapper { | ||
display: grid; | ||
grid-auto-flow: row; | ||
gap: var(--spacing-2); | ||
} | ||
|
||
.label { | ||
padding-left: var(--spacing-6); | ||
color: var(--global-body-text); | ||
font-family: var(--main-font); | ||
font-size: var(--font-size-2); | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .label { | ||
color: var(--global-foreground); | ||
} | ||
|
||
.titleWrapper { | ||
display: grid; | ||
grid-auto-flow: column; | ||
gap: var(--spacing-half); | ||
justify-content: flex-start; | ||
} | ||
|
||
.icon { | ||
width: 1.25rem; | ||
height: 1.25rem; | ||
color: var(--global-foreground); | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .icon { | ||
color: var(--primary-color); | ||
} | ||
|
||
.title { | ||
display: -webkit-box; | ||
overflow: hidden; | ||
color: var(--global-foreground); | ||
text-overflow: ellipsis; | ||
font-family: var(--message-font); | ||
font-size: var(--font-size-7); | ||
line-height: 120%; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 3; | ||
line-clamp: 3; | ||
transition: color var(--default-hover-animation-duration) | ||
var(--default-timing-function); | ||
} | ||
|
||
.wrapper:hover .title { | ||
color: var(--primary-color); | ||
} |
16 changes: 16 additions & 0 deletions
16
...ps/service-site/src/features/posts/components/NavPreviousPost/NavPreviousPost.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
import { aPost } from '../../factories' | ||
import { NavPreviousPost } from './' | ||
|
||
const meta = { | ||
component: NavPreviousPost, | ||
args: { | ||
post: aPost(), | ||
}, | ||
} satisfies Meta<typeof NavPreviousPost> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = {} |
27 changes: 27 additions & 0 deletions
27
frontend/apps/service-site/src/features/posts/components/NavPreviousPost/NavPreviousPost.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Lang } from '@/features/i18n' | ||
import type { Post } from 'contentlayer/generated' | ||
import { ChevronLeft } from 'lucide-react' | ||
import Link from 'next/link' | ||
import type { FC } from 'react' | ||
import { createPostDetailLink } from '../../utils' | ||
import styles from './NavPreviousPost.module.css' | ||
|
||
type Props = { | ||
lang?: Lang | undefined | ||
post: Post | ||
} | ||
|
||
export const NavPreviousPost: FC<Props> = ({ lang, post }) => { | ||
return ( | ||
<Link | ||
href={createPostDetailLink({ lang, slug: post.slug })} | ||
className={styles.wrapper} | ||
> | ||
<span className={styles.label}>Previous</span> | ||
<div className={styles.titleWrapper}> | ||
<ChevronLeft className={styles.icon} /> | ||
<span className={styles.title}>{post.title}</span> | ||
</div> | ||
</Link> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/apps/service-site/src/features/posts/components/NavPreviousPost/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './NavPreviousPost' |
29 changes: 29 additions & 0 deletions
29
.../apps/service-site/src/features/posts/components/PostDetailPage/PostDetailPage.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.navPostWrapper { | ||
display: grid; | ||
grid-template-rows: auto auto; | ||
gap: var(--spacing-8); | ||
} | ||
|
||
.navPrev { | ||
grid-area: 0 / 2; | ||
} | ||
|
||
.navNext { | ||
grid-area: 0 / 2; | ||
} | ||
|
||
@media screen and (min-width: 768px) { | ||
.navPostWrapper { | ||
grid-template-columns: 1fr 1fr; | ||
grid-template-rows: none; | ||
gap: var(--spacing-10); | ||
} | ||
|
||
.navPrev { | ||
grid-area: 0 / 1; | ||
} | ||
|
||
.navNext { | ||
grid-area: 1 / 2; | ||
} | ||
} |
26 changes: 22 additions & 4 deletions
26
frontend/apps/service-site/src/features/posts/components/PostDetailPage/PostDetailPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,48 @@ | ||
import type { Lang } from '@/features/i18n' | ||
import { type Lang, fallbackLang } from '@/features/i18n' | ||
import { LinkHeading } from '@/features/posts/components/LinkHeading' | ||
import { PostHero } from '@/features/posts/components/PostHero' | ||
import { MDXContent } from '@/libs/contentlayer' | ||
import { notFound } from 'next/navigation' | ||
import type { FC } from 'react' | ||
import { findPostByLangAndSlug } from '../../utils' | ||
import { findPostByLangAndSlug, getNextPost, getPrevPost } from '../../utils' | ||
import { NavNextPost } from '../NavNextPost' | ||
import { NavPreviousPost } from '../NavPreviousPost' | ||
import { TableOfContents } from '../TableOfContents' | ||
import styles from './PostDetailPage.module.css' | ||
|
||
const TOC_TARGET_CLASS_NAME = 'target-toc' | ||
|
||
type Props = { | ||
lang: Lang | ||
lang?: Lang | ||
slug: string | ||
} | ||
|
||
export const PostDetailPage: FC<Props> = ({ lang, slug }) => { | ||
const post = findPostByLangAndSlug({ lang, slug }) | ||
const post = findPostByLangAndSlug({ lang: lang ?? fallbackLang, slug }) | ||
if (!post) notFound() | ||
|
||
const prevPost = getPrevPost({ lang: lang ?? fallbackLang, targetPost: post }) | ||
const nextPost = getNextPost({ lang: lang ?? fallbackLang, targetPost: post }) | ||
|
||
return ( | ||
<article className={TOC_TARGET_CLASS_NAME} style={{ padding: '0 120px' }}> | ||
<PostHero post={post} /> | ||
<TableOfContents contentSelector={TOC_TARGET_CLASS_NAME} /> | ||
{/* FIXME: Add href props after implementing categories single page */} | ||
<LinkHeading href="/">Categories</LinkHeading> | ||
<MDXContent code={post.body.code} /> | ||
<div className={styles.navPostWrapper}> | ||
{prevPost && ( | ||
<div className={styles.navPrev}> | ||
<NavPreviousPost lang={lang} post={prevPost} /> | ||
</div> | ||
)} | ||
{nextPost && ( | ||
<div className={styles.navNext}> | ||
<NavNextPost lang={lang} post={nextPost} /> | ||
</div> | ||
)} | ||
</div> | ||
</article> | ||
) | ||
} |
Oops, something went wrong.