@ubx/docs-ui 0.9.0 → 0.10.0
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/Header.js +2 -1
- package/dist/MobileNav.d.ts +5 -0
- package/dist/MobileNav.js +41 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/Header.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Link from "next/link";
|
|
3
3
|
import { ThemeToggle } from "./ThemeToggle";
|
|
4
|
+
import { MobileNav } from "./MobileNav";
|
|
4
5
|
export function Header({ nav, tabs, activeTab, mobileMenu, search, showThemeToggle = true, githubUrl, }) {
|
|
5
6
|
return (_jsxs("header", { className: "border-b border-border bg-background", children: [_jsxs("div", { className: "relative mx-auto flex max-w-7xl items-center gap-3 px-6 py-4", children: [mobileMenu, _jsxs(Link, { href: "/", className: "flex shrink-0 items-center", children: [_jsx("img", { src: "/logo/logo.png", alt: "ubx", className: "logo-light h-6 w-auto" }), _jsx("img", { src: "/logo/logo-dark.png", alt: "ubx", className: "logo-dark h-6 w-auto" })] }), _jsx("div", { className: "flex-1" }), _jsx("nav", { className: "absolute left-1/2 hidden -translate-x-1/2 items-center gap-5 md:flex", children: nav.map((item) => {
|
|
6
7
|
const className = item.current
|
|
7
8
|
? "text-sm text-primary"
|
|
8
9
|
: "text-sm text-foreground-muted hover:text-primary";
|
|
9
10
|
return item.href.startsWith("/") ? (_jsx(Link, { href: item.href, className: className, children: item.label }, item.label)) : (_jsx("a", { href: item.href, className: className, children: item.label }, item.label));
|
|
10
|
-
}) }), search ? _jsx("div", { className: "w-40 shrink-0 sm:w-56 lg:w-64", children: search }) : null, githubUrl ? (_jsxs("a", { href: githubUrl, className: "hidden shrink-0 items-center gap-
|
|
11
|
+
}) }), search ? _jsx("div", { className: "w-40 shrink-0 sm:w-56 lg:w-64", children: search }) : null, githubUrl ? (_jsxs("a", { href: githubUrl, className: "hidden shrink-0 items-center gap-2 rounded-full bg-primary px-4 py-[7px] text-sm text-primary-foreground transition-opacity hover:opacity-90 sm:flex", children: [_jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z" }) }), "Star us on GitHub"] })) : null, showThemeToggle ? _jsx(ThemeToggle, {}) : null, _jsx(MobileNav, { nav: nav, githubUrl: githubUrl })] }), tabs && tabs.length > 0 ? (_jsx("div", { className: "mx-auto max-w-7xl px-6", children: _jsx("nav", { className: "flex gap-6 overflow-x-auto", children: tabs.map((tab) => {
|
|
11
12
|
// Prefix match, so /concepts/ledger keeps the Concepts tab
|
|
12
13
|
// lit rather than only the exact section index.
|
|
13
14
|
const active = activeTab === tab.href || activeTab?.startsWith(tab.href + "/");
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
// The header's destination nav is `hidden md:flex`, so below 768px it was
|
|
6
|
+
// simply gone. Measured on all three sites: navDisplay "none", and the
|
|
7
|
+
// only visible header link was the logo. There was no route to Install,
|
|
8
|
+
// Documentation, Tutorials, Providers or Blog on a phone, anywhere.
|
|
9
|
+
//
|
|
10
|
+
// Same two-state open/close as MobileSidebarToggle, and for the same
|
|
11
|
+
// reason: closing flips `visible` immediately so the transition can play,
|
|
12
|
+
// and the drawer only leaves the DOM once it has had time to finish.
|
|
13
|
+
const TRANSITION_MS = 200;
|
|
14
|
+
export function MobileNav({ nav, githubUrl }) {
|
|
15
|
+
const [mounted, setMounted] = useState(false);
|
|
16
|
+
const [visible, setVisible] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!mounted)
|
|
19
|
+
return;
|
|
20
|
+
// Escape closes it. A drawer with no keyboard exit is a trap for
|
|
21
|
+
// anyone not using a pointer.
|
|
22
|
+
const onKey = (e) => {
|
|
23
|
+
if (e.key === "Escape")
|
|
24
|
+
close();
|
|
25
|
+
};
|
|
26
|
+
document.addEventListener("keydown", onKey);
|
|
27
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
28
|
+
}, [mounted]);
|
|
29
|
+
function open() {
|
|
30
|
+
setMounted(true);
|
|
31
|
+
requestAnimationFrame(() => requestAnimationFrame(() => setVisible(true)));
|
|
32
|
+
}
|
|
33
|
+
function close() {
|
|
34
|
+
setVisible(false);
|
|
35
|
+
setTimeout(() => setMounted(false), TRANSITION_MS);
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: open, "aria-label": "Open navigation", "aria-expanded": mounted, className: "flex h-9 w-9 shrink-0 items-center justify-center rounded text-foreground-muted hover:bg-surface hover:text-primary md:hidden", children: _jsx("svg", { viewBox: "0 0 20 20", width: "20", height: "20", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M3 5.5h14M3 10h14M3 14.5h14", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), mounted && (_jsxs("div", { role: "dialog", "aria-modal": "true", "aria-label": "Navigation", className: "fixed inset-0 z-50 md:hidden", children: [_jsx("button", { type: "button", "aria-label": "Close navigation", onClick: close, className: "absolute inset-0 bg-foreground/40 transition-opacity duration-200 motion-reduce:transition-none " +
|
|
38
|
+
(visible ? "opacity-100" : "opacity-0") }), _jsxs("div", { className: "absolute inset-y-0 right-0 flex w-72 max-w-[85vw] flex-col gap-1 overflow-y-auto bg-background p-5 shadow-lg " +
|
|
39
|
+
"transition-transform duration-200 ease-out motion-reduce:transition-none " +
|
|
40
|
+
(visible ? "translate-x-0" : "translate-x-full"), children: [_jsx("button", { type: "button", onClick: close, "aria-label": "Close navigation", className: "mb-3 flex h-8 w-8 items-center justify-center self-end rounded text-foreground-muted hover:bg-surface hover:text-primary", children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }) }), nav.map((item) => item.href.startsWith("/") ? (_jsx(Link, { href: item.href, onClick: close, className: item.current ? "py-2 text-primary" : "py-2 text-foreground-muted hover:text-primary", children: item.label }, item.label)) : (_jsx("a", { href: item.href, onClick: close, className: item.current ? "py-2 text-primary" : "py-2 text-foreground-muted hover:text-primary", children: item.label }, item.label))), githubUrl ? (_jsx("a", { href: githubUrl, className: "mt-3 rounded-full bg-primary px-4 py-2 text-center text-sm text-primary-foreground", children: "Star us on GitHub" })) : null] })] }))] }));
|
|
41
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED