duckylib 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,13 +8,26 @@
8
8
  import { MediaQuery } from "svelte/reactivity";
9
9
  import Symbol from "../text/Symbol.svelte";
10
10
  import Row from "../containers/Row.svelte";
11
+ import Text from "../text/Text.svelte"
12
+
13
+ interface ContextMenuEntry {
14
+ label: string;
15
+ symbol: string;
16
+ href: string;
17
+ disabled: boolean;
18
+ }
19
+
20
+ interface ContextMenuSection {
21
+ items: ContextMenuEntry[];
22
+ }
11
23
 
12
24
  interface UserToastProps {
13
25
  user: Auth.User;
26
+ contextMenu: ContextMenuSection[];
14
27
  onlogout?: () => Promise<void>;
15
28
  }
16
29
 
17
- let { user, onlogout }: UserToastProps = $props();
30
+ let { user, onlogout, contextMenu }: UserToastProps = $props();
18
31
 
19
32
  let showContextMenu = $state(false);
20
33
 
@@ -61,19 +74,40 @@
61
74
  <!-- svelte-ignore a11y_click_events_have_key_events -->
62
75
  <!-- svelte-ignore a11y_no_static_element_interactions -->
63
76
  <contextentry data-disabled="true" id="informative-username">
64
- <span class="material-symbols-outlined">account_circle</span>
65
- {user.username}
77
+ <Symbol name="account_circle" inheritColor={true} />
78
+ <Text weight="bolder" sizeEm={1.1}>{user.username}</Text>
66
79
  </contextentry>
80
+ <hr />
67
81
  {/if}
82
+ {#each contextMenu as section}
83
+ {#each section.items as item}
84
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
85
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
86
+ <contextentry
87
+ data-disabled="{item.disabled}"
88
+ id="{item.label.replaceAll(/ +/gim, "-").toLowerCase()}"
89
+ onclick={async () => {
90
+ if(browser) window.location.replace(item.href)
91
+ }}
92
+ >
93
+ <Symbol name={item.symbol} inheritColor={true} />
94
+ <Text weight="bolder" sizeEm={1}>{item.label}</Text>
95
+
96
+ </contextentry>
97
+ <hr />
98
+ {/each}
99
+ {/each}
68
100
  <!-- svelte-ignore a11y_click_events_have_key_events -->
69
101
  <!-- svelte-ignore a11y_no_static_element_interactions -->
70
102
  <contextentry
71
103
  data-disabled="false"
72
104
  id="log-out"
73
- onclick={async () => {if(onlogout) await onlogout()}}
105
+ onclick={async () => {
106
+ if (onlogout) await onlogout();
107
+ }}
74
108
  >
75
- <span class="material-symbols-outlined">logout</span>
76
- <red>Log Out</red>
109
+ <Symbol name="logout" inheritColor={true} />
110
+ <Text weight="bold" sizeEm={1} classList={["red"]}>Log Out</Text>
77
111
  </contextentry>
78
112
  <hr />
79
113
  <!-- svelte-ignore a11y_click_events_have_key_events -->
@@ -197,7 +231,7 @@
197
231
  margin-right: auto;
198
232
  background-color: var(--overlay-0);
199
233
  opacity: 0.6;
200
- margin: 0.66em 0;
234
+ margin: 0.4em 0;
201
235
  margin-left: 0.33em;
202
236
  width: 92%;
203
237
  border: none;
@@ -236,7 +270,7 @@
236
270
 
237
271
  width: 95%;
238
272
  cursor: pointer;
239
- padding: 0.1em 0.33em;
273
+ padding: 0em 0.33em;
240
274
  margin: 0.1em 0em;
241
275
 
242
276
  border-radius: 8px;
@@ -1,6 +1,16 @@
1
1
  import type { Auth } from "../../types.ts";
2
+ interface ContextMenuEntry {
3
+ label: string;
4
+ symbol: string;
5
+ href: string;
6
+ disabled: boolean;
7
+ }
8
+ interface ContextMenuSection {
9
+ items: ContextMenuEntry[];
10
+ }
2
11
  interface UserToastProps {
3
12
  user: Auth.User;
13
+ contextMenu: ContextMenuSection[];
4
14
  onlogout?: () => Promise<void>;
5
15
  }
6
16
  declare const UserToast: import("svelte").Component<UserToastProps, {}, "">;
@@ -12,6 +12,17 @@
12
12
  import { PUBLIC_MOBILE_SIZE_PX, PUBLIC_TABLET_SIZE_PX } from "$env/static/public";
13
13
  import SearchBar, { type QueryMapKeys, type SearchResult } from "./SearchBar.svelte";
14
14
 
15
+ interface ContextMenuEntry {
16
+ label: string;
17
+ symbol: string;
18
+ href: string;
19
+ disabled: boolean;
20
+ }
21
+
22
+ interface ContextMenuSection {
23
+ items: ContextMenuEntry[];
24
+ }
25
+
15
26
  export interface HeaderNavigation {
16
27
  label: string;
17
28
  pathname: string;
@@ -41,6 +52,7 @@
41
52
  loginButtonLabel?: string;
42
53
  onlogin?: (() => Promise<void>) | null;
43
54
  onlogout?: (() => Promise<void>) | null;
55
+ userContextMenu?: ContextMenuSection[]
44
56
 
45
57
  nav?: HeaderNavigation[];
46
58
  }
@@ -74,6 +86,7 @@
74
86
  loginButtonLabel,
75
87
  onlogin = null,
76
88
  onlogout = null,
89
+ userContextMenu = [],
77
90
 
78
91
  nav = [],
79
92
  }: HeaderProps = $props();
@@ -166,7 +179,7 @@
166
179
  <Row widthPx="fit">
167
180
 
168
181
  {#if user !== null && onlogout}
169
- <UserToast {user} {onlogout} />
182
+ <UserToast contextMenu={userContextMenu} {user} {onlogout} />
170
183
  {:else if onlogin}
171
184
  <LoginButton {onlogin} label={loginButtonLabel ? loginButtonLabel : "Log In"} />
172
185
  {/if}
@@ -1,5 +1,14 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import { type QueryMapKeys, type SearchResult } from "./SearchBar.svelte";
3
+ interface ContextMenuEntry {
4
+ label: string;
5
+ symbol: string;
6
+ href: string;
7
+ disabled: boolean;
8
+ }
9
+ interface ContextMenuSection {
10
+ items: ContextMenuEntry[];
11
+ }
3
12
  export interface HeaderNavigation {
4
13
  label: string;
5
14
  pathname: string;
@@ -25,6 +34,7 @@ interface HeaderProps {
25
34
  loginButtonLabel?: string;
26
35
  onlogin?: (() => Promise<void>) | null;
27
36
  onlogout?: (() => Promise<void>) | null;
37
+ userContextMenu?: ContextMenuSection[];
28
38
  nav?: HeaderNavigation[];
29
39
  }
30
40
  declare const Header: import("svelte").Component<HeaderProps, {}, "">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "duckylib",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",