feat(Controls): add Drawer wrapper for mobiles

This commit is contained in:
Ilia Mashkov
2026-02-16 14:16:52 +03:00
parent 42854b4950
commit 23831efbe6

View File

@@ -8,10 +8,13 @@
<script lang="ts"> <script lang="ts">
import { appliedFontsManager } from '$entities/Font'; import { appliedFontsManager } from '$entities/Font';
import { getFontUrl } from '$entities/Font/lib'; import { getFontUrl } from '$entities/Font/lib';
import type { ResponsiveManager } from '$shared/lib';
import { cn } from '$shared/shadcn/utils/shadcn-utils'; import { cn } from '$shared/shadcn/utils/shadcn-utils';
import { SidebarMenu } from '$shared/ui'; import { SidebarMenu } from '$shared/ui';
import Drawer from '$shared/ui/Drawer/Drawer.svelte';
import { comparisonStore } from '$widgets/ComparisonSlider/model'; import { comparisonStore } from '$widgets/ComparisonSlider/model';
import ComparisonList from './FontList.svelte'; import { getContext } from 'svelte';
import FontList from './FontList.svelte';
import ToggleMenuButton from './ToggleMenuButton.svelte'; import ToggleMenuButton from './ToggleMenuButton.svelte';
import TypographyControls from './TypographyControls.svelte'; import TypographyControls from './TypographyControls.svelte';
@@ -33,6 +36,7 @@ const fontA = $derived(comparisonStore.fontA);
const fontB = $derived(comparisonStore.fontB); const fontB = $derived(comparisonStore.fontB);
const typography = $derived(comparisonStore.typography); const typography = $derived(comparisonStore.typography);
let menuWrapper = $state<HTMLElement | null>(null); let menuWrapper = $state<HTMLElement | null>(null);
const responsive = getContext<ResponsiveManager>('responsive');
$effect(() => { $effect(() => {
if (!fontA || !fontB) { if (!fontA || !fontB) {
@@ -64,6 +68,28 @@ $effect(() => {
}); });
</script> </script>
{#if responsive.isMobile}
<Drawer>
{#snippet trigger({ onClick })}
<div class={cn('absolute bottom-2 inset-x-0 z-50')}>
<ToggleMenuButton bind:isActive={visible} {onClick} />
</div>
{/snippet}
{#snippet content({ className })}
<div class={cn(className, 'flex flex-col gap-2 h-[60vh]')}>
<div class="h-full overflow-hidden">
<FontList />
</div>
<div class="relative flex w-auto border-b border-gray-400/50 px-2 ml-4 mr-8 lg:mr-10 flex-shrink-0">
</div>
<div class="mr-4 sm:mr-6 flex-shrink-0">
<TypographyControls />
</div>
</div>
{/snippet}
</Drawer>
{:else}
<SidebarMenu <SidebarMenu
class={cn( class={cn(
'w-96 flex flex-col h-full pl-4 lg:pl-6 py-4 sm:py-6 sm:pt-12 gap-4 sm:gap-6 pointer-events-auto overflow-hidden', 'w-96 flex flex-col h-full pl-4 lg:pl-6 py-4 sm:py-6 sm:pt-12 gap-4 sm:gap-6 pointer-events-auto overflow-hidden',
@@ -81,7 +107,7 @@ $effect(() => {
</div> </div>
{/snippet} {/snippet}
<div class="h-2/3 overflow-hidden"> <div class="h-2/3 overflow-hidden">
<ComparisonList /> <FontList />
</div> </div>
<div class="relative flex w-auto border-b border-gray-400/50 px-2 ml-4 mr-8 lg:mr-10"></div> <div class="relative flex w-auto border-b border-gray-400/50 px-2 ml-4 mr-8 lg:mr-10"></div>
@@ -89,3 +115,4 @@ $effect(() => {
<TypographyControls /> <TypographyControls />
</div> </div>
</SidebarMenu> </SidebarMenu>
{/if}