Skip to content

Commit 8891825

Browse files
authored
chore: S2 docs followup (#8504)
* make 'ArrowDown' open the menu onKeyDown * preventDefault on 'ArrowDown' to prevent scrolling * fix chevron in menu button * fix github logo * header/menu layout improvements * lint
1 parent 0db833a commit 8891825

File tree

6 files changed

+45
-30
lines changed

6 files changed

+45
-30
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import {ActionButton} from '@react-spectrum/s2';
44
import {AdobeLogo} from './icons/AdobeLogo';
5-
import ChevronDown from '@react-spectrum/s2/icons/ChevronDown';
65
import {flushSync} from 'react-dom';
7-
import {GithubLogo} from './icons/GithubLogo';
6+
import GithubLogo from './icons/GithubLogo';
87
import {InternationalizedLogo} from './icons/InternationalizedLogo';
98
import {MarkdownMenu} from './MarkdownMenu';
109
import {PageProps} from '@parcel/rsc';
@@ -61,6 +60,21 @@ export default function Header(props: PageProps) {
6160
});
6261
};
6362

63+
let handleActionButtonKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
64+
if (e.key === 'ArrowDown' && !searchOpen) {
65+
e.preventDefault();
66+
toggleShowSearchMenu();
67+
}
68+
};
69+
70+
const ChevronDownIcon = (props) => (
71+
<svg xmlns="http://www.w3.org/2000/svg" width={20} height={20} {...props}>
72+
<path
73+
fill="var(--iconPrimary, #222)"
74+
d="M3.755 7.243a.748.748 0 0 1 1.06-.02l5.183 4.986 5.197-4.999a.749.749 0 1 1 1.04 1.08l-5.717 5.5a.747.747 0 0 1-1.04 0L3.776 8.303a.746.746 0 0 1-.02-1.06Z" />
75+
</svg>
76+
);
77+
6478
return (
6579
<>
6680
<header className={style({width: 'full', display: {default: 'none', lg: 'flex'}, justifyContent: 'center'})}>
@@ -72,7 +86,7 @@ export default function Header(props: PageProps) {
7286
alignItems: 'center'
7387
})}>
7488
<div className={style({justifySelf: 'start'})}>
75-
<ActionButton aria-label="Open menu and search" size="XL" isQuiet onPress={toggleShowSearchMenu} UNSAFE_style={{paddingInlineStart: 10}}>
89+
<ActionButton aria-label="Open menu and search" size="XL" isQuiet onPress={toggleShowSearchMenu} onKeyDown={handleActionButtonKeyDown} UNSAFE_style={{paddingInlineStart: 10}}>
7690
<div className={style({display: 'flex', alignItems: 'center'})}>
7791
<div className={style({marginTop: 4})} style={{viewTransitionName: !searchOpen ? 'search-menu-icon' : 'none'} as CSSProperties}>
7892
{getButtonIcon(currentPage)}
@@ -81,13 +95,13 @@ export default function Header(props: PageProps) {
8195
{getButtonText(currentPage)}
8296
</span>
8397
</div>
84-
<ChevronDown UNSAFE_className={'react-spectrum-select-chevron' + style({paddingEnd: 8})} UNSAFE_style={{width: 18}} />
98+
<ChevronDownIcon className={style({width: 18})} />
8599
</ActionButton>
86100
</div>
87101
<SearchMenu pages={pages} currentPage={currentPage} toggleShowSearchMenu={toggleShowSearchMenu} closeSearchMenu={closeSearchMenu} isSearchOpen={searchOpen} />
88102
<div className={style({display: 'flex', alignItems: 'center', gap: 4, justifySelf: 'end'})}>
89103
<MarkdownMenu url={currentPage.url} />
90-
<ActionButton aria-label="React Spectrum GitHub repo" size="XL" isQuiet>
104+
<ActionButton aria-label="React Spectrum GitHub repo" size="L" isQuiet>
91105
<GithubLogo />
92106
</ActionButton>
93107
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function MarkdownMenu({url}: MarkdownMenuProps) {
4242

4343
return (
4444
<MenuTrigger>
45-
<ActionButton isQuiet aria-label="Markdown options">
45+
<ActionButton size="L" isQuiet aria-label="Markdown options">
4646
<Copy />
4747
</ActionButton>
4848
<Menu onAction={onAction}>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ export default function SearchMenu(props: SearchMenuProps) {
281281
onFocusSearch(); // Open the search overlay
282282
setSearchValue(e.key); // Set the initial search value
283283
}
284+
285+
if (e.key === 'ArrowDown') {
286+
e.preventDefault();
287+
toggleShowSearchMenu();
288+
}
284289
};
285290

286291
let handleButtonPress = () => {
@@ -290,9 +295,8 @@ export default function SearchMenu(props: SearchMenuProps) {
290295
return (
291296
<div
292297
className={style({
293-
width: 'full',
294298
display: 'grid',
295-
gridTemplateColumns: 'auto 1fr auto',
299+
gridTemplateColumns: 'auto 1fr',
296300
alignItems: 'center',
297301
gap: 16
298302
})}>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function SearchResultsMenu({
7878
ref={searchRef}
7979
size="L"
8080
aria-label={`Search ${libraryName}`}
81-
UNSAFE_style={{marginInlineEnd: 308, viewTransitionName: isPrimary ? 'search-menu-search-field' : 'none'} as CSSProperties}
81+
UNSAFE_style={{marginInlineEnd: 296, viewTransitionName: isPrimary ? 'search-menu-search-field' : 'none'} as CSSProperties}
8282
styles={style({width: '[500px]'})} />
8383
</div>
8484

@@ -88,7 +88,6 @@ export default function SearchResultsMenu({
8888

8989
<div style={{display: showCards ? 'none' : 'block'}} className={style({height: 'full', overflow: 'auto'})}>
9090
{mainItems.length > 0 ? (
91-
9291
<div
9392
className={style({marginX: 'auto', marginY: 8, maxWidth: '[500px]'})}
9493
role="region"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const tabs = style({
4747
display: 'flex',
4848
flexShrink: 0,
4949
font: 'ui',
50-
height: 'full'
50+
height: 'full',
51+
paddingTop: 8
5152
});
5253

5354
/**
Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
import React from 'react';
1+
2+
import {createIcon} from '@react-spectrum/s2';
3+
4+
import {forwardRef, Ref, SVGProps} from 'react';
25
import {style} from '@react-spectrum/s2/style' with { type: 'macro' };
36

4-
export const GithubLogo = () => {
5-
return (
6-
<svg
7-
xmlns="http://www.w3.org/2000/svg"
8-
width={20}
9-
height={20}
10-
viewBox="0 0 20 19"
11-
className={style({color: 'gray-1000'})}>
12-
<path
13-
d="M9.969 0C4.457 0 0 4.355 0 9.742c0 4.305 2.855 7.95 6.816 9.238.497.098.676-.207.676-.464 0-.227-.015-1-.015-1.809-2.774.582-3.352-1.16-3.352-1.16-.445-1.129-1.105-1.418-1.105-1.418-.907-.598.066-.598.066-.598 1.008.063 1.535 1 1.535 1 .89 1.485 2.328 1.063 2.906.805.082-.629.348-1.063.63-1.305-2.216-.226-4.544-1.066-4.544-4.804 0-1.067.399-1.938 1.024-2.614-.098-.242-.446-1.242.101-2.582 0 0 .84-.258 2.739 1a9.934 9.934 0 0 1 2.492-.32c.844 0 1.703.11 2.492.32 1.898-1.258 2.742-1 2.742-1 .543 1.34.2 2.34.098 2.582.644.676 1.023 1.547 1.023 2.614 0 3.738-2.328 4.562-4.554 4.804.363.305.675.887.675 1.805 0 1.309-.015 2.355-.015 2.68 0 .257.183.562.675.464 3.961-1.289 6.82-4.933 6.82-9.238C19.942 4.355 15.47 0 9.97 0Zm0 0"
14-
className={style({stroke: 'none', fill: '[currentcolor]'})}
15-
style={{
16-
fillRule: 'evenodd',
17-
fillOpacity: 1
18-
}} />
19-
</svg>
20-
);
21-
};
7+
const SvgComponent = (props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => (<svg className={style({color: 'gray-1000'})} xmlns="http://www.w3.org/2000/svg" width={20} height={20} viewBox="0 0 20 19" ref={ref} {...props}><path
8+
d="M9.969 0C4.457 0 0 4.355 0 9.742c0 4.305 2.855 7.95 6.816 9.238.497.098.676-.207.676-.464 0-.227-.015-1-.015-1.809-2.774.582-3.352-1.16-3.352-1.16-.445-1.129-1.105-1.418-1.105-1.418-.907-.598.066-.598.066-.598 1.008.063 1.535 1 1.535 1 .89 1.485 2.328 1.063 2.906.805.082-.629.348-1.063.63-1.305-2.216-.226-4.544-1.066-4.544-4.804 0-1.067.399-1.938 1.024-2.614-.098-.242-.446-1.242.101-2.582 0 0 .84-.258 2.739 1 .812-.21 1.652-.32 2.492-.32.844 0 1.703.11 2.492.32 1.898-1.258 2.742-1 2.742-1 .543 1.34.2 2.34.098 2.582.644.676 1.023 1.547 1.023 2.614 0 3.738-2.328 4.562-4.554 4.804.363.305.675.887.675 1.805 0 1.309-.015 2.355-.015 2.68 0 .257.183.562.675.464 3.961-1.289 6.82-4.933 6.82-9.238C19.942 4.355 15.47 0 9.97 0m0 0"
9+
className={style({stroke: 'none', fill: '[currentcolor]'})}
10+
style={{
11+
stroke: 'none',
12+
fillRule: 'evenodd',
13+
fillOpacity: 1
14+
}} /></svg>);
15+
const ForwardRef = forwardRef(SvgComponent);
16+
17+
18+
export default /*#__PURE__*/ createIcon(ForwardRef);

0 commit comments

Comments
 (0)