mirror of
https://github.com/hanzoai/svelte.git
synced 2026-10-01 00:41:47 +00:00
Extracted from @hanzo/ui pkg/ui/src/backends/svelte with its history. It lived inside a React component library, which meant every consumer of @hanzo/ui resolved svelte whether they rendered a single Svelte component or not, and the package declared peer svelte>=5 against a dev svelte ^4.2.20 — two answers to one question. Three runtime dependencies, all load-bearing: class-variance-authority for the variants the components already used, and clsx + tailwind-merge behind cn. The cn helper is vendored (17 lines) rather than imported back from @hanzo/ui, because depending on the package this was extracted from would undo the split. No design-system runtime, no icon pack, no CSS-in-JS. svelte-check: 50 files, 0 errors. Co-authored-by: Hanzo Dev <[email protected]>
36 lines
1.0 KiB
Svelte
36 lines
1.0 KiB
Svelte
<!--
|
|
DropdownMenuContent — the menu surface. Standard-token popover styling; roving
|
|
ArrowUp/Down/Home/End focus over its items. Positioned in-flow (absolute) under
|
|
the trigger; `align` picks the edge.
|
|
-->
|
|
<script lang="ts">
|
|
import { getDisclosure, DROPDOWN } from './internal/context'
|
|
import { rovingFocus } from './internal/actions'
|
|
import { cn } from './core/cn'
|
|
|
|
let className: string | undefined = undefined
|
|
export { className as class }
|
|
export let align: 'start' | 'end' = 'start'
|
|
|
|
const { open, contentId, triggerId } = getDisclosure(DROPDOWN, 'DropdownMenuContent')
|
|
</script>
|
|
|
|
{#if $open}
|
|
<div
|
|
role="menu"
|
|
id={contentId}
|
|
aria-labelledby={triggerId}
|
|
tabindex="-1"
|
|
use:rovingFocus
|
|
data-slot="dropdown-menu-content"
|
|
data-state="open"
|
|
class={cn(
|
|
'absolute z-50 mt-1 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md',
|
|
align === 'end' ? 'right-0' : 'left-0',
|
|
className,
|
|
)}
|
|
>
|
|
<slot />
|
|
</div>
|
|
{/if}
|