@rspress/core 0.0.12 → 0.1.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/index.js +34 -26
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +2 -0
- package/dist/loader.js +24 -49
- package/dist/loader.js.map +1 -1
- package/dist/runtime/App.d.ts +8 -0
- package/dist/runtime/Content.d.ts +6 -0
- package/dist/runtime/NoSSR.d.ts +4 -0
- package/dist/runtime/clientEntry.d.ts +1 -0
- package/dist/runtime/hooks.d.ts +22 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/ssrEntry.d.ts +6 -0
- package/dist/runtime/tsconfig.json +9 -0
- package/dist/runtime/utils.d.ts +6 -0
- package/dist/theme/bundle.css +85 -52
- package/dist/theme/bundle.d.ts +24 -2
- package/dist/theme/bundle.js +1425 -897
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +14 -16
- package/src/runtime/global.d.ts +49 -0
- package/src/runtime/tsconfig.json +9 -0
- package/src/theme-default/components/LocalSideBar/{index.module.scss → index.scss} +6 -5
- package/src/theme-default/components/LocalSideBar/index.tsx +4 -4
- package/src/theme-default/components/PackageManagerTabs/icons/Bun.tsx +101 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Npm.tsx +16 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Pnpm.tsx +22 -0
- package/src/theme-default/components/PackageManagerTabs/icons/Yarn.tsx +18 -0
- package/src/theme-default/components/PackageManagerTabs/index.scss +5 -0
- package/src/theme-default/components/PackageManagerTabs/index.tsx +110 -0
- package/src/theme-default/components/Search/SearchPanel.tsx +339 -0
- package/src/theme-default/components/Search/index.tsx +6 -326
- package/src/theme-default/components/Tabs/index.module.scss +1 -0
- package/src/theme-default/components/Tabs/index.tsx +30 -41
- package/src/theme-default/components/Toc/index.css +18 -0
- package/src/theme-default/components/Toc/index.tsx +42 -0
- package/src/theme-default/index.ts +8 -7
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +1 -1
- package/src/theme-default/layout/DocLayout/index.module.scss +6 -3
- package/src/theme-default/layout/DocLayout/index.tsx +9 -7
- package/src/theme-default/logic/useAppearance.ts +0 -1
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
ReactElement,
|
|
4
4
|
ReactNode,
|
|
5
5
|
useContext,
|
|
6
|
+
useState,
|
|
6
7
|
} from 'react';
|
|
7
|
-
import { Tab as HeadlessTab } from '@headlessui/react';
|
|
8
8
|
import { TabDataContext } from '../../logic/TabDataContext';
|
|
9
9
|
import styles from './index.module.scss';
|
|
10
10
|
|
|
@@ -68,48 +68,37 @@ export function Tabs(props: TabsProps): ReactElement {
|
|
|
68
68
|
return false;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
const [activeIndex, setActiveIndex] = useState(defaultIndex);
|
|
71
72
|
|
|
72
73
|
return (
|
|
73
74
|
<div className={styles.container}>
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'disabled' in item &&
|
|
91
|
-
item.disabled,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<HeadlessTab
|
|
96
|
-
key={index}
|
|
97
|
-
disabled={disabled}
|
|
98
|
-
className={({ selected }) =>
|
|
99
|
-
`${styles.tab} ${
|
|
100
|
-
selected ? styles.selected : styles.notSelected
|
|
101
|
-
}`
|
|
75
|
+
<div className={tabContainerClassName}>
|
|
76
|
+
{tabValues.length ? (
|
|
77
|
+
<div className={styles.tabList}>
|
|
78
|
+
{tabValues.map((item, index) => {
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
82
|
+
key={index}
|
|
83
|
+
className={`${styles.tab} ${
|
|
84
|
+
activeIndex === index ? styles.selected : styles.notSelected
|
|
85
|
+
}`}
|
|
86
|
+
onClick={() => {
|
|
87
|
+
onChange?.(index);
|
|
88
|
+
setActiveIndex(index);
|
|
89
|
+
if (groupId) {
|
|
90
|
+
setTabData({ ...tabData, [groupId]: index });
|
|
102
91
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{renderTab(item)}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
})}
|
|
98
|
+
</div>
|
|
99
|
+
) : null}
|
|
100
|
+
</div>
|
|
101
|
+
<div>{children[activeIndex]}</div>
|
|
113
102
|
</div>
|
|
114
103
|
);
|
|
115
104
|
}
|
|
@@ -119,8 +108,8 @@ export function Tab({
|
|
|
119
108
|
...props
|
|
120
109
|
}: ComponentPropsWithRef<'div'>): ReactElement {
|
|
121
110
|
return (
|
|
122
|
-
<
|
|
111
|
+
<div {...props} className="rounded px-2">
|
|
123
112
|
{children}
|
|
124
|
-
</
|
|
113
|
+
</div>
|
|
125
114
|
);
|
|
126
115
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.toc-link {
|
|
2
|
+
padding-bottom: 1px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.toc-link-text {
|
|
6
|
+
padding: 4px 12px;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
text-overflow: ellipsis;
|
|
10
|
+
transition: all 0.2s ease-in-out;
|
|
11
|
+
border-radius: 10px 0 0 10px;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
line-height: 1.75rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.toc-link-text:hover {
|
|
17
|
+
background-color: var(--rp-c-bg-mute);
|
|
18
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Header } from '@rspress/shared';
|
|
2
|
+
import { usePageData } from '@/runtime';
|
|
3
|
+
import { scrollToTarget } from '@/theme-default';
|
|
4
|
+
import './index.css';
|
|
5
|
+
|
|
6
|
+
const TocItem = (header: Header) => {
|
|
7
|
+
return (
|
|
8
|
+
<li key={header.id} className={'py-1'}>
|
|
9
|
+
<a
|
|
10
|
+
href={`#${header.id}`}
|
|
11
|
+
className={
|
|
12
|
+
'toc-link transition-all duration-300 hover:text-text-1 text-text-2 block underline underline-offset-2'
|
|
13
|
+
}
|
|
14
|
+
style={{
|
|
15
|
+
marginLeft: header.depth * 12,
|
|
16
|
+
}}
|
|
17
|
+
onClick={e => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
window.location.hash = header.id;
|
|
20
|
+
const target = document.getElementById(header.id);
|
|
21
|
+
if (target) {
|
|
22
|
+
scrollToTarget(target, false);
|
|
23
|
+
}
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<span className={'toc-link-text block'}>{header.text}</span>
|
|
27
|
+
</a>
|
|
28
|
+
</li>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function Toc() {
|
|
33
|
+
const { page } = usePageData();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ul>
|
|
37
|
+
{page.toc.map(item => (
|
|
38
|
+
<TocItem key={item.id} {...item} />
|
|
39
|
+
))}
|
|
40
|
+
</ul>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -2,14 +2,15 @@ import { NotFoundLayout } from './layout/NotFountLayout';
|
|
|
2
2
|
import { Layout } from './layout/Layout';
|
|
3
3
|
import { HomeLayout } from './layout/HomeLayout';
|
|
4
4
|
import { setup } from './logic';
|
|
5
|
-
import { Nav } from './components/Nav';
|
|
6
|
-
import { Search } from './components/Search';
|
|
7
|
-
import { Tab, Tabs } from './components/Tabs';
|
|
8
|
-
import { Button } from './components/Button';
|
|
9
|
-
import { Link } from './components/Link';
|
|
10
|
-
import { HomeFooter } from './components/HomeFooter';
|
|
11
5
|
|
|
12
|
-
export { Nav
|
|
6
|
+
export { Nav } from './components/Nav';
|
|
7
|
+
export { Search, SearchPanel } from './components/Search';
|
|
8
|
+
export { Tab, Tabs } from './components/Tabs';
|
|
9
|
+
export { Button } from './components/Button';
|
|
10
|
+
export { Link } from './components/Link';
|
|
11
|
+
export { HomeFooter } from './components/HomeFooter';
|
|
12
|
+
export { Toc } from './components/Toc';
|
|
13
|
+
export { PackageManagerTabs } from './components/PackageManagerTabs';
|
|
13
14
|
|
|
14
15
|
export default {
|
|
15
16
|
Layout,
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
width: calc(100% - var(--rp-sidebar-width));
|
|
35
35
|
padding: 48px 48px 72px 0;
|
|
36
36
|
|
|
37
|
-
:global(.rspress-doc)
|
|
37
|
+
:global(.rspress-doc),
|
|
38
|
+
:global(.rspress-doc-footer) {
|
|
38
39
|
width: 100%;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
|
|
53
54
|
.content {
|
|
54
55
|
padding: 48px 0 72px 0;
|
|
55
|
-
:global(.rspress-doc)
|
|
56
|
+
:global(.rspress-doc),
|
|
57
|
+
:global(.rspress-doc-footer) {
|
|
56
58
|
padding: 0 48px;
|
|
57
59
|
box-sizing: content-box;
|
|
58
60
|
width: calc(100vw - var(--rp-aside-width) - var(--rp-sidebar-width));
|
|
@@ -67,7 +69,8 @@
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
.content {
|
|
70
|
-
:global(.rspress-doc)
|
|
72
|
+
:global(.rspress-doc),
|
|
73
|
+
:global(.rspress-doc-footer) {
|
|
71
74
|
box-sizing: content-box;
|
|
72
75
|
width: calc(100vw - var(--rp-sidebar-width) - var(--rp-aside-width));
|
|
73
76
|
padding: 0
|
|
@@ -83,13 +83,15 @@ export function DocLayout(props: DocLayoutProps) {
|
|
|
83
83
|
{isOverviewPage ? (
|
|
84
84
|
<Overview />
|
|
85
85
|
) : (
|
|
86
|
-
<div
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
<div>
|
|
87
|
+
<div className="rspress-doc">
|
|
88
|
+
<TabDataContext.Provider value={{ tabData, setTabData }}>
|
|
89
|
+
<MDXProvider components={getCustomMDXComponent()}>
|
|
90
|
+
<Content />
|
|
91
|
+
</MDXProvider>
|
|
92
|
+
</TabDataContext.Provider>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="rspress-doc-footer">
|
|
93
95
|
{beforeDocFooter}
|
|
94
96
|
{hasFooter && <DocFooter />}
|
|
95
97
|
</div>
|
|
@@ -19,7 +19,6 @@ const setClass = (dark: boolean): void => {
|
|
|
19
19
|
const updateAppearance = (): void => {
|
|
20
20
|
const disableDarkMode = siteData.themeConfig.darkMode === false;
|
|
21
21
|
if (disableDarkMode) {
|
|
22
|
-
setClass(false);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
// We set the MODERN_THEME as a global variable to determine whether the theme is dark or light.
|