11import { useEffect , useState } from 'react' ;
22
3- import { Button , Heading , Input , Popover } from '@douglasneuroinformatics/libui/components' ;
3+ import { Heading , Input , Popover , Tooltip } from '@douglasneuroinformatics/libui/components' ;
44import { CopyButton } from '@opendatacapture/react-core' ;
5- import { ShareIcon } from 'lucide-react' ;
5+ import { Share2Icon } from 'lucide-react' ;
66
77import { useFilesRef } from '@/hooks/useFilesRef' ;
88import { useAppStore } from '@/store' ;
@@ -14,6 +14,7 @@ export const ShareButton = () => {
1414 const editorFilesRef = useFilesRef ( ) ;
1515 const [ shareURL , setShareURL ] = useState ( encodeShareURL ( { files : editorFilesRef . current , label } ) ) ;
1616 const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false ) ;
17+ const [ isTooltipOpen , setIsTooltipOpen ] = useState ( false ) ;
1718
1819 // The user cannot modify the editor without closing the popover
1920 useEffect ( ( ) => {
@@ -23,25 +24,37 @@ export const ShareButton = () => {
2324 } , [ isPopoverOpen , label ] ) ;
2425
2526 return (
26- < Popover open = { isPopoverOpen } onOpenChange = { setIsPopoverOpen } >
27- < Popover . Trigger asChild >
28- < Button className = "h-9 w-9" size = "icon" variant = "outline" >
29- < ShareIcon />
30- </ Button >
31- </ Popover . Trigger >
32- < Popover . Content align = "end" className = "w-[520px] p-4" >
33- < div className = "flex flex-col space-y-2 text-center sm:text-left" >
34- < Heading variant = "h5" > Share Instrument</ Heading >
35- < p className = "text-muted-foreground text-sm" >
36- Anyone with this link can open a snapshot of the current code in your playground. The total size of the
37- URL-encoded source files for this instrument is { formatSize ( shareURL . size ) } .
38- </ p >
39- </ div >
40- < div className = "flex gap-2 pt-4" >
41- < Input readOnly className = "h-9" id = "link" value = { shareURL . href } />
42- < CopyButton size = "sm" text = { shareURL . href } />
43- </ div >
44- </ Popover . Content >
45- </ Popover >
27+ < Tooltip
28+ open = { isTooltipOpen }
29+ onOpenChange = { ( open ) => {
30+ if ( ! isPopoverOpen ) {
31+ setIsTooltipOpen ( open ) ;
32+ }
33+ } }
34+ >
35+ < Popover open = { isPopoverOpen } onOpenChange = { setIsPopoverOpen } >
36+ < Popover . Trigger asChild >
37+ < Tooltip . Trigger className = "h-9 w-9" size = "icon" variant = "outline" >
38+ < Share2Icon />
39+ </ Tooltip . Trigger >
40+ </ Popover . Trigger >
41+ < Popover . Content align = "end" className = "w-[520px] p-4" >
42+ < div className = "flex flex-col space-y-2 text-center sm:text-left" >
43+ < Heading variant = "h5" > Share Instrument</ Heading >
44+ < p className = "text-muted-foreground text-sm" >
45+ Anyone with this link can open a snapshot of the current code in your playground. The total size of the
46+ URL-encoded source files for this instrument is { formatSize ( shareURL . size ) } .
47+ </ p >
48+ </ div >
49+ < div className = "flex gap-2 pt-4" >
50+ < Input readOnly className = "h-9" id = "link" value = { shareURL . href } />
51+ < CopyButton size = "sm" text = { shareURL . href } />
52+ </ div >
53+ </ Popover . Content >
54+ </ Popover >
55+ < Tooltip . Content side = "bottom" >
56+ < p > Share</ p >
57+ </ Tooltip . Content >
58+ </ Tooltip >
4659 ) ;
4760} ;
0 commit comments