@nikala-ui/folio 0.15.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.
Files changed (63) hide show
  1. package/dist/cli/commands/init.js +89 -54
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.js +1 -0
  4. package/dist/search/provider.d.ts +9 -0
  5. package/dist/search/provider.js +4 -2
  6. package/dist/server/plugin/virtual-modules.js +34 -1
  7. package/dist/templates/env.d.ts +26 -0
  8. package/dist/templates/locales/en.json +77 -0
  9. package/dist/themes/default/components/docs-landing-body.d.ts +17 -0
  10. package/dist/themes/default/components/docs-landing-body.jsx +17 -0
  11. package/dist/themes/default/components/docs-page-body.d.ts +21 -0
  12. package/dist/themes/default/components/docs-page-body.jsx +36 -0
  13. package/dist/themes/default/components/page-actions.d.ts +15 -0
  14. package/dist/themes/default/components/page-actions.jsx +60 -0
  15. package/dist/themes/default/components/page-header.d.ts +7 -0
  16. package/dist/themes/default/components/page-header.jsx +3 -0
  17. package/dist/themes/default/components/sidebar-footer.d.ts +6 -0
  18. package/dist/themes/default/components/sidebar-footer.jsx +12 -0
  19. package/dist/themes/default/components/sidebar-header.d.ts +8 -0
  20. package/dist/themes/default/components/sidebar-header.jsx +17 -0
  21. package/dist/themes/default/components/sidebar-mobile-nav.d.ts +7 -0
  22. package/dist/themes/default/components/sidebar-mobile-nav.jsx +17 -0
  23. package/dist/themes/default/components/sidebar-promo.d.ts +8 -0
  24. package/dist/themes/default/components/sidebar-promo.jsx +20 -0
  25. package/dist/themes/default/hooks/use-page-copy.d.ts +6 -0
  26. package/dist/themes/default/hooks/use-page-copy.js +26 -0
  27. package/dist/themes/default/layout.jsx +23 -147
  28. package/dist/themes/default/lib/layout-visibility.d.ts +8 -0
  29. package/dist/themes/default/lib/layout-visibility.js +24 -0
  30. package/dist/themes/default/navigation/mobile-table-of-contents.jsx +2 -2
  31. package/dist/themes/default/sidebar.jsx +17 -47
  32. package/dist/vendor/docs-src/client/page-actions.ts +69 -0
  33. package/dist/vendor/docs-src/navigation/index.ts +2 -0
  34. package/dist/vendor/docs-src/navigation/repository-links.ts +43 -0
  35. package/dist/vendor/docs-src/navigation/sidebar-state.ts +22 -0
  36. package/dist/vendor/docs-src/navigation/sidebar-tree.ts +15 -0
  37. package/dist/vendor/docs-src/search/provider.ts +83 -0
  38. package/dist/vendor/docs-src/themes/default/components/docs-landing-body.tsx +30 -0
  39. package/dist/vendor/docs-src/themes/default/components/docs-page-body.tsx +53 -0
  40. package/dist/vendor/docs-src/themes/default/components/page-actions.tsx +105 -0
  41. package/dist/vendor/docs-src/themes/default/components/page-header.tsx +31 -0
  42. package/dist/vendor/docs-src/themes/default/components/sidebar-footer.tsx +21 -0
  43. package/dist/vendor/docs-src/themes/default/components/sidebar-header.tsx +30 -0
  44. package/dist/vendor/docs-src/themes/default/components/sidebar-mobile-nav.tsx +33 -0
  45. package/dist/vendor/docs-src/themes/default/components/sidebar-promo.tsx +37 -0
  46. package/dist/vendor/docs-src/themes/default/content/breadcrumbs.tsx +43 -0
  47. package/dist/vendor/docs-src/themes/default/content/pager.tsx +19 -0
  48. package/dist/vendor/docs-src/themes/default/content/table-of-contents.tsx +32 -0
  49. package/dist/vendor/docs-src/themes/default/hooks/use-page-copy.ts +29 -0
  50. package/dist/vendor/docs-src/themes/default/icons.ts +16 -0
  51. package/dist/vendor/docs-src/themes/default/index.ts +46 -0
  52. package/dist/vendor/docs-src/themes/default/layout.tsx +176 -0
  53. package/dist/vendor/docs-src/themes/default/lib/layout-visibility.ts +39 -0
  54. package/dist/vendor/docs-src/themes/default/navbar.tsx +130 -0
  55. package/dist/vendor/docs-src/themes/default/navigation/mobile-table-of-contents.tsx +61 -0
  56. package/dist/vendor/docs-src/themes/default/navigation/sidebar-tree.tsx +202 -0
  57. package/dist/vendor/docs-src/themes/default/overlays/search-dialog.tsx +106 -0
  58. package/dist/vendor/docs-src/themes/default/sidebar.tsx +86 -0
  59. package/dist/vendor/docs-src/themes/index.ts +4 -0
  60. package/dist/vendor/docs-src/themes/types.ts +87 -0
  61. package/dist/version.d.ts +1 -1
  62. package/dist/version.js +1 -1
  63. package/package.json +2 -2
