flowbite-svelte icon indicating copy to clipboard operation
flowbite-svelte copied to clipboard

support hide/show Sidebar

Open xmlking opened this issue 2 years ago • 2 comments

any plans to support hide/show Sidebar? by exporting show, and transition props in Sidebar.svelte, I think we could allow users to customize to their needs (via Hamburger, button, etc)

<script lang="ts">
	import classNames from 'classnames'
	import {fly} from 'svelte/transition';

	export let show = true;
	export let asideClass: string = 'w-64';
</script>

{#if show}
	<aside transition:fly={{x: -250, opacity: 1}} class={classNames(asideClass, $$props.class)} {...$$restProps}
		   aria-label="Sidebar">
		<slot/>
	</aside>
{/if}

Usage example

<script>
        import { sidebarOpen  } from '$lib/stores/sidebarStore';

	let show = true;
	sidebarOpen.subscribe((value) => {
		show = value === true;
	});
</script>

<Sidebar {show} {asideClass}>
	<SidebarWrapper {divClass}>
		<SidebarGroup>
....

xmlking avatar Jun 29 '22 01:06 xmlking

What do you think about Svelte-sidebar-menu? It is responsive, flexible and has example with Flowbite-Svelte. Repo

shinokada avatar Jun 29 '22 04:06 shinokada

Svelte-sidebar-menu looks great but few reasons why I like to build my layout all from flowbite-svelte components where Svelte-sidebar-menu is not perfect fitting my needs:

  1. try to build entier WebApp with just flowbite-svelte components without depending on 3rd party components for consistent styling and maintenance
  2. I like to arrange my layout with a sticky header and footer wittout using absolute positioning ( z-50 top-0 left-0 ) , I am setting up mine
<DarkMode btnClass={darkmodebtn}/>

<div class="flex flex-col h-screen">
	<!--  start::navbar   -->
		<Header />
	<!--  end::navbar     -->
	<div class="flex flex-1 overflow-hidden">
		<!--   start::Sidebar    -->
		<SideMenu />
		<!--   end::Sidebar      -->
		<!--   start::Main Content     -->
		<main class="container overflow-y-auto mx-auto py-32 px-8 dark:text-white" >
			<slot/>
		</main>
		<!--   end::Main Content      -->
	</div>
	<!--   start::Footer    -->
	<Footer/>
	<!--   end::Footer      -->
</div>
  1. like to use my own button icon to hide/show sidenav and like to add sidenav either left or right

xmlking avatar Jun 30 '22 05:06 xmlking

Once the Drawer component is done, you can add anything in the component.

shinokada avatar Sep 04 '22 01:09 shinokada

I believe this is what you wanted.

https://flowbite-svelte.com/drawer#Drawer_navigation

shinokada avatar Sep 04 '22 23:09 shinokada