@hanzo/ui 5.3.26 → 5.3.29
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/content/index.ts +26 -0
- package/dist/util/index.js +6 -0
- package/dist/util/index.mjs +6 -1
- package/docs/_registry/index.ts +426 -0
- package/docs/_registry/layout/docs-min.tsx +197 -0
- package/docs/_registry/layout/page-min.tsx +128 -0
- package/docs/components/accordion.tsx +118 -0
- package/docs/components/banner.tsx +144 -0
- package/docs/components/callout.tsx +112 -0
- package/docs/components/card.tsx +52 -0
- package/docs/components/codeblock.tsx +258 -0
- package/docs/components/dialog/search-algolia.tsx +132 -0
- package/docs/components/dialog/search-default.tsx +131 -0
- package/docs/components/dialog/search-orama.tsx +143 -0
- package/docs/components/dialog/search.tsx +529 -0
- package/docs/components/dynamic-codeblock.tsx +129 -0
- package/docs/components/files.tsx +81 -0
- package/docs/components/github-info.tsx +107 -0
- package/docs/components/heading.tsx +33 -0
- package/docs/components/image-zoom.css +77 -0
- package/docs/components/image-zoom.tsx +58 -0
- package/docs/components/index.ts +7 -0
- package/docs/components/inline-toc.tsx +48 -0
- package/docs/components/sidebar/base.tsx +451 -0
- package/docs/components/sidebar/link-item.tsx +65 -0
- package/docs/components/sidebar/page-tree.tsx +113 -0
- package/docs/components/sidebar/tabs/dropdown.tsx +109 -0
- package/docs/components/sidebar/tabs/index.tsx +89 -0
- package/docs/components/steps.tsx +9 -0
- package/docs/components/tabs.tsx +203 -0
- package/docs/components/toc/clerk.tsx +173 -0
- package/docs/components/toc/default.tsx +57 -0
- package/docs/components/toc/index.tsx +136 -0
- package/docs/components/type-table.tsx +174 -0
- package/docs/components/ui/accordion.tsx +88 -0
- package/docs/components/ui/button.tsx +28 -0
- package/docs/components/ui/collapsible.tsx +42 -0
- package/docs/components/ui/navigation-menu.tsx +83 -0
- package/docs/components/ui/popover.tsx +32 -0
- package/docs/components/ui/scroll-area.tsx +59 -0
- package/docs/components/ui/tabs.tsx +145 -0
- package/docs/contexts/i18n.tsx +56 -0
- package/docs/contexts/search.tsx +165 -0
- package/docs/contexts/tree.tsx +65 -0
- package/docs/css/black.css +39 -0
- package/docs/css/catppuccin.css +49 -0
- package/docs/css/colors/index.css +51 -0
- package/docs/css/dusk.css +47 -0
- package/docs/css/layouts/docs.css +1 -0
- package/docs/css/layouts/home.css +1 -0
- package/docs/css/layouts/notebook.css +1 -0
- package/docs/css/neutral.css +7 -0
- package/docs/css/ocean.css +48 -0
- package/docs/css/preset.css +305 -0
- package/docs/css/purple.css +39 -0
- package/docs/css/shadcn.css +36 -0
- package/docs/css/shiki.css +90 -0
- package/docs/css/solar.css +75 -0
- package/docs/css/style.css +9 -0
- package/docs/css/vitepress.css +77 -0
- package/docs/i18n.tsx +30 -0
- package/docs/icons.tsx +354 -0
- package/docs/layouts/docs/client.tsx +129 -0
- package/docs/layouts/docs/index.tsx +321 -0
- package/docs/layouts/docs/page/client.tsx +376 -0
- package/docs/layouts/docs/page/index.tsx +251 -0
- package/docs/layouts/docs/sidebar.tsx +265 -0
- package/docs/layouts/home/client.tsx +375 -0
- package/docs/layouts/home/index.tsx +51 -0
- package/docs/layouts/home/navbar.tsx +55 -0
- package/docs/layouts/notebook/client.tsx +281 -0
- package/docs/layouts/notebook/index.tsx +461 -0
- package/docs/layouts/notebook/page/client.tsx +375 -0
- package/docs/layouts/notebook/page/index.tsx +251 -0
- package/docs/layouts/notebook/sidebar.tsx +248 -0
- package/docs/layouts/shared/index.tsx +89 -0
- package/docs/layouts/shared/language-toggle.tsx +66 -0
- package/docs/layouts/shared/link-item.tsx +119 -0
- package/docs/layouts/shared/search-toggle.tsx +78 -0
- package/docs/layouts/shared/theme-toggle.tsx +86 -0
- package/docs/mdx.server.tsx +37 -0
- package/docs/mdx.tsx +97 -0
- package/docs/og.tsx +101 -0
- package/docs/page.tsx +85 -0
- package/docs/provider/base.tsx +173 -0
- package/docs/provider/next.tsx +23 -0
- package/docs/provider/react-router.tsx +23 -0
- package/docs/provider/tanstack.tsx +23 -0
- package/docs/provider/waku.tsx +23 -0
- package/docs/source.ts +3 -0
- package/docs/theme/typography/LICENSE +21 -0
- package/docs/theme/typography/index.ts +201 -0
- package/docs/theme/typography/styles.ts +449 -0
- package/docs/utils/cn.ts +1 -0
- package/docs/utils/is-active.ts +23 -0
- package/docs/utils/merge-refs.ts +15 -0
- package/docs/utils/use-copy-button.ts +39 -0
- package/docs/utils/use-footer-items.ts +27 -0
- package/docs/utils/use-is-scroll-top.ts +21 -0
- package/package.json +4 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
use,
|
|
7
|
+
useEffectEvent,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import * as Primitive from '@radix-ui/react-tabs';
|
|
14
|
+
import { mergeRefs } from '@/utils/merge-refs';
|
|
15
|
+
|
|
16
|
+
type ChangeListener = (v: string) => void;
|
|
17
|
+
const listeners = new Map<string, Set<ChangeListener>>();
|
|
18
|
+
|
|
19
|
+
export interface TabsProps extends ComponentProps<typeof Primitive.Tabs> {
|
|
20
|
+
/**
|
|
21
|
+
* Identifier for Sharing value of tabs
|
|
22
|
+
*/
|
|
23
|
+
groupId?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enable persistent
|
|
27
|
+
*/
|
|
28
|
+
persist?: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* If true, updates the URL hash based on the tab's id
|
|
32
|
+
*/
|
|
33
|
+
updateAnchor?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const TabsContext = createContext<{
|
|
37
|
+
valueToIdMap: Map<string, string>;
|
|
38
|
+
} | null>(null);
|
|
39
|
+
|
|
40
|
+
function useTabContext() {
|
|
41
|
+
const ctx = use(TabsContext);
|
|
42
|
+
if (!ctx) throw new Error('You must wrap your component in <Tabs>');
|
|
43
|
+
return ctx;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const TabsList = Primitive.TabsList;
|
|
47
|
+
|
|
48
|
+
export const TabsTrigger = Primitive.TabsTrigger;
|
|
49
|
+
|
|
50
|
+
export function Tabs({
|
|
51
|
+
ref,
|
|
52
|
+
groupId,
|
|
53
|
+
persist = false,
|
|
54
|
+
updateAnchor = false,
|
|
55
|
+
defaultValue,
|
|
56
|
+
value: _value,
|
|
57
|
+
onValueChange: _onValueChange,
|
|
58
|
+
...props
|
|
59
|
+
}: TabsProps) {
|
|
60
|
+
const tabsRef = useRef<HTMLDivElement>(null);
|
|
61
|
+
const valueToIdMap = useMemo(() => new Map<string, string>(), []);
|
|
62
|
+
const [value, setValue] =
|
|
63
|
+
_value === undefined
|
|
64
|
+
? // eslint-disable-next-line react-hooks/rules-of-hooks -- not supposed to change controlled/uncontrolled
|
|
65
|
+
useState(defaultValue)
|
|
66
|
+
: // eslint-disable-next-line react-hooks/rules-of-hooks -- not supposed to change controlled/uncontrolled
|
|
67
|
+
[_value, useEffectEvent((v: string) => _onValueChange?.(v))];
|
|
68
|
+
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
if (!groupId) return;
|
|
71
|
+
let previous = sessionStorage.getItem(groupId);
|
|
72
|
+
if (persist) previous ??= localStorage.getItem(groupId);
|
|
73
|
+
if (previous) setValue(previous);
|
|
74
|
+
|
|
75
|
+
const groupListeners = listeners.get(groupId) ?? new Set();
|
|
76
|
+
groupListeners.add(setValue);
|
|
77
|
+
listeners.set(groupId, groupListeners);
|
|
78
|
+
return () => {
|
|
79
|
+
groupListeners.delete(setValue);
|
|
80
|
+
};
|
|
81
|
+
}, [groupId, persist, setValue]);
|
|
82
|
+
|
|
83
|
+
useLayoutEffect(() => {
|
|
84
|
+
const hash = window.location.hash.slice(1);
|
|
85
|
+
if (!hash) return;
|
|
86
|
+
|
|
87
|
+
for (const [value, id] of valueToIdMap.entries()) {
|
|
88
|
+
if (id === hash) {
|
|
89
|
+
setValue(value);
|
|
90
|
+
tabsRef.current?.scrollIntoView();
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [setValue, valueToIdMap]);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Primitive.Tabs
|
|
98
|
+
ref={mergeRefs(ref, tabsRef)}
|
|
99
|
+
value={value}
|
|
100
|
+
onValueChange={(v: string) => {
|
|
101
|
+
if (updateAnchor) {
|
|
102
|
+
const id = valueToIdMap.get(v);
|
|
103
|
+
|
|
104
|
+
if (id) {
|
|
105
|
+
window.history.replaceState(null, '', `#${id}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (groupId) {
|
|
110
|
+
const groupListeners = listeners.get(groupId);
|
|
111
|
+
if (groupListeners) {
|
|
112
|
+
for (const listener of groupListeners) listener(v);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
sessionStorage.setItem(groupId, v);
|
|
116
|
+
if (persist) localStorage.setItem(groupId, v);
|
|
117
|
+
} else {
|
|
118
|
+
setValue(v);
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
{...props}
|
|
122
|
+
>
|
|
123
|
+
<TabsContext value={useMemo(() => ({ valueToIdMap }), [valueToIdMap])}>
|
|
124
|
+
{props.children}
|
|
125
|
+
</TabsContext>
|
|
126
|
+
</Primitive.Tabs>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function TabsContent({
|
|
131
|
+
value,
|
|
132
|
+
...props
|
|
133
|
+
}: ComponentProps<typeof Primitive.TabsContent>) {
|
|
134
|
+
const { valueToIdMap } = useTabContext();
|
|
135
|
+
|
|
136
|
+
if (props.id) {
|
|
137
|
+
valueToIdMap.set(value, props.id);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Primitive.TabsContent value={value} {...props}>
|
|
142
|
+
{props.children}
|
|
143
|
+
</Primitive.TabsContent>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface Translations {
|
|
5
|
+
search: string;
|
|
6
|
+
searchNoResult: string;
|
|
7
|
+
|
|
8
|
+
toc: string;
|
|
9
|
+
tocNoHeadings: string;
|
|
10
|
+
|
|
11
|
+
lastUpdate: string;
|
|
12
|
+
chooseLanguage: string;
|
|
13
|
+
nextPage: string;
|
|
14
|
+
previousPage: string;
|
|
15
|
+
chooseTheme: string;
|
|
16
|
+
editOnGithub: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LocaleItem {
|
|
20
|
+
name: string;
|
|
21
|
+
locale: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface I18nContextType {
|
|
25
|
+
locale?: string;
|
|
26
|
+
onChange?: (v: string) => void;
|
|
27
|
+
text: Translations;
|
|
28
|
+
locales?: LocaleItem[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const defaultTranslations: Translations = {
|
|
32
|
+
search: 'Search',
|
|
33
|
+
searchNoResult: 'No results found',
|
|
34
|
+
toc: 'On this page',
|
|
35
|
+
tocNoHeadings: 'No Headings',
|
|
36
|
+
lastUpdate: 'Last updated on',
|
|
37
|
+
chooseLanguage: 'Choose a language',
|
|
38
|
+
nextPage: 'Next Page',
|
|
39
|
+
previousPage: 'Previous Page',
|
|
40
|
+
chooseTheme: 'Theme',
|
|
41
|
+
editOnGithub: 'Edit on GitHub',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const I18nContext = createContext<I18nContextType>({
|
|
45
|
+
text: defaultTranslations,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function I18nLabel(props: { label: keyof Translations }): string {
|
|
49
|
+
const { text } = useI18n();
|
|
50
|
+
|
|
51
|
+
return text[props.label];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function useI18n(): I18nContextType {
|
|
55
|
+
return useContext(I18nContext);
|
|
56
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
type ComponentType,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useState,
|
|
8
|
+
createContext,
|
|
9
|
+
use,
|
|
10
|
+
useEffectEvent,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
interface HotKey {
|
|
14
|
+
display: ReactNode;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Key code or a function determining whether the key is pressed.
|
|
18
|
+
*/
|
|
19
|
+
key: string | ((e: KeyboardEvent) => boolean);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SharedProps {
|
|
23
|
+
open: boolean;
|
|
24
|
+
onOpenChange: (open: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SearchLink = [name: string, href: string];
|
|
28
|
+
|
|
29
|
+
export interface TagItem {
|
|
30
|
+
name: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SearchProviderProps {
|
|
35
|
+
/**
|
|
36
|
+
* Preload search dialog before opening it
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue `true`
|
|
39
|
+
*/
|
|
40
|
+
preload?: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Custom links to be displayed if search is empty
|
|
44
|
+
*/
|
|
45
|
+
links?: SearchLink[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Hotkeys for triggering search dialog
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue Meta/Ctrl + K
|
|
51
|
+
*/
|
|
52
|
+
hotKey?: HotKey[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Replace default search dialog, allowing you to use other solutions such as Algolia Search
|
|
56
|
+
*
|
|
57
|
+
* It receives the `open` and `onOpenChange` prop, can be lazy loaded with `next/dynamic`
|
|
58
|
+
*/
|
|
59
|
+
SearchDialog: ComponentType<SharedProps>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Additional props to the dialog
|
|
63
|
+
*/
|
|
64
|
+
options?: Partial<SharedProps & Record<string, unknown>>;
|
|
65
|
+
|
|
66
|
+
children?: ReactNode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface SearchContextType {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
hotKey: HotKey[];
|
|
72
|
+
setOpenSearch: (value: boolean) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const SearchContext = createContext<SearchContextType>({
|
|
76
|
+
enabled: false,
|
|
77
|
+
hotKey: [],
|
|
78
|
+
setOpenSearch: () => undefined,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export function useSearchContext(): SearchContextType {
|
|
82
|
+
return use(SearchContext);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function MetaOrControl() {
|
|
86
|
+
const [key, setKey] = useState('⌘');
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const isWindows = window.navigator.userAgent.includes('Windows');
|
|
90
|
+
|
|
91
|
+
if (isWindows) setKey('Ctrl');
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
return key;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function SearchProvider({
|
|
98
|
+
SearchDialog,
|
|
99
|
+
children,
|
|
100
|
+
preload = true,
|
|
101
|
+
options,
|
|
102
|
+
hotKey = [
|
|
103
|
+
{
|
|
104
|
+
key: (e) => e.metaKey || e.ctrlKey,
|
|
105
|
+
display: <MetaOrControl />,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: 'k',
|
|
109
|
+
display: 'K',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
links,
|
|
113
|
+
}: SearchProviderProps) {
|
|
114
|
+
const [isOpen, setIsOpen] = useState(preload ? false : undefined);
|
|
115
|
+
const onKeyDown = useEffectEvent((e: KeyboardEvent) => {
|
|
116
|
+
if (
|
|
117
|
+
hotKey.every((v) =>
|
|
118
|
+
typeof v.key === 'string' ? e.key === v.key : v.key(e),
|
|
119
|
+
)
|
|
120
|
+
) {
|
|
121
|
+
setIsOpen((open) => !open);
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
window.addEventListener('keydown', onKeyDown);
|
|
128
|
+
return () => {
|
|
129
|
+
window.removeEventListener('keydown', onKeyDown);
|
|
130
|
+
};
|
|
131
|
+
}, [hotKey]);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<SearchContext
|
|
135
|
+
value={useMemo(
|
|
136
|
+
() => ({
|
|
137
|
+
enabled: true,
|
|
138
|
+
hotKey,
|
|
139
|
+
setOpenSearch: setIsOpen,
|
|
140
|
+
}),
|
|
141
|
+
[hotKey],
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
{isOpen !== undefined && (
|
|
145
|
+
<SearchDialog
|
|
146
|
+
open={isOpen}
|
|
147
|
+
onOpenChange={setIsOpen}
|
|
148
|
+
// @ts-expect-error -- insert prop for official UIs
|
|
149
|
+
links={links}
|
|
150
|
+
{...options}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
{children}
|
|
154
|
+
</SearchContext>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Show children only when search is enabled via React Context
|
|
160
|
+
*/
|
|
161
|
+
export function SearchOnly({ children }: { children: ReactNode }) {
|
|
162
|
+
const search = useSearchContext();
|
|
163
|
+
|
|
164
|
+
if (search.enabled) return children;
|
|
165
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import type * as PageTree from '@hanzo/docs-core/page-tree';
|
|
3
|
+
import { usePathname } from '@hanzo/docs-core/framework';
|
|
4
|
+
import { type ReactNode, useMemo, useRef, createContext, use } from 'react';
|
|
5
|
+
import { searchPath } from '@hanzo/docs-core/breadcrumb';
|
|
6
|
+
|
|
7
|
+
type MakeRequired<O, K extends keyof O> = Omit<O, K> & Pick<Required<O>, K>;
|
|
8
|
+
|
|
9
|
+
interface TreeContextType {
|
|
10
|
+
root: MakeRequired<PageTree.Root | PageTree.Folder, '$id'>;
|
|
11
|
+
full: PageTree.Root;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TreeContext = createContext<TreeContextType | null>(null);
|
|
15
|
+
const PathContext = createContext<PageTree.Node[]>([]);
|
|
16
|
+
|
|
17
|
+
export function TreeContextProvider({
|
|
18
|
+
tree: rawTree,
|
|
19
|
+
children,
|
|
20
|
+
}: {
|
|
21
|
+
tree: PageTree.Root;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}) {
|
|
24
|
+
const nextIdRef = useRef(0);
|
|
25
|
+
const pathname = usePathname();
|
|
26
|
+
|
|
27
|
+
// I found that object-typed props passed from a RSC will be re-constructed, hence breaking all hooks' dependencies
|
|
28
|
+
// using the id here to make sure this never happens
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
const tree = useMemo(() => rawTree, [rawTree.$id ?? rawTree]);
|
|
31
|
+
const path = useMemo(() => {
|
|
32
|
+
return (
|
|
33
|
+
searchPath(tree.children, pathname) ??
|
|
34
|
+
(tree.fallback ? searchPath(tree.fallback.children, pathname) : null) ??
|
|
35
|
+
[]
|
|
36
|
+
);
|
|
37
|
+
}, [tree, pathname]);
|
|
38
|
+
|
|
39
|
+
const root =
|
|
40
|
+
path.findLast((item) => item.type === 'folder' && item.root) ?? tree;
|
|
41
|
+
root.$id ??= String(nextIdRef.current++);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<TreeContext
|
|
45
|
+
value={useMemo(
|
|
46
|
+
() => ({ root, full: tree }) as TreeContextType,
|
|
47
|
+
[root, tree],
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
<PathContext value={path}>{children}</PathContext>
|
|
51
|
+
</TreeContext>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function useTreePath(): PageTree.Node[] {
|
|
56
|
+
return use(PathContext);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function useTreeContext(): TreeContextType {
|
|
60
|
+
const ctx = use(TreeContext);
|
|
61
|
+
|
|
62
|
+
if (!ctx)
|
|
63
|
+
throw new Error('You must wrap this component under <DocsLayout />');
|
|
64
|
+
return ctx;
|
|
65
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import './colors/index.css';
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-fd-background: hsl(0, 0%, 98%);
|
|
5
|
+
--color-fd-foreground: hsl(0, 0%, 3.9%);
|
|
6
|
+
--color-fd-muted: hsl(0, 0%, 96.1%);
|
|
7
|
+
--color-fd-muted-foreground: hsl(0, 0%, 45.1%);
|
|
8
|
+
--color-fd-popover: hsl(0, 0%, 100%);
|
|
9
|
+
--color-fd-popover-foreground: hsl(0, 0%, 15.1%);
|
|
10
|
+
--color-fd-card: hsl(0, 0%, 99.7%);
|
|
11
|
+
--color-fd-card-foreground: hsl(0, 0%, 3.9%);
|
|
12
|
+
--color-fd-border: hsla(0, 0%, 60%, 0.2);
|
|
13
|
+
--color-fd-primary: hsl(0, 0%, 9%);
|
|
14
|
+
--color-fd-primary-foreground: hsl(0, 0%, 98%);
|
|
15
|
+
--color-fd-secondary: hsl(0, 0%, 96.1%);
|
|
16
|
+
--color-fd-secondary-foreground: hsl(0, 0%, 9%);
|
|
17
|
+
--color-fd-accent: hsl(0, 0%, 94.1%);
|
|
18
|
+
--color-fd-accent-foreground: hsl(0, 0%, 9%);
|
|
19
|
+
--color-fd-ring: hsl(0, 0%, 63.9%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dark {
|
|
23
|
+
--color-fd-background: hsl(0, 0%, 2%);
|
|
24
|
+
--color-fd-foreground: hsl(0, 0%, 98%);
|
|
25
|
+
--color-fd-muted: hsl(0, 0%, 8%);
|
|
26
|
+
--color-fd-muted-foreground: hsl(0, 0%, 60%);
|
|
27
|
+
--color-fd-popover: hsl(0, 0%, 4%);
|
|
28
|
+
--color-fd-popover-foreground: hsl(0, 0%, 98%);
|
|
29
|
+
--color-fd-card: hsl(0, 0%, 4%);
|
|
30
|
+
--color-fd-card-foreground: hsl(0, 0%, 98%);
|
|
31
|
+
--color-fd-border: hsl(0, 0%, 50%, 0.2);
|
|
32
|
+
--color-fd-primary: hsl(0, 0%, 98%);
|
|
33
|
+
--color-fd-primary-foreground: hsl(0, 0%, 9%);
|
|
34
|
+
--color-fd-secondary: hsl(0, 0%, 12.9%);
|
|
35
|
+
--color-fd-secondary-foreground: hsl(0, 0%, 98%);
|
|
36
|
+
--color-fd-accent: hsl(0, 0%, 15%);
|
|
37
|
+
--color-fd-accent-foreground: hsl(0, 0%, 100%);
|
|
38
|
+
--color-fd-ring: hsl(0, 0%, 34.9%);
|
|
39
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@import './colors/index.css';
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-fd-popover: hsl(220, 22%, 92%);
|
|
5
|
+
--color-fd-popover-foreground: hsl(234, 16%, 35%);
|
|
6
|
+
--color-fd-secondary-foreground: hsl(234, 16%, 35%);
|
|
7
|
+
--color-fd-border: hsl(223, 16%, 83%);
|
|
8
|
+
--color-fd-primary: hsl(266, 85%, 58%);
|
|
9
|
+
--color-fd-primary-foreground: hsl(220, 22%, 92%);
|
|
10
|
+
--color-fd-muted: hsl(220, 22%, 92%);
|
|
11
|
+
--color-fd-card: hsl(220, 22%, 92%);
|
|
12
|
+
--color-fd-accent: hsl(223, 16%, 83%);
|
|
13
|
+
--color-fd-accent-foreground: hsl(234, 16%, 35%);
|
|
14
|
+
--color-fd-card-foreground: hsl(234, 16%, 35%);
|
|
15
|
+
--color-fd-muted-foreground: hsl(233, 10%, 47%);
|
|
16
|
+
--color-fd-foreground: hsl(234, 16%, 35%);
|
|
17
|
+
--color-fd-secondary: hsl(220, 22%, 92%);
|
|
18
|
+
--color-fd-background: hsl(220, 23%, 95%);
|
|
19
|
+
--color-fd-ring: hsl(267, 84%, 81%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dark {
|
|
23
|
+
--color-fd-background: hsl(240, 21%, 15%);
|
|
24
|
+
--color-fd-foreground: hsl(226, 64%, 88%);
|
|
25
|
+
--color-fd-ring: hsl(267, 84%, 81%);
|
|
26
|
+
--color-fd-primary: hsl(267, 84%, 81%);
|
|
27
|
+
--color-fd-popover: hsl(240, 23%, 9%);
|
|
28
|
+
--color-fd-card: hsl(240, 21%, 12%);
|
|
29
|
+
--color-fd-muted: hsl(240, 21%, 12%);
|
|
30
|
+
--color-fd-border: hsl(237, 16%, 23%);
|
|
31
|
+
--color-fd-accent: hsl(237, 16%, 23%);
|
|
32
|
+
--color-fd-secondary: hsl(240, 21%, 12%);
|
|
33
|
+
--color-fd-primary-foreground: hsl(240, 23%, 9%);
|
|
34
|
+
--color-fd-card-foreground: hsl(226, 64%, 88%);
|
|
35
|
+
--color-fd-secondary-foreground: hsl(226, 64%, 88%);
|
|
36
|
+
--color-fd-popover-foreground: hsl(226, 64%, 88%);
|
|
37
|
+
--color-fd-accent-foreground: hsl(226, 64%, 88%);
|
|
38
|
+
--color-fd-muted-foreground: hsl(228, 24%, 72%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#nd-sidebar {
|
|
42
|
+
--color-fd-secondary: hsl(223, 16%, 83%);
|
|
43
|
+
--color-fd-muted: hsl(223, 16%, 83%);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dark #nd-sidebar {
|
|
47
|
+
--color-fd-secondary: hsl(237, 16%, 23%);
|
|
48
|
+
--color-fd-muted: hsl(237, 16%, 23%);
|
|
49
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@theme {
|
|
2
|
+
--color-fd-background: hsl(0, 0%, 96%);
|
|
3
|
+
--color-fd-foreground: hsl(0, 0%, 3.9%);
|
|
4
|
+
--color-fd-muted: hsl(0, 0%, 96.1%);
|
|
5
|
+
--color-fd-muted-foreground: hsl(0, 0%, 45.1%);
|
|
6
|
+
--color-fd-popover: hsl(0, 0%, 98%);
|
|
7
|
+
--color-fd-popover-foreground: hsl(0, 0%, 15.1%);
|
|
8
|
+
--color-fd-card: hsl(0, 0%, 94.7%);
|
|
9
|
+
--color-fd-card-foreground: hsl(0, 0%, 3.9%);
|
|
10
|
+
--color-fd-border: hsla(0, 0%, 80%, 50%);
|
|
11
|
+
--color-fd-primary: hsl(0, 0%, 9%);
|
|
12
|
+
--color-fd-primary-foreground: hsl(0, 0%, 98%);
|
|
13
|
+
--color-fd-secondary: hsl(0, 0%, 93.1%);
|
|
14
|
+
--color-fd-secondary-foreground: hsl(0, 0%, 9%);
|
|
15
|
+
--color-fd-accent: hsla(0, 0%, 82%, 50%);
|
|
16
|
+
--color-fd-accent-foreground: hsl(0, 0%, 9%);
|
|
17
|
+
--color-fd-ring: hsl(0, 0%, 63.9%);
|
|
18
|
+
--color-fd-overlay: hsla(0, 0%, 0%, 0.2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dark {
|
|
22
|
+
--color-fd-background: hsl(0, 0%, 7.04%);
|
|
23
|
+
--color-fd-foreground: hsl(0, 0%, 92%);
|
|
24
|
+
--color-fd-muted: hsl(0, 0%, 12.9%);
|
|
25
|
+
--color-fd-muted-foreground: hsla(0, 0%, 70%, 0.8);
|
|
26
|
+
--color-fd-popover: hsl(0, 0%, 11.6%);
|
|
27
|
+
--color-fd-popover-foreground: hsl(0, 0%, 86.9%);
|
|
28
|
+
--color-fd-card: hsl(0, 0%, 9.8%);
|
|
29
|
+
--color-fd-card-foreground: hsl(0, 0%, 98%);
|
|
30
|
+
--color-fd-border: hsla(0, 0%, 40%, 20%);
|
|
31
|
+
--color-fd-primary: hsl(0, 0%, 98%);
|
|
32
|
+
--color-fd-primary-foreground: hsl(0, 0%, 9%);
|
|
33
|
+
--color-fd-secondary: hsl(0, 0%, 12.9%);
|
|
34
|
+
--color-fd-secondary-foreground: hsl(0, 0%, 92%);
|
|
35
|
+
--color-fd-accent: hsla(0, 0%, 40.9%, 30%);
|
|
36
|
+
--color-fd-accent-foreground: hsl(0, 0%, 90%);
|
|
37
|
+
--color-fd-ring: hsl(0, 0%, 54.9%);
|
|
38
|
+
--color-fd-overlay: hsla(0, 0%, 0%, 0.2);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@theme static {
|
|
42
|
+
--color-fd-info: oklch(62.3% 0.214 259.815);
|
|
43
|
+
--color-fd-warning: oklch(76.9% 0.188 70.08);
|
|
44
|
+
--color-fd-error: oklch(63.7% 0.237 25.331);
|
|
45
|
+
--color-fd-success: oklch(72.3% 0.219 149.579);
|
|
46
|
+
--color-fd-idea: oklch(70.5% 0.209 60.849);
|
|
47
|
+
--color-fd-diff-remove: rgba(200, 10, 100, 0.12);
|
|
48
|
+
--color-fd-diff-remove-symbol: rgb(230, 10, 100);
|
|
49
|
+
--color-fd-diff-add: rgba(14, 180, 100, 0.1);
|
|
50
|
+
--color-fd-diff-add-symbol: rgb(10, 200, 100);
|
|
51
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@import './colors/index.css';
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-fd-background: hsl(250, 20%, 92%);
|
|
5
|
+
--color-fd-primary: hsl(340, 40%, 48%);
|
|
6
|
+
--color-fd-border: hsl(240, 40%, 90%);
|
|
7
|
+
--color-fd-accent: hsl(250, 30%, 90%);
|
|
8
|
+
--color-fd-accent-foreground: hsl(250, 20%, 20%);
|
|
9
|
+
--color-fd-muted: hsl(240, 30%, 94%);
|
|
10
|
+
--color-fd-muted-foreground: hsl(240, 10%, 50%);
|
|
11
|
+
--color-fd-foreground: hsl(220, 20%, 30%);
|
|
12
|
+
--color-fd-secondary: hsl(250, 40%, 94%);
|
|
13
|
+
--color-fd-secondary-foreground: hsl(240, 40%, 10%);
|
|
14
|
+
--color-fd-card: hsl(250, 20%, 92%);
|
|
15
|
+
--color-fd-card-foreground: hsl(250, 20%, 20%);
|
|
16
|
+
--color-fd-popover-foreground: hsl(250, 40%, 20%);
|
|
17
|
+
--color-fd-popover: hsl(250, 40%, 96%);
|
|
18
|
+
--color-fd-primary-foreground: hsl(240, 80%, 20%);
|
|
19
|
+
--color-fd-ring: hsl(340, 40%, 48%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dark {
|
|
23
|
+
--color-fd-ring: hsl(340, 100%, 90%);
|
|
24
|
+
--color-fd-primary-foreground: hsl(240, 40%, 4%);
|
|
25
|
+
--color-fd-popover: hsl(240, 20%, 5%);
|
|
26
|
+
--color-fd-popover-foreground: hsl(250, 20%, 90%);
|
|
27
|
+
--color-fd-primary: hsl(340, 100%, 90%);
|
|
28
|
+
--color-fd-border: hsl(220, 15%, 15%);
|
|
29
|
+
--color-fd-background: hsl(220, 15%, 6%);
|
|
30
|
+
--color-fd-foreground: hsl(220, 15%, 87%);
|
|
31
|
+
--color-fd-muted: hsl(220, 20%, 15%);
|
|
32
|
+
--color-fd-muted-foreground: hsl(220, 15%, 60%);
|
|
33
|
+
--color-fd-accent: hsl(250, 20%, 15%);
|
|
34
|
+
--color-fd-secondary: hsl(240, 20%, 15%);
|
|
35
|
+
--color-fd-card-foreground: hsl(240, 15%, 87%);
|
|
36
|
+
--color-fd-card: hsl(240, 20%, 5%);
|
|
37
|
+
--color-fd-secondary-foreground: hsl(250, 20%, 90%);
|
|
38
|
+
--color-fd-accent-foreground: hsl(340, 5%, 90%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#nd-sidebar {
|
|
42
|
+
background-color: hsl(250 20% 90%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dark #nd-sidebar {
|
|
46
|
+
background-color: hsl(240 20% 5%);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source '../../dist/layouts/docs/**/*.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source '../../dist/layouts/home/**/*.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source '../../dist/layouts/notebook/**/*.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@import './colors/index.css';
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-fd-background: hsl(0, 0%, 98%);
|
|
5
|
+
--color-fd-foreground: hsl(0, 0%, 3.9%);
|
|
6
|
+
--color-fd-muted: hsl(220, 90%, 96.1%);
|
|
7
|
+
--color-fd-muted-foreground: hsl(0, 0%, 45.1%);
|
|
8
|
+
--color-fd-popover: hsl(0, 0%, 98%);
|
|
9
|
+
--color-fd-popover-foreground: hsl(0, 0%, 15.1%);
|
|
10
|
+
--color-fd-card: hsl(220, 50%, 98%);
|
|
11
|
+
--color-fd-card-foreground: hsl(0, 0%, 3.9%);
|
|
12
|
+
--color-fd-border: hsl(220, 50%, 89.8%);
|
|
13
|
+
--color-fd-primary: hsl(210, 80%, 20.2%);
|
|
14
|
+
--color-fd-primary-foreground: hsl(0, 0%, 98%);
|
|
15
|
+
--color-fd-secondary: hsl(220, 90%, 96.1%);
|
|
16
|
+
--color-fd-secondary-foreground: hsl(0, 0%, 9%);
|
|
17
|
+
--color-fd-accent: hsl(220, 50%, 94.1%);
|
|
18
|
+
--color-fd-accent-foreground: hsl(0, 0%, 9%);
|
|
19
|
+
--color-fd-ring: hsl(220, 100%, 63.9%);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dark {
|
|
23
|
+
--color-fd-background: hsl(220, 60%, 8%);
|
|
24
|
+
--color-fd-foreground: hsl(220, 60%, 94.5%);
|
|
25
|
+
--color-fd-muted: hsl(220, 50%, 10%);
|
|
26
|
+
--color-fd-muted-foreground: hsl(220, 30%, 65%);
|
|
27
|
+
--color-fd-popover: hsl(220, 50%, 10%);
|
|
28
|
+
--color-fd-popover-foreground: hsl(220, 60%, 94.5%);
|
|
29
|
+
--color-fd-card: hsla(220, 56%, 15%, 0.4);
|
|
30
|
+
--color-fd-card-foreground: hsl(220, 60%, 94.5%);
|
|
31
|
+
--color-fd-border: hsla(220, 50%, 50%, 0.2);
|
|
32
|
+
--color-fd-primary: hsl(205, 100%, 85%);
|
|
33
|
+
--color-fd-primary-foreground: hsl(0, 0%, 9%);
|
|
34
|
+
--color-fd-secondary: hsl(220, 50%, 20%);
|
|
35
|
+
--color-fd-secondary-foreground: hsl(220, 80%, 90%);
|
|
36
|
+
--color-fd-accent: hsl(220, 40%, 20%);
|
|
37
|
+
--color-fd-accent-foreground: hsl(220, 80%, 90%);
|
|
38
|
+
--color-fd-ring: hsl(205, 100%, 85%);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dark body {
|
|
42
|
+
background-image: linear-gradient(
|
|
43
|
+
rgba(5, 105, 255, 0.15),
|
|
44
|
+
transparent 20rem,
|
|
45
|
+
transparent
|
|
46
|
+
);
|
|
47
|
+
background-repeat: no-repeat;
|
|
48
|
+
}
|