-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave-button.tsx
41 lines (39 loc) · 1.13 KB
/
save-button.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Button } from '@/components/ui/button'
import { HardDriveUpload, LoaderCircle } from 'lucide-react'
import { useFormStatus } from 'react-dom'
import {
TooltipProvider,
Tooltip,
TooltipContent,
TooltipTrigger,
} from '@/components/ui/tooltip'
const iconClassName = '!h-[1em] !w-[1em]'
export function SaveButton({ noSession }: { noSession?: boolean }) {
const { pending } = useFormStatus()
return (
<TooltipProvider>
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
className="text-xl"
type={noSession ? 'button' : 'submit'}
disabled={pending}
size="lg"
>
{pending ? (
<LoaderCircle className={`animate-spin ${iconClassName}`} />
) : (
<HardDriveUpload className={iconClassName} />
)}{' '}
Save
</Button>
</TooltipTrigger>
{noSession && (
<TooltipContent className="bg-accent text-accent-foreground">
<p> Log in to save</p>
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
)
}