@alauda/doom 1.17.4 → 1.17.5

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.
@@ -3,15 +3,15 @@ import { clsx } from 'clsx';
3
3
  import { upperCase } from 'es-toolkit';
4
4
  import { useCallback } from 'react';
5
5
  export const Directive = ({ className, type = 'info', title, children, open, onToggle, }) => {
6
- const rootClassName = clsx('rspress-directive', type, className);
6
+ const rootClassName = clsx('rp-callout', `rp-callout--${type}`, className);
7
7
  const titleNode = title || upperCase(type);
8
- const contentNode = (_jsx("div", { className: "rspress-directive-content", children: children }));
8
+ const contentNode = _jsx("div", { className: "rp-callout__content", children: children });
9
9
  const handleToggle = useCallback((ev) => {
10
10
  onToggle?.(ev.currentTarget.open);
11
11
  }, [onToggle]);
12
12
  if (type === 'details') {
13
- return (_jsxs("details", { className: rootClassName, open: open, onToggle: handleToggle, children: [_jsx("summary", { className: "rspress-directive-title", children: titleNode }), contentNode] }));
13
+ return (_jsxs("details", { className: rootClassName, open: open, onToggle: handleToggle, children: [_jsx("summary", { className: "rp-callout__title", children: titleNode }), contentNode] }));
14
14
  }
15
- return (_jsxs("div", { className: rootClassName, children: [_jsx("div", { className: "rspress-directive-title", children: titleNode }), contentNode] }));
15
+ return (_jsxs("div", { className: rootClassName, children: [_jsx("div", { className: "rp-callout__title", children: titleNode }), contentNode] }));
16
16
  };
17
17
  export default Directive;
@@ -5,7 +5,6 @@ import { DEFAULT_PAGE_EXTENSIONS } from '@rspress/shared/constants';
5
5
  import { clsx } from 'clsx';
6
6
  import virtual from 'doom-@global-virtual';
7
7
  import { useMemo } from 'react';
8
- import classes from '../../../styles/link.module.scss';
9
8
  import { isUnversioned } from '../../shared/helpers.js';
10
9
  import { useIsPrint } from '../hooks/index.js';
11
10
  import { Directive } from './Directive.js';
@@ -34,7 +33,7 @@ const ExternalSiteLink_ = ({ name, href = '', className, ...props }) => {
34
33
  ? site.base
35
34
  : addTrailingSlash(site.base + site.version)) +
36
35
  (lang && lang !== siteData.lang ? addTrailingSlash(lang) : '') +
37
- (hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx(classes.link, 'rp-cursor-pointer', className), ...props }));
36
+ (hash ? `${url}#${hash}` : url), target: "_blank", rel: "noopener noreferrer", className: clsx('rp-link', className), ...props }));
38
37
  };
39
38
  export const ExternalSiteLink = (props) => (_jsx(NoSSR, { children: _jsx(ExternalSiteLink_, { ...props }) }));
40
39
  export default ExternalSiteLink;
@@ -0,0 +1,7 @@
1
+ import type MasonryLayout from 'masonry-layout';
2
+ import { type HTMLAttributes } from 'react';
3
+ export interface MasonryProps extends HTMLAttributes<HTMLDivElement> {
4
+ options?: MasonryLayout.Options;
5
+ }
6
+ export declare const Masonry: ({ options, ...props }: MasonryProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Masonry;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef } from 'react';
3
+ export const Masonry = ({ options, ...props }) => {
4
+ const ref = useRef(null);
5
+ useLayoutEffect(() => {
6
+ if (!ref.current) {
7
+ return;
8
+ }
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
+ const masonry = new (require('masonry-layout'))(ref.current, options);
11
+ return () => {
12
+ masonry.destroy?.();
13
+ };
14
+ }, [options]);
15
+ return _jsx("div", { ref: ref, ...props });
16
+ };
17
+ export default Masonry;
@@ -3,6 +3,7 @@ import { isEqualPath, usePageData, useSidebar } from '@rspress/core/runtime';
3
3
  import { FallbackHeading, Link, renderInlineMarkdown, } from '@rspress/core/theme-original';
4
4
  import { Fragment, useCallback, useMemo } from 'react';
5
5
  import classes from '../../../styles/overview.module.scss';
6
+ import { Masonry } from './Masonry.js';
6
7
  import { findItemByRoutePath, isSidebarDivider, isSidebarSectionHeader, isSingleFile, } from './_utils.js';
