Skip to content

Commit

Permalink
fix: added toast message when copied
Browse files Browse the repository at this point in the history
  • Loading branch information
fluid-design-io committed Oct 18, 2023
1 parent c3c457b commit 98b392c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apps/web/components/toolbar/shareable-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ import { colorHelper } from "@/lib/colorHelper";
import { Skeleton } from "@ui/components/ui/skeleton";
import { cn } from "ui/lib/utils";
import Image from "next/image";
import { useToast } from "ui/components/ui/use-toast";

function ToolbarShareableLink() {
const menuItem = primaryToolbarMenu.Share;
const { baseColors } = useColorStore();
const [open, setOpen] = useState(false);
const [colors, setColors] = useState("");
const { toast } = useToast();
const [loadingSocialPreview, setLoadingSocialPreview] = useState(true);
const handleCopy = () => {
navigator.clipboard.writeText(colors);
navigator.clipboard.writeText(
`${process.env.NEXT_PUBLIC_URL}/?colors=${colors}`,
);
setOpen(false);
toast({
title: "Copied to clipboard!",
});
};
useEffect(() => {
if (!baseColors) return;
Expand All @@ -52,9 +59,12 @@ function ToolbarShareableLink() {

<Image
src={`${process.env.NEXT_PUBLIC_URL}/api/og?colors=${colors}`}
className={cn("absolute inset-0 h-full w-full object-cover")}
className={cn(
"absolute inset-0 h-full w-full object-cover transition-opacity",
loadingSocialPreview ? "opacity-0" : "opacity-100",
)}
alt="Social preview"
// onLoad={() => setLoadingSocialPreview(false)}
onLoad={() => setLoadingSocialPreview(false)}
width={288}
height={151}
/>
Expand Down

0 comments on commit 98b392c

Please sign in to comment.