Skip to content

Commit

Permalink
lfg
Browse files Browse the repository at this point in the history
  • Loading branch information
irsyadadl committed Oct 24, 2024
1 parent 475cd49 commit ee7e81b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/blocks/sidebar/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function AppSidebar(props: React.ComponentProps<typeof Sidebar>) {
</Menu.Content>
</Menu>
</Sidebar.Footer>
<Sidebar.Rail />
{pathname !== "/blocks/sidebar/sidebar-02" && <Sidebar.Rail />}
</Sidebar>
)
}
Expand Down
16 changes: 6 additions & 10 deletions components/ui/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type NavbarOptions = {
type NavbarContextProps = {
open: boolean
setOpen: (open: boolean) => void
openCompact: boolean
setOpenCompact: (open: boolean) => void
isCompact: boolean
toggleNavbar: () => void
} & NavbarOptions
Expand Down Expand Up @@ -67,7 +65,6 @@ const Navbar = ({
intent = "navbar",
...props
}: NavbarProviderProps) => {
const [openCompact, setOpenCompact] = React.useState(false)
const isCompact = useMediaQuery("(max-width: 600px)")
const [_open, _setOpen] = React.useState(defaultOpen)
const open = openProp ?? _open
Expand All @@ -84,21 +81,20 @@ const Navbar = ({
)

const toggleNavbar = React.useCallback(() => {
return isCompact ? setOpenCompact((open) => !open) : setOpen((open) => !open)
}, [isCompact, setOpen, setOpenCompact])
setOpen((open) => !open)
}, [isCompact, setOpen])

const contextValue = React.useMemo<NavbarContextProps>(
() => ({
open,
setOpen,
isCompact,
openCompact,
setOpenCompact,
toggleNavbar,
intent,
isSticky,
side
}),
[open, setOpen, isCompact, openCompact, setOpenCompact, toggleNavbar, intent, isSticky, side]
[open, setOpen, isCompact, toggleNavbar, intent, isSticky, side]
)
return (
<NavbarContext.Provider value={contextValue}>
Expand Down Expand Up @@ -130,11 +126,11 @@ interface NavbarProps extends React.ComponentProps<"div"> {
}

const Nav = ({ className, ...props }: NavbarProps) => {
const { isCompact, side, intent, isSticky, openCompact, setOpenCompact } = useNavbar()
const { isCompact, side, intent, isSticky, open, setOpen } = useNavbar()

if (isCompact) {
return (
<Sheet isOpen={openCompact} onOpenChange={setOpenCompact} {...props}>
<Sheet isOpen={open} onOpenChange={setOpen} {...props}>
<Sheet.Content
side={side}
aria-label="Compact Navbar"
Expand Down
11 changes: 1 addition & 10 deletions resources/content/docs/components/layouts/sidebar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,9 @@ export function AppSidebar() {
const [isOpen, setIsOpen] = React.useState(false)
return (
<Sidebar.Provider isOpen={isOpen} onOpenChange={onOpenChange}>
<Sidebar.Provider isOpen={isOpen} onOpenChange={setIsOpen}>
<Sidebar />
</Sidebar.Provider>
)
}
```

## Default Opened
If you want the sidebar to be open by default, you can set the `defaultOpen` prop to `true`. You can see examples of this in [Sidebar 04](/blocks/sidebar/sidebar-04).
```
<Sidebar.Provider defaultOpen>
<Sidebar />
<Sidebar.Inset />
</Sidebar.Provider>
```
1 change: 1 addition & 0 deletions resources/content/docs/prologue/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This all changes are made on the 2024 release.

## October 24
- Significant improvements to [Breadcrumbs](/docs/components/navigation/breadcrumbs)
- Fix Navbar Props

## October 23
- Tooltip now added to sidebar when collapsed. [Example](/blocks/sidebar/sidebar-02)
Expand Down

0 comments on commit ee7e81b

Please sign in to comment.