7
8
  const getChildLink = (traverseItem) => {
8
9
  if ('link' in traverseItem && traverseItem.link) {
@@ -13,6 +14,10 @@ const getChildLink = (traverseItem) => {
13
14
  }
14
15
  return '';
15
16
  };
17
+ const masonryOptions = {
18
+ itemSelector: `.${classes.overviewGroup}`,
19
+ gutter: 16,
20
+ };
16
21
  // The sidebar data include two types: sidebar item and sidebar group.
17
22
  // In overpage page, we select all the related sidebar groups and show the groups in the page.
18
23
  // In the meantime, some sidebar items also should be shown in the page, we collect them in the group named 'Others' and show them in the page.
@@ -108,6 +113,6 @@ export function Overview(props) {
108
113
  }, [getGroup, overviewSidebarGroups]);
109
114
  const groups = customGroups ?? defaultGroups;
110
115
  return (_jsxs("div", { className: "overview-index doom-overview-index", children: [content, groups.map((group) => (_jsxs(Fragment, { children: [(!title || [title, defaultGroupTitle].includes(group.name)) &&
111
- groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx("div", { className: classes.overviewGroups, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup, children: [_jsx("h3", { children: _jsx(Link, { href: item.link, ...renderInlineMarkdown(item.text) }) }), _jsx("div", { className: classes.overviewDescription, children: item.description }), _jsx("ul", { className: classes.overviewList, children: item.headers?.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]}`, children: _jsx(Link, { href: `${item.link}#${header.id}`, ...renderInlineMarkdown(header.text) }) }, header.id))) })] }, item.link))) })] }, group.name)))] }));
116
+ groups.length === 1 ? (_jsx("h2", { style: { paddingTop: 0 } })) : (_jsx(FallbackHeading, { level: 2, title: group.name })), _jsx(Masonry, { className: classes.overviewGroups, options: masonryOptions, children: group.items.map((item) => (_jsxs("div", { className: classes.overviewGroup, children: [_jsx("h3", { children: _jsx(Link, { href: item.link, ...renderInlineMarkdown(item.text) }) }), item.description && (_jsx("div", { className: classes.overviewDescription, children: item.description })), !item.headers?.length || (_jsx("ul", { className: classes.overviewList, children: item.headers.map((header) => (_jsx("li", { className: `${classes.overviewGroupLi} ${classes[`level${header.depth}`]}`, children: _jsx(Link, { href: `${item.link}#${header.id}`, ...renderInlineMarkdown(header.text) }) }, header.id))) }))] }, item.link))) })] }, group.name)))] }));
112
117
  }
113
118
  export default Overview;
@@ -9,6 +9,7 @@ export * from './JsonViewer.js';
9
9
  export * from './K8sCrd.js';
10
10
  export * from './K8sPermissionTable.js';
11
11
  export * from './Markdown.js';
12
+ export * from './Masonry.js';
12
13
  export * from './Mermaid.js';
13
14
  export * from './OpenAPIPath.js';
14
15
  export * from './OpenAPIRef.js';
@@ -9,6 +9,7 @@ export * from './JsonViewer.js';
9
9
  export * from './K8sCrd.js';
10
10
  export * from './K8sPermissionTable.js';
11
11
  export * from './Markdown.js';
12
+ export * from './Masonry.js';
12
13
  export * from './Mermaid.js';
13
14
  export * from './OpenAPIPath.js';
14
15
  export * from './OpenAPIRef.js';
@@ -1,7 +1,7 @@
1
1
  import { addLeadingSlash, normalizePosixPath, removeTrailingSlash, } from '@rspress/shared';
2
2
  import { UNVERSIONED, UNVERSIONED_PREFIX } from "./constants.js";
3
3
  export const removeBothEndsSlashes = (str) => str?.replace(/^\/|\/$/g, '') || '';
4
- export const getPdfName = (lang, userBase, title) => `${removeBothEndsSlashes(userBase) || title || 'exported'}-${lang}.pdf`;
4
+ export const getPdfName = (lang, userBase, title) => `/${removeBothEndsSlashes(userBase) || title || 'exported'}-${lang}.pdf`;
5
5
  export const isExplicitlyUnversioned = (version) => version === UNVERSIONED || !!version?.startsWith(UNVERSIONED_PREFIX);
6
6
  export const isUnversioned = (version) => !version || isExplicitlyUnversioned(version);
7
7
  export const getUnversionedVersion = (version) => {
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useLang, useSite, withBase } from '@rspress/core/runtime';
3
- import { Layout as OriginalLayout, getCustomMDXComponent, } from '@rspress/core/theme-original';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useLang, useSite } from '@rspress/core/runtime';
3
+ import { Link, Layout as OriginalLayout, getCustomMDXComponent, } from '@rspress/core/theme-original';
4
4
  import virtual from 'doom-@global-virtual';
5
- import { useMemo } from 'react';
5
+ import { useCallback, useMemo, useState } from 'react';
6
6
  import { useLocation } from 'react-router';
7
- import classes from '../../styles/link.module.scss';
8
7
  import { useTranslation } from "../runtime/index.js";
8
+ import { ForceRenderContext } from "./VersionsNav/context.js";
9
9
  import { VersionsNav } from "./VersionsNav/index.js";
10
10
  const X = getCustomMDXComponent();
11
11
  const cleanupUrlPath = (urlPath) => {
@@ -80,7 +80,10 @@ export const Layout = () => {
80
80
  return getClosestSidebar(sidebarItems, pathname);
81
81
  }
82
82
  }, [pathname, siteLang, themeConfig]);
