Skip to content
Merged
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
58 changes: 58 additions & 0 deletions components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useState } from 'preact/hooks';

export default function CopyButton({ value }: { value: string }) {
const [copied, setCopied] = useState(false);

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(value);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
} catch (e) {
console.error('Failed to copy:', e);
}
};

return (
<button
type='button'
onClick={handleCopy}
class='flex-shrink-0 p-2 cursor-pointer text-slate-400 hover:text-green-400 hover:bg-green-500/10 rounded transition-all duration-200'
title='Copy to clipboard'
>
{copied
? (
<svg
xmlns='http://www.w3.org/2000/svg'
width='16'
height='16'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
class='text-green-400'
>
<path d='M5 12l5 5L20 7' />
</svg>
)
: (
<svg
xmlns='http://www.w3.org/2000/svg'
width='16'
height='16'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
>
<rect x='9' y='9' width='13' height='13' rx='2' />
<path d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1' />
</svg>
)}
</button>
);
}
55 changes: 2 additions & 53 deletions components/CopyField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'preact/hooks';
import CopyButton from './CopyButton.tsx';

type CopyFieldProps = {
label: string;
Expand All @@ -7,18 +7,6 @@ type CopyFieldProps = {
};

export default function CopyField({ label, value, title }: CopyFieldProps) {
const [copied, setCopied] = useState(false);

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(value);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
} catch (e) {
console.error('Failed to copy:', e);
}
};

return (
<div class='bg-slate-800/50 rounded-lg p-4 border border-slate-700/50 overflow-hidden min-h-12'>
<div class='flex items-start gap-3 min-w-0'>
Expand All @@ -31,46 +19,7 @@ export default function CopyField({ label, value, title }: CopyFieldProps) {
>
{value}
</code>
<button
type='button'
onClick={handleCopy}
class='flex-shrink-0 p-2 cursor-pointer text-slate-400 hover:text-green-400 hover:bg-green-500/10 rounded transition-all duration-200'
title='Copy to clipboard'
>
{copied
? (
<svg
xmlns='http://www.w3.org/2000/svg'
width='16'
height='16'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
class='text-green-400'
>
<path d='M5 12l5 5L20 7' />
</svg>
)
: (
<svg
xmlns='http://www.w3.org/2000/svg'
width='16'
height='16'
viewBox='0 0 24 24'
fill='none'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
>
<rect x='9' y='9' width='13' height='13' rx='2' />
<path d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1' />
</svg>
)}
</button>
<CopyButton value={value} />
</div>
</div>
</div>
Expand Down
48 changes: 13 additions & 35 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@
"preview": "deno task build && deno task start",
"clean": "rm -rf ./dist && rm -rf ./_fresh && rm -rf ./node_modules && rm -f ./deno.lock && rm -f ./package-lock.json"
},
"lint": {
"rules": {
"tags": [
"fresh",
"recommended"
]
}
},
"exclude": [
"**/_fresh/*"
],
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
"exclude": ["**/_fresh/*"],
"imports": {
"@/": "./",
"@deno/gfm": "jsr:@deno/gfm@^0.11.0",
"fresh": "jsr:@fresh/core@^2.1.4",
"preact": "npm:preact@^10.27.2",
"@preact/signals": "npm:@preact/signals@^2.3.2",
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.0.7",
"vite": "npm:vite@^7.1.12",
"tailwindcss": "npm:tailwindcss@^4.1.16",
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.16",
"@valibot/valibot": "jsr:@valibot/valibot@^1.1.0",
"fresh": "jsr:@fresh/core@^2.2.0",
"preact": "npm:preact@^10.28.2",
"@preact/signals": "npm:@preact/signals@^2.5.1",
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.0.8",
"vite": "npm:vite@^7.3.1",
"tailwindcss": "npm:tailwindcss@^4.1.18",
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.18",
"@valibot/valibot": "jsr:@valibot/valibot@^1.2.0",
"$std/": "https://deno.land/std@0.216.0/",
"bcrypt": "https://deno.land/x/bcrypt/mod.ts"
},
"compilerOptions": {
"lib": [
"dom",
"dom.asynciterable",
"dom.iterable",
"deno.ns",
"deno.unstable"
],
"lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns", "deno.unstable"],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxPrecompileSkipElements": [
Expand All @@ -60,22 +45,15 @@
"noscript",
"template"
],
"types": [
"vite/client"
]
"types": ["vite/client"]
},
"fmt": {
"useTabs": false,
"lineWidth": 120,
"indentWidth": 4,
"singleQuote": true,
"proseWrap": "always",
"exclude": [
"**/node_modules/**",
"**/.git/**",
"**/.vscode/**",
"**/.github/**"
]
"exclude": ["**/node_modules/**", "**/.git/**", "**/.vscode/**", "**/.github/**"]
},
"nodeModulesDir": "auto"
}
Loading
Loading