Skip to content

Commit c7d16ad

Browse files
committed
feat: new UUID component
1 parent e662c57 commit c7d16ad

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

src/lib/components/UUID.svelte

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script lang="ts">
2+
import Clipboard from "@lucide/svelte/icons/clipboard"
3+
import ClipboardCheck from "@lucide/svelte/icons/clipboard-check"
4+
let { uuid }: { uuid: string } = $props()
5+
let copied = $state(false)
6+
console.log(uuid)
7+
</script>
8+
9+
<button
10+
class="mx-auto btn cursor-pointer rounded-md preset-outlined-surface-500 p-2 text-xs"
11+
type="button"
12+
onclick={async (e) => {
13+
e.preventDefault()
14+
await navigator.clipboard.writeText(uuid)
15+
copied = true
16+
setTimeout(() => (copied = false), 2000)
17+
}}
18+
>
19+
ID: <span class="w-18 truncate">{uuid}</span>
20+
{#if copied}
21+
<ClipboardCheck class="h-4" />
22+
{:else}
23+
<Clipboard class="h-4" />
24+
{/if}
25+
</button>

src/routes/dashboard/[slug]/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import Landmark from "@lucide/svelte/icons/landmark"
88
import Package from "@lucide/svelte/icons/package"
99
import Settings from "@lucide/svelte/icons/settings"
10+
import UUID from "$lib/components/UUID.svelte"
1011
1112
const { data, children } = $props()
1213
@@ -26,7 +27,7 @@
2627
<span class="my-auto">
2728
{data.scripter.profiles.username}
2829
</span>
29-
<small class="my-auto">{data.scripter.id}</small>
30+
<small class="my-auto"><UUID uuid={data.scripter.id}></UUID></small>
3031
</h3>
3132

3233
<div class="my-8 grid place-items-center">

src/routes/scripts/ScriptHeader.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import UUID from "$lib/components/UUID.svelte"
23
import StatsHeader from "./StatsHeader.svelte"
34
45
const data = $props()
@@ -28,7 +29,7 @@
2829
{description ?? "Loading..."}
2930
</h2>
3031
<h3 class="my-4">
31-
{id ?? "Loading..."}
32+
<UUID uuid={id ?? "Loading..."}></UUID>
3233
</h3>
3334
<StatsHeader {id} />
3435
</div>

src/routes/user/[slug]/+page.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { zodClient } from "sveltekit-superforms/adapters"
55
import Head from "$lib/components/Head.svelte"
66
import { superForm } from "sveltekit-superforms"
7+
import UUID from "$lib/components/UUID.svelte"
78
89
const { data, form } = $props()
910
const profile = $derived(data.profile!)
@@ -30,7 +31,7 @@
3031
<main class="container mx-auto my-6 flex max-w-3xl flex-col">
3132
<header class="my-24 flex flex-col">
3233
<h1 class="mx-auto my-2 text-3xl font-bold">Username: {profile.username}</h1>
33-
<h2 class="mx-auto my-8 leading-normal font-semibold">ID: {profile.id}</h2>
34+
<UUID uuid={profile.id}></UUID>
3435
</header>
3536

3637
<RoleBadge />

0 commit comments

Comments
 (0)