Files
frontend-svelte/src/shared/shadcn/ui/sidebar/sidebar-rail.svelte
Ilia Mashkov 4ba02b5933
Some checks failed
Lint / Lint Code (push) Failing after 7m9s
Test / Svelte Checks (push) Failing after 7m20s
fix: new dprint import format settings
2026-01-02 17:01:59 +03:00

40 lines
1.5 KiB
Svelte

<script lang="ts">
import {
type WithElementRef,
cn,
} from '$shared/shadcn/utils/shadcn-utils.js';
import type { HTMLAttributes } from 'svelte/elements';
import { useSidebar } from './context.svelte.js';
let {
ref = $bindable(null),
class: className,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLButtonElement>, HTMLButtonElement> = $props();
const sidebar = useSidebar();
</script>
<button
bind:this={ref}
data-sidebar="rail"
data-slot="sidebar-rail"
aria-label="Toggle Sidebar"
tabIndex={-1}
onclick={sidebar.toggle}
title="Toggle Sidebar"
class={cn(
'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-end-4 group-data-[side=right]:start-0 after:absolute after:inset-y-0 after:start-[calc(1/2*100%-1px)] after:w-[2px] sm:flex',
'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
'[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:start-full',
'[[data-side=left][data-collapsible=offcanvas]_&]:-end-2',
'[[data-side=right][data-collapsible=offcanvas]_&]:-start-2',
className,
)}
{...restProps}
>
{@render children?.()}
</button>