Installation
Dependencies
This component requires the following dependencies:button- shadcn/ui button componentdialog- shadcn/ui dialog componentinput- shadcn/ui input componentlabel- shadcn/ui label componentswitch- shadcn/ui switch componenttooltip- shadcn/ui tooltip componentlucide-react- Icon library (CheckIcon, CopyIcon, ExternalLink, Link, Share2)
Usage
Features
- Copy to clipboard - Click to copy share link with visual feedback
- Animated icons - Smooth transition between copy and check icons
- Toggle settings - Switch for enabling comments and suggestions
- Multiple actions - Copy Link and Preview buttons
- Tooltip feedback - Shows “Copied!” confirmation
- Read-only input - Share URL displayed in non-editable field
- Icon buttons - Multiple action options with icons
- Ref usage - Uses useRef for direct input access
Component Structure
The component includes:Dialogwith controlled stateDialogTriggerwith Share2 iconDialogContentwith medium widthDialogHeaderwith title and description- Toggle section:
- Switch for comments and suggestions
- Share link section:
- Read-only Input with share URL
- Copy button with:
- Animated CheckIcon/CopyIcon transition
- Tooltip showing copy status
- useRef for clipboard access
- Action buttons:
- Copy Link button
- Preview button with ExternalLink icon
- State management for:
- Dialog visibility
- Copy status
- Input ref
- Copy handler with timeout for feedback
The copy button uses CSS transitions (
transition-[transform,opacity] duration-200) to smoothly animate between the copy and check icons. The component uses cn() utility to conditionally apply classes based on the copied state.