diff --git a/src/components/RoadCard/LongBadge.tsx b/src/components/RoadCard/LongBadge.tsx new file mode 100644 index 000000000..82d727e8b --- /dev/null +++ b/src/components/RoadCard/LongBadge.tsx @@ -0,0 +1,34 @@ +import type { BadgeProps } from './RoadCardPage'; + +export function LongBadge({ badgeUrl }: BadgeProps) { + return ( +
+ + Road Card + + +
+ + + Copy Link + +
+
+ ); +} diff --git a/src/components/RoadCard/RoadCardPage.tsx b/src/components/RoadCard/RoadCardPage.tsx index 1c913583f..6020c2afb 100644 --- a/src/components/RoadCard/RoadCardPage.tsx +++ b/src/components/RoadCard/RoadCardPage.tsx @@ -1,14 +1,27 @@ +import { useEffect, useState } from 'preact/hooks'; import Cookies from 'js-cookie'; import { TOKEN_COOKIE_NAME, decodeToken } from '../../lib/jwt'; +import { WideBadge } from './WideBadge'; +import { LongBadge } from './LongBadge'; + +import CopyIcon from '../../icons/copy.svg'; + +export type BadgeProps = { + badgeUrl: string; +}; export function RoadCardPage() { + const [selectedBadge, setSelectedBadge] = useState<'long' | 'wide'>('long'); + const [isCopied, setIsCopied] = useState(false); const token = Cookies.get(TOKEN_COOKIE_NAME); if (!token) { return null; } - const user = decodeToken(token); - console.log(user); + + const badgeUrl = `${ + import.meta.env.PUBLIC_API_URL + }/v1-badge/${selectedBadge}/${user.id}`; const textareaContent = ` `.trim(); + const handleCopyEmbed = () => { + navigator.clipboard.writeText(textareaContent); + setIsCopied(true); + }; + + useEffect(() => { + let timeout: ReturnType; + if (isCopied) { + timeout = setTimeout(() => { + setIsCopied(false); + }, 2000); + } + return () => clearTimeout(timeout); + }, [isCopied]); + return ( -
+ <>

Grab your #RoadCard

@@ -32,100 +60,54 @@ export function RoadCardPage() {

-
-
- - Road Card - - -
- - setSelectedBadge('wide')} > - Copy Link - + Wide +
-
- Embed - -

- You can include it on your website or follow the instructions to{' '} - - include it on your GitHub profile. - -

-
-
-
- - Road Card - +
+ {selectedBadge === 'long' && } -
- - Download - - } + +
+
+ Embed +
-
-
- Embed