Skip to content

Commit

Permalink
chore(docs): update VersionDropdown to support v1 - v5
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 12, 2023
1 parent e277f97 commit a8593c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 1 addition & 3 deletions apps/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ export default async function MainRootLayout(
props: PropsWithChildren
): Promise<ReactElement> {
const { children } = props;
const { version } = await import("@react-md/core/package.json").then(
(pkg) => pkg.default
);
const headersInstance = headers();
const version = process.env.NEXT_PUBLIC_RMD_VERSION;
const isMac = !!headersInstance.get("user-agent")?.includes("Mac");
const { prismStyles, themeStyles, ...providerProps } =
await getInitialState();
Expand Down
5 changes: 4 additions & 1 deletion apps/docs/src/components/RootLayout/VersionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { type ReactElement } from "react";
import styles from "./VersionDropdown.module.scss";
import { VersionMenuItem } from "./VersionMenuItem.jsx";

// I might just want to start @react-md/core at v6
const MAJOR_VERSIONS_BEFORE = 5;

export interface VersionDropdownProps extends SemVer {
version: string;
isHiddenOnPhone?: boolean;
Expand All @@ -15,7 +18,7 @@ export function VersionDropdown(props: VersionDropdownProps): ReactElement {
const { version, major, minor, patch, alpha, isHiddenOnPhone } = props;
const isAlphaPreview = alpha !== null;
const isMajorPreview = minor === 0 && patch === 0 && isAlphaPreview;
const previousCount = major - 1;
const previousCount = MAJOR_VERSIONS_BEFORE + major - 1;
return (
<DropdownMenu
className={cnb(isHiddenOnPhone && styles.dropdown)}
Expand Down

0 comments on commit a8593c5

Please sign in to comment.