@nikala-ui/folio 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/cli/commands/init.js +105 -51
- package/dist/client/app.jsx +6 -3
- package/dist/client/components/docs-layout-shell.d.ts +1 -0
- package/dist/client/components/docs-layout-shell.jsx +1 -1
- package/dist/client/components/docs-page-content.jsx +9 -5
- package/dist/client/navigation/page-navigation.js +10 -27
- package/dist/client/public/algolia-logo.svg +15 -0
- package/dist/client/public/favicon.ico +0 -0
- package/dist/client/public/logo.svg +11 -0
- package/dist/client/routing/use-docs-router.d.ts +1 -0
- package/dist/client/routing/use-docs-router.js +12 -3
- package/dist/client/style.css +139 -55
- package/dist/components/ui/api-table.jsx +6 -4
- package/dist/components/ui/code-block.jsx +6 -4
- package/dist/components/ui/command.jsx +9 -5
- package/dist/components/ui/list.jsx +3 -1
- package/dist/components/ui/logo.d.ts +4 -1
- package/dist/components/ui/logo.jsx +8 -22
- package/dist/components/ui/package-manager-tabs.jsx +4 -2
- package/dist/components/ui/pager.jsx +4 -2
- package/dist/components/ui/section-heading.jsx +1 -1
- package/dist/components/ui/sidebar.jsx +6 -3
- package/dist/components/ui/spinner.jsx +3 -1
- package/dist/components/ui/theme-toggle.jsx +14 -12
- package/dist/config.d.ts +1 -0
- package/dist/config.js +84 -29
- package/dist/core/content-scanner.d.ts +2 -1
- package/dist/core/content-scanner.js +2 -9
- package/dist/core/plugin/index.d.ts +2 -0
- package/dist/core/plugin/index.js +1 -0
- package/dist/core/plugin/lifecycle-error.d.ts +19 -0
- package/dist/core/plugin/lifecycle-error.js +28 -0
- package/dist/core/plugin/lifecycle-snapshot.d.ts +1 -0
- package/dist/core/plugin/lifecycle-snapshot.js +156 -0
- package/dist/core/plugin/lifecycle.d.ts +34 -0
- package/dist/core/plugin/lifecycle.js +170 -0
- package/dist/core/route-tree.d.ts +3 -2
- package/dist/core/route-tree.js +40 -10
- package/dist/index.d.ts +7 -4
- package/dist/index.js +4 -3
- package/dist/plugin.d.ts +60 -0
- package/dist/plugin.js +51 -0
- package/dist/plugins/i18n/components/site-language-switcher.d.ts +10 -0
- package/dist/plugins/i18n/components/site-language-switcher.jsx +39 -0
- package/dist/plugins/i18n/constants.d.ts +1 -0
- package/dist/plugins/i18n/constants.js +1 -0
- package/dist/plugins/i18n/index.d.ts +11 -0
- package/dist/plugins/i18n/index.js +89 -0
- package/dist/plugins/i18n/navigation.d.ts +5 -0
- package/dist/plugins/i18n/navigation.js +33 -0
- package/dist/plugins/i18n/runtime.d.ts +19 -0
- package/dist/plugins/i18n/runtime.jsx +65 -0
- package/dist/plugins/i18n/site-locale.d.ts +12 -0
- package/dist/plugins/i18n/site-locale.js +119 -0
- package/dist/search/provider.d.ts +9 -0
- package/dist/search/provider.js +4 -2
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +69 -33
- package/dist/server/module-serialization.d.ts +6 -0
- package/dist/server/module-serialization.js +26 -0
- package/dist/server/plugin/components.d.ts +7 -0
- package/dist/server/plugin/components.js +82 -0
- package/dist/server/plugin/constants.d.ts +17 -0
- package/dist/server/plugin/constants.js +21 -0
- package/dist/server/{plugin.d.ts → plugin/index.d.ts} +3 -1
- package/dist/server/plugin/index.js +166 -0
- package/dist/server/plugin/lifecycle.d.ts +32 -0
- package/dist/server/plugin/lifecycle.js +110 -0
- package/dist/server/plugin/styles.d.ts +3 -0
- package/dist/server/plugin/styles.js +22 -0
- package/dist/server/plugin/virtual-modules.d.ts +11 -0
- package/dist/server/plugin/virtual-modules.js +121 -0
- package/dist/server/seo.d.ts +4 -0
- package/dist/server/seo.js +87 -0
- package/dist/templates/env.d.ts +26 -0
- package/dist/templates/locales/en.json +77 -0
- package/dist/themes/default/components/docs-landing-body.d.ts +17 -0
- package/dist/themes/default/components/docs-landing-body.jsx +17 -0
- package/dist/themes/default/components/docs-page-body.d.ts +21 -0
- package/dist/themes/default/components/docs-page-body.jsx +36 -0
- package/dist/themes/default/components/page-actions.d.ts +15 -0
- package/dist/themes/default/components/page-actions.jsx +60 -0
- package/dist/themes/default/components/page-header.d.ts +7 -0
- package/dist/themes/default/components/page-header.jsx +3 -0
- package/dist/themes/default/components/sidebar-footer.d.ts +6 -0
- package/dist/themes/default/components/sidebar-footer.jsx +12 -0
- package/dist/themes/default/components/sidebar-header.d.ts +8 -0
- package/dist/themes/default/components/sidebar-header.jsx +17 -0
- package/dist/themes/default/components/sidebar-mobile-nav.d.ts +7 -0
- package/dist/themes/default/components/sidebar-mobile-nav.jsx +17 -0
- package/dist/themes/default/components/sidebar-promo.d.ts +8 -0
- package/dist/themes/default/components/sidebar-promo.jsx +20 -0
- package/dist/themes/default/content/breadcrumbs.jsx +5 -2
- package/dist/themes/default/content/table-of-contents.jsx +3 -1
- package/dist/themes/default/hooks/use-page-copy.d.ts +6 -0
- package/dist/themes/default/hooks/use-page-copy.js +26 -0
- package/dist/themes/default/layout.jsx +30 -127
- package/dist/themes/default/lib/layout-visibility.d.ts +8 -0
- package/dist/themes/default/lib/layout-visibility.js +24 -0
- package/dist/themes/default/navbar.jsx +14 -7
- package/dist/themes/default/navigation/mobile-table-of-contents.jsx +5 -3
- package/dist/themes/default/navigation/sidebar-tree.d.ts +2 -0
- package/dist/themes/default/navigation/sidebar-tree.jsx +11 -2
- package/dist/themes/default/overlays/search-dialog.jsx +14 -3
- package/dist/themes/default/sidebar.jsx +21 -49
- package/dist/themes/types.d.ts +5 -0
- package/dist/types.d.ts +36 -0
- package/dist/utils/format-title.d.ts +1 -0
- package/dist/utils/format-title.js +11 -0
- package/dist/vendor/docs-src/client/page-actions.ts +69 -0
- package/dist/vendor/docs-src/components/ui/api-table.tsx +6 -4
- package/dist/vendor/docs-src/components/ui/code-block.tsx +6 -4
- package/dist/vendor/docs-src/components/ui/command.tsx +9 -5
- package/dist/vendor/docs-src/components/ui/list.tsx +4 -2
- package/dist/vendor/docs-src/components/ui/logo.tsx +19 -48
- package/dist/vendor/docs-src/components/ui/package-manager-tabs.tsx +4 -2
- package/dist/vendor/docs-src/components/ui/pager.tsx +4 -2
- package/dist/vendor/docs-src/components/ui/section-heading.tsx +5 -1
- package/dist/vendor/docs-src/components/ui/sidebar.tsx +7 -4
- package/dist/vendor/docs-src/components/ui/spinner.tsx +3 -1
- package/dist/vendor/docs-src/components/ui/theme-toggle.tsx +15 -13
- package/dist/vendor/docs-src/navigation/index.ts +2 -0
- package/dist/vendor/docs-src/navigation/repository-links.ts +43 -0
- package/dist/vendor/docs-src/navigation/sidebar-state.ts +22 -0
- package/dist/vendor/docs-src/navigation/sidebar-tree.ts +15 -0
- package/dist/vendor/docs-src/plugins/i18n/components/site-language-switcher.tsx +56 -0
- package/dist/vendor/docs-src/plugins/i18n/constants.ts +1 -0
- package/dist/vendor/docs-src/plugins/i18n/index.ts +110 -0
- package/dist/vendor/docs-src/plugins/i18n/navigation.ts +49 -0
- package/dist/vendor/docs-src/plugins/i18n/runtime.tsx +91 -0
- package/dist/vendor/docs-src/plugins/i18n/site-locale.ts +140 -0
- package/dist/vendor/docs-src/search/provider.ts +83 -0
- package/dist/vendor/docs-src/themes/default/components/docs-landing-body.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/docs-page-body.tsx +53 -0
- package/dist/vendor/docs-src/themes/default/components/page-actions.tsx +105 -0
- package/dist/vendor/docs-src/themes/default/components/page-header.tsx +31 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-footer.tsx +21 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-header.tsx +30 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-mobile-nav.tsx +33 -0
- package/dist/vendor/docs-src/themes/default/components/sidebar-promo.tsx +37 -0
- package/dist/vendor/docs-src/themes/default/content/breadcrumbs.tsx +43 -0
- package/dist/vendor/docs-src/themes/default/content/pager.tsx +19 -0
- package/dist/vendor/docs-src/themes/default/content/table-of-contents.tsx +32 -0
- package/dist/vendor/docs-src/themes/default/hooks/use-page-copy.ts +29 -0
- package/dist/vendor/docs-src/themes/default/icons.ts +16 -0
- package/dist/vendor/docs-src/themes/default/index.ts +46 -0
- package/dist/vendor/docs-src/themes/default/layout.tsx +176 -0
- package/dist/vendor/docs-src/themes/default/lib/layout-visibility.ts +39 -0
- package/dist/vendor/docs-src/themes/default/navbar.tsx +130 -0
- package/dist/vendor/docs-src/themes/default/navigation/mobile-table-of-contents.tsx +61 -0
- package/dist/vendor/docs-src/themes/default/navigation/sidebar-tree.tsx +202 -0
- package/dist/vendor/docs-src/themes/default/overlays/search-dialog.tsx +106 -0
- package/dist/vendor/docs-src/themes/default/sidebar.tsx +86 -0
- package/dist/vendor/docs-src/themes/index.ts +4 -0
- package/dist/vendor/docs-src/themes/types.ts +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +11 -4
- package/dist/server/plugin.js +0 -521
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/layout.tsx
|
|
2
|
+
import { createSignal, Show, splitProps, type ParentComponent } from "solid-js";
|
|
3
|
+
import { SidebarProvider } from "@/components/ui/sidebar";
|
|
4
|
+
import { SidebarInset } from "@/components/ui/sidebar";
|
|
5
|
+
import { DocsNavbar } from "./navbar.jsx";
|
|
6
|
+
import { DocsSidebar } from "./sidebar.jsx";
|
|
7
|
+
import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
|
|
8
|
+
import { cn } from "@/lib/cn";
|
|
9
|
+
import { getRepositorySourceUrl } from "../../navigation/repository-links.js";
|
|
10
|
+
import { resolveSearchProvider } from "../../search/provider.js";
|
|
11
|
+
import type { DocsLayoutProps } from "../types.js";
|
|
12
|
+
import { DocsPageBody } from "./components/docs-page-body.jsx";
|
|
13
|
+
import { DocsLandingBody } from "./components/docs-landing-body.jsx";
|
|
14
|
+
import { PageHeader } from "./components/page-header.jsx";
|
|
15
|
+
import { createPageCopy } from "./hooks/use-page-copy.js";
|
|
16
|
+
import {
|
|
17
|
+
isLandingPage,
|
|
18
|
+
shouldShowLandingSidebar,
|
|
19
|
+
shouldShowNavbar,
|
|
20
|
+
shouldShowSidebarFooter,
|
|
21
|
+
shouldShowSidebarHeader,
|
|
22
|
+
shouldShowToc,
|
|
23
|
+
shouldUseSidebarLayout,
|
|
24
|
+
} from "./lib/layout-visibility.js";
|
|
25
|
+
|
|
26
|
+
export const DocsLayout: ParentComponent<DocsLayoutProps> = (props) => {
|
|
27
|
+
const [local, rest] = splitProps(props, [
|
|
28
|
+
"config",
|
|
29
|
+
"tree",
|
|
30
|
+
"pages",
|
|
31
|
+
"currentPage",
|
|
32
|
+
"onNavigate",
|
|
33
|
+
"breadcrumbs",
|
|
34
|
+
"toc",
|
|
35
|
+
"prev",
|
|
36
|
+
"next",
|
|
37
|
+
"sourceContent",
|
|
38
|
+
"children",
|
|
39
|
+
"class",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const [searchOpen, setSearchOpen] = createSignal(false);
|
|
43
|
+
const pageCopy = createPageCopy(() => local.sourceContent);
|
|
44
|
+
const searchEnabled = () => local.config.search?.enabled !== false;
|
|
45
|
+
const searchProvider = () => resolveSearchProvider(local.config.search);
|
|
46
|
+
|
|
47
|
+
const currentUrl = () => local.currentPage?.url;
|
|
48
|
+
const landingPage = () => isLandingPage(local.currentPage, local.config);
|
|
49
|
+
const showLandingSidebar = () => shouldShowLandingSidebar(local.config);
|
|
50
|
+
const showNavbar = () => shouldShowNavbar(local.config);
|
|
51
|
+
const showToc = () => shouldShowToc(local.toc, local.currentPage, local.config, landingPage());
|
|
52
|
+
const sidebarLayout = () => shouldUseSidebarLayout(local.config);
|
|
53
|
+
const sidebarHeader = () => shouldShowSidebarHeader(local.config);
|
|
54
|
+
const sidebarFooter = () => shouldShowSidebarFooter(local.config);
|
|
55
|
+
const sidebarPromo = () => local.config.navigation?.sidebar?.promo;
|
|
56
|
+
const sourceUrl = () => {
|
|
57
|
+
const page = local.currentPage;
|
|
58
|
+
const repository = local.config.repository;
|
|
59
|
+
if (!page?.sourcePath || !repository) return undefined;
|
|
60
|
+
return getRepositorySourceUrl(repository, page.sourcePath, local.config.contentDir || "docs");
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const markdown = pageCopy.markdown;
|
|
64
|
+
const aiProviders = () => local.config.pageActions?.ai || [];
|
|
65
|
+
const copyPageEnabled = () => local.config.pageActions?.copyPage !== false;
|
|
66
|
+
const copyMarkdownEnabled = () => local.config.pageActions?.copyMarkdown !== false;
|
|
67
|
+
const pageActions = () => local.currentPage?.pageActions || [];
|
|
68
|
+
|
|
69
|
+
const sidebar = (className?: string) => (
|
|
70
|
+
<DocsSidebar
|
|
71
|
+
tree={local.tree}
|
|
72
|
+
pages={local.pages}
|
|
73
|
+
nav={local.config.navigation?.navbar || local.config.nav}
|
|
74
|
+
currentUrl={currentUrl()}
|
|
75
|
+
title={local.config.title}
|
|
76
|
+
logo={local.config.logo}
|
|
77
|
+
headerSubtitle={local.config.navigation?.sidebar?.headerSubtitle}
|
|
78
|
+
footerText={local.config.navigation?.sidebar?.footerText}
|
|
79
|
+
showHeader={sidebarHeader()}
|
|
80
|
+
showFooter={sidebarFooter()}
|
|
81
|
+
class={className}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const content = () => (
|
|
86
|
+
<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
87
|
+
<DocsPageBody
|
|
88
|
+
breadcrumbs={local.breadcrumbs}
|
|
89
|
+
currentPage={local.currentPage}
|
|
90
|
+
toc={local.toc}
|
|
91
|
+
prev={local.prev}
|
|
92
|
+
next={local.next}
|
|
93
|
+
showToc={showToc()}
|
|
94
|
+
sidebarPromo={sidebarPromo()}
|
|
95
|
+
pageActions={
|
|
96
|
+
<Show when={local.currentPage?.title}>
|
|
97
|
+
<PageHeader
|
|
98
|
+
title={local.currentPage!.title}
|
|
99
|
+
description={local.currentPage?.description}
|
|
100
|
+
sourceUrl={sourceUrl()}
|
|
101
|
+
pageActions={pageActions()}
|
|
102
|
+
aiProviders={aiProviders()}
|
|
103
|
+
copyPageEnabled={copyPageEnabled()}
|
|
104
|
+
copyMarkdownEnabled={copyMarkdownEnabled()}
|
|
105
|
+
pageUrl={local.currentPage?.url}
|
|
106
|
+
pageTitle={local.currentPage?.title}
|
|
107
|
+
markdown={markdown}
|
|
108
|
+
onCopyPage={pageCopy.copyPage}
|
|
109
|
+
onCopyMarkdown={pageCopy.copyMarkdown}
|
|
110
|
+
/>
|
|
111
|
+
</Show>
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
{local.children}
|
|
115
|
+
</DocsPageBody>
|
|
116
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined} />
|
|
117
|
+
</SidebarInset>
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const landingContent = () => (
|
|
121
|
+
<SidebarInset class={cn("min-w-0", local.class)} {...rest}>
|
|
122
|
+
<DocsLandingBody
|
|
123
|
+
breadcrumbs={local.breadcrumbs}
|
|
124
|
+
showBreadcrumbs={local.config.home?.showBreadcrumbs === true}
|
|
125
|
+
showPager={local.config.home?.showPager === true}
|
|
126
|
+
prev={local.prev}
|
|
127
|
+
next={local.next}
|
|
128
|
+
>
|
|
129
|
+
{local.children}
|
|
130
|
+
</DocsLandingBody>
|
|
131
|
+
<DocsSearchDialog open={searchOpen()} onOpenChange={setSearchOpen} pages={local.pages} provider={searchEnabled() ? searchProvider().implementation : undefined} />
|
|
132
|
+
</SidebarInset>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<SidebarProvider defaultOpen={true} class="min-h-screen w-full items-stretch">
|
|
137
|
+
<Show when={landingPage()} fallback={<Show when={sidebarLayout()} fallback={
|
|
138
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
139
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={true} showSidebarTrigger={false} onOpenSearch={() => setSearchOpen(true)} />
|
|
140
|
+
<div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{content()}</div>
|
|
141
|
+
</div>
|
|
142
|
+
}>
|
|
143
|
+
{sidebar()}
|
|
144
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
145
|
+
<DocsNavbar config={local.config} currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} showBrand={false} onOpenSearch={() => setSearchOpen(true)} />
|
|
146
|
+
{content()}
|
|
147
|
+
</div>
|
|
148
|
+
</Show>}>
|
|
149
|
+
<div class="flex min-h-screen min-w-0 flex-1 flex-col">
|
|
150
|
+
<Show when={showNavbar()}>
|
|
151
|
+
<DocsNavbar
|
|
152
|
+
config={local.config}
|
|
153
|
+
currentPage={local.currentPage}
|
|
154
|
+
pages={local.pages}
|
|
155
|
+
onNavigate={local.onNavigate}
|
|
156
|
+
showBrand={true}
|
|
157
|
+
showSidebarTrigger={showLandingSidebar()}
|
|
158
|
+
mobileSidebarTrigger={landingPage()}
|
|
159
|
+
onOpenSearch={() => setSearchOpen(true)}
|
|
160
|
+
/>
|
|
161
|
+
</Show>
|
|
162
|
+
<Show when={showLandingSidebar()} fallback={
|
|
163
|
+
<>
|
|
164
|
+
<Show when={landingPage()}>
|
|
165
|
+
{sidebar("md:hidden")}
|
|
166
|
+
</Show>
|
|
167
|
+
{landingContent()}
|
|
168
|
+
</>
|
|
169
|
+
}>
|
|
170
|
+
<div class="flex min-h-0 min-w-0 max-w-full flex-1 items-start">{sidebar()}{landingContent()}</div>
|
|
171
|
+
</Show>
|
|
172
|
+
</div>
|
|
173
|
+
</Show>
|
|
174
|
+
</SidebarProvider>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocsConfig, PageData, TocItem } from "../../../types.js";
|
|
2
|
+
|
|
3
|
+
export function isLandingPage(page: PageData | undefined, config: DocsConfig): boolean {
|
|
4
|
+
return page?.url === "/" && config.home?.layout === "landing";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function shouldShowLandingSidebar(config: DocsConfig): boolean {
|
|
8
|
+
return config.home?.showSidebar === true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function shouldShowNavbar(config: DocsConfig): boolean {
|
|
12
|
+
return config.home?.showNavbar !== false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function shouldShowToc(
|
|
16
|
+
toc: TocItem[] | undefined,
|
|
17
|
+
page: PageData | undefined,
|
|
18
|
+
config: DocsConfig,
|
|
19
|
+
landingPage: boolean,
|
|
20
|
+
): boolean {
|
|
21
|
+
return Boolean(
|
|
22
|
+
toc &&
|
|
23
|
+
toc.length > 0 &&
|
|
24
|
+
page?.frontmatter?.toc !== false &&
|
|
25
|
+
(!landingPage || config.home?.showToc === true),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function shouldUseSidebarLayout(config: DocsConfig): boolean {
|
|
30
|
+
return config.navigation?.layout !== "top";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function shouldShowSidebarHeader(config: DocsConfig): boolean {
|
|
34
|
+
return config.navigation?.sidebar?.header !== false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function shouldShowSidebarFooter(config: DocsConfig): boolean {
|
|
38
|
+
return config.navigation?.sidebar?.footer !== false;
|
|
39
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/navbar.tsx
|
|
2
|
+
import { For, Show, splitProps, type Component } from "solid-js";
|
|
3
|
+
import { Navbar } from "@/components/ui/navbar";
|
|
4
|
+
import { NavbarContainer } from "@/components/ui/navbar";
|
|
5
|
+
import { NavbarBrand } from "@/components/ui/navbar";
|
|
6
|
+
import { NavbarContent } from "@/components/ui/navbar";
|
|
7
|
+
import { NavbarItem } from "@/components/ui/navbar";
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
10
|
+
import { Badge } from "@/components/ui/badge";
|
|
11
|
+
import { Kbd } from "@/components/ui/kbd";
|
|
12
|
+
import { SidebarTrigger } from "@/components/ui/sidebar";
|
|
13
|
+
import { ThemeToggle } from "@/components/ui/theme-toggle";
|
|
14
|
+
import { DocsSiteLanguageSwitcher } from "../../plugins/i18n/components/site-language-switcher.jsx";
|
|
15
|
+
import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
|
|
16
|
+
import { Logo } from "@/components/ui/logo";
|
|
17
|
+
import { Search } from "lucide-solid";
|
|
18
|
+
import type { DocsNavbarProps } from "../types.js";
|
|
19
|
+
|
|
20
|
+
export const DocsNavbar: Component<DocsNavbarProps> = (props) => {
|
|
21
|
+
const [local, rest] = splitProps(props, ["config", "currentPage", "pages", "onNavigate", "onOpenSearch", "showBrand", "showSidebarTrigger", "mobileSidebarTrigger", "class"]);
|
|
22
|
+
|
|
23
|
+
const title = () => local.config.title || "Folio";
|
|
24
|
+
const logoText = () => local.config.logo?.text || title();
|
|
25
|
+
const logoHref = () => local.config.logo?.href || "/";
|
|
26
|
+
const repoUrl = () => local.config.repository?.url;
|
|
27
|
+
const siteLocale = useSiteLocale();
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Navbar
|
|
31
|
+
variant="default"
|
|
32
|
+
maxWidth="full"
|
|
33
|
+
isSticky={true}
|
|
34
|
+
class={local.class}
|
|
35
|
+
{...rest}
|
|
36
|
+
>
|
|
37
|
+
<NavbarContainer class="h-14 md:h-14 px-4 sm:px-6">
|
|
38
|
+
<NavbarContent justify="start" class="gap-3">
|
|
39
|
+
<Show when={local.showSidebarTrigger !== false || local.mobileSidebarTrigger === true}>
|
|
40
|
+
<SidebarTrigger
|
|
41
|
+
aria-label="Toggle documentation sidebar"
|
|
42
|
+
class={local.mobileSidebarTrigger ? "md:hidden" : undefined}
|
|
43
|
+
/>
|
|
44
|
+
</Show>
|
|
45
|
+
<Show when={local.showBrand !== false}>
|
|
46
|
+
<NavbarBrand href={logoHref()} class="text-base font-bold tracking-tight">
|
|
47
|
+
<Show when={local.config.logo?.image} fallback={<Logo class="h-6 w-auto" />}>
|
|
48
|
+
{(img) => <img src={img()} alt={logoText()} class="size-6 object-contain" />}
|
|
49
|
+
</Show>
|
|
50
|
+
<span>{logoText()}</span>
|
|
51
|
+
</NavbarBrand>
|
|
52
|
+
</Show>
|
|
53
|
+
<Show when={(local.config.navigation?.navbar || local.config.nav)?.length}>
|
|
54
|
+
<NavbarContent justify="start" class="hidden min-w-0 flex-1 gap-1 overflow-hidden px-1 md:flex">
|
|
55
|
+
<For each={local.config.navigation?.navbar || local.config.nav}>
|
|
56
|
+
{(item) => (
|
|
57
|
+
<NavbarItem>
|
|
58
|
+
<a
|
|
59
|
+
href={item.href}
|
|
60
|
+
target={item.external ? "_blank" : undefined}
|
|
61
|
+
rel={item.external ? "noreferrer" : undefined}
|
|
62
|
+
class={buttonVariants({ variant: "ghost", size: "sm" }) + " shrink-0 whitespace-nowrap text-xs"}
|
|
63
|
+
>
|
|
64
|
+
{item.title}
|
|
65
|
+
</a>
|
|
66
|
+
</NavbarItem>
|
|
67
|
+
)}
|
|
68
|
+
</For>
|
|
69
|
+
</NavbarContent>
|
|
70
|
+
</Show>
|
|
71
|
+
</NavbarContent>
|
|
72
|
+
|
|
73
|
+
<NavbarContent justify="end" class="gap-2">
|
|
74
|
+
{/* Search Trigger Button */}
|
|
75
|
+
<Show when={local.config.search?.enabled !== false && local.onOpenSearch}>
|
|
76
|
+
<NavbarItem>
|
|
77
|
+
<Button
|
|
78
|
+
variant="outline"
|
|
79
|
+
size="sm"
|
|
80
|
+
onClick={() => local.onOpenSearch?.()}
|
|
81
|
+
class="hidden sm:inline-flex text-muted-foreground w-48 sm:w-64 justify-between h-8 text-xs font-normal"
|
|
82
|
+
>
|
|
83
|
+
<span class="inline-flex items-center gap-2">
|
|
84
|
+
<Search class="size-3.5" />
|
|
85
|
+
<span>{siteLocale.t("navigation.search")}</span>
|
|
86
|
+
</span>
|
|
87
|
+
<Kbd size="sm">⌘K</Kbd>
|
|
88
|
+
</Button>
|
|
89
|
+
<Button
|
|
90
|
+
variant="ghost"
|
|
91
|
+
size="sm"
|
|
92
|
+
onClick={() => local.onOpenSearch?.()}
|
|
93
|
+
class="sm:hidden p-2"
|
|
94
|
+
aria-label={siteLocale.t("navigation.searchLabel")}
|
|
95
|
+
>
|
|
96
|
+
<Search class="size-4" />
|
|
97
|
+
</Button>
|
|
98
|
+
</NavbarItem>
|
|
99
|
+
</Show>
|
|
100
|
+
|
|
101
|
+
{/* GitHub Repository Link */}
|
|
102
|
+
<Show when={repoUrl()}>
|
|
103
|
+
{(url) => (
|
|
104
|
+
<NavbarItem>
|
|
105
|
+
<a
|
|
106
|
+
href={url()}
|
|
107
|
+
target="_blank"
|
|
108
|
+
rel="noreferrer"
|
|
109
|
+
class={buttonVariants({ variant: "ghost", size: "sm" }) + " hidden sm:inline-flex h-8 px-2 text-xs"}
|
|
110
|
+
>
|
|
111
|
+
{siteLocale.t("navigation.github")}
|
|
112
|
+
</a>
|
|
113
|
+
</NavbarItem>
|
|
114
|
+
)}
|
|
115
|
+
</Show>
|
|
116
|
+
|
|
117
|
+
<NavbarItem>
|
|
118
|
+
<DocsSiteLanguageSwitcher currentPage={local.currentPage} pages={local.pages} onNavigate={local.onNavigate} />
|
|
119
|
+
</NavbarItem>
|
|
120
|
+
|
|
121
|
+
{/* Theme Toggle */}
|
|
122
|
+
<NavbarItem>
|
|
123
|
+
<ThemeToggle />
|
|
124
|
+
</NavbarItem>
|
|
125
|
+
</NavbarContent>
|
|
126
|
+
</NavbarContainer>
|
|
127
|
+
|
|
128
|
+
</Navbar>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createSignal, onCleanup, onMount, splitProps, type Component } from "solid-js";
|
|
2
|
+
import { Collapsible } from "@/components/ui/collapsible";
|
|
3
|
+
import { CollapsibleContent } from "@/components/ui/collapsible";
|
|
4
|
+
import { CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
5
|
+
import { cn } from "@/lib/cn";
|
|
6
|
+
import { ChevronDown } from "lucide-solid";
|
|
7
|
+
import { DocsTableOfContents } from "../content/table-of-contents.jsx";
|
|
8
|
+
import type { DocsTableOfContentsProps } from "../../types.js";
|
|
9
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
10
|
+
|
|
11
|
+
export const DocsMobileTableOfContents: Component<DocsTableOfContentsProps> = (props) => {
|
|
12
|
+
const [local, rest] = splitProps(props, ["items", "title", "class", "onActiveChange"]);
|
|
13
|
+
const [open, setOpen] = createSignal(false);
|
|
14
|
+
const [activeId, setActiveId] = createSignal(local.items[0]?.id || "");
|
|
15
|
+
const [rootElement, setRootElement] = createSignal<HTMLDivElement>();
|
|
16
|
+
const siteLocale = useSiteLocale();
|
|
17
|
+
const title = () => local.title ?? siteLocale.t("tableOfContents.title");
|
|
18
|
+
const activeTitle = () => local.items.find((item) => item.id === activeId())?.text || title();
|
|
19
|
+
const handleActiveChange = (id: string) => {
|
|
20
|
+
setActiveId(id);
|
|
21
|
+
local.onActiveChange?.(id);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
26
|
+
if (open() && !rootElement()?.contains(event.target as Node)) {
|
|
27
|
+
setOpen(false);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
32
|
+
onCleanup(() => document.removeEventListener("pointerdown", handlePointerDown));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Collapsible
|
|
37
|
+
open={open()}
|
|
38
|
+
onOpenChange={setOpen}
|
|
39
|
+
ref={setRootElement}
|
|
40
|
+
class={cn(
|
|
41
|
+
"z-20 xl:hidden sticky top-16 rounded-md border border-border bg-background/95 shadow-sm backdrop-blur supports-backdrop-filter:bg-background/80",
|
|
42
|
+
local.class
|
|
43
|
+
)}
|
|
44
|
+
>
|
|
45
|
+
<CollapsibleTrigger
|
|
46
|
+
type="button"
|
|
47
|
+
aria-label={title()}
|
|
48
|
+
class="flex min-h-10 items-center justify-between rounded-md px-3 py-2 text-sm font-medium text-foreground"
|
|
49
|
+
>
|
|
50
|
+
<span class="truncate text-left">{activeTitle()}</span>
|
|
51
|
+
<ChevronDown class={cn("size-4 text-muted-foreground transition-transform", open() && "rotate-180")} />
|
|
52
|
+
</CollapsibleTrigger>
|
|
53
|
+
<CollapsibleContent
|
|
54
|
+
onClick={() => setOpen(false)}
|
|
55
|
+
class="absolute inset-x-0 top-full z-30 max-h-[min(60vh,24rem)] rounded-b-md border border-t-0 border-border bg-card px-3 py-2 shadow-lg overflow-y-auto!"
|
|
56
|
+
>
|
|
57
|
+
<DocsTableOfContents items={local.items} title={title()} onActiveChange={handleActiveChange} class="max-h-56 overflow-y-auto" {...rest} />
|
|
58
|
+
</CollapsibleContent>
|
|
59
|
+
</Collapsible>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { createEffect, createSignal, For, Show, type Component, type JSX } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
import { Collapsible } from "@/components/ui/collapsible";
|
|
4
|
+
import { CollapsibleContent } from "@/components/ui/collapsible";
|
|
5
|
+
import { CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
6
|
+
import { SidebarGroup } from "@/components/ui/sidebar";
|
|
7
|
+
import { SidebarGroupContent } from "@/components/ui/sidebar";
|
|
8
|
+
import { SidebarMenu } from "@/components/ui/sidebar";
|
|
9
|
+
import { SidebarMenuButton } from "@/components/ui/sidebar";
|
|
10
|
+
import { SidebarMenuItem } from "@/components/ui/sidebar";
|
|
11
|
+
import { SidebarMenuSub } from "@/components/ui/sidebar";
|
|
12
|
+
import { SidebarMenuSubButton } from "@/components/ui/sidebar";
|
|
13
|
+
import { SidebarMenuSubItem } from "@/components/ui/sidebar";
|
|
14
|
+
import { sidebarMenuButtonVariants } from "@/components/ui/sidebar";
|
|
15
|
+
import { useSidebar } from "@/components/ui/sidebar";
|
|
16
|
+
import { Button } from "@/components/ui/button";
|
|
17
|
+
import { cn } from "@/lib/cn";
|
|
18
|
+
import { ChevronRight, Folder } from "lucide-solid";
|
|
19
|
+
import type { SidebarItem } from "../../../types.js";
|
|
20
|
+
import type { PageData } from "../../../types.js";
|
|
21
|
+
import { localizeSidebarTree } from "../../../plugins/i18n/navigation.js";
|
|
22
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
23
|
+
import { resolveDefaultIcon } from "../icons.js";
|
|
24
|
+
import {
|
|
25
|
+
containsActiveSidebarItem,
|
|
26
|
+
containsNewSidebarItem,
|
|
27
|
+
isSidebarItemActive,
|
|
28
|
+
isSidebarItemNew,
|
|
29
|
+
} from "../../../navigation/sidebar-state.js";
|
|
30
|
+
|
|
31
|
+
export interface SidebarTreeProps {
|
|
32
|
+
tree: SidebarItem[];
|
|
33
|
+
pages?: readonly PageData[];
|
|
34
|
+
currentUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const SidebarTree: Component<SidebarTreeProps> = (props) => {
|
|
38
|
+
const sidebar = useSidebar();
|
|
39
|
+
const siteLocale = useSiteLocale();
|
|
40
|
+
const activeLocale = () => {
|
|
41
|
+
const currentPage = props.pages?.find((page) => page.url === props.currentUrl);
|
|
42
|
+
const pageLocale = currentPage?.frontmatter.locale;
|
|
43
|
+
return typeof pageLocale === "string" ? pageLocale : siteLocale.locale();
|
|
44
|
+
};
|
|
45
|
+
const localizedTree = () => localizeSidebarTree(props.tree, props.pages || [], activeLocale());
|
|
46
|
+
|
|
47
|
+
const renderCategoryIcon = (name: string | undefined): JSX.Element => (
|
|
48
|
+
<Show when={renderIcon(name, "size-4 shrink-0")} fallback={<Folder class="size-4 shrink-0" />}>
|
|
49
|
+
{renderIcon(name, "size-4 shrink-0")}
|
|
50
|
+
</Show>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const renderIcon = (name: string | undefined, className: string): JSX.Element | undefined => {
|
|
54
|
+
if (!name) return undefined;
|
|
55
|
+
const Icon = resolveDefaultIcon(name);
|
|
56
|
+
return Icon ? <Dynamic component={Icon} class={className} aria-hidden="true" /> : undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const renderPage = (item: SidebarItem): JSX.Element => (
|
|
60
|
+
<SidebarMenuSubItem>
|
|
61
|
+
<SidebarMenuSubButton
|
|
62
|
+
href={item.href || "#"}
|
|
63
|
+
isActive={isSidebarItemActive(item, props.currentUrl)}
|
|
64
|
+
aria-current={isSidebarItemActive(item, props.currentUrl) ? "page" : undefined}
|
|
65
|
+
class="w-full"
|
|
66
|
+
onClick={() => sidebar.setOpenMobile(false)}
|
|
67
|
+
>
|
|
68
|
+
{renderIcon(item.icon, "size-3.5 shrink-0")}
|
|
69
|
+
<span class="min-w-0 flex-1 truncate">{item.title}</span>
|
|
70
|
+
<Show when={isSidebarItemNew(item)}>
|
|
71
|
+
<span class="size-1.5 shrink-0 rounded-lg bg-primary" />
|
|
72
|
+
</Show>
|
|
73
|
+
</SidebarMenuSubButton>
|
|
74
|
+
</SidebarMenuSubItem>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const renderNested = (item: SidebarItem): JSX.Element => {
|
|
78
|
+
const [open, setOpen] = createSignal(item.collapsed === false);
|
|
79
|
+
createEffect(() => {
|
|
80
|
+
if (containsActiveSidebarItem(item, props.currentUrl)) setOpen(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Show when={item.items?.length} fallback={renderPage(item)}>
|
|
85
|
+
<Collapsible open={open()} onOpenChange={setOpen} class="group/collapsible">
|
|
86
|
+
<SidebarMenuSubItem>
|
|
87
|
+
<CollapsibleTrigger as="div" class="w-full text-left">
|
|
88
|
+
<SidebarMenuSubButton class="w-full justify-between">
|
|
89
|
+
<Folder class="size-3.5 shrink-0" />
|
|
90
|
+
<span class="flex-1 truncate">{item.title}</span>
|
|
91
|
+
<ChevronRight class={cn("size-3.5 shrink-0 transition-transform", open() && "rotate-90")} />
|
|
92
|
+
</SidebarMenuSubButton>
|
|
93
|
+
</CollapsibleTrigger>
|
|
94
|
+
<CollapsibleContent>
|
|
95
|
+
<SidebarMenuSub class="w-full">
|
|
96
|
+
<For each={item.items}>{(child) => renderNested(child)}</For>
|
|
97
|
+
</SidebarMenuSub>
|
|
98
|
+
</CollapsibleContent>
|
|
99
|
+
</SidebarMenuSubItem>
|
|
100
|
+
</Collapsible>
|
|
101
|
+
</Show>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const renderCategory = (group: SidebarItem): JSX.Element => {
|
|
106
|
+
const [open, setOpen] = createSignal(group.collapsed === false || containsActiveSidebarItem(group, props.currentUrl));
|
|
107
|
+
createEffect(() => {
|
|
108
|
+
if (containsActiveSidebarItem(group, props.currentUrl)) setOpen(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<SidebarGroup class="w-full">
|
|
113
|
+
<SidebarGroupContent class="w-full">
|
|
114
|
+
<SidebarMenu>
|
|
115
|
+
<SidebarMenuItem class="w-full flex-col items-stretch">
|
|
116
|
+
<Show
|
|
117
|
+
when={group.href}
|
|
118
|
+
fallback={
|
|
119
|
+
<SidebarMenuButton
|
|
120
|
+
type="button"
|
|
121
|
+
class="w-full justify-between font-normal"
|
|
122
|
+
tooltip={group.title}
|
|
123
|
+
aria-expanded={open()}
|
|
124
|
+
onClick={() => setOpen((value) => !value)}
|
|
125
|
+
>
|
|
126
|
+
{renderCategoryIcon(group.icon)}
|
|
127
|
+
<span class="flex-1 truncate group-data-[collapsible=icon]:hidden">{group.title}</span>
|
|
128
|
+
<Show when={containsNewSidebarItem(group)}>
|
|
129
|
+
<span class="size-1.5 shrink-0 rounded-lg bg-primary" />
|
|
130
|
+
</Show>
|
|
131
|
+
<ChevronRight class={cn("ml-auto size-3.5 shrink-0 transition-transform group-data-[collapsible=icon]:hidden", open() && "rotate-90")} />
|
|
132
|
+
</SidebarMenuButton>
|
|
133
|
+
}
|
|
134
|
+
>
|
|
135
|
+
<SidebarMenuButton
|
|
136
|
+
href={group.href}
|
|
137
|
+
class="min-w-0 flex-1 pr-10 font-normal group-data-[collapsible=icon]:pr-0"
|
|
138
|
+
tooltip={group.title}
|
|
139
|
+
isActive={isSidebarItemActive(group, props.currentUrl)}
|
|
140
|
+
aria-current={isSidebarItemActive(group, props.currentUrl) ? "page" : undefined}
|
|
141
|
+
onClick={() => sidebar.setOpenMobile(false)}
|
|
142
|
+
>
|
|
143
|
+
{renderCategoryIcon(group.icon)}
|
|
144
|
+
<span class="flex-1 truncate group-data-[collapsible=icon]:hidden">{group.title}</span>
|
|
145
|
+
<Show when={containsNewSidebarItem(group)}>
|
|
146
|
+
<span class="size-1.5 shrink-0 rounded-lg bg-primary" />
|
|
147
|
+
</Show>
|
|
148
|
+
</SidebarMenuButton>
|
|
149
|
+
<Button
|
|
150
|
+
variant="ghost"
|
|
151
|
+
size="icon"
|
|
152
|
+
class="absolute right-1 top-0 size-8 group-data-[collapsible=icon]:hidden"
|
|
153
|
+
aria-label={`${open() ? "Collapse" : "Expand"} ${group.title}`}
|
|
154
|
+
aria-expanded={open()}
|
|
155
|
+
onClick={() => setOpen((value) => !value)}
|
|
156
|
+
>
|
|
157
|
+
<ChevronRight class={cn("size-3.5 transition-transform", open() && "rotate-90")} />
|
|
158
|
+
</Button>
|
|
159
|
+
</Show>
|
|
160
|
+
<Show when={open()}>
|
|
161
|
+
<div class="w-full group-data-[collapsible=icon]:hidden">
|
|
162
|
+
<SidebarMenuSub class="w-full">
|
|
163
|
+
<For each={group.items}>{(item) => renderNested(item)}</For>
|
|
164
|
+
</SidebarMenuSub>
|
|
165
|
+
</div>
|
|
166
|
+
</Show>
|
|
167
|
+
</SidebarMenuItem>
|
|
168
|
+
</SidebarMenu>
|
|
169
|
+
</SidebarGroupContent>
|
|
170
|
+
</SidebarGroup>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const renderRootPage = (item: SidebarItem): JSX.Element => (
|
|
175
|
+
<SidebarGroup class="w-full">
|
|
176
|
+
<SidebarGroupContent class="w-full">
|
|
177
|
+
<SidebarMenu>
|
|
178
|
+
<SidebarMenuItem class="w-full">
|
|
179
|
+
<a
|
|
180
|
+
href={item.href || "#"}
|
|
181
|
+
onClick={() => sidebar.setOpenMobile(false)}
|
|
182
|
+
data-sidebar="menu-button"
|
|
183
|
+
data-active={isSidebarItemActive(item, props.currentUrl) ? "true" : "false"}
|
|
184
|
+
aria-current={isSidebarItemActive(item, props.currentUrl) ? "page" : undefined}
|
|
185
|
+
class={cn(sidebarMenuButtonVariants({ variant: "default", size: "default" }), "text-sm font-normal")}
|
|
186
|
+
>
|
|
187
|
+
{renderIcon(item.icon, "size-4 shrink-0")}
|
|
188
|
+
<span class="truncate">{item.title}</span>
|
|
189
|
+
</a>
|
|
190
|
+
</SidebarMenuItem>
|
|
191
|
+
</SidebarMenu>
|
|
192
|
+
</SidebarGroupContent>
|
|
193
|
+
</SidebarGroup>
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<>
|
|
198
|
+
<For each={localizedTree().filter((item) => !item.items)}>{(item) => renderRootPage(item)}</For>
|
|
199
|
+
<For each={localizedTree().filter((item) => Boolean(item.items))}>{(group) => renderCategory(group)}</For>
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
};
|