mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-05 21:54:50 +00:00
feat: add BaseTooltip component using Reka UI
Add foundational tooltip component with three variants (default, small, large), four positioning sides, and configurable delay/disabled state. Wrap App.vue in TooltipProvider for app-wide tooltip support. Include Storybook stories for all variants, sides, disabled, and long text.
This commit is contained in:
56
src/components/ui/tooltip/BaseTooltip.vue
Normal file
56
src/components/ui/tooltip/BaseTooltip.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
|
||||
import {
|
||||
TooltipArrow,
|
||||
TooltipContent,
|
||||
TooltipPortal,
|
||||
TooltipRoot,
|
||||
TooltipTrigger
|
||||
} from 'reka-ui'
|
||||
|
||||
import type { TooltipVariants } from '@/components/ui/tooltip/tooltip.variants'
|
||||
import { tooltipVariants } from '@/components/ui/tooltip/tooltip.variants'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
const {
|
||||
text = '',
|
||||
side = 'top',
|
||||
sideOffset = 4,
|
||||
variant = 'default',
|
||||
delayDuration,
|
||||
disabled = false,
|
||||
class: className
|
||||
} = defineProps<{
|
||||
text?: string
|
||||
side?: 'top' | 'bottom' | 'left' | 'right'
|
||||
sideOffset?: number
|
||||
variant?: NonNullable<TooltipVariants['variant']>
|
||||
delayDuration?: number
|
||||
disabled?: boolean
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipRoot :delay-duration="delayDuration" :disabled="disabled || !text">
|
||||
<TooltipTrigger as-child>
|
||||
<slot />
|
||||
</TooltipTrigger>
|
||||
<TooltipPortal>
|
||||
<TooltipContent
|
||||
:side="side"
|
||||
:side-offset="sideOffset"
|
||||
:class="cn(tooltipVariants({ variant }), className)"
|
||||
>
|
||||
{{ text }}
|
||||
<TooltipArrow
|
||||
v-if="variant !== 'default'"
|
||||
:width="8"
|
||||
:height="5"
|
||||
class="fill-node-component-tooltip-surface"
|
||||
/>
|
||||
</TooltipContent>
|
||||
</TooltipPortal>
|
||||
</TooltipRoot>
|
||||
</template>
|
||||
Reference in New Issue
Block a user