-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow four levels of sidebar entries
Currently, the code that generates the navigation sidebar from a directory tree stops at the second level of a given top-level section. However, some sections include three levels of content. This change edits the sidebar generator so it works recursively. Also fix an issue with the `DocsNavigationItems` component that prevents the docs site from highlighting sidebar entries past two levels of depth. The component treats a sidebar subsection as "active" if one of its entries is equivalent to the current page path. But if the current page path is a grandchild of a sidebar subsection, this means that the component hides the grandchild, since none of the children of the subsection is equivalent to the current page. This change determines that a sidebar subsection is "active" if the selected path _starts with_ the subsection path. Also edit the CSS padding of navigation links to depend on the current level of the navigation menu. This allows for indentation of submenu links beyond the second level.
- Loading branch information
Showing
7 changed files
with
205 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { userEvent, within } from "@storybook/testing-library"; | ||
import { expect } from "@storybook/jest"; | ||
import { default as DocNavigation } from "layouts/DocsPage/Navigation"; | ||
import { NavigationCategory } from "./types"; | ||
|
||
export const NavigationFourLevels = () => { | ||
const data = [ | ||
{ | ||
icon: "cloud", | ||
title: "Enroll Resources", | ||
entries: [ | ||
{ | ||
title: "Machine ID", | ||
slug: "/enroll-resources/machine-id/", | ||
entries: [ | ||
{ | ||
title: "Deploy Machine ID", | ||
slug: "/enroll-resources/machine-id/deployment/", | ||
entries: [ | ||
{ | ||
title: "Deploy Machine ID on AWS", | ||
slug: "/enroll-resources/machine-id/deployment/aws/", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
return ( | ||
<DocNavigation | ||
data={data as Array<NavigationCategory>} | ||
section={true} | ||
currentVersion="16.x" | ||
currentPathGetter={() => { | ||
return "/enroll-resources/machine-id/deployment/aws/"; | ||
}} | ||
></DocNavigation> | ||
); | ||
}; | ||
|
||
const meta: Meta<typeof DocNavigation> = { | ||
title: "layouts/DocNavigation", | ||
component: NavigationFourLevels, | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.