@@ -0,0 +1,32 @@
1
+ // packages/docs/src/themes/default/content/table-of-contents.tsx
2
+ import { createSignal, onMount, Show, splitProps, type Component } from "solid-js";
3
+ import { TableOfContents as CoreTableOfContents } from "@/components/ui/table-of-contents";
4
+ import type { DocsTableOfContentsProps } from "../../types.js";
5
+ import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
6
+
7
+ export const DocsTableOfContents: Component<DocsTableOfContentsProps> = (props) => {
8
+ const [local, rest] = splitProps(props, ["items", "title", "class"]);
9
+ const [ready, setReady] = createSignal(false);
10
+ const siteLocale = useSiteLocale();
11
+
12
+ onMount(() => {
13
+ if (typeof window === "undefined") {
14
+ setReady(true);
15
+ return;
16
+ }
17
+
18
+ const frame = window.requestAnimationFrame(() => setReady(true));
19
+ return () => window.cancelAnimationFrame(frame);
20
+ });
21
+
22
+ return (
23
+ <Show when={ready()}>
24
+ <CoreTableOfContents
25
+ items={local.items}
26
+ title={local.title ?? siteLocale.t("tableOfContents.title")}
27
+ class={local.class}
28
+ {...rest}
29
+ />
30
+ </Show>
31
+ );
32
+ };
@@ -0,0 +1,29 @@
1
+ import { createClipboard } from "@/hooks/create-clipboard";
2
+ import { pageToMarkdown, pageToText, sourceToMarkdown } from "../../../client/page-actions.js";
3
+ import type { Accessor } from "solid-js";
4
+
5
+ function pageElement(): HTMLElement | null {
6
+ if (typeof document === "undefined") return null;
7
+ return document.querySelector("main article [data-docs-page-content]") as HTMLElement | null;
8
+ }
9
+
10
+ export function createPageCopy(sourceContent: Accessor<string | undefined>) {
11
+ const clipboard = createClipboard();
12
+ const markdown = () => {
13
+ const source = sourceContent();
14
+ const page = pageElement();
15
+ return source ? sourceToMarkdown(source) : page ? pageToMarkdown(page) : "";
16
+ };
17
+
18
+ const copyPage = async () => {
19
+ const page = pageElement();
20
+ if (page) await clipboard.copy(pageToText(page));
21
+ };
22
+
23
+ const copyMarkdown = async () => {
24
+ const content = markdown();
25
+ if (content) await clipboard.copy(content);
26
+ };
27
+
28
+ return { markdown, copyPage, copyMarkdown };
29
+ }
@@ -0,0 +1,16 @@
1
+ import { icons } from "virtual:folio-icons";
2
+ import type { DocsIcon } from "../../types.js";
3
+
4
+ function toComponentName(name: string): string {
5
+ return name
6
+ .split(/[-_\s]+/)
7
+ .filter(Boolean)
8
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
9
+ .join("");
10
+ }
11
+
12
+ export function resolveDefaultIcon(name?: string): DocsIcon | undefined {
13
+ if (!name) return undefined;
14
+ const icon = icons[toComponentName(name)];
15
+ return icon;
16
+ }
@@ -0,0 +1,46 @@
1
+ // packages/docs/src/themes/default/index.ts
2
+ export * from "./layout.jsx";
3
+ export * from "./navbar.jsx";
4
+ export * from "./sidebar.jsx";
5
+ export * from "./content/table-of-contents.jsx";
6
+ export * from "./content/breadcrumbs.jsx";
7
+ export * from "./content/pager.jsx";
8
+ export * from "./overlays/search-dialog.jsx";
9
+
10
+ import { DocsLayout } from "./layout.jsx";
11
+ import { DocsNavbar } from "./navbar.jsx";
12
+ import { DocsSidebar } from "./sidebar.jsx";
13
+ import { DocsTableOfContents } from "./content/table-of-contents.jsx";
14
+ import { DocsBreadcrumbs } from "./content/breadcrumbs.jsx";
15
+ import { DocsPager, DocsPagination } from "./content/pager.jsx";
16
+ import { DocsSearchDialog } from "./overlays/search-dialog.jsx";
17
+ import { ThemeProvider } from "@/providers/theme-provider";
18
+ import type { DocsThemeContract } from "../types.js";
19
+
20
+ export type {
21
+ BreadcrumbItemData,
22
+ DocsBreadcrumbsProps,
23
+ DocsLayoutProps,
24
+ DocsNavbarProps,
25
+ DocsPaginationProps,
26
+ DocsPagerProps,
27
+ DocsSearchDialogProps,
28
+ DocsSidebarProps,
29
+ DocsTableOfContentsProps,
30
+ DocsThemeContract,
31
+ } from "../types.js";
32
+
33
+ export const defaultTheme: DocsThemeContract = {
34
+ name: "default",
35
+ Provider: ThemeProvider,
36
+ Layout: DocsLayout,
37
+ Navbar: DocsNavbar,
38
+ Sidebar: DocsSidebar,
39
+ TableOfContents: DocsTableOfContents,
40
+ Breadcrumbs: DocsBreadcrumbs,
41
+ Pagination: DocsPagination,
42
+ Pager: DocsPager,
43
+ SearchDialog: DocsSearchDialog,
44
+ };
45
+
46
+ export default defaultTheme;
@@ -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
+ };