Skip to content

Commit 831c022

Browse files
committed
add showArrow prop to tooltip
1 parent 43feea4 commit 831c022

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@invopop/popui",
33
"license": "MIT",
4-
"version": "0.1.80",
4+
"version": "0.1.81",
55
"repository": {
66
"url": "https://github.com/invopop/popui"
77
},

svelte/src/lib/tooltip/tooltip-content.svelte

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
sideOffset = 0,
88
side = 'top',
99
children,
10+
showArrow = false,
1011
arrowClasses
1112
}: TooltipPrimitive.ContentProps & {
13+
showArrow?: boolean
1214
arrowClasses?: string
1315
} = $props()
1416
</script>
@@ -25,20 +27,22 @@
2527
)}
2628
>
2729
{@render children?.()}
28-
<TooltipPrimitive.Arrow>
29-
{#snippet child({ props })}
30-
<div
31-
class={cn(
32-
'bg-background-default-negative z-[1002] size-2.5 rotate-45 rounded-[2px]',
33-
'data-[side=top]:translate-x-1/2 data-[side=top]:translate-y-[calc(-50%_+_2px)]',
34-
'data-[side=bottom]:-translate-x-1/2 data-[side=bottom]:-translate-y-[calc(-50%_+_1px)]',
35-
'data-[side=right]:translate-x-[calc(50%_+_2px)] data-[side=right]:translate-y-1/2',
36-
'data-[side=left]:-translate-y-[calc(50%_-_3px)]',
37-
arrowClasses
38-
)}
39-
{...props}
40-
></div>
41-
{/snippet}
42-
</TooltipPrimitive.Arrow>
30+
{#if showArrow}
31+
<TooltipPrimitive.Arrow>
32+
{#snippet child({ props })}
33+
<div
34+
class={cn(
35+
'bg-background-default-negative z-[1002] size-2.5 rotate-45 rounded-[2px]',
36+
'data-[side=top]:translate-x-1/2 data-[side=top]:translate-y-[calc(-50%_+_2px)]',
37+
'data-[side=bottom]:-translate-x-1/2 data-[side=bottom]:-translate-y-[calc(-50%_+_1px)]',
38+
'data-[side=right]:translate-x-[calc(50%_+_2px)] data-[side=right]:translate-y-1/2',
39+
'data-[side=left]:-translate-y-[calc(50%_-_3px)]',
40+
arrowClasses
41+
)}
42+
{...props}
43+
></div>
44+
{/snippet}
45+
</TooltipPrimitive.Arrow>
46+
{/if}
4347
</TooltipPrimitive.Content>
4448
</TooltipPrimitive.Portal>

0 commit comments

Comments
 (0)