Skip to content

Commit 36fb0c0

Browse files
committed
fix: selected script now has a different color
1 parent 5b3b94a commit 36fb0c0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/routes/scripts/+layout.svelte

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22
import Navigation from "../Navigation.svelte"
33
import Footer from "../Footer.svelte"
44
import Sidebar from "../Sidebar.svelte"
5+
import { page } from "$app/state"
56
67
let { data, children } = $props()
78
const scripts = $derived(data.scripts!)
89
let search = $state("")
910
1011
$inspect(data.script)
12+
13+
function getStyle(id: string, access: boolean, type: string) {
14+
if (page.url.pathname == "/scripts/" + id) return "text-primary-950-50"
15+
if (type == "premium") {
16+
if (access) return "text-primary-500 dark:text-primary-500"
17+
return "text-warning-500"
18+
}
19+
}
1120
</script>
1221

1322
<Navigation />
1423
<main class="flex max-h-full justify-between overflow-y-hidden">
15-
<aside class="flex h-full max-w-96 min-w-64 flex-col border-r-1 border-surface-500 p-2">
24+
<aside class="flex h-full max-w-96 min-w-64 flex-col border-r border-surface-500 p-2">
1625
<input
1726
type="text"
1827
placeholder="🔍 Search script..."
@@ -24,12 +33,10 @@
2433
<li class="flex preset-outlined-success-200-800 hover:preset-tonal">
2534
<a
2635
href={script.id}
27-
class="h-full w-full px-2 {script.metadata.type == 'premium'
28-
? script.access
29-
? 'text-primary-500'
30-
: 'text-warning-500'
31-
: ''}">{script.title}</a
36+
class="h-full w-full px-2 {getStyle(script.id, script.access, script.metadata.type)}"
3237
>
38+
{script.title}
39+
</a>
3340
</li>
3441
{/each}
3542
</ul>

0 commit comments

Comments
 (0)