-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add paper theme #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4e2caa1
fix: resolve TypeScript build errors
rsbh 6981860
feat: add paper theme with dynamic theme registry
rsbh 0b43016
feat: refine paper theme layout, navbar, and page styling
rsbh 27fc7e6
fix: fixed navbar, fixed reading progress, paper-style content
rsbh c393b7b
feat: rewrite ReadingProgress as tick-based ruler TOC
rsbh ee06184
feat: add prose typography styles to paper theme content
rsbh 4af9530
feat: support classNames in paper Layout, fix API sidebar and search
rsbh fe0af49
fix: address PR review issues for paper theme
rsbh f94569f
fix: resolve overlapping headings and stylelint issues
rsbh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ web_modules/ | |
| # Next.js build output | ||
| .next | ||
| out | ||
| next-env.d.ts | ||
|
|
||
| # Fumadocs generated | ||
| .source | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,4 +14,9 @@ | |
| .content { | ||
| height: 100%; | ||
| overflow-y: auto; | ||
| padding-right: 0; | ||
| } | ||
|
|
||
| .hiddenSearch { | ||
| display: none; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,71 @@ | ||
| .nav { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--rs-space-5); | ||
| } | ||
|
|
||
| .chapter { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--rs-space-2); | ||
| } | ||
|
|
||
| .chapterLabel { | ||
| font-size: var(--rs-font-size-small); | ||
| font-weight: 600; | ||
| text-transform: uppercase; | ||
| letter-spacing: 0.05em; | ||
| color: var(--rs-color-foreground-base-primary); | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
|
|
||
| .chapterItems { | ||
| list-style: none; | ||
| padding: 0; | ||
| margin: 0; | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--rs-space-1); | ||
| padding-left: var(--rs-space-4); | ||
| } | ||
|
|
||
| .link { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--rs-space-2); | ||
| font-size: var(--rs-font-size-small); | ||
| color: var(--rs-color-foreground-base-tertiary); | ||
| text-decoration: none; | ||
| padding: var(--rs-space-1) 0; | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } | ||
|
|
||
| .link:hover { | ||
| color: var(--rs-color-foreground-base-primary); | ||
| } | ||
|
|
||
| .active { | ||
| color: var(--rs-color-foreground-accent-primary); | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| .icon { | ||
| display: flex; | ||
| align-items: center; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .subLabel { | ||
| font-size: var(--rs-font-size-small); | ||
| font-weight: 500; | ||
| color: var(--rs-color-foreground-base-secondary); | ||
| margin-top: var(--rs-space-3); | ||
| display: block; | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| } |
This file contains hidden or 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,96 @@ | ||
| 'use client' | ||
|
|
||
| import { usePathname } from 'next/navigation' | ||
| import NextLink from 'next/link' | ||
| import { MethodBadge } from '../../components/api/method-badge' | ||
| import type { PageTree, PageTreeItem } from '../../types' | ||
| import styles from './ChapterNav.module.css' | ||
|
|
||
| const iconMap: Record<string, React.ReactNode> = { | ||
| 'method-get': <MethodBadge method="GET" size="micro" />, | ||
| 'method-post': <MethodBadge method="POST" size="micro" />, | ||
| 'method-put': <MethodBadge method="PUT" size="micro" />, | ||
| 'method-delete': <MethodBadge method="DELETE" size="micro" />, | ||
| 'method-patch': <MethodBadge method="PATCH" size="micro" />, | ||
| } | ||
|
|
||
| interface ChapterNavProps { | ||
| tree: PageTree | ||
| } | ||
|
|
||
| function buildChapterIndices(children: PageTreeItem[]): Map<PageTreeItem, number> { | ||
| const indices = new Map<PageTreeItem, number>() | ||
| let index = 0 | ||
| for (const item of children) { | ||
| if (item.type === 'folder' && item.children) { | ||
| index++ | ||
| indices.set(item, index) | ||
| } | ||
| } | ||
| return indices | ||
| } | ||
|
|
||
| export function ChapterNav({ tree }: ChapterNavProps) { | ||
| const pathname = usePathname() | ||
| const chapterIndices = buildChapterIndices(tree.children) | ||
|
|
||
| return ( | ||
| <nav className={styles.nav}> | ||
| <ul className={styles.chapterItems}> | ||
| {tree.children.map((item) => { | ||
| if (item.type === 'separator') return null | ||
|
|
||
| if (item.type === 'folder' && item.children) { | ||
| const chapterIndex = chapterIndices.get(item) ?? 0 | ||
| return ( | ||
| <li key={item.name} className={styles.chapter}> | ||
| <span className={styles.chapterLabel}> | ||
| {String(chapterIndex).padStart(2, '0')}. {item.name} | ||
| </span> | ||
| <ul className={styles.chapterItems}> | ||
| {item.children.map((child) => ( | ||
| <ChapterItem key={child.url ?? child.name} item={child} pathname={pathname} /> | ||
| ))} | ||
| </ul> | ||
| </li> | ||
| ) | ||
| } | ||
|
|
||
| return <ChapterItem key={item.url ?? item.name} item={item} pathname={pathname} /> | ||
| })} | ||
| </ul> | ||
| </nav> | ||
| ) | ||
| } | ||
|
|
||
| function ChapterItem({ item, pathname }: { item: PageTreeItem; pathname: string }) { | ||
| if (item.type === 'separator') return null | ||
|
|
||
| if (item.type === 'folder' && item.children) { | ||
| return ( | ||
| <li> | ||
| <span className={styles.subLabel}>{item.name}</span> | ||
| <ul className={styles.chapterItems}> | ||
| {item.children.map((child) => ( | ||
| <ChapterItem key={child.url ?? child.name} item={child} pathname={pathname} /> | ||
| ))} | ||
| </ul> | ||
| </li> | ||
| ) | ||
| } | ||
|
|
||
| const isActive = pathname === item.url | ||
| const icon = item.icon ? iconMap[item.icon] : null | ||
|
|
||
| return ( | ||
| <li> | ||
| <NextLink | ||
| href={item.url ?? '#'} | ||
| className={`${styles.link} ${isActive ? styles.active : ''}`} | ||
| > | ||
| {icon && <span className={styles.icon}>{icon}</span>} | ||
| <span>{item.name}</span> | ||
| </NextLink> | ||
| </li> | ||
| ) | ||
| } |
This file contains hidden or 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,33 @@ | ||
| .layout { | ||
| --paper-sidebar-width: 260px; | ||
|
|
||
| min-height: 100vh; | ||
| } | ||
|
|
||
| .body { | ||
| flex: 1; | ||
| } | ||
|
|
||
| .sidebar { | ||
| width: var(--paper-sidebar-width); | ||
| padding: var(--rs-space-7) var(--rs-space-5); | ||
| background: var(--rs-color-background-neutral-primary); | ||
| overflow-y: auto; | ||
| font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace; | ||
| } | ||
|
|
||
| .title { | ||
| text-transform: uppercase; | ||
| letter-spacing: 0.08em; | ||
| color: var(--rs-color-foreground-accent-primary); | ||
| font-family: inherit; | ||
| font-size: var(--rs-font-size-mono-large); | ||
| margin-bottom: var(--rs-space-7); | ||
| } | ||
|
|
||
| .content { | ||
| flex: 1; | ||
| overflow-y: auto; | ||
| background: var(--rs-color-background-neutral-primary); | ||
| padding-right: var(--paper-sidebar-width); | ||
| } | ||
This file contains hidden or 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,25 @@ | ||
| 'use client' | ||
|
|
||
| import { Flex, Headline } from '@raystack/apsara' | ||
| import { cx } from 'class-variance-authority' | ||
| import { Footer } from '../../components/ui/footer' | ||
| import { ChapterNav } from './ChapterNav' | ||
| import type { ThemeLayoutProps } from '../../types' | ||
| import styles from './Layout.module.css' | ||
|
|
||
| export function Layout({ children, config, tree, classNames }: ThemeLayoutProps) { | ||
| return ( | ||
| <Flex direction="column" className={cx(styles.layout, classNames?.layout)}> | ||
| <Flex className={cx(styles.body, classNames?.body)}> | ||
| <aside className={cx(styles.sidebar, classNames?.sidebar)}> | ||
| <Headline size="small" weight="medium" as="h1" className={styles.title}> | ||
| {config.title} | ||
| </Headline> | ||
| <ChapterNav tree={tree} /> | ||
| </aside> | ||
| <div className={cx(styles.content, classNames?.content)}>{children}</div> | ||
| </Flex> | ||
| <Footer config={config.footer} /> | ||
| </Flex> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.