Skip to content

Commit

Permalink
chore: fix sidebar open state
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Oct 29, 2024
1 parent 15ce682 commit c7b0c82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function SidebarCategory(props: SidebarCategoryProps) {
}, [toggle, shouldScroll, isMobile, contentRef])

return (
<chakra.div ps="10" ref={ref} {...rest}>
<chakra.div ps="7" ref={ref} {...rest}>
<chakra.p
className="sidebar-category-header"
width="full"
Expand Down
19 changes: 4 additions & 15 deletions apps/website/src/docs/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
Collapse,
Icon,
Flex,
Center,
Container,
Text,
HStack,
} from '@chakra-ui/react'
Expand All @@ -29,13 +27,7 @@ import SidebarLink from './sidebar-link'

import Link from 'next/link'

import {
NavItem,
SearchInput,
useHotkeys,
useCollapse,
NavItemProps,
} from '@saas-ui/react'
import { useHotkeys, useCollapse } from '@saas-ui/react'

import { FiChevronDown, FiChevronRight } from 'react-icons/fi'
import { LuCheck } from 'react-icons/lu'
Expand Down Expand Up @@ -145,11 +137,7 @@ function SidebarGroup({
{routes?.map((lvl2, index) => {
if (!lvl2.routes) {
return (
<SidebarLink
ps="10"
key={lvl2.path || index}
href={lvl2.path}
>
<SidebarLink ps="7" key={lvl2.path || index} href={lvl2.path}>
<span>{convertBackticksToInlineCode(lvl2.title)}</span>
{lvl2.new && (
<Badge
Expand Down Expand Up @@ -200,6 +188,7 @@ function SidebarGroup({
}

const selected = pathname.startsWith(lvl2.path)

const opened = selected || lvl2.open

const sortedRoutes = lvl2.sort
Expand Down Expand Up @@ -374,7 +363,7 @@ export const isMainNavLinkActive = (href: string, path: string) => {
const [, , group, category] = href.split('/')

return path.includes(
href.split('/').length >= 3 ? `${group}/${category}` : group
href.split('/').length >= 4 ? `${group}/${category}` : group
)
}

Expand Down
4 changes: 1 addition & 3 deletions apps/website/src/layouts/mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Pagination from '@/docs/components/pagination'
import Sidebar from '@/docs/components/sidebar/sidebar'
import docsSidebar from '@/data/docs-sidebar'
import coreSidebar from '@/data/core-sidebar'
import componentsSidebar from '@/data/components-sidebar'
import hooksSidebar from '@/data/hooks-sidebar'
import proSidebar from '@/data/pro-sidebar'
import nextjsSidebar from '@/data/nextjs-sidebar'
import guidesSidebar from '@/data/guides-sidebar'
Expand All @@ -24,7 +22,7 @@ export function getRoutes(slug: string) {
const configMap = {
'/docs/core': coreSidebar,
'/docs/components': coreSidebar,
'/docs/hooks': hooksSidebar,
'/docs/hooks': coreSidebar,
'/docs/guides': guidesSidebar,
'/docs/pro': proSidebar,
'/docs/nextjs-starter-kit': nextjsSidebar,
Expand Down

0 comments on commit c7b0c82

Please sign in to comment.