Skip to content

Commit

Permalink
chore(website): Update order of previous docs links
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 24, 2021
1 parent a9f2d64 commit 87998b9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
7 changes: 2 additions & 5 deletions packages/documentation/src/components/Layout/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { DropdownMenu } from "@react-md/menu";
import { unitToNumber } from "@react-md/utils";

import { CodePreferenceToggle } from "components/CodePreference";
import { RMD_MAJOR_VERSION } from "constants/rmdVersion";

import ToggleTheme from "./ToggleTheme";
import ToggleRTL from "./ToggleRTL";
import GithubLink from "./GithubLink";
import TableOfContentsMenuItem from "./TableOfContentsMenuItem";
import VersionMenuItem from "./VersionMenuItem";
import PreviousDocsMenuItems from "./PreviousDocsMenuItems";

const margin = unitToNumber(scssVariables["rmd-app-bar-lr-margin"]);
const options = {
Expand All @@ -32,9 +31,7 @@ export default function ActionMenu(): ReactElement {
<ToggleTheme as="menuitem" />,
<ToggleRTL as="menuitem" />,
<CodePreferenceToggle as="menuitem" />,
...Array.from({ length: RMD_MAJOR_VERSION - 1 }, (_, i) => (
<VersionMenuItem version={`v${i + 1}`} />
)),
<PreviousDocsMenuItems />,
<GithubLink as="menuitem" />,
<TableOfContentsMenuItem />,
]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BELOW_INNER_RIGHT_ANCHOR } from "@react-md/utils";
import { RMD_MAJOR_VERSION } from "constants/rmdVersion";

import styles from "./NavHeaderTitle.module.scss";
import VersionMenuItem from "./VersionMenuItem";
import PreviousDocsMenuItems from "./PreviousDocsMenuItems";

export default function NavHeaderTitle(): ReactElement {
const { layout } = useLayoutConfig();
Expand All @@ -19,9 +19,7 @@ export default function NavHeaderTitle(): ReactElement {
<AppBarTitle keyline={!isToggleableLayout(layout)}>react-md</AppBarTitle>
<DropdownMenu
id="version-picker"
items={Array.from({ length: RMD_MAJOR_VERSION - 1 }, (_, i) => (
<VersionMenuItem small version={`v${i + 1}`} />
))}
items={[<PreviousDocsMenuItems small />]}
dropdownIcon={<ArrowDropDownSVGIcon />}
anchor={BELOW_INNER_RIGHT_ANCHOR}
className={styles.menu}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ReactElement } from "react";

import { RMD_MAJOR_VERSION } from "constants/rmdVersion";

import VersionMenuItem from "./VersionMenuItem";

const MAX = RMD_MAJOR_VERSION - 1;

export interface PreviousDocsMenuItemsProps {
small?: boolean;
}

export default function PreviousDocsMenuItems({
small,
}: PreviousDocsMenuItemsProps): ReactElement {
return (
<>
{typeof window !== "undefined" &&
window.location.origin !== "https://react-md.dev" && (
<VersionMenuItem key="latest" small={small} version="latest" />
)}
{Array.from({ length: MAX }, (_, i) => (
<VersionMenuItem key={i} small={small} version={`v${MAX - i}`} />
))}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EventName, sendAnalyticsEvent } from "utils/analytics";

export interface VersionMenuItemProps extends MenuItemLinkProps {
small?: boolean;
version: "v1" | "latest" | string;
version: `v${string}` | "latest";
}

export default forwardRef<HTMLAnchorElement, VersionMenuItemProps>(
Expand Down

0 comments on commit 87998b9

Please sign in to comment.