Download apps/readest-app/src/components/assistant/TooltipIconButton.tsx from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/components/assistant/TooltipIconButton.tsx
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src/components/assistant/TooltipIconButton.tsx
-
curl -L -o TooltipIconButton.tsx https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/components/assistant/TooltipIconButton.tsx
1.24 kB
| 'use client'; | |
| import { forwardRef, type ComponentPropsWithRef } from 'react'; | |
| import { Slottable } from '@radix-ui/react-slot'; | |
| import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip'; | |
| import { Button } from '@/components/ui/button'; | |
| import { cn } from '@/utils/tailwind'; | |
| export type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & { | |
| tooltip: string; | |
| side?: 'top' | 'bottom' | 'left' | 'right'; | |
| }; | |
| export const TooltipIconButton = forwardRef<HTMLButtonElement, TooltipIconButtonProps>( | |
| ({ children, tooltip, side = 'bottom', className, ...rest }, ref) => { | |
| return ( | |
| <TooltipProvider> | |
| <Tooltip> | |
| <TooltipTrigger asChild> | |
| <Button | |
| variant='ghost' | |
| size='icon-sm' | |
| {...rest} | |
| className={cn('size-6 p-1', className)} | |
| ref={ref} | |
| > | |
| <Slottable>{children}</Slottable> | |
| <span className='sr-only'>{tooltip}</span> | |
| </Button> | |
| </TooltipTrigger> | |
| <TooltipContent side={side}>{tooltip}</TooltipContent> | |
| </Tooltip> | |
| </TooltipProvider> | |
| ); | |
| }, | |
| ); | |
| TooltipIconButton.displayName = 'TooltipIconButton'; | |