Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/ui-kit. 🦊 fox ui, svelte 5 and tailwind 4 flo-bit.dev/ui-kit
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869<script lang="ts"> import type { WithElementRef } from 'bits-ui'; import type { HTMLAttributes } from 'svelte/elements'; import ScrollArea from '../scroll-area/ScrollArea.svelte'; import { cn } from '$lib/utils';
const { class: className, mobileClasses, children, mobileOnly = false, ...restProps }: WithElementRef<HTMLAttributes<HTMLDivElement>> & { mobileClasses?: string; mobileOnly?: boolean; } = $props();</script>
<div popover="auto" id="mobile-menu" class={cn( 'mobileMenuPopover border-base-200 bg-base-50 dark:border-base-300/10 dark:bg-base-950 my-2 ml-2 overflow-y-hidden rounded-2xl', 'inset-auto top-0 left-0 block h-[calc(100dvh-1rem)] w-72 border shadow-lg lg:hidden', className, mobileClasses )} {...restProps}> <ScrollArea orientation="vertical" class="h-screen"> {@render children?.()} </ScrollArea></div>
{#if !mobileOnly} <div class={cn( 'border-base-200 bg-base-50 dark:border-base-300/10 dark:bg-base-950 fixed top-0 bottom-0 left-0 z-40', 'hidden -translate-x-72 border-r lg:block lg:w-72 lg:translate-x-0 xl:w-80', className )} {...restProps} > <ScrollArea orientation="vertical" class="h-screen overflow-y-scroll"> {@render children?.()} </ScrollArea> </div>{/if}
<style> .mobileMenuPopover { /* Closed state transformed off the screen */ transform: translateX(-110%); transition: transform 0.1s, overlay 0.1s ease-out;
/* Styles while the menu is open */ &:popover-open { transform: translateX(0); }
/* Backdrop that overlays other content */ &::backdrop { background-color: rgba(0, 0, 0, 0.5); } }</style>