-
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.
Generate sidebar entries at an arbitrary depth
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 _includes_ the subsection path.
- Loading branch information
Showing
5 changed files
with
206 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
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 { TabItem } from "./TabItem"; | ||
import { Tabs } from "./Tabs"; | ||
|
||
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 37 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 Tabs> = { | ||
title: "layouts/DocNavigation", | ||
component: NavigationFourLevels, | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof Tabs>; | ||
|
||
// export const InitialStateTab: Story = { | ||
// play: async ({ canvasElement, step }) => { | ||
// const canvas = within(canvasElement); | ||
// await step("Should be the text for the selected option", async () => { | ||
// expect( | ||
// await canvas.findByText( | ||
// "Instructions for installing release using shell commands." | ||
// ) | ||
// ).toBeTruthy(); | ||
// }); | ||
// await step( | ||
// "Selected option should be disabled for re-selection", | ||
// async () => { | ||
// expect(canvas.getByText("Shell")).toBeDisabled(); | ||
// } | ||
// ); | ||
// }, | ||
// }; |
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.