Skip to content

Commit 386be9d

Browse files
authored
Merge pull request #36 from emilkrebs/improve-performance
Improved database initialization
2 parents 790f166 + 41cfc6f commit 386be9d

File tree

14 files changed

+484
-530
lines changed

14 files changed

+484
-530
lines changed

components/CopyButton.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { useState } from 'preact/hooks';
2+
3+
export default function CopyButton({ value }: { value: string }) {
4+
const [copied, setCopied] = useState(false);
5+
6+
const handleCopy = async () => {
7+
try {
8+
await navigator.clipboard.writeText(value);
9+
setCopied(true);
10+
setTimeout(() => setCopied(false), 1500);
11+
} catch (e) {
12+
console.error('Failed to copy:', e);
13+
}
14+
};
15+
16+
return (
17+
<button
18+
type='button'
19+
onClick={handleCopy}
20+
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'
21+
title='Copy to clipboard'
22+
>
23+
{copied
24+
? (
25+
<svg
26+
xmlns='http://www.w3.org/2000/svg'
27+
width='16'
28+
height='16'
29+
viewBox='0 0 24 24'
30+
fill='none'
31+
stroke='currentColor'
32+
strokeWidth='2'
33+
strokeLinecap='round'
34+
strokeLinejoin='round'
35+
class='text-green-400'
36+
>
37+
<path d='M5 12l5 5L20 7' />
38+
</svg>
39+
)
40+
: (
41+
<svg
42+
xmlns='http://www.w3.org/2000/svg'
43+
width='16'
44+
height='16'
45+
viewBox='0 0 24 24'
46+
fill='none'
47+
stroke='currentColor'
48+
strokeWidth='2'
49+
strokeLinecap='round'
50+
strokeLinejoin='round'
51+
>
52+
<rect x='9' y='9' width='13' height='13' rx='2' />
53+
<path d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1' />
54+
</svg>
55+
)}
56+
</button>
57+
);
58+
}

components/CopyField.tsx

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'preact/hooks';
1+
import CopyButton from './CopyButton.tsx';
22

33
type CopyFieldProps = {
44
label: string;
@@ -7,18 +7,6 @@ type CopyFieldProps = {
77
};
88

99
export default function CopyField({ label, value, title }: CopyFieldProps) {
10-
const [copied, setCopied] = useState(false);
11-
12-
const handleCopy = async () => {
13-
try {
14-
await navigator.clipboard.writeText(value);
15-
setCopied(true);
16-
setTimeout(() => setCopied(false), 1500);
17-
} catch (e) {
18-
console.error('Failed to copy:', e);
19-
}
20-
};
21-
2210
return (
2311
<div class='bg-slate-800/50 rounded-lg p-4 border border-slate-700/50 overflow-hidden min-h-12'>
2412
<div class='flex items-start gap-3 min-w-0'>
@@ -31,46 +19,7 @@ export default function CopyField({ label, value, title }: CopyFieldProps) {
3119
>
3220
{value}
3321
</code>
34-
<button
35-
type='button'
36-
onClick={handleCopy}
37-
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'
38-
title='Copy to clipboard'
39-
>
40-
{copied
41-
? (
42-
<svg
43-
xmlns='http://www.w3.org/2000/svg'
44-
width='16'
45-
height='16'
46-
viewBox='0 0 24 24'
47-
fill='none'
48-
stroke='currentColor'
49-
strokeWidth='2'
50-
strokeLinecap='round'
51-
strokeLinejoin='round'
52-
class='text-green-400'
53-
>
54-
<path d='M5 12l5 5L20 7' />
55-
</svg>
56-
)
57-
: (
58-
<svg
59-
xmlns='http://www.w3.org/2000/svg'
60-
width='16'
61-
height='16'
62-
viewBox='0 0 24 24'
63-
fill='none'
64-
stroke='currentColor'
65-
strokeWidth='2'
66-
strokeLinecap='round'
67-
strokeLinejoin='round'
68-
>
69-
<rect x='9' y='9' width='13' height='13' rx='2' />
70-
<path d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1' />
71-
</svg>
72-
)}
73-
</button>
22+
<CopyButton value={value} />
7423
</div>
7524
</div>
7625
</div>

deno.json

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,24 @@
99
"preview": "deno task build && deno task start",
1010
"clean": "rm -rf ./dist && rm -rf ./_fresh && rm -rf ./node_modules && rm -f ./deno.lock && rm -f ./package-lock.json"
1111
},
12-
"lint": {
13-
"rules": {
14-
"tags": [
15-
"fresh",
16-
"recommended"
17-
]
18-
}
19-
},
20-
"exclude": [
21-
"**/_fresh/*"
22-
],
12+
"lint": { "rules": { "tags": ["fresh", "recommended"] } },
13+
"exclude": ["**/_fresh/*"],
2314
"imports": {
2415
"@/": "./",
2516
"@deno/gfm": "jsr:@deno/gfm@^0.11.0",
26-
"fresh": "jsr:@fresh/core@^2.1.4",
27-
"preact": "npm:preact@^10.27.2",
28-
"@preact/signals": "npm:@preact/signals@^2.3.2",
29-
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.0.7",
30-
"vite": "npm:vite@^7.1.12",
31-
"tailwindcss": "npm:tailwindcss@^4.1.16",
32-
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.16",
33-
"@valibot/valibot": "jsr:@valibot/valibot@^1.1.0",
17+
"fresh": "jsr:@fresh/core@^2.2.0",
18+
"preact": "npm:preact@^10.28.2",
19+
"@preact/signals": "npm:@preact/signals@^2.5.1",
20+
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.0.8",
21+
"vite": "npm:vite@^7.3.1",
22+
"tailwindcss": "npm:tailwindcss@^4.1.18",
23+
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.18",
24+
"@valibot/valibot": "jsr:@valibot/valibot@^1.2.0",
3425
"$std/": "https://deno.land/std@0.216.0/",
3526
"bcrypt": "https://deno.land/x/bcrypt/mod.ts"
3627
},
3728
"compilerOptions": {
38-
"lib": [
39-
"dom",
40-
"dom.asynciterable",
41-
"dom.iterable",
42-
"deno.ns",
43-
"deno.unstable"
44-
],
29+
"lib": ["dom", "dom.asynciterable", "dom.iterable", "deno.ns", "deno.unstable"],
4530
"jsx": "precompile",
4631
"jsxImportSource": "preact",
4732
"jsxPrecompileSkipElements": [
@@ -60,22 +45,15 @@
6045
"noscript",
6146
"template"
6247
],
63-
"types": [
64-
"vite/client"
65-
]
48+
"types": ["vite/client"]
6649
},
6750
"fmt": {
6851
"useTabs": false,
6952
"lineWidth": 120,
7053
"indentWidth": 4,
7154
"singleQuote": true,
7255
"proseWrap": "always",
73-
"exclude": [
74-
"**/node_modules/**",
75-
"**/.git/**",
76-
"**/.vscode/**",
77-
"**/.github/**"
78-
]
56+
"exclude": ["**/node_modules/**", "**/.git/**", "**/.vscode/**", "**/.github/**"]
7957
},
8058
"nodeModulesDir": "auto"
8159
}

0 commit comments

Comments
 (0)