diff --git a/crabfit-frontend/src/App.tsx b/crabfit-frontend/src/App.tsx index 9163223..de2c8b5 100644 --- a/crabfit-frontend/src/App.tsx +++ b/crabfit-frontend/src/App.tsx @@ -23,7 +23,7 @@ const App = () => { useEffect(() => { setIsDark(colortheme === 'System' ? darkQuery.matches : colortheme === 'Dark'); - }, [colortheme]); + }, [colortheme, darkQuery.matches]); return ( diff --git a/crabfit-frontend/src/pages/Event/Event.tsx b/crabfit-frontend/src/pages/Event/Event.tsx index d000fe0..9d629f7 100644 --- a/crabfit-frontend/src/pages/Event/Event.tsx +++ b/crabfit-frontend/src/pages/Event/Event.tsx @@ -65,6 +65,8 @@ const Event = (props) => { const [min, setMin] = useState(0); const [max, setMax] = useState(0); + const [copied, setCopied] = useState(null); + useEffect(() => { const fetchEvent = async () => { try { @@ -272,7 +274,16 @@ const Event = (props) => { {(!!event || isLoading) ? ( <> {event?.name} - https://crab.fit/{id} + navigator.clipboard?.writeText(`https://crab.fit/${id}`) + .then(() => { + setCopied('Copied!'); + setTimeout(() => setCopied(null), 1000); + }) + .catch((e) => console.error('Failed to copy', e)) + } + title={!!navigator.clipboard ? 'Click to copy' : ''} + >{copied ?? `https://crab.fit/${id}`} {!!event?.name && <>Copy the link to this page, or share via email. diff --git a/crabfit-frontend/src/pages/Event/eventStyle.ts b/crabfit-frontend/src/pages/Event/eventStyle.ts index b3da59f..c427909 100644 --- a/crabfit-frontend/src/pages/Event/eventStyle.ts +++ b/crabfit-frontend/src/pages/Event/eventStyle.ts @@ -89,6 +89,14 @@ export const ShareInfo = styled.p` border-radius: 3px; } `} + + ${props => props.onClick && ` + cursor: pointer; + + &:hover { + color: ${props.theme.primaryDark}; + } + `} `; export const Tabs = styled.div`