Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"eslint-config-next": "14.2.3",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.1",
"typescript": "^5"
"typescript": "^5",
"@playwright/test": "^1.49.1"
}
}
25 changes: 25 additions & 0 deletions src/components/CopyLinkButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";

import { useState } from "react";
import { useSession } from "next-auth/react"

export default function CopyLinkButton() {
const { data: session } = useSession();
const [ isCopied, setCopied ] = useState(false);

const dataCopy = async () => {
await navigator.clipboard.writeText(`${window.location.origin}/u/${session?.githubLogin}`);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};

return (
<button
onClick={ dataCopy }
aria-label="Copy profile link"
className="inline-flex h-10 items-center gap-2 rounded-full border border-[var(--border)] bg-[var(--card)] px-4 text-sm font-medium text-[var(--card-foreground)] transition-colors hover:bg-[var(--control)]"
>
{ isCopied ? "✓ Copied!" : "🔗 Copy link"}
</button>
);
}
2 changes: 2 additions & 0 deletions src/components/DashboardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SignOutButton from "@/components/SignOutButton";
import ThemeToggle from "@/components/ThemeToggle";
import UserAvatar from "@/components/UserAvatar";
import KeyboardShortcuts from "@/components/KeyboardShortcuts";
import CopyLinkButton from "./CopyLinkButton";

export default function DashboardHeader() {
const { data: session } = useSession();
Expand Down Expand Up @@ -62,6 +63,7 @@ export default function DashboardHeader() {
)}
<KeyboardShortcuts />
<UserAvatar />
<CopyLinkButton />
<ThemeToggle />
<SignOutButton />
</div>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"jsx": "preserve",
"incremental": true,
"plugins": [
{
Expand Down
Loading