mirror of
https://github.com/pheralb/svgl.git
synced 2024-11-10 14:46:54 +08:00
✨ Add popover UI component
This commit is contained in:
parent
bbaa5cd05d
commit
1d6384b1f2
16
src/ui/popover/index.ts
Normal file
16
src/ui/popover/index.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Popover as PopoverPrimitive } from 'bits-ui';
|
||||||
|
import Content from './popover-content.svelte';
|
||||||
|
const Root = PopoverPrimitive.Root;
|
||||||
|
const Trigger = PopoverPrimitive.Trigger;
|
||||||
|
const Close = PopoverPrimitive.Close;
|
||||||
|
|
||||||
|
export {
|
||||||
|
Root,
|
||||||
|
Content,
|
||||||
|
Trigger,
|
||||||
|
Close,
|
||||||
|
Root as Popover,
|
||||||
|
Content as PopoverContent,
|
||||||
|
Trigger as PopoverTrigger,
|
||||||
|
Close as PopoverClose
|
||||||
|
};
|
29
src/ui/popover/popover-content.svelte
Normal file
29
src/ui/popover/popover-content.svelte
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Popover as PopoverPrimitive } from 'bits-ui';
|
||||||
|
|
||||||
|
import { cn } from '@/utils/cn';
|
||||||
|
import { flyAndScale } from '@/utils/flyAndScale';
|
||||||
|
|
||||||
|
type $$Props = PopoverPrimitive.ContentProps;
|
||||||
|
|
||||||
|
let className: $$Props['class'] = undefined;
|
||||||
|
export let transition: $$Props['transition'] = flyAndScale;
|
||||||
|
export let transitionConfig: $$Props['transitionConfig'] = undefined;
|
||||||
|
export let align: $$Props['align'] = 'center';
|
||||||
|
export let sideOffset: $$Props['sideOffset'] = 4;
|
||||||
|
export { className as class };
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<PopoverPrimitive.Content
|
||||||
|
{transition}
|
||||||
|
{transitionConfig}
|
||||||
|
{align}
|
||||||
|
{sideOffset}
|
||||||
|
{...$$restProps}
|
||||||
|
class={cn(
|
||||||
|
'z-50 w-60 rounded-md border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 p-4 text-popover-foreground shadow-md outline-none',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</PopoverPrimitive.Content>
|
Loading…
Reference in New Issue
Block a user