Skip to content

Commit 231514b

Browse files
committed
Use custom design and layout
1 parent e8586cb commit 231514b

File tree

12 files changed

+95
-73
lines changed

12 files changed

+95
-73
lines changed

packages/docs/src/components/language-toggle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ const styles = stylex.create({
8787
},
8888
buttonActive: {
8989
// 'bg-fd-primary/10 font-medium text-fd-primary'
90-
backgroundColor: 'var(--bg-fd-primary/10)',
90+
backgroundColor:
91+
'color-mix(in oklab, var(--bg-fd-primary) 10%, transparent)',
9192
fontWeight: 500,
9293
color: 'var(--text-fd-primary)',
9394
},

packages/docs/src/components/layout/docs.tsx

Lines changed: 67 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@ import { useSearchContext } from 'fumadocs-ui/contexts/search';
77
import { useSidebar } from 'fumadocs-ui/contexts/sidebar';
88
import { usePathname } from 'fumadocs-core/framework';
99
import * as stylex from '@stylexjs/stylex';
10-
import { StyleXComponentProps } from './shared';
10+
import { BaseLayoutProps, StyleXComponentProps } from './shared';
11+
import { activeLinkMarker } from '../../theming/vars.stylex';
1112

12-
export interface DocsLayoutProps {
13+
export interface DocsLayoutProps extends BaseLayoutProps {
1314
tree: PageTree.Root;
1415
children: ReactNode;
1516
}
1617

17-
export function DocsLayout({ tree, children }: DocsLayoutProps) {
18+
export function DocsLayout({ tree, children, ...props }: DocsLayoutProps) {
1819
return (
1920
<TreeContextProvider tree={tree}>
2021
<header {...stylex.props(layoutStyles.header)}>
2122
<nav {...stylex.props(layoutStyles.nav)}>
23+
<NavbarSidebarTrigger
24+
{...stylex.props(layoutStyles.sidebarTrigger)}
25+
/>
2226
<Link href="/" {...stylex.props(layoutStyles.title)}>
23-
My Docs
27+
{props.nav?.title ?? 'My Docs'}
2428
</Link>
2529

30+
<div {...stylex.props(layoutStyles.gap)} />
2631
<SearchToggle />
27-
<NavbarSidebarTrigger
28-
{...stylex.props(layoutStyles.sidebarTrigger)}
29-
/>
3032
</nav>
3133
</header>
3234
<main id="nd-docs-layout" {...stylex.props(layoutStyles.main)}>
@@ -40,10 +42,14 @@ const layoutStyles = stylex.create({
4042
header: {
4143
// sticky top-0 bg-fd-background h-14 z-20
4244
position: 'sticky',
45+
display: 'flex',
4346
top: 0,
4447
backgroundColor: 'var(--bg-fd-background)',
45-
height: 14,
48+
height: '56px',
4649
zIndex: 20,
50+
borderBottomWidth: 1,
51+
borderBottomStyle: 'solid',
52+
borderBottomColor: 'var(--color-fd-border)',
4753
},
4854
nav: {
4955
// flex flex-row items-center gap-2 size-full px-4
@@ -54,21 +60,20 @@ const layoutStyles = stylex.create({
5460
width: '100%',
5561
paddingInline: 4 * 4,
5662
},
57-
title: {
58-
// font-medium mr-auto
59-
fontWeight: 500,
60-
marginInlineEnd: 'auto',
63+
title: {},
64+
gap: {
65+
flexGrow: 1,
6166
},
6267
sidebarTrigger: {
6368
// md:hidden
64-
display: { default: 'none', '@media (min-width: 768px)': 'block' },
69+
// display: { default: 'none', '@media (min-width: 768px)': 'block' },
6570
},
6671
main: {
6772
// flex flex-1 flex-row [--fd-nav-height:56px]
6873
display: 'flex',
6974
flexGrow: 1,
7075
flexDirection: 'row',
71-
['--fd-nav-height' as any]: 56 * 4,
76+
['--fd-nav-height' as any]: '56px',
7277
},
7378
});
7479

@@ -170,7 +175,7 @@ const sidebarStyles = stylex.create({
170175
},
171176
},
172177
notOpen: {
173-
display: { default: 'flex', '@media (max-width: 767px)': 'none' },
178+
display: 'none',
174179
},
175180
});
176181

@@ -190,6 +195,7 @@ function SidebarItem({
190195
{...stylex.props(
191196
linkVariants.base,
192197
pathname === item.url ? linkVariants.active : linkVariants.inactive,
198+
pathname === item.url && activeLinkMarker,
193199
)}
194200
>
195201
{item.icon}
@@ -207,29 +213,39 @@ function SidebarItem({
207213
);
208214
}
209215

216+
// type "folder"
210217
return (
211-
<div>
212-
{item.index ? (
213-
<Link
214-
{...stylex.props(
215-
linkVariants.base,
216-
pathname === item.index.url
217-
? linkVariants.active
218-
: linkVariants.inactive,
219-
)}
220-
href={item.index.url}
221-
>
222-
{item.index.icon}
223-
{item.index.name}
224-
</Link>
225-
) : (
226-
<p {...stylex.props(linkVariants.base, sidebarItemStyles.textStart)}>
227-
{item.icon}
228-
{item.name}
229-
</p>
230-
)}
218+
<details {...stylex.props(sidebarItemStyles.details)}>
219+
<summary>
220+
{item.index ? (
221+
<Link
222+
{...stylex.props(
223+
linkVariants.base,
224+
sidebarItemStyles.summaryLink,
225+
pathname === item.index.url
226+
? linkVariants.active
227+
: linkVariants.inactive,
228+
)}
229+
href={item.index.url}
230+
>
231+
{item.index.icon}
232+
{item.index.name}
233+
</Link>
234+
) : (
235+
<p
236+
{...stylex.props(
237+
linkVariants.base,
238+
sidebarItemStyles.summaryLink,
239+
sidebarItemStyles.textStart,
240+
)}
241+
>
242+
{item.icon}
243+
{item.name}
244+
</p>
245+
)}
246+
</summary>
231247
<div {...stylex.props(sidebarItemStyles.childContainer)}>{children}</div>
232-
</div>
248+
</details>
233249
);
234250
}
235251
const sidebarItemStyles = stylex.create({
@@ -239,31 +255,41 @@ const sidebarItemStyles = stylex.create({
239255
marginTop: { default: 6 * 4, ':first-child': 0 },
240256
marginBottom: 2 * 4,
241257
},
258+
details: {
259+
['--summary-color' as any]: {
260+
default: null,
261+
[stylex.when.descendant(':is(*)', activeLinkMarker)]: 'hotpink',
262+
},
263+
},
264+
summaryLink: {
265+
color:
266+
'var(--summary-color, color-mix(in oklab, var(--text-fd-foreground) 80%, transparent))',
267+
},
242268
textStart: { textAlign: 'start' },
243269
childContainer: {
244270
paddingInlineStart: 4 * 4,
245271
borderInlineStartWidth: 1,
246272
borderInlineStartStyle: 'solid',
247-
borderInlineStartColor: 'var(--border-fd-border)',
273+
borderInlineStartColor: 'var(--color-fd-border)',
248274
display: 'flex',
249275
flexDirection: 'column',
276+
['--summary-color' as any]: 'initial',
250277
},
251278
});
252279

253280
const linkVariants = stylex.create({
254281
base: {
255-
display: 'flex',
282+
display: 'inline-flex',
256283
alignItems: 'center',
257284
gap: 2 * 4,
258-
width: '100%',
285+
// width: '100%',
259286
padding: 1.5 * 4,
260287
borderRadius: '8px',
261288
color: 'color-mix(in oklab, var(--text-fd-foreground) 80%, transparent)',
262-
['--svg-size' as any]: '4px',
263289
},
264290
active: {
265291
fontWeight: 500,
266-
color: 'var(--text-fd-primary)',
292+
color: 'hotpink',
267293
},
268294
inactive: {
269295
color: {

packages/docs/src/components/layout/home/client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const navbarStyles = stylex.create({
6363
backdropFilter: 'blur(16px)',
6464
borderBottomWidth: 1,
6565
borderBottomStyle: 'solid',
66-
borderBottomColor: 'var(--border-fd-border)',
66+
borderBottomColor: 'var(--color-fd-border)',
6767
transitionProperty: 'color, background-color',
6868
},
6969
headerWithVals: {
@@ -218,7 +218,7 @@ const navItemStyles = stylex.create({
218218
borderRadius: '8px',
219219
borderWidth: 1,
220220
borderStyle: 'solid',
221-
borderColor: 'var(--border-fd-border)',
221+
borderColor: 'var(--color-fd-border)',
222222
backgroundColor: 'var(--bg-fd-muted)',
223223
padding: 4,
224224
['--svg-size' as any]: '4px',
@@ -230,7 +230,7 @@ const navItemStyles = stylex.create({
230230
borderRadius: '8px',
231231
borderWidth: 1,
232232
borderStyle: 'solid',
233-
borderColor: 'var(--border-fd-border)',
233+
borderColor: 'var(--color-fd-border)',
234234
backgroundColor: {
235235
default: 'var(--bg-fd-card)',
236236
':hover': 'color-mix(in oklab, var(--bg-fd-accent) 80%, transparent)',

packages/docs/src/components/search-toggle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const styles = stylex.create({
9292
borderRadius: 8,
9393
borderWidth: 1,
9494
borderStyle: 'solid',
95-
borderColor: 'var(--border-fd-border)',
95+
borderColor: 'var(--color-fd-border)',
9696

9797
backgroundColor:
9898
'color-mix(in oklab, var(--bg-fd-secondary) 50%, transparent)',
@@ -120,7 +120,7 @@ const styles = stylex.create({
120120
borderRadius: 8,
121121
borderWidth: 1,
122122
borderStyle: 'solid',
123-
borderColor: 'var(--border-fd-border)',
123+
borderColor: 'var(--color-fd-border)',
124124
backgroundColor: 'var(--bg-fd-background)',
125125
paddingInline: 1.5 * 4,
126126
},

packages/docs/src/components/theme-toggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const styles = stylex.create({
101101
borderRadius: 9999,
102102
borderWidth: 1,
103103
borderStyle: 'solid',
104-
borderColor: 'var(--border-fd-border)',
104+
borderColor: 'var(--color-fd-border)',
105105
padding: 1 * 4,
106106
},
107107
sizeFull: {

packages/docs/src/pages/blog/[...slugs]/_layout.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import type { ReactNode } from 'react';
2-
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
2+
import { DocsLayout } from '@/components/layout/docs';
33
import { blogSource } from '@/lib/source';
44
import { baseOptions } from '@/lib/layout.shared';
55
import * as stylex from '@stylexjs/stylex';
66
import { vars } from '../../../theming/vars.stylex';
77

88
export default function Layout({ children }: { children: ReactNode }) {
99
return (
10-
<DocsLayout
11-
{...baseOptions()}
12-
sidebar={{ enabled: false }}
13-
tree={blogSource.pageTree}
14-
>
10+
<DocsLayout {...baseOptions()} tree={blogSource.pageTree}>
1511
<div {...stylex.props(styles.container)}>{children}</div>
1612
</DocsLayout>
1713
);

packages/docs/src/pages/blog/[...slugs]/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
DocsDescription,
88
DocsPage,
99
DocsTitle,
10-
} from 'fumadocs-ui/page';
10+
} from '@/components/layout/page';
1111
import { baseOptions } from '@/lib/layout.shared';
1212
import { mdxComponents } from '@/components/mdx';
1313
import nmnImage from '@/static/img/nmn.jpg';
@@ -42,8 +42,8 @@ export default function BlogPage({ slugs }: PageProps<'/blog/[...slugs]'>) {
4242
<DocsPage
4343
{...baseOptions()}
4444
toc={page.data.toc}
45-
tableOfContent={{ style: 'clerk' }}
46-
breadcrumb={{ enabled: true }}
45+
// tableOfContent={{ style: 'clerk' }}
46+
// breadcrumb={{ enabled: true }}
4747
>
4848
<title>{`${page.data.title} | StyleX`}</title>
4949
<DocsTitle>

packages/docs/src/pages/blog/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ReactNode } from 'react';
22
import { baseOptions } from '@/lib/layout.shared';
3-
import { HomeLayout } from 'fumadocs-ui/layouts/home';
3+
import { HomeLayout } from '@/components/layout/home';
44

55
export default function Layout({ children }: { children: ReactNode }) {
66
return <HomeLayout {...baseOptions()}>{children}</HomeLayout>;

packages/docs/src/pages/docs/[...slugs].tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
DocsDescription,
77
DocsPage,
88
DocsTitle,
9-
} from 'fumadocs-ui/page';
9+
} from '@/components/layout/page';
1010
import { mdxComponents } from '@/components/mdx';
1111
import * as stylex from '@stylexjs/stylex';
1212

@@ -26,7 +26,7 @@ export default function DocPage({ slugs }: PageProps<'/docs/[...slugs]'>) {
2626

2727
const MDX = page.data.body;
2828
return (
29-
<DocsPage toc={page.data.toc} tableOfContent={{ style: 'clerk' }}>
29+
<DocsPage toc={page.data.toc}>
3030
<title>{`${page.data.title} | StyleX`}</title>
3131
<DocsTitle>
3232
{slugs.length > 1 && slugs[0] === 'api' ? (

packages/docs/src/pages/docs/_layout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ReactNode } from 'react';
2-
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
2+
import { DocsLayout } from '@/components/layout/docs';
33
import { source } from '@/lib/source';
44
import { baseOptions } from '@/lib/layout.shared';
55

@@ -9,11 +9,7 @@ export default function Layout({ children }: { children: ReactNode }) {
99
return (
1010
<DocsLayout
1111
{...base}
12-
sidebar={{
13-
tabs: false,
14-
}}
1512
links={[base.links![2]!]}
16-
tabMode="top"
1713
nav={{
1814
...base.nav,
1915
enabled: true,

0 commit comments

Comments
 (0)