-
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
6 changed files
with
203 additions
and
87 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,48 @@ | ||
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"; | ||
|
||
export const NavigationFourLevels = () => { | ||
const data = [ | ||
{ | ||
icon: "wrench", | ||
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} | ||
Check failure on line 34 in layouts/DocsPage/Navigation.stories.tsx GitHub Actions / Lint code base
|
||
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
Oops, something went wrong.