Skip to content

Commit 7d0f0ec

Browse files
authored
chore: bump rspress to v2.0.0-beta.12 (#84)
1 parent 03bbc4f commit 7d0f0ec

File tree

8 files changed

+529
-513
lines changed

8 files changed

+529
-513
lines changed

.changeset/sour-wombats-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": patch
3+
---
4+
5+
fix: style regression of `VersionsNav`

.changeset/tiny-ghosts-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": patch
3+
---
4+
5+
chore: bump `rspress` to `v2.0.0-beta.12`

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@
5858
},
5959
"dependencies": {
6060
"@cspell/eslint-plugin": "^8.19.4 || ^9.0.2",
61-
"@eslint-react/eslint-plugin": "^1.51.2",
61+
"@eslint-react/eslint-plugin": "^1.51.3",
6262
"@inquirer/prompts": "^7.5.3",
6363
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
6464
"@playwright/browser-chromium": "^1.52.0",
6565
"@rsbuild/plugin-react": "^1.3.2",
6666
"@rsbuild/plugin-sass": "^1.3.2",
6767
"@rsbuild/plugin-svgr": "^1.2.0",
6868
"@rsbuild/plugin-yaml": "^1.0.2",
69-
"@rspress/core": "2.0.0-beta.11",
70-
"@rspress/plugin-algolia": "2.0.0-beta.11",
71-
"@rspress/plugin-llms": "^2.0.0-beta.11",
69+
"@rspress/core": "https://pkg.pr.new/@rspress/core@6b02230",
70+
"@rspress/plugin-algolia": "https://pkg.pr.new/@rspress/plugin-algolia@6b02230",
71+
"@rspress/plugin-llms": "https://pkg.pr.new/@rspress/plugin-llms@6b02230",
7272
"@shikijs/transformers": "^3.6.0",
7373
"@total-typescript/ts-reset": "^0.6.1",
7474
"chokidar": "^4.0.3",
@@ -83,7 +83,7 @@
8383
"mdast-util-mdx": "^3.0.0",
8484
"mdast-util-mdx-jsx": "^3.2.0",
8585
"mermaid": "^11.6.0",
86-
"openai": "^5.1.1",
86+
"openai": "^5.3.0",
8787
"openapi-types": "^12.1.3",
8888
"p-ratelimit": "^1.0.1",
8989
"pdf-lib": "^1.17.1",
@@ -102,7 +102,7 @@
102102
"tinyglobby": "^0.2.14",
103103
"type-fest": "^4.41.0",
104104
"typescript": "^5.8.3",
105-
"typescript-eslint": "^8.33.1",
105+
"typescript-eslint": "^8.34.0",
106106
"x-fetch": "^0.2.6",
107107
"yaml": "^2.8.0",
108108
"yoctocolors": "^2.1.1"
@@ -112,12 +112,12 @@
112112
"@changesets/cli": "^2.29.4",
113113
"@eslint/js": "^9.28.0",
114114
"@swc-node/register": "^1.10.10",
115-
"@swc/core": "1.11.31",
115+
"@swc/core": "1.12.0",
116116
"@types/cli-progress": "^3.11.6",
117117
"@types/ejs": "^3.1.5",
118-
"@types/node": "^22.15.30",
118+
"@types/node": "^22.15.31",
119119
"@types/picomatch": "^4.0.0",
120-
"@types/react": "^19.1.6",
120+
"@types/react": "^19.1.7",
121121
"@types/react-dom": "^19.1.6",
122122
"@types/swagger2openapi": "^7.0.4",
123123
"@unts/patch-package": "^8.1.1",

patches/@rspress+theme-default+2.0.0-beta.11.patch

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/global/VersionsNav/Down.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const SvgDown = () => (
1+
export const Down = () => (
22
<svg width="1em" height="1em" viewBox="0 0 32 32">
33
<path fill="currentColor" d="M16 22L6 12l1.4-1.4l8.6 8.6l8.6-8.6L26 12z" />
44
</svg>
Lines changed: 71 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Tag } from '@rspress/core/theme'
22
import {
33
isExternalUrl,
4-
withoutBase,
4+
matchNavbar,
55
type NavItem,
66
type NavItemWithChildren,
77
type NavItemWithLink,
88
type NavItemWithLinkAndChildren,
99
} from '@rspress/shared'
10-
import { useCallback, useState, type ReactNode } from 'react'
10+
import { useRef, useState, type ReactNode } from 'react'
1111

12-
import { SvgDown } from './Down.js'
12+
import { Down } from './Down.js'
1313
import {
1414
NavMenuSingleItem,
1515
type NavMenuSingleItemProps,
@@ -23,7 +23,7 @@ export interface NavMenuGroupItem {
2323
tag?: string
2424
// Design for i18n highlight.
2525
activeValue?: string
26-
// Currrnt pathname.
26+
// Current pathname.
2727
pathname?: string
2828
// Base path.
2929
base?: string
@@ -35,32 +35,32 @@ function ActiveGroupItem({ item }: { item: NavItemWithLink }) {
3535
return (
3636
<div
3737
key={item.link}
38-
className="rounded-2xl my-1 flex"
38+
className="rp-rounded-2xl rp-my-1 rp-flex"
3939
style={{
4040
padding: '0.4rem 1.5rem 0.4rem 0.75rem',
4141
}}
4242
>
4343
{item.tag && <Tag tag={item.tag} />}
44-
<span className="text-brand">{item.text}</span>
44+
<span className="rp-text-brand">{item.text}</span>
4545
</div>
4646
)
4747
}
4848

4949
function NormalGroupItem({ item }: { item: NavItemWithLink }) {
5050
return (
51-
<div key={item.link} className="font-medium my-1">
51+
<div key={item.link} className="rp-font-medium rp-my-1">
5252
<a
5353
href={item.link}
5454
target={isExternalUrl(item.link) ? '_blank' : undefined}
5555
rel="noopener noreferrer"
5656
>
5757
<div
58-
className="rounded-2xl hover:bg-mute"
58+
className="rp-rounded-2xl hover:rp-bg-mute"
5959
style={{
6060
padding: '0.4rem 1.5rem 0.4rem 0.75rem',
6161
}}
6262
>
63-
<div className="flex">
63+
<div className="rp-flex">
6464
{item.tag && <Tag tag={item.tag} />}
6565
<span>{item.text}</span>
6666
</div>
@@ -71,21 +71,41 @@ function NormalGroupItem({ item }: { item: NavItemWithLink }) {
7171
}
7272

7373
export function NavMenuGroup(item: NavMenuGroupItem) {
74-
const { activeValue, items: groupItems, base = '', pathname = '' } = item
74+
const {
75+
activeValue,
76+
items: groupItems,
77+
base = '',
78+
link = '',
79+
pathname = '',
80+
} = item
7581
const [isOpen, setIsOpen] = useState(false)
82+
const closeTimerRef = useRef<number>(null)
7683

77-
const onOpen = useCallback(() => {
78-
setIsOpen(true)
79-
}, [])
84+
const clearCloseTimer = () => {
85+
if (closeTimerRef.current) {
86+
clearTimeout(closeTimerRef.current)
87+
closeTimerRef.current = null
88+
}
89+
}
90+
91+
/**
92+
* Handle mouse leave event for the dropdown menu
93+
* Closes the menu after a 150ms delay to allow diagonal mouse movement
94+
* to the dropdown content area
95+
*/
96+
const handleMouseLeave = () => {
97+
closeTimerRef.current = window.setTimeout(() => {
98+
setIsOpen(false)
99+
}, 150)
100+
}
80101

81-
const onClose = useCallback(() => {
82-
setIsOpen(false)
83-
}, [])
102+
const handleMouseEnter = () => {
103+
clearCloseTimer()
104+
setIsOpen(true)
105+
}
84106

85107
const renderLinkItem = (item: NavItemWithLink) => {
86-
const isLinkActive = new RegExp(item.activeMatch || item.link).test(
87-
withoutBase(pathname, base),
88-
)
108+
const isLinkActive = matchNavbar(item, pathname, base)
89109
if (activeValue === item.text || (!activeValue && isLinkActive)) {
90110
return <ActiveGroupItem key={item.link} item={item} />
91111
}
@@ -100,7 +120,7 @@ export function NavMenuGroup(item: NavMenuGroupItem) {
100120
{'link' in item ? (
101121
renderLinkItem(item)
102122
) : (
103-
<p className="font-bold text-gray-400 my-1 not:first:border">
123+
<p className="rp-font-bold rp-text-gray-400 rp-my-1 not:first:rp-border">
104124
{item.text}
105125
</p>
106126
)}
@@ -109,49 +129,47 @@ export function NavMenuGroup(item: NavMenuGroupItem) {
109129
)
110130
}
111131

112-
const hasMultiItems = groupItems.length > 1
113-
114-
const Content = hasMultiItems || item.link ? 'button' : 'span'
115-
116-
const content = (
117-
<Content
118-
onMouseEnter={hasMultiItems ? onOpen : undefined}
119-
className={`${Content === 'button' ? 'rspress-nav-menu-group-button ' : ''}flex-center items-center font-medium text-sm text-text-1${hasMultiItems ? ' hover:text-text-2 transition-colors duration-200' : ''}`}
132+
return (
133+
<div
134+
className="rp-relative rp-flex rp-items-center rp-justify-center rp-h-14"
135+
onMouseLeave={handleMouseLeave}
120136
>
121-
{item.link ? (
122-
<NavMenuSingleItem
123-
{...(item as NavMenuSingleItemProps)}
124-
rightIcon={<SvgWrapper icon={SvgDown} />}
125-
/>
126-
) : (
127-
<>
128-
<span
129-
className="text-sm font-medium flex"
130-
style={hasMultiItems ? { marginRight: '2px' } : undefined}
131-
>
132-
<Tag tag={item.tag} />
133-
{item.text}
134-
</span>
135-
{hasMultiItems && <SvgWrapper icon={SvgDown} />}
136-
</>
137-
)}
138-
</Content>
139-
)
140-
141-
return hasMultiItems ? (
142-
<div className="relative flex-center h-14" onMouseLeave={onClose}>
143-
{content}
144137
<div
145-
className="rspress-nav-menu-group-content absolute mx-0.8 transition-opacity duration-300"
138+
onMouseEnter={handleMouseEnter}
139+
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"
140+
>
141+
{link ? (
142+
<NavMenuSingleItem
143+
{...(item as NavMenuSingleItemProps)}
144+
rightIcon={<SvgWrapper icon={Down} />}
145+
/>
146+
) : (
147+
<>
148+
<span
149+
className="rp-text-sm rp-font-medium rp-flex"
150+
style={{
151+
marginRight: '2px',
152+
}}
153+
>
154+
<Tag tag={item.tag} />
155+
{item.text}
156+
</span>
157+
<SvgWrapper icon={Down} />
158+
</>
159+
)}
160+
</div>
161+
<div
162+
className="rspress-nav-menu-group-content rp-absolute rp-mx-0.8 rp-transition-opacity rp-duration-300"
146163
style={{
147164
opacity: isOpen ? 1 : 0,
148165
visibility: isOpen ? 'visible' : 'hidden',
149166
right: 0,
150167
top: '52px',
151168
}}
169+
onMouseEnter={clearCloseTimer}
152170
>
153171
<div
154-
className="p-3 pr-2 w-full h-full max-h-100vh whitespace-nowrap"
172+
className="rp-p-3 rp-pr-2 rp-w-full rp-h-full rp-max-h-100vh rp-whitespace-nowrap"
155173
style={{
156174
boxShadow: 'var(--rp-shadow-3)',
157175
zIndex: 100,
@@ -169,7 +187,5 @@ export function NavMenuGroup(item: NavMenuGroupItem) {
169187
</div>
170188
</div>
171189
</div>
172-
) : (
173-
content
174190
)
175191
}

src/global/VersionsNav/NavMenuSingleItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export function NavMenuSingleItem({
4646
>
4747
<div
4848
className={`rspress-nav-menu-item ${styles.singleItem} ${
49-
isActive ? styles.activeItem : ''
50-
} text-sm font-medium ${compact ? 'mx-0.5' : 'mx-1.5'} px-3 py-2 flex items-center`}
49+
isActive ? `${styles.activeItem} rspress-nav-menu-item-active` : ''
50+
} rp-text-sm rp-font-medium ${compact ? 'rp-mx-0.5' : 'rp-mx-1.5'} rp-px-3 rp-py-2 rp-flex rp-items-center`}
5151
>
5252
<Tag tag={tag} />
5353
{text}

0 commit comments

Comments
 (0)