Skip to content

Commit 7ae1c9e

Browse files
committed
chore: new docs releases subpage navigate up
1 parent 7e7af57 commit 7ae1c9e

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

packages/dev/s2-docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@react-spectrum/utils": "^3.12.6",
3939
"@react-types/shared": "^3.30.0",
4040
"@react-types/textfield": "^3.12.3",
41+
"@spectrum-icons/workflow": "^4.2.25",
4142
"emojibase-data": "^16.0.3",
4243
"fast-glob": "^3.3.3",
4344
"globals-docs": "^2.4.1",

packages/dev/s2-docs/pages/react-aria/releases/v1-13-0.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Time} from '../../../src/ReleasesList';
1515
import {ReleasedVersions} from '../../../src/ReleasesList';
1616

1717
export const section = '';
18+
export const isSubpage = true;
1819
export const tags = ['release', 'React Aria'];
1920
export const date = 'October 2, 2025';
2021
export const title = 'v1.13.0';
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
'use client';
2+
3+
import {ButtonRenderProps, Link, Provider} from 'react-aria-components';
4+
import {baseColor, focusRing, fontRelative, style} from '@react-spectrum/s2/style' with { type: 'macro' };
5+
import ChevronLeftIcon from '@react-spectrum/s2/icons/ChevronLeft';
6+
import { IconContext } from '@react-spectrum/s2';
7+
import { centerBaseline } from '../../../@react-spectrum/s2/src/CenterBaseline';
8+
import React from 'react';
9+
import { control } from '../../../@react-spectrum/s2/src/style-utils' with { type: 'macro' };
10+
11+
12+
const controlStyle = control({shape: 'default', icon: true});
13+
export const btnStyles = style<ButtonRenderProps>({
14+
...focusRing(),
15+
...controlStyle,
16+
position: 'relative',
17+
justifyContent: 'center',
18+
flexShrink: 0,
19+
fontWeight: 'medium',
20+
userSelect: 'none',
21+
transition: 'default',
22+
forcedColorAdjust: 'none',
23+
backgroundColor: {
24+
default: 'transparent',
25+
forcedColors: {
26+
default: 'ButtonFace'
27+
}
28+
},
29+
color: {
30+
default: baseColor('neutral'),
31+
isDisabled: 'disabled',
32+
forcedColors: {
33+
default: 'ButtonText',
34+
isDisabled: {
35+
default: 'GrayText'
36+
}
37+
}
38+
},
39+
'--iconPrimary': {
40+
type: 'fill',
41+
value: 'currentColor'
42+
},
43+
outlineColor: {
44+
default: 'focus-ring',
45+
forcedColors: 'Highlight'
46+
},
47+
borderStyle: 'none',
48+
disableTapHighlight: true,
49+
'--iconWidth': {
50+
type: 'width',
51+
value: fontRelative(20)
52+
}
53+
});
54+
55+
export function GoUpOneLink() {
56+
return (
57+
<Link href="/">
58+
<Provider
59+
values={[
60+
[IconContext, {
61+
render: centerBaseline({slot: 'icon', styles: style({order: 0})}),
62+
styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})
63+
}]
64+
]}>
65+
<ChevronLeftIcon />
66+
</Provider>
67+
</Link>
68+
);
69+
}

packages/dev/s2-docs/src/Layout.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {CodePlatterProvider} from './CodePlatter';
1616
import {ExampleSwitcher} from './ExampleSwitcher';
1717
import {getLibraryFromPage, getLibraryFromUrl, getLibraryLabel} from './library';
1818
import {getTextWidth} from './textWidth';
19+
import {GoUpOneLink} from './GoUpOneLink';
1920
import {H2, H3, H4} from './Headings';
2021
import Header from './Header';
2122
import {Link} from './Link';
@@ -63,6 +64,16 @@ const components = {
6364
ExampleList
6465
};
6566

67+
const subPageComponents = {
68+
...components,
69+
h1: ({children, ...props}) => (
70+
<div className={style({display: 'flex', alignItems: 'center', gap: 8})}>
71+
<GoUpOneLink />
72+
<h1 {...props} id="top" style={{'--width-per-em': getTextWidth(children)} as any} className={h1}>{children}</h1>
73+
</div>
74+
)
75+
};
76+
6677
function anchorId(children) {
6778
return children.replace(/\s/g, '-').replace(/[^a-zA-Z0-9-_]/g, '').toLowerCase();
6879
}
@@ -128,6 +139,7 @@ let articleStyles = style({
128139
export function Layout(props: PageProps & {children: ReactElement<any>}) {
129140
let {pages, currentPage, children} = props;
130141
let hasToC = !currentPage.exports?.hideNav && currentPage.tableOfContents?.[0]?.children && currentPage.tableOfContents?.[0]?.children?.length > 0;
142+
let isSubpage = currentPage.exports?.isSubpage;
131143
let library = getLibraryLabel(getLibraryFromPage(currentPage));
132144
let keywords = [...new Set((currentPage.exports?.keywords ?? []).concat([library]).filter(k => !!k))];
133145
let ogImage = getOgImageUrl(currentPage);
@@ -243,7 +255,7 @@ export function Layout(props: PageProps & {children: ReactElement<any>}) {
243255
<article
244256
className={articleStyles({isWithToC: hasToC})}>
245257
{currentPage.exports?.version && <VersionBadge version={currentPage.exports.version} />}
246-
{React.cloneElement(children, {components, pages})}
258+
{React.cloneElement(children, {components: isSubpage ? subPageComponents : components, pages})}
247259
</article>
248260
</CodePlatterProvider>
249261
{hasToC && <aside

0 commit comments

Comments
 (0)