83
- const pdfLink = useMemo(() => found &&
84
- withBase(`${found.exportItem.name ?? found.sidebar.text}-${lang}.pdf`), [found, lang]);
85
- return (_jsx(OriginalLayout, { afterNavMenu: _jsx(VersionsNav, {}), beforeOutline: pdfLink && (_jsx(X.p, { style: { marginBottom: 16 }, children: _jsx("a", { className: classes.link, href: pdfLink, target: "_blank", rel: "noopener noreferrer", children: t('view_docs_as_pdf') }) })) }));
83
+ const pdfLink = useMemo(() => found && `/${found.exportItem.name ?? found.sidebar.text}-${lang}.pdf`, [found, lang]);
84
+ const [render, setRender] = useState(false);
85
+ const forceRender = useCallback(() => {
86
+ setRender((v) => !v);
87
+ }, []);
88
+ return (_jsxs(ForceRenderContext, { value: useMemo(() => ({ value: render, setValue: forceRender }), [forceRender, render]), children: [_jsx(VersionsNav, {}), _jsx(OriginalLayout, { beforeOutline: pdfLink && (_jsx(X.p, { className: "rp-doc", style: { marginBottom: 16 }, children: _jsx(Link, { href: pdfLink, target: "_blank", rel: "noopener noreferrer", children: t('view_docs_as_pdf') }) })) })] }));
86
89
  };
@@ -0,0 +1,2 @@
1
+ import { type LinkProps } from '@rspress/core/theme-original';
2
+ export declare const Link: (props: LinkProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Link as OriginalLink, } from '@rspress/core/theme-original';
3
+ export const Link = (props) => {
4
+ if (typeof location !== 'undefined' &&
5
+ props.href?.startsWith(`${location.protocol}//${location.host}`)) {
6
+ return _jsx("a", { ...props });
7
+ }
8
+ return (_jsx(OriginalLink, { ...props, download:
9
+ // type-coverage:ignore-next-line -- out of control
10
+ props.download == null
11
+ ? props.href?.endsWith('.pdf')
12
+ : // type-coverage:ignore-next-line -- out of control
13
+ props.download }));
14
+ };
@@ -0,0 +1,5 @@
1
+ export declare const ForceRenderContext: import("react").Context<{
2
+ value: boolean;
3
+ setValue: () => void;
4
+ }>;
5
+ export declare const useForceRender: () => () => void;
@@ -0,0 +1,3 @@
1
+ import { createContext, use } from 'react';
2
+ export const ForceRenderContext = createContext(null);
3
+ export const useForceRender = () => use(ForceRenderContext).setValue;
@@ -1,14 +1,13 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { isProduction, NoSSR, useSite, withBase } from '@rspress/core/runtime';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { isProduction, NoSSR, useLocaleSiteData, useSite, } from '@rspress/core/runtime';
3
3
  import {} from '@rspress/shared';
4
4
  import virtual from 'doom-@global-virtual';
5
5
  import { noop } from 'es-toolkit';
6
6
  import { useEffect, useMemo, useState } from 'react';
7
7
  import siteData from 'virtual-site-data';
8
8
  import { parse } from 'yaml';
9
- import { ACP_BASE, getPdfName, getUnversionedVersion, isExplicitlyUnversioned, } from '../../shared/index.js';
10
- import { NavMenuGroup } from './NavMenuGroup.js';
11
- import { NavMenuSingleItem } from './NavMenuSingleItem.js';
9
+ import { ACP_BASE, getPdfName, getUnversionedVersion, isExplicitlyUnversioned, } from "../../shared/index.js";
10
+ import { useForceRender } from "./context.js";
12
11
  import { useLang, useTranslation } from '@alauda/doom/runtime';
13
12
  const LEGACY_VERSIONS = ['3.18.1', '3.18.0', '3.16', '3.14'];
