diff --git a/src/components/Project/components/ShareButton.tsx b/src/components/Project/components/ShareButton.tsx new file mode 100644 index 00000000..67695f03 --- /dev/null +++ b/src/components/Project/components/ShareButton.tsx @@ -0,0 +1,95 @@ +import { Input } from '@/components/Input' +import DiscordLogo from '@/components/icon/DiscordLogo' +import { ShareIcon } from '@/components/icon/ShareIcon' +import { XLogo } from '@/components/icon/XLogo' +import { Button } from '@/components/ui/Button' +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTrigger, +} from '@/components/ui/Dialog' +import { useCallback, useState } from 'react' + +export type ShareButtonProps = { + className?: string +} + +export const ShareButton: React.FC = ({ className }) => { + const currentUrl = typeof window !== 'undefined' ? window.location.href : '' + + return ( + + + + + + + + Share + + + +
+ {/* // TODO: What to do when clicked? */} + + {/* // TODO: What to do when clicked? */} + +
+
+ +
+ + +
+
+
+
+
+ ) +} + +const CopyButton: React.FC = () => { + const [buttonText, setButtonText] = useState('Copy link') + const [currentTimer, setCurrentTimer] = useState(null) + + const currentUrl = typeof window !== 'undefined' ? window.location.href : '' + + const onClick = useCallback(() => { + if (currentTimer) { + clearTimeout(currentTimer) + } + navigator.clipboard.writeText(currentUrl) + setButtonText('Copied!') + const timer = setTimeout(() => { + setButtonText('Copy link') + }, 1000) + setCurrentTimer(timer) + }, [currentTimer, currentUrl]) + + return ( + + ) +} diff --git a/src/components/Project/components/Stats.tsx b/src/components/Project/components/Stats.tsx index 0a3c40db..525300e5 100644 --- a/src/components/Project/components/Stats.tsx +++ b/src/components/Project/components/Stats.tsx @@ -1,11 +1,13 @@ import { Link } from '@/components/Link' import { ShareIcon } from '@/components/icon/ShareIcon' import { Button } from '@/components/ui/Button' +import { Dialog } from '@/components/ui/Dialog' import { Progress } from '@/components/ui/Progress' import { Separator } from '@/components/ui/Separator' import { useJbProject } from '@/hooks/useJbProject' import { ReactNode } from 'react' import { twMerge } from 'tailwind-merge' +import { ShareButton } from './ShareButton' export type StatsProps = { className?: string @@ -37,16 +39,11 @@ export const Stats: React.FC = ({ className }) => { -
- -
+ - + ) diff --git a/src/components/icon/XLogo.tsx b/src/components/icon/XLogo.tsx index eef8ebf3..82a78c4a 100644 --- a/src/components/icon/XLogo.tsx +++ b/src/components/icon/XLogo.tsx @@ -12,6 +12,7 @@ export const XLogo: React.FC = ({ className }) => { viewBox="0 0 300 300" version="1.1" xmlns="http://www.w3.org/2000/svg" + fill="currentColor" >