Skip to content

Commit 2a40c2d

Browse files
committed
fix: add tooltip to playground share button
1 parent fd16262 commit 2a40c2d

1 file changed

Lines changed: 35 additions & 21 deletions

File tree

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { 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';
44
import { CopyButton } from '@opendatacapture/react-core';
55
import { Share2Icon } from 'lucide-react';
66

@@ -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,38 @@ 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-
<Share2Icon />
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+
delayDuration={700}
29+
open={isTooltipOpen}
30+
onOpenChange={(open) => {
31+
if (!isPopoverOpen) {
32+
setIsTooltipOpen(open);
33+
}
34+
}}
35+
>
36+
<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
37+
<Popover.Trigger asChild>
38+
<Tooltip.Trigger className="h-9 w-9" size="icon" variant="outline">
39+
<Share2Icon />
40+
</Tooltip.Trigger>
41+
</Popover.Trigger>
42+
<Popover.Content align="end" className="w-[520px] p-4">
43+
<div className="flex flex-col space-y-2 text-center sm:text-left">
44+
<Heading variant="h5">Share Instrument</Heading>
45+
<p className="text-muted-foreground text-sm">
46+
Anyone with this link can open a snapshot of the current code in your playground. The total size of the
47+
URL-encoded source files for this instrument is {formatSize(shareURL.size)}.
48+
</p>
49+
</div>
50+
<div className="flex gap-2 pt-4">
51+
<Input readOnly className="h-9" id="link" value={shareURL.href} />
52+
<CopyButton size="sm" text={shareURL.href} />
53+
</div>
54+
</Popover.Content>
55+
<Tooltip.Content side="bottom">
56+
<p>Share</p>
57+
</Tooltip.Content>
58+
</Popover>
59+
</Tooltip>
4660
);
4761
};

0 commit comments

Comments
 (0)