docs: redesigned navigation (#9525)

Redesign navigation bar to reflect new design and allow for dropdowns

Closes DX-943
This commit is contained in:
Shahed Nasser
2024-10-11 07:10:00 +00:00
committed by GitHub
parent 7c5415ba3a
commit 49a91fd40e
63 changed files with 934 additions and 978 deletions
@@ -1,25 +0,0 @@
import { SidebarItem } from "types"
import { mobileSidebarItemsV1, mobileSidebarItemsV2 } from ".."
type Options = {
baseUrl: string
version?: "v1" | "v2"
}
export function getMobileSidebarItems({
baseUrl,
version = "v1",
}: Options): SidebarItem[] {
const mobileItems =
version === "v2" ? mobileSidebarItemsV2 : mobileSidebarItemsV1
return mobileItems.map((item) => {
if (item.type !== "link") {
return item
}
return {
...item,
path: `${baseUrl}${item.path}`,
}
})
}
@@ -1,27 +1,31 @@
import { NavigationDropdownItem } from "types"
import { navDropdownItemsV1, navDropdownItemsV2 } from ".."
import { NavigationItem } from "types"
import { navDropdownItems } from ".."
type Options = {
basePath: string
activePath: string
version?: "v1" | "v2"
}
export function getNavDropdownItems({
basePath,
activePath,
version = "v1",
}: Options): NavigationDropdownItem[] {
const items = version === "v2" ? navDropdownItemsV2 : navDropdownItemsV1
return items.map((item) => {
if (item.type === "divider") {
return item
export function getNavDropdownItems({ basePath }: Options): NavigationItem[] {
return navDropdownItems.map((item) => {
const newItem = {
...item,
}
return {
...item,
isActive: activePath === item.path,
path: `${basePath}${item.path}`,
if (newItem.type === "link") {
newItem.path = `${basePath}${newItem.path}`
} else {
newItem.children = newItem.children.map((childItem) => {
if (childItem.type !== "link") {
return childItem
}
return {
...childItem,
link: `${basePath}${childItem.link}`,
}
})
}
return newItem
})
}
-1
View File
@@ -5,7 +5,6 @@ export * from "./decode-str"
export * from "./dom-utils"
export * from "./format-report-link"
export * from "./get-link-with-base-path"
export * from "./get-mobile-sidebar-items"
export * from "./get-navbar-items"
export * from "./get-os-shortcut"
export * from "./get-scrolled-top"