14
13
  const LEGACY_NAV_ITEMS = LEGACY_VERSIONS.map((v) => ({
@@ -21,6 +20,12 @@ if (!isProduction()) {
21
20
  }
22
21
  const VersionsNav_ = () => {
23
22
  const { site } = useSite();
23
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
24
+ const { nav } = useLocaleSiteData();
25
+ const configNav = useMemo(() => (Array.isArray(nav) ? nav : nav.default), [nav]);
26
+ const originalConfigNav = useMemo(() => [...configNav], [configNav]);
27
+ // hack to rerender nav when configNav is changed
28
+ const forceRender = useForceRender();
24
29
  const lang = useLang();
25
30
  const t = useTranslation();
26
31
  const siteTitle = site.originalTitle ?? site.title;
@@ -28,7 +33,7 @@ const VersionsNav_ = () => {
28
33
  if (!virtual.download) {
29
34
  return;
30
35
  }
31
- return withBase(getPdfName(lang, virtual.userBase, siteTitle));
36
+ return getPdfName(lang, virtual.userBase, siteTitle);
32
37
  }, [lang, siteTitle]);
33
38
  const [versionsBase, version] = useMemo(() => {
34
39
  const unversionedVersion = getUnversionedVersion(virtual.version);
@@ -46,37 +51,58 @@ const VersionsNav_ = () => {
46
51
  useEffect(() => {
47
52
  const fetchVersions = async () => {
48
53
  if (versionsBase == null) {
49
- if (!version) {
50
- return;
51
- }
54
+ return;
52
55
  }
53
- else {
54
- const res = await fetch(`${isProduction() ? versionsBase : siteData.base}versions.yaml`);
55
- if (!res.ok) {
56
- return;
57
- }
58
- const text = await res.text();
59
- const versions = parse(text);
60
- if (version && !versions.includes(version)) {
61
- versions.unshift(version);
62
- }
63
- setVersions(versions);
56
+ const res = await fetch(`${isProduction() ? versionsBase : siteData.base}versions.yaml`);
57
+ if (!res.ok) {
58
+ return;
64
59
  }
60
+ const text = await res.text();
61
+ const versions = parse(text);
62
+ if (version && !versions.includes(version)) {
63
+ versions.unshift(version);
64
+ }
65
+ setVersions(versions);
65
66
  };
66
67
  void fetchVersions().catch(noop);
67
68
  }, [version, versionsBase]);
68
- const navItems = useMemo(() => {
69
- const versionItems = versions.map((v) => versionsBase == null
70
- ? { text: v, items: [] }
71
- : { text: v, link: `${versionsBase}${v}/`, activeMatch: v });
72
- if (versionsBase != null &&
73
- ALLOWED_LEGACY_DOMAINS.has(location.hostname) &&
74
- virtual.userBase === ACP_BASE) {
75
- versionItems.push(...LEGACY_NAV_ITEMS);
69
+ const navList = useMemo(() => {
70
+ const navList = [];
71
+ if (downloadLink) {
72
+ navList.push({
73
+ text: t('download_pdf'),
74
+ link: downloadLink,
75
+ });
76
+ }
77
+ if (versionsBase == null) {
78
+ if (version) {
79
+ navList.push({ text: version, items: [] });
80
+ }
76
81
  }
77
- return versionItems;
78
- }, [versionsBase, versions]);
79
- return (_jsxs(_Fragment, { children: [downloadLink && (_jsx(NavMenuSingleItem, { text: t('download_pdf'), link: downloadLink, download: true })), !navItems.length || (_jsx(NavMenuGroup, { text: version, base: versionsBase, items: navItems, pathname: siteData.base }))] }));
82
+ else {
83
+ const versionItems = versions.map((v) => ({
84
+ text: v,
85
+ link: `${location.protocol}//${location.host}${versionsBase}${v}/`,
86
+ activeMatch: v === version ? '.' : undefined,
87
+ }));
88
+ if (ALLOWED_LEGACY_DOMAINS.has(location.hostname) &&
89
+ virtual.userBase === ACP_BASE) {
90
+ versionItems.push(...LEGACY_NAV_ITEMS);
91
+ }
92
+ navList.push({
93
+ text: version,
94
+ items: versionItems,
95
+ });
96
+ }
97
+ return navList;
98
+ }, [downloadLink, t, version, versionsBase, versions]);
99
+ useEffect(() => {
100
+ // eslint-disable-next-line react-hooks/immutability
101
+ configNav.length = originalConfigNav.length;
102
+ configNav.push(...navList);
103
+ forceRender();
104
+ }, [configNav, forceRender, navList, originalConfigNav]);
105
+ return null;
80
106
  };
81
107
  export const VersionsNav = () => (_jsx(NoSSR, { children: _jsx(VersionsNav_, {}) }));
82
108
  export default VersionsNav;
@@ -1,4 +1,5 @@
1
1
  export * from '@rspress/core/theme-original';
2
2
  export { EditLink } from './EditLink.tsx';
3
3
  export { Layout } from './Layout.tsx';
4
+ export { Link } from './Link.tsx';
4
5
  export { Search } from './Search.tsx';
@@ -2,4 +2,5 @@
2
2
  export * from '@rspress/core/theme-original';
3
3
  export { EditLink } from "./EditLink.js";
4
4
  export { Layout } from "./Layout.js";
5
+ export { Link } from "./Link.js";
5
6
  export { Search } from "./Search.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.17.4",
3
+ "version": "1.17.5",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -42,17 +42,17 @@
42
42
  "dependencies": {
43
43
  "@alauda/doom-export": "^0.3.1",
44
44
  "@cspell/eslint-plugin": "^9.4.0",
45
- "@eslint-react/eslint-plugin": "^2.4.0",
45
+ "@eslint-react/eslint-plugin": "^2.5.0",
46
46
  "@inquirer/prompts": "^8.1.0",
47
47
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
48
48
  "@rsbuild/plugin-react": "^1.4.2",
49
49
  "@rsbuild/plugin-sass": "^1.4.0",
50
50
  "@rsbuild/plugin-svgr": "^1.2.3",
51
51
  "@rsbuild/plugin-yaml": "^1.0.3",
52
- "@rspress/core": "2.0.0-rc.3",
53
- "@rspress/plugin-algolia": "2.0.0-rc.3",
54
- "@rspress/plugin-sitemap": "2.0.0-rc.3",
55
- "@rspress/shared": "2.0.0-rc.3",
52
+ "@rspress/core": "2.0.0-rc.4",
53
+ "@rspress/plugin-algolia": "2.0.0-rc.4",
54
+ "@rspress/plugin-sitemap": "2.0.0-rc.4",
55
+ "@rspress/shared": "2.0.0-rc.4",
56
56
  "@shikijs/transformers": "^3.20.0",
57
57
  "@total-typescript/ts-reset": "^0.6.1",
58
58
  "@types/react": "^19.2.7",
@@ -67,6 +67,7 @@
67
67
  "globals": "^16.5.0",
68
68
  "html-tag-names": "^2.1.0",
69
69
  "jsencrypt": "^3.5.4",
70
+ "masonry-layout": "^4.2.2",
70
71
  "mdast-util-mdx": "^3.0.0",
71
72
  "mdast-util-mdx-jsx": "^3.2.0",
72
73
  "mdast-util-phrasing": "^4.1.0",
@@ -101,7 +102,7 @@
101
102
  "tinyglobby": "^0.2.15",
102
103
  "type-fest": "^5.3.1",
103
104
  "typescript": "^5.9.3",
104
- "typescript-eslint": "^8.50.1",
105
+ "typescript-eslint": "^8.51.0",
105
106
  "unified": "^11.0.5",
106
107
  "unified-lint-rule": "^3.0.1",
107
108
  "unist-util-position": "^5.0.0",
@@ -1,11 +1,31 @@
1
1
  :global .overview-index.doom-overview-index {
2
- margin-left: auto;
3
- margin-right: auto;
4
- padding-left: 0;
5
- padding-right: 0;
2
+ h2 {
3
+ letter-spacing: -0.02em;
4
+ color: var(--rp-c-text-1);
5
+ border-top: 1px solid var(--rp-c-divider-light);
6
+ margin: 36px 0;
7
+ padding-top: 36px;
8
+ font-size: 24px;
9
+ transition: color 0.5s;
10
+
11
+ &:first-child:before {
12
+ display: none;
13
+ }
14
+ }
6
15
 
7
- h2:first-child:before {
8
- display: none;
16
+ h3 > a {
17
+ margin: 0;
18
+ line-height: 1.3;
19
+ letter-spacing: -0.01em;
20
+ color: var(--rp-c-link);
21
+ font-size: 18px;
22
+ font-weight: 600;
23
+ transition: color 0.5s;
24
+ }
25
+
26
+ h2,
27
+ h3 {
28
+ line-height: 1;
9
29
  }
10
30
 
11
31
  .rp-link:hover {
@@ -15,7 +35,7 @@
15
35
 
16
36
  .overview-list {
17
37
  list-style: none;
18
- margin: 0;
38
+ margin-bottom: 0;
19
39
  padding-left: 0;
20
40
  }
21
41
 
@@ -60,15 +80,19 @@
60
80
 
61
81
  .overview-group {
62
82
  break-inside: avoid;
63
- margin-bottom: 28px;
83
+ margin-bottom: 16px;
64
84
  background-color: var(--rp-c-bg-soft);
65
85
  border-radius: var(--rp-radius);
66
- padding: 28px 32px;
86
+ padding: 24px;
67
87
  transition: background-color 0.5s;
68
88
 
69
89
  h3 {
70
90
  margin-top: 0;
71
91
  margin-bottom: 8px;
92
+
93
+ &:last-child {
94
+ margin-bottom: 0;
95
+ }
72
96
  }
73
97
  }
74
98
 
@@ -84,14 +108,18 @@
84
108
  }
85
109
  }
86
110
 
111
+ .overview-group {
112
+ width: 100%;
113
+ }
114
+
87
115
  @media (min-width: 768px) {
88
- .overview-groups {
89
- columns: 2;
116
+ .overview-group {
117
+ width: calc((100% - 16px) / 2);
90
118
  }
91
119
  }
92
120
 
93
121
  @media (min-width: 1024px) {
94
- .overview-groups {
95
- columns: 3;
122
+ .overview-group {
123
+ width: calc((100% - 32px) / 3);
96
124
  }
97
125
  }
@@ -1 +0,0 @@
1
- export declare const Down: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- export const Down = () => (_jsx("svg", { width: "1em", height: "1em", viewBox: "0 0 32 32", children: _jsx("path", { fill: "currentColor", d: "M16 22L6 12l1.4-1.4l8.6 8.6l8.6-8.6L26 12z" }) }));
@@ -1,13 +0,0 @@
1
- import { type NavItem } from '@rspress/shared';
2
- import { type ReactNode } from 'react';
3
- export interface NavMenuGroupItem {
4
- text?: string | ReactNode;
5
- link?: string;
6
- items: NavItem[];
7
- tag?: string;
8
- activeValue?: string;
9
- pathname?: string;
10
- base?: string;
11
- langs?: string[];
12
- }
13
- export declare function NavMenuGroup(item: NavMenuGroupItem): import("react/jsx-runtime").JSX.Element;
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Tag } from '@rspress/core/theme-original';
3
- import { isExternalUrl, } from '@rspress/shared';
4
- import { useRef, useState } from 'react';
5
- import { matchNavbar } from '../../shared/index.js';
6
- import { Down } from './Down.js';
7
- import { NavMenuSingleItem, } from './NavMenuSingleItem.js';
8
- import { SvgWrapper } from './SvgWrapper.js';
9
- function ActiveGroupItem({ item }) {
10
- return (_jsxs("div", { className: "rp-rounded-2xl rp-my-1 rp-flex", style: {
11
- padding: '0.4rem 1.5rem 0.4rem 0.75rem',
12
- }, children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { className: "rp-text-brand", children: item.text })] }, item.link));
13
- }
14
- function NormalGroupItem({ item }) {
15
- return (_jsx("div", { className: "rp-font-medium rp-my-1", children: _jsx("a", { href: item.link, target: isExternalUrl(item.link) ? '_blank' : undefined, rel: "noopener noreferrer", children: _jsx("div", { className: "rp-rounded-2xl hover:rp-bg-mute", style: {
16
- padding: '0.4rem 1.5rem 0.4rem 0.75rem',
17
- }, children: _jsxs("div", { className: "rp-flex", children: [item.tag && _jsx(Tag, { tag: item.tag }), _jsx("span", { children: item.text })] }) }) }) }, item.link));
18
- }
19
- export function NavMenuGroup(item) {
20
- const { activeValue, items: groupItems, base = '', link = '', pathname = '', } = item;
21
- const [isOpen, setIsOpen] = useState(false);
22
- const closeTimerRef = useRef(null);
23
- const clearCloseTimer = () => {
24
- if (closeTimerRef.current) {
25
- clearTimeout(closeTimerRef.current);
26
- closeTimerRef.current = null;
27
- }
28
- };
29
- /**
30
- * Handle mouse leave event for the dropdown menu
31
- * Closes the menu after a 150ms delay to allow diagonal mouse movement
32
- * to the dropdown content area
33
- */
34
- const handleMouseLeave = () => {
35
- closeTimerRef.current = window.setTimeout(() => {
36
- setIsOpen(false);
37
- }, 150);
38
- };
39
- const handleMouseEnter = () => {
40
- clearCloseTimer();
41
- setIsOpen(true);
42
- };
43
- const renderLinkItem = (item) => {
44
- const isLinkActive = matchNavbar(item, pathname, base);
45
- if (activeValue === item.text || (!activeValue && isLinkActive)) {
46
- return _jsx(ActiveGroupItem, { item: item }, item.link);
47
- }
48
- return _jsx(NormalGroupItem, { item: item }, item.link);
49
- };
50
- const renderGroup = (item) => {
51
- return (_jsxs("div", { children: ['link' in item ? (renderLinkItem(item)) : (_jsx("p", { className: "rp-font-bold rp-text-gray-400 rp-my-1 not:first:rp-border", children: item.text })), item.items.map(renderLinkItem)] }));
52
- };
53
- return (_jsxs("div", { className: "rp-relative rp-flex rp-items-center rp-justify-center rp-text-sm rp-h-14", onMouseLeave: handleMouseLeave, children: [_jsx("div", { onMouseEnter: handleMouseEnter, className: "rspress-nav-menu-group-button rp-flex rp-justify-center rp-items-center rp-font-medium rp-text-sm rp-text-text-1 hover:rp-text-text-2 rp-transition-colors rp-duration-200 rp-cursor-pointer", children: link ? (_jsx(NavMenuSingleItem, { ...item, rightIcon: _jsx(SvgWrapper, { icon: Down }) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "rp-text-sm rp-font-medium rp-flex", style: {
54
- marginRight: '2px',
55
- }, children: [_jsx(Tag, { tag: item.tag }), item.text] }), _jsx(SvgWrapper, { icon: Down })] })) }), _jsx("div", { className: "rspress-nav-menu-group-content rp-absolute rp-mx-0.8 rp-transition-opacity rp-duration-300", style: {
56
- opacity: isOpen ? 1 : 0,
57
- visibility: isOpen ? 'visible' : 'hidden',
58
- right: 0,
59
- top: '52px',
60
- }, onMouseEnter: clearCloseTimer, children: _jsx("div", { className: "rp-p-3 rp-pr-2 rp-w-full rp-h-full rp-max-h-100vh rp-whitespace-nowrap", style: {
61
- boxShadow: 'var(--rp-shadow-3)',
62
- zIndex: 100,
63
- border: '1px solid var(--rp-c-divider-light)',
64
- borderRadius: 'var(--rp-radius-large)',
65
- background: 'var(--rp-c-bg)',
66
- }, children: groupItems.map((item) => (_jsx("div", { children: 'items' in item ? renderGroup(item) : renderLinkItem(item) }, item.text))) }) })] }));
67
- }
@@ -1,11 +0,0 @@
1
- import type { NavItemWithLink } from '@rspress/core';
2
- import { type ReactNode } from 'react';
3
- export interface NavMenuSingleItemProps extends Omit<NavItemWithLink, 'text'> {
4
- base?: string;
5
- compact?: boolean;
6
- download?: string | boolean;
7
- pathname?: string;
8
- rightIcon?: ReactNode;
9
- text?: ReactNode;
10
- }
11
- export declare function NavMenuSingleItem({ activeMatch, base, download, link, pathname, rightIcon, text, tag, }: NavMenuSingleItemProps): import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Tag } from '@rspress/core/theme-original';
3
- import { isExternalUrl } from '@rspress/shared';
4
- import { useMemo } from 'react';
5
- import { withoutBase } from "../../shared/index.js";
6
- import styles from '@alauda/doom/styles/versions-nav.module.scss';
7
- export function NavMenuSingleItem({ activeMatch, base, download, link, pathname, rightIcon, text, tag, }) {
8
- const isActive = useMemo(() => !!base &&
9
- !!pathname &&
10
- new RegExp(activeMatch || link).test(withoutBase(pathname, base)), [activeMatch, base, link, pathname]);
11
- return (_jsx("a", { href: link, download: download, target: isExternalUrl(link) ? '_blank' : undefined, rel: "noopener noreferrer", children: _jsxs("div", { className: `rspress-nav-menu-item ${styles.singleItem} ${isActive ? styles.activeItem : ''} rp-text-sm rp-font-medium rp-px-3 rp-py-2 rp-flex rp-items-center`, children: [_jsx(Tag, { tag: tag }), text, rightIcon] }) }, link));
12
- }
@@ -1,8 +0,0 @@
1
- import type { FC, SVGAttributes } from 'react';
2
- /**
3
- * A wrapper for custom SVG icon.
4
- * When the user uses a custom SVG, the imported icon can be a string or a React component.
5
- */
6
- export declare function SvgWrapper({ icon: Icon, ...rest }: {
7
- icon: string | FC<React.SVGProps<SVGSVGElement>>;
8
- } & SVGAttributes<SVGSVGElement | HTMLImageElement>): import("react/jsx-runtime").JSX.Element | null;
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * A wrapper for custom SVG icon.
4
- * When the user uses a custom SVG, the imported icon can be a string or a React component.
5
- */
6
- export function SvgWrapper({ icon: Icon, ...rest }) {
7
- if (!Icon) {
8
- return null;
9
- }
10
- if (typeof Icon === 'string') {
11
- return _jsx("img", { src: Icon, ...rest });
12
- }
13
- return _jsx(Icon, { ...rest });
14
- }
@@ -1,36 +0,0 @@
1
- .link {
2
- font-weight: 500;
3
- transition: opacity 0.2s;
4
-
5
- &:hover {
6
- opacity: 0.85;
7
- }
8
-
9
- &:active {
10
- opacity: 0.7;
11
- }
12
-
13
- &[target='_blank']:after {
14
- content: '↗';
15
- margin-left: 0.2em;
16
- margin-right: 0.1em;
17
- font-size: 0.7em;
18
- font-weight: 700;
19
- transition: transform 0.2s;
20
- display: inline-block;
21
- transform: translate(0, -0.3em);
22
- }
23
- }
24
-
25
- .link,
26
- :global(summary) .link {
27
- &:not(:global(.rp-header-anchor)) {
28
- font-weight: 500;
29
- color: var(--rp-c-link);
30
- transition: color 0.25s;
31
- }
32
-
33
- &:hover {
34
- border-bottom: 1px solid var(--rp-c-brand);
35
- }
36
- }
@@ -1,130 +0,0 @@
1
- :global {
2
- .rp-relative {
3
- position: relative;
4
- }
5
-
6
- .rp-flex {
7
- display: flex;
8
- }
9
-
10
- .rp-items-center {
11
- align-items: center;
12
- }
13
-
14
- .rp-justify-center {
15
- justify-content: center;
16
- }
17
-
18
- .rp-h-14 {
19
- height: 3.5rem;
20
- }
21
-
22
- .rp-duration-200 {
23
- transition-duration: 0.2s;
24
- }
25
-
26
- .rp-transition-colors {
27
- transition-property:
28
- color, background-color, border-color, text-decoration-color, fill, stroke;
29
- transition-duration: 0.15s;
30
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
31
- }
32
-
33
- .rp-text-text-1 {
34
- color: var(--rp-c-text-1);
35
- }
36
-
37
- .hover\:rp-text-text-2:hover {
38
- color: var(--rp-c-text-2);
39
- }
40
-
41
- .rp-font-medium {
42
- font-weight: 500;
43
- }
44
-
45
- .rp-text-sm {
46
- font-size: 0.875rem;
47
- line-height: 1.25rem;
48
- }
49
-
50
- .rp-cursor-pointer {
51
- cursor: pointer;
52
- }
53
-
54
- .rp-absolute {
55
- position: absolute;
56
- }
57
-
58
- .rp-duration-300 {
59
- transition-duration: 0.3s;
60
- }
61
-
62
- .rp-transition-opacity {
63
- transition-property: opacity;
64
- transition-duration: 0.15s;
65
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
66
- }
67
-
68
- .rp-pr-2 {
69
- padding-right: 0.5rem;
70
- }
71
-
72
- .rp-p-3 {
73
- padding: 0.75rem;
74
- }
75
-
76
- .rp-whitespace-nowrap {
77
- white-space: nowrap;
78
- }
79
-
80
- .rp-w-full {
81
- width: 100%;
82
- }
83
-
84
- .rp-h-full {
85
- height: 100%;
86
- }
87
-
88
- .rp-rounded-2xl {
89
- border-radius: 1rem;
90
- }
91
-
92
- .rp-my-1 {
93
- margin-top: 0.25rem;
94
- margin-bottom: 0.25rem;
95
- }
96
-
97
- .rp-text-brand {
98
- color: var(--rp-c-brand);
99
- }
100
-
101
- .rp-py-2 {
102
- padding-top: 0.5rem;
103
- padding-bottom: 0.5rem;
104
- }
105
-
106
- .rp-px-3 {
107
- padding-left: 0.75rem;
108
- padding-right: 0.75rem;
109
- }
110
-
111
- .hover\:rp-bg-mute:hover {
112
- background-color: var(--rp-c-bg-mute);
113
- }
114
-
115
- .rspress-nav-menu-item {
116
- margin: -0.75rem -0.5rem;
117
- }
118
- }
119
-
120
- .singleItem {
121
- word-break: keep-all;
122
- }
123
-
124
- .activeItem,
125
- .singleItem:hover {
126
- background-color: var(--rp-c-bg-mute);
127
- cursor: pointer;
128
- color: var(--rp-c-link);
129
- border-radius: var(--rp-radius);
130
- }