@dreamlake/dockit 0.2.1 → 0.2.3
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.
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useState, useLayoutEffect } from "react";
|
|
2
|
+
import { useMemo, useRef, useState, useLayoutEffect } from "react";
|
|
3
3
|
import { usePageContext } from "vike-react/usePageContext";
|
|
4
|
-
import { tabForUrl, TABS } from "../lib/tabs.js";
|
|
4
|
+
import { tabForUrl, TABS, urlInTab } from "../lib/tabs.js";
|
|
5
|
+
import { pages } from "../lib/navigation.js";
|
|
6
|
+
import { useHiddenToggle } from "../lib/use-hidden-toggle.js";
|
|
5
7
|
const SPRING = "cubic-bezier(0.4, 0.7, 0.3, 1)";
|
|
6
8
|
function TabStrip() {
|
|
7
9
|
const { urlPathname } = usePageContext();
|
|
8
10
|
const activeTab = tabForUrl(urlPathname);
|
|
11
|
+
const [showHidden] = useHiddenToggle();
|
|
12
|
+
const visibleTabs = useMemo(() => {
|
|
13
|
+
if (showHidden) return TABS;
|
|
14
|
+
return TABS.filter(
|
|
15
|
+
(tab) => tab.id === activeTab || pages.some((p) => !p.hidden && urlInTab(p.path, tab.id))
|
|
16
|
+
);
|
|
17
|
+
}, [showHidden, activeTab]);
|
|
9
18
|
const containerRef = useRef(null);
|
|
10
19
|
const linkRefs = useRef({});
|
|
11
20
|
const [hovered, setHovered] = useState(null);
|
|
@@ -35,7 +44,7 @@ function TabStrip() {
|
|
|
35
44
|
window.addEventListener("resize", onResize);
|
|
36
45
|
return () => window.removeEventListener("resize", onResize);
|
|
37
46
|
}, [targetTab]);
|
|
38
|
-
if (
|
|
47
|
+
if (visibleTabs.length === 0) return null;
|
|
39
48
|
return /* @__PURE__ */ jsxs(
|
|
40
49
|
"ol",
|
|
41
50
|
{
|
|
@@ -45,7 +54,7 @@ function TabStrip() {
|
|
|
45
54
|
style: { height: "100%" },
|
|
46
55
|
onMouseLeave: () => setHovered(null),
|
|
47
56
|
children: [
|
|
48
|
-
|
|
57
|
+
visibleTabs.map((tab) => {
|
|
49
58
|
const isActive = tab.id === activeTab;
|
|
50
59
|
return /* @__PURE__ */ jsx(
|
|
51
60
|
"li",
|
|
@@ -19,30 +19,22 @@ function HiddenRevealChip() {
|
|
|
19
19
|
onClick: () => setShow(false),
|
|
20
20
|
"aria-label": "Dev mode on — hidden pages are visible. Click to hide again.",
|
|
21
21
|
title: "Dev mode on — hidden pages are visible (Cmd+Shift+D to toggle)",
|
|
22
|
+
className: "text-doc-template-warn",
|
|
22
23
|
style: {
|
|
23
24
|
display: "inline-flex",
|
|
24
25
|
alignItems: "center",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
padding: "2px 7px",
|
|
27
|
+
border: "1px solid color-mix(in srgb, var(--color-doc-template-warn) 45%, transparent)",
|
|
28
|
+
borderRadius: 4,
|
|
29
|
+
background: "var(--color-doc-template-warn-soft)",
|
|
30
|
+
fontFamily: "var(--font-doc-template-mono)",
|
|
31
|
+
fontSize: 10,
|
|
32
|
+
fontWeight: 600,
|
|
33
|
+
letterSpacing: "0.08em",
|
|
34
|
+
lineHeight: 1.4,
|
|
31
35
|
cursor: "pointer"
|
|
32
36
|
},
|
|
33
|
-
children:
|
|
34
|
-
"span",
|
|
35
|
-
{
|
|
36
|
-
"aria-hidden": true,
|
|
37
|
-
style: {
|
|
38
|
-
width: 8,
|
|
39
|
-
height: 8,
|
|
40
|
-
borderRadius: 999,
|
|
41
|
-
background: "var(--color-doc-template-warn)",
|
|
42
|
-
boxShadow: "0 0 0 3px var(--color-doc-template-warn-soft)"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
)
|
|
37
|
+
children: "DEV"
|
|
46
38
|
}
|
|
47
39
|
);
|
|
48
40
|
}
|
|
@@ -17,6 +17,8 @@ async function onRenderHtml(pageContext) {
|
|
|
17
17
|
const themeScript = dangerouslySkipEscape(
|
|
18
18
|
`<script>(function(){try{var raw=localStorage.getItem('doc:theme');var t=raw;try{t=JSON.parse(raw);}catch(_){}var d=document.documentElement;if(t==='light'){d.setAttribute('data-theme','light');}else if(t==='dark'){d.setAttribute('data-theme','dark');}else{d.setAttribute('data-theme',window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');}}catch(e){}})()<\/script>`
|
|
19
19
|
);
|
|
20
|
+
const headScripts = (siteConfig.headScripts ?? []).filter((src) => /^(https?:)?\/\/[^"'<>\s]+$|^\/[^"'<>\s]*$/.test(src)).map((src) => `<script src="${src}" defer><\/script>`).join("\n ");
|
|
21
|
+
const headScriptTags = headScripts ? dangerouslySkipEscape(headScripts) : "";
|
|
20
22
|
return {
|
|
21
23
|
documentHtml: escapeInject`<!DOCTYPE html>
|
|
22
24
|
<html lang="en">
|
|
@@ -24,6 +26,7 @@ async function onRenderHtml(pageContext) {
|
|
|
24
26
|
<meta charset="UTF-8" />
|
|
25
27
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
26
28
|
${themeScript}
|
|
29
|
+
${headScriptTags}
|
|
27
30
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
28
31
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
|
29
32
|
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap" rel="stylesheet" />
|
package/dist/site-config.d.ts
CHANGED
|
@@ -64,6 +64,11 @@ export interface SiteConfig {
|
|
|
64
64
|
* per-page imports. Same-name entries override the library's. Typed
|
|
65
65
|
* loosely to avoid coupling this module to React. */
|
|
66
66
|
mdxComponents?: Record<string, unknown>;
|
|
67
|
+
/** External script URLs injected as `<script src defer>` into every page's
|
|
68
|
+
* head at SSR time (e.g. the Studio design-integration bridge). URLs only
|
|
69
|
+
* — http(s), protocol-relative, or absolute-path; anything else is
|
|
70
|
+
* silently dropped. */
|
|
71
|
+
headScripts?: string[];
|
|
67
72
|
}
|
|
68
73
|
export declare const siteConfig: SiteConfig;
|
|
69
74
|
/** Merge site-provided values into the singleton (mutates in place). */
|
package/package.json
CHANGED