-
Notifications
You must be signed in to change notification settings - Fork 253
Expand file tree
/
Copy pathheader.svelte
More file actions
65 lines (60 loc) 路 2.51 KB
/
Copy pathheader.svelte
File metadata and controls
65 lines (60 loc) 路 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script lang="ts">
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { DropList, DropListItem, DropListLink, Avatar } from '$lib/components';
import { app } from '$lib/stores/app';
import { sdkForConsole } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
$: currentProject = $page.params.project;
const onChange = async (event: Event) => {
const target = event.target as HTMLSelectElement;
await goto(`${base}/console/${target.value}`);
};
const toggleTheme = () => {
$app.theme = $app.theme === 'light' ? 'dark' : 'light';
};
let showDropdown = false;
</script>
<div class="console-header">
<div class="start">
{#if currentProject}
<div class="select is-only-desktop">
<select on:change={onChange}>
{#await sdkForConsole.projects.list() then { projects }}
{#each projects as project}
<option value={project.$id} selected={currentProject === project.$id}>
{project.name}
</option>
{/each}
{/await}
</select>
<span class="icon-down-open" aria-hidden="true" />
</div>
<button class="button is-only-icon" aria-label="Create Project">
<span class="icon-plus" aria-hidden="true" />
</button>
{/if}
</div>
<div class="end">
{#if $user}
<DropList bind:show={showDropdown} position="bottom" horizontal="left">
<button class="transparent-button" on:click={() => (showDropdown = !showDropdown)}>
<span class="is-only-desktop">{$user.name}</span>
<Avatar
size={50}
name={$user.name}
src={sdkForConsole.avatars.getInitials($user.name, 50, 50).toString()} />
</button>
<svelte:fragment slot="list">
<DropListLink href="/console/$me" icon="user">Your Account</DropListLink>
<DropListItem
on:click={toggleTheme}
icon={$app.theme === 'light' ? 'sun-inv' : 'moon-inv'}>
Toggle Theme
</DropListItem>
</svelte:fragment>
</DropList>
{/if}
</div>
</div>