From 45078dad46e3ee92e6c9bf3457da470da31937f5 Mon Sep 17 00:00:00 2001 From: Jean-Charles FAUCHET Date: Fri, 14 Jun 2024 18:09:20 +0200 Subject: [PATCH] feat: sidebar add withNabar props --- apps/web/src/routes/docs/layout.tsx | 2 +- packages/lib/package.json | 2 +- packages/lib/src/components/Navbar/Navbar.tsx | 8 ++++---- .../Navbar/composables/use-navbar-context.ts | 8 ++++---- packages/lib/src/components/Sidebar/Sidebar.tsx | 11 +++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/web/src/routes/docs/layout.tsx b/apps/web/src/routes/docs/layout.tsx index f19acc71e..f0a9cf35e 100644 --- a/apps/web/src/routes/docs/layout.tsx +++ b/apps/web/src/routes/docs/layout.tsx @@ -8,7 +8,7 @@ export default component$(() => { return (
- + diff --git a/packages/lib/package.json b/packages/lib/package.json index 77ac5a449..b33f4b5a1 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { "name": "flowbite-qwik", - "version": "0.21.2", + "version": "0.21.3", "description": "Unofficial Qwik components built for Flowbite and Tailwind CSS", "keywords": [ "design-system", diff --git a/packages/lib/src/components/Navbar/Navbar.tsx b/packages/lib/src/components/Navbar/Navbar.tsx index 72ae12eee..bc7bbb7c9 100644 --- a/packages/lib/src/components/Navbar/Navbar.tsx +++ b/packages/lib/src/components/Navbar/Navbar.tsx @@ -1,7 +1,7 @@ import { component$, PropsOf, Slot, useContextProvider, useStore } from '@builder.io/qwik' import { twMerge } from 'tailwind-merge' import clsx from 'clsx' -import { NavbarContext } from '~/components/Navbar/composables/use-navbar-context' +import { navbarContext } from '~/components/Navbar/composables/use-navbar-context' type NavbarProps = PropsOf<'nav'> & { menuOpen?: boolean @@ -14,12 +14,12 @@ type NavbarProps = PropsOf<'nav'> & { export const Navbar = component$( ({ border = false, fluid = false, sticky = false, separator = false, menuOpen = false, rounded = false, class: classNames, ...props }) => { - useContextProvider(NavbarContext, useStore({ isOpen: menuOpen })) + useContextProvider(navbarContext, useStore({ isOpen: menuOpen })) return ( diff --git a/packages/lib/src/components/Navbar/composables/use-navbar-context.ts b/packages/lib/src/components/Navbar/composables/use-navbar-context.ts index 1f2927e0d..7ce2c38a1 100644 --- a/packages/lib/src/components/Navbar/composables/use-navbar-context.ts +++ b/packages/lib/src/components/Navbar/composables/use-navbar-context.ts @@ -1,14 +1,14 @@ import { $, createContextId, useComputed$, useContext } from '@builder.io/qwik' type NavbarContextProps = { isOpen: boolean } -export const NavbarContext = createContextId('Navbar') +export const navbarContext = createContextId('Navbar') export function useNavbarContext() { - const navbarContext = useContext(NavbarContext) + const state = useContext(navbarContext) - const isOpen = useComputed$(() => navbarContext.isOpen) + const isOpen = useComputed$(() => state.isOpen) const setIsOpen = $((value: boolean) => { - navbarContext.isOpen = value + state.isOpen = value }) return { diff --git a/packages/lib/src/components/Sidebar/Sidebar.tsx b/packages/lib/src/components/Sidebar/Sidebar.tsx index 6626ef8b9..f960ecfa9 100644 --- a/packages/lib/src/components/Sidebar/Sidebar.tsx +++ b/packages/lib/src/components/Sidebar/Sidebar.tsx @@ -11,9 +11,10 @@ import { IconCloseOutline } from 'flowbite-qwik-icons' type SidebarProps = PropsOf<'aside'> & { highlight?: boolean closeButton?: boolean + withNavbar?: boolean } -const InternalSidebar = component$(({ highlight = false, closeButton = false, class: classNames, ...attrs }) => { +const InternalSidebar = component$(({ highlight = false, withNavbar = false, closeButton = false, class: classNames, ...attrs }) => { const { isOpen, setIsOpen } = useSidebarOpen() const sidebar = useSignal() @@ -30,11 +31,9 @@ const InternalSidebar = component$(({ highlight = false, closeButt