Use toast in photo share modal

This commit is contained in:
Sam Becker 2023-09-06 18:34:32 -05:00
parent a8d4ae7288
commit 2256c303f4
2 changed files with 3 additions and 11 deletions

View File

@ -6,11 +6,10 @@ import { absoluteRouteForPhoto, routeForPhoto } from '@/site/routes';
import { TbPhotoShare } from 'react-icons/tb'; import { TbPhotoShare } from 'react-icons/tb';
import { cc } from '@/utility/css'; import { cc } from '@/utility/css';
import { BiCopy } from 'react-icons/bi'; import { BiCopy } from 'react-icons/bi';
import { useState } from 'react';
import { Photo } from '.'; import { Photo } from '.';
import { toast } from 'sonner';
export default function PhotoModal({ photo }: { photo: Photo }) { export default function PhotoModal({ photo }: { photo: Photo }) {
const [copied, setIsCopied] = useState(false);
const shareUrl = absoluteRouteForPhoto(photo); const shareUrl = absoluteRouteForPhoto(photo);
return ( return (
@ -24,13 +23,6 @@ export default function PhotoModal({ photo }: { photo: Photo }) {
<div className="flex-grow"> <div className="flex-grow">
Share Photo Share Photo
</div> </div>
{copied && <div className={cc(
'text-sm leading-none py-1.5 px-2',
'bg-blue-600 text-white',
'rounded-full',
)}>
Copied!
</div>}
</div> </div>
<PhotoOGTile photo={photo} /> <PhotoOGTile photo={photo} />
<div className={cc( <div className={cc(
@ -52,7 +44,7 @@ export default function PhotoModal({ photo }: { photo: Photo }) {
)} )}
onClick={() => { onClick={() => {
navigator.clipboard.writeText(shareUrl); navigator.clipboard.writeText(shareUrl);
setIsCopied(true); toast.success('Link to photo copied');
}} }}
> >
<BiCopy size={18} /> <BiCopy size={18} />

View File

@ -139,7 +139,7 @@ export default function SiteChecklistClient({
<IconButton <IconButton
onClick={() => { onClick={() => {
navigator.clipboard.writeText(secret); navigator.clipboard.writeText(secret);
toast('Secret copied to clipboard', { toast.success('Secret copied to clipboard', {
duration: 4000, duration: 4000,
}); });
}} }}