File tree Expand file tree Collapse file tree 4 files changed +32
-10
lines changed
packages/documentation/src/components/Layout Expand file tree Collapse file tree 4 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,12 @@ import { DropdownMenu } from "@react-md/menu";
77import { unitToNumber } from "@react-md/utils" ;
88
99import { CodePreferenceToggle } from "components/CodePreference" ;
10- import { RMD_MAJOR_VERSION } from "constants/rmdVersion" ;
1110
1211import ToggleTheme from "./ToggleTheme" ;
1312import ToggleRTL from "./ToggleRTL" ;
1413import GithubLink from "./GithubLink" ;
1514import TableOfContentsMenuItem from "./TableOfContentsMenuItem" ;
16- import VersionMenuItem from "./VersionMenuItem " ;
15+ import PreviousDocsMenuItems from "./PreviousDocsMenuItems " ;
1716
1817const margin = unitToNumber ( scssVariables [ "rmd-app-bar-lr-margin" ] ) ;
1918const options = {
@@ -32,9 +31,7 @@ export default function ActionMenu(): ReactElement {
3231 < ToggleTheme as = "menuitem" /> ,
3332 < ToggleRTL as = "menuitem" /> ,
3433 < CodePreferenceToggle as = "menuitem" /> ,
35- ...Array . from ( { length : RMD_MAJOR_VERSION - 1 } , ( _ , i ) => (
36- < VersionMenuItem version = { `v${ i + 1 } ` } />
37- ) ) ,
34+ < PreviousDocsMenuItems /> ,
3835 < GithubLink as = "menuitem" /> ,
3936 < TableOfContentsMenuItem /> ,
4037 ] }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { BELOW_INNER_RIGHT_ANCHOR } from "@react-md/utils";
1010import { RMD_MAJOR_VERSION } from "constants/rmdVersion" ;
1111
1212import styles from "./NavHeaderTitle.module.scss" ;
13- import VersionMenuItem from "./VersionMenuItem " ;
13+ import PreviousDocsMenuItems from "./PreviousDocsMenuItems " ;
1414
1515export default function NavHeaderTitle ( ) : ReactElement {
1616 const { layout } = useLayoutConfig ( ) ;
@@ -19,9 +19,7 @@ export default function NavHeaderTitle(): ReactElement {
1919 < AppBarTitle keyline = { ! isToggleableLayout ( layout ) } > react-md</ AppBarTitle >
2020 < DropdownMenu
2121 id = "version-picker"
22- items = { Array . from ( { length : RMD_MAJOR_VERSION - 1 } , ( _ , i ) => (
23- < VersionMenuItem small version = { `v${ i + 1 } ` } />
24- ) ) }
22+ items = { [ < PreviousDocsMenuItems small /> ] }
2523 dropdownIcon = { < ArrowDropDownSVGIcon /> }
2624 anchor = { BELOW_INNER_RIGHT_ANCHOR }
2725 className = { styles . menu }
Original file line number Diff line number Diff line change 1+ import type { ReactElement } from "react" ;
2+
3+ import { RMD_MAJOR_VERSION } from "constants/rmdVersion" ;
4+
5+ import VersionMenuItem from "./VersionMenuItem" ;
6+
7+ const MAX = RMD_MAJOR_VERSION - 1 ;
8+
9+ export interface PreviousDocsMenuItemsProps {
10+ small ?: boolean ;
11+ }
12+
13+ export default function PreviousDocsMenuItems ( {
14+ small,
15+ } : PreviousDocsMenuItemsProps ) : ReactElement {
16+ return (
17+ < >
18+ { typeof window !== "undefined" &&
19+ window . location . origin !== "https://react-md.dev" && (
20+ < VersionMenuItem key = "latest" small = { small } version = "latest" />
21+ ) }
22+ { Array . from ( { length : MAX } , ( _ , i ) => (
23+ < VersionMenuItem key = { i } small = { small } version = { `v${ MAX - i } ` } />
24+ ) ) }
25+ </ >
26+ ) ;
27+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { EventName, sendAnalyticsEvent } from "utils/analytics";
66
77export interface VersionMenuItemProps extends MenuItemLinkProps {
88 small ?: boolean ;
9- version : "v1" | "latest" | string ;
9+ version : `v${ string } ` | "latest" ;
1010}
1111
1212export default forwardRef < HTMLAnchorElement , VersionMenuItemProps > (
You can’t perform that action at this time.
0 commit comments