@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.
- package/dist/cli/commands/init.js +89 -54
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/search/provider.d.ts +9 -0
- package/dist/search/provider.js +4 -2
- package/dist/server/plugin/virtual-modules.js +34 -1
- 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/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 +23 -147
- 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/navigation/mobile-table-of-contents.jsx +2 -2
- package/dist/themes/default/sidebar.jsx +17 -47
- package/dist/vendor/docs-src/client/page-actions.ts +69 -0
- 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/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 +2 -2
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/overlays/search-dialog.tsx
|
|
2
|
+
import { createEffect, createSignal, For, Show, type Component } from "solid-js";
|
|
3
|
+
import { CommandDialog } from "@/components/ui/command";
|
|
4
|
+
import { CommandInput } from "@/components/ui/command";
|
|
5
|
+
import { CommandList } from "@/components/ui/command";
|
|
6
|
+
import { CommandEmpty } from "@/components/ui/command";
|
|
7
|
+
import { CommandGroup } from "@/components/ui/command";
|
|
8
|
+
import { CommandItem } from "@/components/ui/command";
|
|
9
|
+
import { FileText } from "lucide-solid";
|
|
10
|
+
import type { DocsSearchDialogProps } from "../../types.js";
|
|
11
|
+
import { resolveSearchProvider, searchPages } from "../../../search/provider.js";
|
|
12
|
+
import { useSiteLocale } from "../../../plugins/i18n/runtime.jsx";
|
|
13
|
+
|
|
14
|
+
export const DocsSearchDialog: Component<DocsSearchDialogProps> = (props) => {
|
|
15
|
+
const siteLocale = useSiteLocale();
|
|
16
|
+
const showAlgoliaAttribution = () =>
|
|
17
|
+
typeof props.provider !== "string" && props.provider?.name === "algolia";
|
|
18
|
+
|
|
19
|
+
const handleOpenChange = (open: boolean) => {
|
|
20
|
+
props.onOpenChange(open);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleSelect = (url: string) => {
|
|
24
|
+
handleOpenChange(false);
|
|
25
|
+
if (props.onSelectPage) {
|
|
26
|
+
props.onSelectPage(url);
|
|
27
|
+
} else if (typeof window !== "undefined") {
|
|
28
|
+
window.location.href = url;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<CommandDialog
|
|
34
|
+
open={props.open}
|
|
35
|
+
onOpenChange={handleOpenChange}
|
|
36
|
+
onOpenAutoFocus={(event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
window.requestAnimationFrame(() => {
|
|
39
|
+
document.querySelector<HTMLInputElement>("#docs-search-input")?.focus();
|
|
40
|
+
});
|
|
41
|
+
}}
|
|
42
|
+
enableHotkey={props.provider !== undefined}
|
|
43
|
+
>
|
|
44
|
+
{({ search }) => {
|
|
45
|
+
const query = () => search().trim();
|
|
46
|
+
const resolvedProvider = () => resolveSearchProvider({ provider: props.provider });
|
|
47
|
+
const [filteredPages, setFilteredPages] = createSignal(props.pages || []);
|
|
48
|
+
const [searching, setSearching] = createSignal(false);
|
|
49
|
+
let requestId = 0;
|
|
50
|
+
|
|
51
|
+
createEffect(() => {
|
|
52
|
+
const currentRequest = ++requestId;
|
|
53
|
+
setSearching(true);
|
|
54
|
+
Promise.resolve(searchPages(resolvedProvider(), query(), props.pages || []))
|
|
55
|
+
.then((results) => {
|
|
56
|
+
if (currentRequest === requestId) setFilteredPages(results);
|
|
57
|
+
})
|
|
58
|
+
.finally(() => {
|
|
59
|
+
if (currentRequest === requestId) setSearching(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<CommandInput id="docs-search-input" placeholder={siteLocale.t("search.placeholder")} />
|
|
66
|
+
<CommandList>
|
|
67
|
+
<Show when={!searching() && query().length > 0 && filteredPages().length === 0}>
|
|
68
|
+
<CommandEmpty>{siteLocale.t("search.empty")}</CommandEmpty>
|
|
69
|
+
</Show>
|
|
70
|
+
<Show when={!searching() && filteredPages().length > 0}>
|
|
71
|
+
<CommandGroup heading={siteLocale.t("search.pages")}>
|
|
72
|
+
<For each={filteredPages()}>
|
|
73
|
+
{(page) => (
|
|
74
|
+
<CommandItem
|
|
75
|
+
title={page.title}
|
|
76
|
+
subtitle={page.url}
|
|
77
|
+
description={page.description}
|
|
78
|
+
icon={FileText}
|
|
79
|
+
shouldFilter={false}
|
|
80
|
+
onSelect={() => handleSelect(page.url)}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</For>
|
|
84
|
+
</CommandGroup>
|
|
85
|
+
</Show>
|
|
86
|
+
</CommandList>
|
|
87
|
+
<Show when={showAlgoliaAttribution()}>
|
|
88
|
+
<div class="flex items-center justify-end border-t border-border px-3 py-2">
|
|
89
|
+
<a
|
|
90
|
+
href="https://www.algolia.com"
|
|
91
|
+
target="_blank"
|
|
92
|
+
rel="noreferrer"
|
|
93
|
+
class="inline-flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground"
|
|
94
|
+
aria-label={`${siteLocale.t("search.by")} Algolia`}
|
|
95
|
+
>
|
|
96
|
+
<span>{siteLocale.t("search.by")}</span>
|
|
97
|
+
<img src="/algolia-logo.svg" alt="Algolia" class="h-4 w-auto object-contain" />
|
|
98
|
+
</a>
|
|
99
|
+
</div>
|
|
100
|
+
</Show>
|
|
101
|
+
</>
|
|
102
|
+
);
|
|
103
|
+
}}
|
|
104
|
+
</CommandDialog>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// packages/docs/src/themes/default/sidebar.tsx
|
|
2
|
+
import { createSignal, onCleanup, onMount, Show, splitProps, type Component } from "solid-js";
|
|
3
|
+
import { Sidebar } from "@/components/ui/sidebar";
|
|
4
|
+
import { SidebarContent } from "@/components/ui/sidebar";
|
|
5
|
+
import { useSidebar } from "@/components/ui/sidebar";
|
|
6
|
+
import { createFocusTrap } from "@/hooks/create-focus-trap";
|
|
7
|
+
import { createLockScroll } from "@/hooks/create-lock-scroll";
|
|
8
|
+
import { cn } from "@/lib/cn";
|
|
9
|
+
import type { DocsSidebarProps } from "../types.js";
|
|
10
|
+
import { SidebarFooter } from "./components/sidebar-footer.jsx";
|
|
11
|
+
import { SidebarHeader } from "./components/sidebar-header.jsx";
|
|
12
|
+
import { SidebarMobileNav } from "./components/sidebar-mobile-nav.jsx";
|
|
13
|
+
import { SidebarTree } from "./navigation/sidebar-tree.jsx";
|
|
14
|
+
import { useSiteLocale } from "../../plugins/i18n/runtime.jsx";
|
|
15
|
+
|
|
16
|
+
export const DocsSidebar: Component<DocsSidebarProps> = (props) => {
|
|
17
|
+
const [local, rest] = splitProps(props, ["tree", "pages", "nav", "currentUrl", "title", "logo", "headerSubtitle", "footerText", "showHeader", "showFooter", "class"]);
|
|
18
|
+
const brandText = () => local.logo?.text || local.title || "Folio";
|
|
19
|
+
const siteLocale = useSiteLocale();
|
|
20
|
+
const sidebar = useSidebar();
|
|
21
|
+
const [sidebarElement, setSidebarElement] = createSignal<HTMLDivElement>();
|
|
22
|
+
|
|
23
|
+
createFocusTrap(sidebarElement, {
|
|
24
|
+
enabled: () => sidebar.isMobile() && sidebar.openMobile(),
|
|
25
|
+
});
|
|
26
|
+
createLockScroll({
|
|
27
|
+
enabled: () => sidebar.isMobile() && sidebar.openMobile(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
onMount(() => {
|
|
31
|
+
if (typeof window === "undefined") return;
|
|
32
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
33
|
+
if (event.key === "Escape" && sidebar.isMobile() && sidebar.openMobile()) {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
sidebar.setOpenMobile(false);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
39
|
+
onCleanup(() => window.removeEventListener("keydown", handleKeyDown));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Show when={sidebar.isMobile() && sidebar.openMobile()}>
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
aria-label={siteLocale.t("navigation.closeSidebar")}
|
|
48
|
+
class="fixed inset-0 z-40 cursor-default bg-black/50 md:hidden"
|
|
49
|
+
onClick={() => sidebar.setOpenMobile(false)}
|
|
50
|
+
/>
|
|
51
|
+
</Show>
|
|
52
|
+
<Show when={!sidebar.isMobile() || sidebar.openMobile()}>
|
|
53
|
+
<div class={cn(
|
|
54
|
+
"w-0 md:shrink-0",
|
|
55
|
+
sidebar.open() ? "md:w-(--sidebar-width)" : "md:w-(--sidebar-width-icon)"
|
|
56
|
+
)}>
|
|
57
|
+
<Sidebar
|
|
58
|
+
ref={setSidebarElement}
|
|
59
|
+
collapsible={sidebar.isMobile() ? "none" : "icon"}
|
|
60
|
+
class={cn(
|
|
61
|
+
"top-0 self-start z-30 h-screen shrink-0 rounded-none border-y-0 border-l-0 border-r border-border bg-card shadow-sm md:fixed md:inset-y-0 md:left-0",
|
|
62
|
+
"overflow-hidden max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-50 max-md:w-[min(17rem,calc(100vw-1rem))] max-md:shadow-xl",
|
|
63
|
+
local.class
|
|
64
|
+
)}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
<Show when={local.showHeader !== false}>
|
|
68
|
+
<SidebarHeader logo={local.logo} brandText={brandText()} subtitle={local.headerSubtitle} />
|
|
69
|
+
</Show>
|
|
70
|
+
|
|
71
|
+
<SidebarContent class="h-full overflow-y-auto scrollbar-none [&::-webkit-scrollbar]:hidden">
|
|
72
|
+
<Show when={local.nav?.length}>
|
|
73
|
+
<SidebarMobileNav items={local.nav} onNavigate={() => sidebar.setOpenMobile(false)} />
|
|
74
|
+
</Show>
|
|
75
|
+
<SidebarTree tree={local.tree} pages={local.pages} currentUrl={local.currentUrl} />
|
|
76
|
+
</SidebarContent>
|
|
77
|
+
|
|
78
|
+
<Show when={local.showFooter !== false}>
|
|
79
|
+
<SidebarFooter brandText={brandText()} footerText={local.footerText} />
|
|
80
|
+
</Show>
|
|
81
|
+
</Sidebar>
|
|
82
|
+
</div>
|
|
83
|
+
</Show>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Component, JSX, ParentComponent } from "solid-js";
|
|
2
|
+
import type { DocsConfig, NavItem, PageData, TocItem, SidebarItem } from "../types.js";
|
|
3
|
+
import type { SearchAdapter } from "../search/provider.js";
|
|
4
|
+
|
|
5
|
+
export type BreadcrumbItemData = { title: string; href?: string };
|
|
6
|
+
|
|
7
|
+
export interface DocsNavbarProps {
|
|
8
|
+
config: DocsConfig;
|
|
9
|
+
currentPage?: PageData;
|
|
10
|
+
pages?: readonly PageData[];
|
|
11
|
+
onNavigate?: (url: string) => void;
|
|
12
|
+
onOpenSearch?: () => void;
|
|
13
|
+
showBrand?: boolean;
|
|
14
|
+
showSidebarTrigger?: boolean;
|
|
15
|
+
mobileSidebarTrigger?: boolean;
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface DocsSidebarProps {
|
|
20
|
+
tree: SidebarItem[];
|
|
21
|
+
pages?: readonly PageData[];
|
|
22
|
+
nav?: NavItem[];
|
|
23
|
+
currentUrl?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
logo?: DocsConfig["logo"];
|
|
26
|
+
headerSubtitle?: string;
|
|
27
|
+
footerText?: string;
|
|
28
|
+
showHeader?: boolean;
|
|
29
|
+
showFooter?: boolean;
|
|
30
|
+
class?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DocsTableOfContentsProps {
|
|
34
|
+
items: TocItem[];
|
|
35
|
+
title?: string;
|
|
36
|
+
class?: string;
|
|
37
|
+
onActiveChange?: (id: string) => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface DocsBreadcrumbsProps {
|
|
41
|
+
items: BreadcrumbItemData[];
|
|
42
|
+
class?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DocsPaginationProps {
|
|
46
|
+
prev?: { title: string; href: string };
|
|
47
|
+
next?: { title: string; href: string };
|
|
48
|
+
class?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type DocsPagerProps = DocsPaginationProps;
|
|
52
|
+
|
|
53
|
+
export interface DocsSearchDialogProps {
|
|
54
|
+
open: boolean;
|
|
55
|
+
onOpenChange: (open: boolean) => void;
|
|
56
|
+
pages?: PageData[];
|
|
57
|
+
onSelectPage?: (url: string) => void;
|
|
58
|
+
provider?: string | SearchAdapter;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DocsLayoutProps {
|
|
62
|
+
config: DocsConfig;
|
|
63
|
+
tree: SidebarItem[];
|
|
64
|
+
pages?: PageData[];
|
|
65
|
+
currentPage?: PageData;
|
|
66
|
+
onNavigate?: (url: string) => void;
|
|
67
|
+
breadcrumbs?: BreadcrumbItemData[];
|
|
68
|
+
toc?: TocItem[];
|
|
69
|
+
prev?: { title: string; href: string };
|
|
70
|
+
next?: { title: string; href: string };
|
|
71
|
+
sourceContent?: string;
|
|
72
|
+
children?: JSX.Element;
|
|
73
|
+
class?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface DocsThemeContract {
|
|
77
|
+
name: string;
|
|
78
|
+
Provider?: ParentComponent<{ defaultTheme?: "light" | "dark" | "system"; storageKey?: string }>;
|
|
79
|
+
Layout: Component<DocsLayoutProps>;
|
|
80
|
+
Navbar?: Component<DocsNavbarProps>;
|
|
81
|
+
Sidebar?: Component<DocsSidebarProps>;
|
|
82
|
+
TableOfContents?: Component<DocsTableOfContentsProps>;
|
|
83
|
+
Breadcrumbs?: Component<DocsBreadcrumbsProps>;
|
|
84
|
+
Pagination?: Component<DocsPaginationProps>;
|
|
85
|
+
Pager?: Component<DocsPagerProps>;
|
|
86
|
+
SearchDialog?: Component<DocsSearchDialogProps>;
|
|
87
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FOLIO_VERSION = "0.15.
|
|
1
|
+
export declare const FOLIO_VERSION = "0.15.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FOLIO_VERSION = "0.15.
|
|
1
|
+
export const FOLIO_VERSION = "0.15.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nikala-ui/folio",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Zero-config, fast, and elegant documentation engine for SolidJS, built on Nikala UI and Tailwind CSS v4",
|
|
6
6
|
"type": "module",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"tailwindcss": ">=4.0.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@nikala-ui/folio-algolia": "0.
|
|
102
|
+
"@nikala-ui/folio-algolia": "0.3.0",
|
|
103
103
|
"@types/fs-extra": "^11.0.4",
|
|
104
104
|
"@types/node": "^26.1.1",
|
|
105
105
|
"bun-types": "1.3.14",
|