@fumadocs/base-ui 16.15.18 → 16.16.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/css/generated/docs.css +1 -1
- package/css/generated/flux.css +1 -1
- package/css/generated/glass.css +1 -1
- package/css/generated/notebook.css +1 -1
- package/css/generated/shared.css +1 -1
- package/css/generated/spacious.css +1 -0
- package/css/lib/base.css +26 -1
- package/dist/.translations/index.d.ts +3 -0
- package/dist/.translations/keys.js +3 -0
- package/dist/components/toc/block.js +4 -2
- package/dist/layouts/docs/client.d.ts +1 -0
- package/dist/layouts/docs/client.js +9 -3
- package/dist/layouts/docs/index.d.ts +2 -1
- package/dist/layouts/docs/page/slots/toc.js +2 -1
- package/dist/layouts/docs/slots/container.js +1 -8
- package/dist/layouts/glass/index.d.ts +11 -13
- package/dist/layouts/glass/index.js +11 -6
- package/dist/layouts/glass/page/slots/toc.js +3 -1
- package/dist/layouts/glass/slots/header.js +1 -1
- package/dist/layouts/notebook/client.d.ts +1 -0
- package/dist/layouts/notebook/client.js +9 -3
- package/dist/layouts/notebook/index.d.ts +2 -1
- package/dist/layouts/notebook/page/slots/toc.js +2 -1
- package/dist/layouts/notebook/slots/container.js +6 -12
- package/dist/layouts/shared/client.d.ts +1 -1
- package/dist/layouts/shared/client.js +17 -1
- package/dist/layouts/shared/index.d.ts +8 -0
- package/dist/layouts/spacious/index.d.ts +37 -0
- package/dist/layouts/spacious/index.js +80 -0
- package/dist/layouts/spacious/page/index.d.ts +56 -0
- package/dist/layouts/spacious/page/index.js +150 -0
- package/dist/layouts/spacious/page/slots/breadcrumb.d.ts +10 -0
- package/dist/layouts/spacious/page/slots/breadcrumb.js +51 -0
- package/dist/layouts/spacious/page/slots/footer.d.ts +15 -0
- package/dist/layouts/spacious/page/slots/footer.js +61 -0
- package/dist/layouts/spacious/page/slots/toc.d.ts +44 -0
- package/dist/layouts/spacious/page/slots/toc.js +208 -0
- package/dist/layouts/spacious/slots/actions.d.ts +5 -0
- package/dist/layouts/spacious/slots/actions.js +224 -0
- package/dist/layouts/spacious/slots/header.d.ts +5 -0
- package/dist/layouts/spacious/slots/header.js +34 -0
- package/dist/layouts/spacious/slots/sidebar.d.ts +9 -0
- package/dist/layouts/spacious/slots/sidebar.js +305 -0
- package/dist/style.css +600 -18
- package/package.json +17 -9
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../../utils/cn.js";
|
|
3
|
+
import { TOCProvider as TOCProvider$1, TOCScrollArea, useTOCItems } from "../../../../components/toc/index.js";
|
|
4
|
+
import { default_exports } from "../../../../components/toc/default.js";
|
|
5
|
+
import { clerk_exports } from "../../../../components/toc/clerk.js";
|
|
6
|
+
import { block_exports } from "../../../../components/toc/block.js";
|
|
7
|
+
import { useTreePath } from "../../../../contexts/tree.js";
|
|
8
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../../../../components/ui/collapsible.js";
|
|
9
|
+
import { useSpaciousLayout } from "../../index.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { ChevronDownIcon, TextIcon } from "lucide-react";
|
|
12
|
+
import { useEffect, useRef, useState } from "react";
|
|
13
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
14
|
+
import { useTOCSelector } from "fumadocs-core/toc";
|
|
15
|
+
import { Popover } from "@base-ui/react/popover";
|
|
16
|
+
//#region src/layouts/spacious/page/slots/toc.tsx
|
|
17
|
+
const variants = {
|
|
18
|
+
normal: default_exports,
|
|
19
|
+
clerk: clerk_exports,
|
|
20
|
+
block: block_exports
|
|
21
|
+
};
|
|
22
|
+
const selectTopmost = (items) => items.find((item) => item.active)?.original;
|
|
23
|
+
const selectProgress = (items) => (items.findLastIndex((item) => item.active) + 1) / Math.max(1, items.length);
|
|
24
|
+
function TOCProvider(props) {
|
|
25
|
+
return /* @__PURE__ */ jsx(TOCProvider$1, { ...props });
|
|
26
|
+
}
|
|
27
|
+
function TOC({ container, header, footer, ...props }) {
|
|
28
|
+
const t = useTranslations({ note: "table of contents" });
|
|
29
|
+
const items = useTOCItems();
|
|
30
|
+
const { props: { aiChat } } = useSpaciousLayout();
|
|
31
|
+
if (items.length === 0 && !header && !footer) return;
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
id: "nd-toc",
|
|
34
|
+
...container,
|
|
35
|
+
className: cn("sticky top-0 flex flex-col shrink-0 w-(--fd-toc-width) h-full ps-16 pt-6 pb-4 overflow-clip *:min-w-[calc(var(--fd-toc-width)---spacing(16))] layout:[--fd-toc-width:--spacing(76)] transition-[width,padding,opacity,visibility] duration-300 ease-in-out motion-reduce:transition-none max-md:hidden", aiChat?.open && aiChat.panel ? "invisible w-0 ps-0 opacity-0" : "@max-5xl:invisible @max-5xl:w-0 @max-5xl:ps-0 @max-5xl:opacity-0 @max-5xl:transition-none", container?.className),
|
|
36
|
+
children: [
|
|
37
|
+
header,
|
|
38
|
+
/* @__PURE__ */ jsxs("h3", {
|
|
39
|
+
className: "inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground",
|
|
40
|
+
children: [/* @__PURE__ */ jsx(TextIcon, { className: "size-4" }), t("On this page")]
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx(TOCList, { ...props }),
|
|
43
|
+
footer
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** the TOC bar for mobile */
|
|
48
|
+
function TOCPopover({ container, trigger, content, header, footer, ...props }) {
|
|
49
|
+
const t = useTranslations({ note: "table of contents" });
|
|
50
|
+
const page = useTreePath().at(-1);
|
|
51
|
+
const ref = useRef(null);
|
|
52
|
+
const [open, setOpen] = useState(false);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!open) return;
|
|
55
|
+
const onClick = (e) => {
|
|
56
|
+
if (e.target instanceof Node && !ref.current?.contains(e.target)) setOpen(false);
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener("click", onClick);
|
|
59
|
+
return () => window.removeEventListener("click", onClick);
|
|
60
|
+
}, [open]);
|
|
61
|
+
return /* @__PURE__ */ jsx(Collapsible, {
|
|
62
|
+
open,
|
|
63
|
+
onOpenChange: setOpen,
|
|
64
|
+
...container,
|
|
65
|
+
className: cn("sticky top-[calc(var(--fd-banner-height,0px)+var(--fd-header-height))] z-30 [grid-area:toc-popover] h-(--fd-toc-popover-height) md:hidden max-md:layout:[--fd-toc-popover-height:--spacing(10)]", container?.className),
|
|
66
|
+
children: /* @__PURE__ */ jsxs("header", {
|
|
67
|
+
ref,
|
|
68
|
+
className: "bg-fd-card [anchor-name:--fd-top-bar]",
|
|
69
|
+
children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
70
|
+
...trigger,
|
|
71
|
+
className: cn("flex w-full h-10 items-center gap-2.5 px-4 text-start text-sm text-fd-muted-foreground focus-visible:outline-none", trigger?.className),
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(TOCProgress, {
|
|
74
|
+
size: 18,
|
|
75
|
+
className: cn("shrink-0", open && "text-fd-primary")
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx(ActiveHeading, {
|
|
78
|
+
fallback: page?.name ?? t("On this page"),
|
|
79
|
+
className: cn("flex-1 transition-colors", open && "text-fd-foreground")
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-4 shrink-0 mx-0.5 transition-transform", open && "rotate-180") })
|
|
82
|
+
]
|
|
83
|
+
}), /* @__PURE__ */ jsx(CollapsibleContent, {
|
|
84
|
+
...content,
|
|
85
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
86
|
+
className: "flex flex-col px-4 max-h-[50vh]",
|
|
87
|
+
children: [
|
|
88
|
+
header,
|
|
89
|
+
/* @__PURE__ */ jsx(TOCList, {
|
|
90
|
+
...props,
|
|
91
|
+
onSelect: () => setOpen(false)
|
|
92
|
+
}),
|
|
93
|
+
footer
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
})]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/** the TOC dropdown for page header */
|
|
101
|
+
function TOCDropdown({ trigger, content, header, footer, ...props }) {
|
|
102
|
+
const t = useTranslations({ note: "table of contents" });
|
|
103
|
+
const [open, setOpen] = useState(false);
|
|
104
|
+
return /* @__PURE__ */ jsxs(Popover.Root, {
|
|
105
|
+
open,
|
|
106
|
+
onOpenChange: setOpen,
|
|
107
|
+
children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
108
|
+
...trigger,
|
|
109
|
+
className: cn("flex items-center gap-2 min-w-0 h-8 px-1.5 -mx-1.5 rounded-lg text-start text-sm transition-colors", open ? "bg-fd-accent text-fd-accent-foreground" : "text-fd-muted-foreground hover:bg-fd-accent/60 hover:text-fd-accent-foreground", trigger?.className),
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(TOCProgress, { className: "shrink-0" }),
|
|
112
|
+
/* @__PURE__ */ jsx(ActiveHeading, {
|
|
113
|
+
fallback: t("On this page"),
|
|
114
|
+
activeClassName: "text-fd-foreground"
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-3.5 shrink-0 transition-transform", open && "rotate-180") })
|
|
117
|
+
]
|
|
118
|
+
}), /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
119
|
+
align: "start",
|
|
120
|
+
sideOffset: 8,
|
|
121
|
+
positionMethod: "fixed",
|
|
122
|
+
className: "z-50",
|
|
123
|
+
children: /* @__PURE__ */ jsxs(Popover.Popup, {
|
|
124
|
+
...content,
|
|
125
|
+
className: cn("flex flex-col w-[min(22rem,calc(100vw-1rem))] max-h-[min(28rem,var(--available-height))] p-3 rounded-2xl border bg-fd-popover text-fd-popover-foreground shadow-xl outline-none origin-(--transform-origin) transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] data-starting-style:opacity-0 data-starting-style:scale-95 data-ending-style:opacity-0 data-ending-style:scale-95 motion-reduce:transition-none", content?.className),
|
|
126
|
+
children: [
|
|
127
|
+
header,
|
|
128
|
+
/* @__PURE__ */ jsx(TOCList, {
|
|
129
|
+
...props,
|
|
130
|
+
className: "py-1",
|
|
131
|
+
onSelect: () => setOpen(false)
|
|
132
|
+
}),
|
|
133
|
+
footer
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
}) })]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function TOCList({ style = "block", list, className, onSelect }) {
|
|
140
|
+
const items = useTOCItems();
|
|
141
|
+
const { TOCItems, TOCItem, TOCEmpty } = variants[style];
|
|
142
|
+
return /* @__PURE__ */ jsx(TOCScrollArea, {
|
|
143
|
+
className,
|
|
144
|
+
children: /* @__PURE__ */ jsxs(TOCItems, {
|
|
145
|
+
...list,
|
|
146
|
+
children: [items.length === 0 && /* @__PURE__ */ jsx(TOCEmpty, {}), items.map((item) => /* @__PURE__ */ jsx(TOCItem, {
|
|
147
|
+
item,
|
|
148
|
+
onClick: onSelect
|
|
149
|
+
}, item.url))]
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** rolls in from the direction of scrolling */
|
|
154
|
+
function ActiveHeading({ fallback, className, activeClassName }) {
|
|
155
|
+
const items = useTOCItems();
|
|
156
|
+
const active = useTOCSelector(selectTopmost);
|
|
157
|
+
const [shown, setShown] = useState({
|
|
158
|
+
item: active,
|
|
159
|
+
roll: 1
|
|
160
|
+
});
|
|
161
|
+
if (shown.item !== active) setShown({
|
|
162
|
+
item: active,
|
|
163
|
+
roll: items.indexOf(active) >= items.indexOf(shown.item) ? 1 : -1
|
|
164
|
+
});
|
|
165
|
+
return /* @__PURE__ */ jsx("span", {
|
|
166
|
+
className: cn("flex min-w-0 overflow-hidden", active && activeClassName, className),
|
|
167
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
168
|
+
className: "truncate motion-safe:animate-fd-roll-in",
|
|
169
|
+
style: { "--fd-roll": shown.roll },
|
|
170
|
+
children: active ? active.title : fallback
|
|
171
|
+
}, active?.url)
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function TOCProgress({ size = 16, ...props }) {
|
|
175
|
+
const value = useTOCSelector(selectProgress);
|
|
176
|
+
const circle = {
|
|
177
|
+
cx: size / 2,
|
|
178
|
+
cy: size / 2,
|
|
179
|
+
r: size / 2 - 1.5,
|
|
180
|
+
fill: "none",
|
|
181
|
+
strokeWidth: 1.5
|
|
182
|
+
};
|
|
183
|
+
const circumference = 2 * Math.PI * circle.r;
|
|
184
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
185
|
+
role: "progressbar",
|
|
186
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
187
|
+
width: size,
|
|
188
|
+
height: size,
|
|
189
|
+
"aria-valuenow": value,
|
|
190
|
+
"aria-valuemin": 0,
|
|
191
|
+
"aria-valuemax": 1,
|
|
192
|
+
...props,
|
|
193
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
194
|
+
...circle,
|
|
195
|
+
className: "stroke-current/25"
|
|
196
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
197
|
+
...circle,
|
|
198
|
+
stroke: "currentColor",
|
|
199
|
+
strokeLinecap: "round",
|
|
200
|
+
strokeDasharray: circumference,
|
|
201
|
+
strokeDashoffset: circumference * (1 - value),
|
|
202
|
+
transform: `rotate(-90 ${circle.cx} ${circle.cy})`,
|
|
203
|
+
className: "transition-[stroke-dashoffset] duration-300"
|
|
204
|
+
})]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { TOC, TOCDropdown, TOCPopover, TOCProvider };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
//#region src/layouts/spacious/slots/actions.d.ts
|
|
3
|
+
/** AI chat, language switcher and icon links move into the options menu on smaller viewports */
|
|
4
|
+
export declare function HeaderActions({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
5
|
+
//#endregion
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "../../../components/ui/button.js";
|
|
4
|
+
import { useI18n } from "../../../contexts/i18n.js";
|
|
5
|
+
import { LinkItem } from "../../shared/client.js";
|
|
6
|
+
import { useSpaciousLayout } from "../index.js";
|
|
7
|
+
import Link from "fumadocs-core/link";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ArrowUpRightIcon, CheckIcon, ChevronDownIcon, ChevronsUpDownIcon, EllipsisIcon, LanguagesIcon, MessageCircleIcon, MonitorIcon, MoonIcon, SunIcon, SunMoonIcon } from "lucide-react";
|
|
10
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
11
|
+
import { useTheme } from "next-themes";
|
|
12
|
+
import { flushSync } from "react-dom";
|
|
13
|
+
import { Menu } from "@base-ui/react/menu";
|
|
14
|
+
//#region src/layouts/spacious/slots/actions.tsx
|
|
15
|
+
const popupClass = "flex flex-col max-h-(--available-height) overflow-y-auto rounded-2xl border bg-fd-popover text-sm text-fd-popover-foreground shadow-lg outline-none origin-(--transform-origin) transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] data-starting-style:opacity-0 data-starting-style:scale-95 data-ending-style:opacity-0 data-ending-style:scale-[0.97] data-ending-style:duration-100 motion-reduce:transition-none";
|
|
16
|
+
const itemClass = "flex w-full min-h-9 items-center gap-3 rounded-lg px-2.5 py-1.5 text-start outline-none transition-colors duration-100 data-highlighted:bg-fd-accent data-highlighted:text-fd-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0";
|
|
17
|
+
function IconLinks({ className }) {
|
|
18
|
+
const { menuItems } = useSpaciousLayout();
|
|
19
|
+
return menuItems.map((item, i) => item.type === "icon" && /* @__PURE__ */ jsx(LinkItem, {
|
|
20
|
+
item,
|
|
21
|
+
"aria-label": item.label,
|
|
22
|
+
className: cn(buttonVariants({
|
|
23
|
+
variant: "ghost",
|
|
24
|
+
size: "icon-sm"
|
|
25
|
+
}), className),
|
|
26
|
+
children: item.icon
|
|
27
|
+
}, i));
|
|
28
|
+
}
|
|
29
|
+
/** AI chat, language switcher and icon links move into the options menu on smaller viewports */
|
|
30
|
+
function HeaderActions({ className, ...props }) {
|
|
31
|
+
const { slots, props: { aiChat } } = useSpaciousLayout();
|
|
32
|
+
const t = useTranslations({ note: "AI chat button" });
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
34
|
+
className: cn("flex items-center gap-0.5 rounded-lg bg-fd-background", className),
|
|
35
|
+
...props,
|
|
36
|
+
children: [
|
|
37
|
+
aiChat && /* @__PURE__ */ jsxs("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
"aria-pressed": aiChat.open,
|
|
40
|
+
className: cn(buttonVariants({ variant: "ghost" }), "h-7.5 gap-1.5 px-2 max-lg:hidden", aiChat.open ? "bg-fd-accent text-fd-accent-foreground" : "text-fd-muted-foreground"),
|
|
41
|
+
onClick: () => aiChat.onOpenChange(!aiChat.open),
|
|
42
|
+
children: [/* @__PURE__ */ jsx(MessageCircleIcon, { className: "size-4" }), t("Ask AI")]
|
|
43
|
+
}),
|
|
44
|
+
slots.languageSelect && /* @__PURE__ */ jsxs(slots.languageSelect.root, {
|
|
45
|
+
className: "h-7.5 gap-1.5 px-2 text-fd-muted-foreground max-lg:hidden",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(LanguagesIcon, { className: "size-4" }),
|
|
48
|
+
/* @__PURE__ */ jsx(slots.languageSelect.text, {}),
|
|
49
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3.5 transition-transform in-data-popup-open:rotate-180" })
|
|
50
|
+
]
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(IconLinks, { className: "text-fd-muted-foreground max-lg:hidden" }),
|
|
53
|
+
/* @__PURE__ */ jsx(OptionsMenu, {})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function OptionsMenu() {
|
|
58
|
+
const { props: { aiChat }, slots, menuItems } = useSpaciousLayout();
|
|
59
|
+
const t = useTranslations();
|
|
60
|
+
const iconLinks = menuItems.filter((item) => item.type === "icon");
|
|
61
|
+
if (!aiChat && !slots.themeSwitch && !slots.languageSelect && iconLinks.length === 0) return;
|
|
62
|
+
return /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
|
|
63
|
+
"aria-label": t("Options", { note: "aria-label" }),
|
|
64
|
+
className: cn(buttonVariants({
|
|
65
|
+
variant: "ghost",
|
|
66
|
+
size: "icon-sm"
|
|
67
|
+
}), "text-fd-muted-foreground data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground", !slots.themeSwitch && "lg:hidden"),
|
|
68
|
+
children: /* @__PURE__ */ jsx(EllipsisIcon, {})
|
|
69
|
+
}), /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
70
|
+
align: "end",
|
|
71
|
+
sideOffset: 8,
|
|
72
|
+
positionMethod: "fixed",
|
|
73
|
+
className: "z-50",
|
|
74
|
+
children: /* @__PURE__ */ jsxs(Menu.Popup, {
|
|
75
|
+
className: cn(popupClass, "w-64 *:not-first:border-t"),
|
|
76
|
+
children: [
|
|
77
|
+
(aiChat || slots.themeSwitch) && /* @__PURE__ */ jsxs("div", {
|
|
78
|
+
className: "flex flex-col p-1",
|
|
79
|
+
children: [aiChat && /* @__PURE__ */ jsxs(Menu.Item, {
|
|
80
|
+
className: cn(itemClass, "lg:hidden"),
|
|
81
|
+
onClick: () => aiChat.onOpenChange(!aiChat.open),
|
|
82
|
+
children: [/* @__PURE__ */ jsx(MessageCircleIcon, { className: "text-fd-muted-foreground" }), t("Ask AI", { note: "AI chat button" })]
|
|
83
|
+
}), slots.themeSwitch && /* @__PURE__ */ jsxs("div", {
|
|
84
|
+
className: "flex items-center gap-3 py-1 ps-2.5 pe-1",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsx(SunMoonIcon, { className: "size-4 text-fd-muted-foreground" }),
|
|
87
|
+
/* @__PURE__ */ jsx("span", {
|
|
88
|
+
"aria-hidden": true,
|
|
89
|
+
className: "flex-1",
|
|
90
|
+
children: t("Theme", { note: "site menu" })
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx(ThemeSegments, {})
|
|
93
|
+
]
|
|
94
|
+
})]
|
|
95
|
+
}),
|
|
96
|
+
slots.languageSelect && /* @__PURE__ */ jsx(Languages$1, { className: "lg:hidden" }),
|
|
97
|
+
iconLinks.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: "flex flex-col p-1 lg:hidden",
|
|
99
|
+
children: iconLinks.map((item, i) => /* @__PURE__ */ jsxs(Menu.LinkItem, {
|
|
100
|
+
closeOnClick: true,
|
|
101
|
+
render: /* @__PURE__ */ jsx(Link, {
|
|
102
|
+
href: item.url,
|
|
103
|
+
external: item.external
|
|
104
|
+
}),
|
|
105
|
+
className: itemClass,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "flex items-center justify-center size-4",
|
|
109
|
+
children: item.icon
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: "flex-1",
|
|
113
|
+
children: item.text
|
|
114
|
+
}),
|
|
115
|
+
item.external && /* @__PURE__ */ jsx(ArrowUpRightIcon, { className: "text-fd-muted-foreground" })
|
|
116
|
+
]
|
|
117
|
+
}, i))
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
}) })] });
|
|
122
|
+
}
|
|
123
|
+
function Languages$1({ className }) {
|
|
124
|
+
const { locale, locales = [], onChange } = useI18n();
|
|
125
|
+
const t = useTranslations({ note: "language switcher" });
|
|
126
|
+
return /* @__PURE__ */ jsx("div", {
|
|
127
|
+
className: cn("p-1", className),
|
|
128
|
+
children: /* @__PURE__ */ jsxs(Menu.SubmenuRoot, { children: [/* @__PURE__ */ jsxs(Menu.SubmenuTrigger, {
|
|
129
|
+
className: cn(itemClass, "data-popup-open:bg-fd-accent"),
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsx(LanguagesIcon, { className: "text-fd-muted-foreground" }),
|
|
132
|
+
/* @__PURE__ */ jsx("span", {
|
|
133
|
+
className: "flex-1 whitespace-nowrap",
|
|
134
|
+
children: t("Language")
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ jsx("span", {
|
|
137
|
+
className: "truncate text-fd-muted-foreground",
|
|
138
|
+
children: locales.find((item) => item.locale === locale)?.name
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx(ChevronsUpDownIcon, { className: "size-3.5! text-fd-muted-foreground" })
|
|
141
|
+
]
|
|
142
|
+
}), /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
143
|
+
sideOffset: 8,
|
|
144
|
+
alignOffset: -4,
|
|
145
|
+
positionMethod: "fixed",
|
|
146
|
+
className: "z-50",
|
|
147
|
+
children: /* @__PURE__ */ jsx(Menu.Popup, {
|
|
148
|
+
className: cn(popupClass, "min-w-44 p-1"),
|
|
149
|
+
children: /* @__PURE__ */ jsx(Menu.RadioGroup, {
|
|
150
|
+
value: locale,
|
|
151
|
+
onValueChange: (value) => onChange?.(value),
|
|
152
|
+
children: locales.map((item) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
|
|
153
|
+
value: item.locale,
|
|
154
|
+
closeOnClick: true,
|
|
155
|
+
className: itemClass,
|
|
156
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
157
|
+
className: "flex-1",
|
|
158
|
+
children: item.name
|
|
159
|
+
}), /* @__PURE__ */ jsx(Menu.RadioItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "text-fd-primary" }) })]
|
|
160
|
+
}, item.locale))
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
}) })] })
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const themes = [
|
|
167
|
+
[
|
|
168
|
+
"system",
|
|
169
|
+
MonitorIcon,
|
|
170
|
+
"0deg"
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
"light",
|
|
174
|
+
SunIcon,
|
|
175
|
+
"-90deg"
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
"dark",
|
|
179
|
+
MoonIcon,
|
|
180
|
+
"40deg"
|
|
181
|
+
]
|
|
182
|
+
];
|
|
183
|
+
function ThemeSegments() {
|
|
184
|
+
const { theme, setTheme } = useTheme();
|
|
185
|
+
const t = useTranslations({ note: "theme switcher" });
|
|
186
|
+
const labels = {
|
|
187
|
+
light: t("Light", { note: "aria-label" }),
|
|
188
|
+
dark: t("Dark", { note: "aria-label" }),
|
|
189
|
+
system: t("System", { note: "aria-label" })
|
|
190
|
+
};
|
|
191
|
+
const index = themes.findIndex(([key]) => key === theme);
|
|
192
|
+
function onPick(e, turn) {
|
|
193
|
+
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
194
|
+
e.currentTarget.firstElementChild?.animate([{
|
|
195
|
+
rotate: turn,
|
|
196
|
+
scale: .6
|
|
197
|
+
}, {
|
|
198
|
+
rotate: "0deg",
|
|
199
|
+
scale: 1
|
|
200
|
+
}], {
|
|
201
|
+
duration: 520,
|
|
202
|
+
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return /* @__PURE__ */ jsxs(Menu.RadioGroup, {
|
|
206
|
+
value: theme,
|
|
207
|
+
onValueChange: (value) => document.startViewTransition?.(() => flushSync(() => setTheme(value))) ?? setTheme(value),
|
|
208
|
+
"aria-label": t("Toggle Theme", { note: "aria-label" }),
|
|
209
|
+
className: "relative flex rounded-full border bg-fd-secondary p-0.5",
|
|
210
|
+
children: [index !== -1 && /* @__PURE__ */ jsx("span", {
|
|
211
|
+
"aria-hidden": true,
|
|
212
|
+
className: "absolute top-0.5 start-0.5 size-7 rounded-full bg-fd-background shadow-sm ring-1 ring-fd-border translate-x-[calc(var(--index)*100%)] rtl:-translate-x-[calc(var(--index)*100%)] transition-[translate] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",
|
|
213
|
+
style: { "--index": index }
|
|
214
|
+
}), themes.map(([key, Icon, turn]) => /* @__PURE__ */ jsx(Menu.RadioItem, {
|
|
215
|
+
value: key,
|
|
216
|
+
"aria-label": labels[key],
|
|
217
|
+
className: cn("relative flex items-center justify-center size-7 rounded-full outline-none transition-colors duration-150 hover:text-fd-foreground focus-visible:ring-2 focus-visible:ring-fd-ring data-highlighted:text-fd-foreground [&_svg]:size-3.5", key === theme ? "text-fd-foreground" : "text-fd-muted-foreground data-highlighted:bg-fd-accent"),
|
|
218
|
+
onClick: (e) => onPick(e, turn),
|
|
219
|
+
children: /* @__PURE__ */ jsx(Icon, {})
|
|
220
|
+
}, key))]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
export { HeaderActions };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { buttonVariants } from "../../../components/ui/button.js";
|
|
4
|
+
import { SidebarTrigger } from "../../../components/sidebar/base.js";
|
|
5
|
+
import { useSpaciousLayout } from "../index.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { SidebarIcon } from "lucide-react";
|
|
8
|
+
//#region src/layouts/spacious/slots/header.tsx
|
|
9
|
+
/** the mobile navbar */
|
|
10
|
+
function Header({ className, ...props }) {
|
|
11
|
+
const { slots } = useSpaciousLayout();
|
|
12
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
13
|
+
id: "nd-subnav",
|
|
14
|
+
className: cn("sticky top-(--fd-banner-height,0px) z-30 [grid-area:header] flex items-center h-(--fd-header-height) ps-4 pe-2.5 bg-fd-card [anchor-name:--fd-top-bar] md:hidden", className),
|
|
15
|
+
...props,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(slots.navTitle, { className: "inline-flex items-center gap-2.5 me-auto font-semibold" }),
|
|
18
|
+
slots.searchTrigger && /* @__PURE__ */ jsx(slots.searchTrigger.sm, {
|
|
19
|
+
hideIfDisabled: true,
|
|
20
|
+
className: "p-2"
|
|
21
|
+
}),
|
|
22
|
+
/* @__PURE__ */ jsx(SidebarTrigger, {
|
|
23
|
+
className: buttonVariants({
|
|
24
|
+
variant: "ghost",
|
|
25
|
+
size: "icon-sm",
|
|
26
|
+
className: "p-2"
|
|
27
|
+
}),
|
|
28
|
+
children: /* @__PURE__ */ jsx(SidebarIcon, {})
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Header };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SidebarProviderProps as SidebarProviderProps$1, base_d_exports } from "../../../components/sidebar/base.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/layouts/spacious/slots/sidebar.d.ts
|
|
4
|
+
export type SidebarProviderProps = SidebarProviderProps$1;
|
|
5
|
+
export type SidebarProps = ComponentProps<'aside'>;
|
|
6
|
+
export declare function SidebarProvider(props: SidebarProviderProps): import("react").JSX.Element;
|
|
7
|
+
export declare function Sidebar({ className, ...props }: SidebarProps): import("react").JSX.Element | undefined;
|
|
8
|
+
export declare function SidebarDrawer(): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|