hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { Tooltip as TooltipPrimitive } from "@kobalte/core/tooltip"; |
| 2 | import type { ComponentProps, ValidComponent } from "solid-js"; |
| 3 | import { splitProps } from "solid-js"; |
| 4 | import { cn } from "@/lib/cn"; |
| 5 | |
| 6 | // Kobalte's tooltip opens on hover and on keyboard focus, so a focusable |
| 7 | // trigger reaches keyboard users too. It is deliberately not a touch surface: |
| 8 | // anything a tooltip says must also be readable without it, since a tap can |
| 9 | // never open one. |
| 10 | export const Tooltip = TooltipPrimitive; |
| 11 | export const TooltipTrigger = TooltipPrimitive.Trigger; |
| 12 | |
| 13 | export function TooltipContent<T extends ValidComponent = "div">( |
| 14 | props: ComponentProps<typeof TooltipPrimitive.Content<T>>, |
| 15 | ) { |
| 16 | const [local, rest] = splitProps(props as ComponentProps<typeof TooltipPrimitive.Content>, [ |
| 17 | "class", |
| 18 | ]); |
| 19 | return ( |
| 20 | <TooltipPrimitive.Portal> |
| 21 | <TooltipPrimitive.Content |
| 22 | class={cn( |
| 23 | "z-[70] max-w-64 rounded-md border border-border/80 bg-popover px-3 py-2 text-xs text-popover-foreground shadow-xl shadow-black/10", |
| 24 | "origin-(--kb-tooltip-content-transform-origin) animate-in fade-in-0 zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", |
| 25 | local.class, |
| 26 | )} |
| 27 | {...rest} |
| 28 | /> |
| 29 | </TooltipPrimitive.Portal> |
| 30 | ); |
| 31 | } |