Skip to content

Commit 7b3084c

Browse files
authored
Merge pull request #965 from joshunrau/playground-icons
2 parents 66f945f + 291ba39 commit 7b3084c

4 files changed

Lines changed: 123 additions & 96 deletions

File tree

apps/playground/src/components/Header/ActionButton/ActionButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type ActionButtonProps = {
1111

1212
export const ActionButton = ({ disabled, icon, onClick, tooltip }: ActionButtonProps) => (
1313
<div className="relative">
14-
<Tooltip delayDuration={700}>
14+
<Tooltip>
1515
<Tooltip.Trigger
1616
className="h-9 w-9"
1717
disabled={disabled}
Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react';
22

3-
import { Button, Dialog, Form } from '@douglasneuroinformatics/libui/components';
3+
import { Dialog, Form, Tooltip } from '@douglasneuroinformatics/libui/components';
44
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
55
import { CopyPlusIcon } from 'lucide-react';
66
import { z } from 'zod';
@@ -33,41 +33,46 @@ export const CloneButton = () => {
3333
};
3434

3535
return (
36-
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
37-
<Dialog.Trigger asChild>
38-
<Button className="h-9 w-9" size="icon" variant="outline">
39-
<CopyPlusIcon />
40-
</Button>
41-
</Dialog.Trigger>
42-
<Dialog.Content className="sm:max-w-[475px]">
43-
<Dialog.Header>
44-
<Dialog.Title>Create New Instrument</Dialog.Title>
45-
<Dialog.Description>
46-
This will save the current playground state in local storage as a new instrument.
47-
</Dialog.Description>
48-
</Dialog.Header>
49-
<Form
50-
className="[&_button]:max-w-32"
51-
content={{
52-
label: {
53-
kind: 'string',
54-
label: 'Label',
55-
variant: 'input'
56-
}
57-
}}
58-
submitBtnLabel="Save"
59-
validationSchema={z.object({
60-
label: z
61-
.string()
62-
.min(1)
63-
.refine(
64-
(arg) => !instruments.find((instrument) => instrument.label === arg),
65-
'An instrument with this label already exists'
66-
)
67-
})}
68-
onSubmit={(data) => void handleSubmit(data)}
69-
/>
70-
</Dialog.Content>
71-
</Dialog>
36+
<Tooltip>
37+
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
38+
<Dialog.Trigger asChild>
39+
<Tooltip.Trigger className="h-9 w-9" size="icon" variant="outline">
40+
<CopyPlusIcon />
41+
</Tooltip.Trigger>
42+
</Dialog.Trigger>
43+
<Dialog.Content className="sm:max-w-[475px]">
44+
<Dialog.Header>
45+
<Dialog.Title>Create New Instrument</Dialog.Title>
46+
<Dialog.Description>
47+
This will save the current playground state in local storage as a new instrument.
48+
</Dialog.Description>
49+
</Dialog.Header>
50+
<Form
51+
className="[&_button]:max-w-32"
52+
content={{
53+
label: {
54+
kind: 'string',
55+
label: 'Label',
56+
variant: 'input'
57+
}
58+
}}
59+
submitBtnLabel="Save"
60+
validationSchema={z.object({
61+
label: z
62+
.string()
63+
.min(1)
64+
.refine(
65+
(arg) => !instruments.find((instrument) => instrument.label === arg),
66+
'An instrument with this label already exists'
67+
)
68+
})}
69+
onSubmit={(data) => void handleSubmit(data)}
70+
/>
71+
</Dialog.Content>
72+
</Dialog>
73+
<Tooltip.Content side="bottom">
74+
<p>Create New Instrument</p>
75+
</Tooltip.Content>
76+
</Tooltip>
7277
);
7378
};
Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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';
5-
import { ShareIcon } from 'lucide-react';
5+
import { Share2Icon } from 'lucide-react';
66

77
import { useFilesRef } from '@/hooks/useFilesRef';
88
import { 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

Comments
 (0)