duckylib 0.1.7 → 0.1.9

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.
@@ -4,16 +4,15 @@
4
4
  interface LoginButtonProps {
5
5
  label?: string;
6
6
  withIcon?: boolean;
7
+
8
+ onlogin?: () => Promise<void>;
7
9
  }
8
10
 
9
- let {label = "Log In", withIcon = true}: LoginButtonProps = $props();
11
+ let {label = "Log In", withIcon = true, onlogin}: LoginButtonProps = $props();
10
12
 
11
- function login() {
12
- console.log("login")
13
- }
14
13
  </script>
15
14
 
16
- <button onclick={login}>
15
+ <button onclick={async () => {if(onlogin) await onlogin()}}>
17
16
  {#if withIcon}<Symbol name="account_circle" inheritColor={true} sizePx={20} hoverEffect={false} />{/if}
18
17
  <p class="font-bold">{label}</p>
19
18
  </button>
@@ -1,6 +1,7 @@
1
1
  interface LoginButtonProps {
2
2
  label?: string;
3
3
  withIcon?: boolean;
4
+ onlogin?: () => Promise<void>;
4
5
  }
5
6
  declare const LoginButton: import("svelte").Component<LoginButtonProps, {}, "">;
6
7
  type LoginButton = ReturnType<typeof LoginButton>;
@@ -11,9 +11,10 @@
11
11
 
12
12
  interface UserToastProps {
13
13
  user: Auth.User;
14
+ onlogout?: () => Promise<void>;
14
15
  }
15
16
 
16
- let { user }: UserToastProps = $props();
17
+ let { user, onlogout }: UserToastProps = $props();
17
18
 
18
19
  let showContextMenu = $state(false);
19
20
 
@@ -69,7 +70,7 @@
69
70
  <contextentry
70
71
  data-disabled="false"
71
72
  id="log-out"
72
- onclick={(e: any) => {}}
73
+ onclick={async () => {if(onlogout) await onlogout()}}
73
74
  >
74
75
  <span class="material-symbols-outlined">logout</span>
75
76
  <red>Log Out</red>
@@ -1,6 +1,7 @@
1
1
  import type { Auth } from "../../types.ts";
2
2
  interface UserToastProps {
3
3
  user: Auth.User;
4
+ onlogout?: () => Promise<void>;
4
5
  }
5
6
  declare const UserToast: import("svelte").Component<UserToastProps, {}, "">;
6
7
  type UserToast = ReturnType<typeof UserToast>;
@@ -38,6 +38,8 @@
38
38
  defaultNav?: boolean;
39
39
 
40
40
  authFeatures?: boolean;
41
+ onlogin?: (() => Promise<void>) | null;
42
+ onlogout?: (() => Promise<void>) | null;
41
43
 
42
44
  nav?: HeaderNavigation[];
43
45
  }
@@ -68,6 +70,8 @@
68
70
  label = "",
69
71
 
70
72
  authFeatures = false,
73
+ onlogin = null,
74
+ onlogout = null,
71
75
 
72
76
  nav = [],
73
77
  }: HeaderProps = $props();
@@ -160,10 +164,10 @@
160
164
  {#if authFeatures}
161
165
  <Row widthPx="fit">
162
166
 
163
- {#if user !== null}
164
- <UserToast {user} />
165
- {:else}
166
- <LoginButton label="Log in to Join" />
167
+ {#if user !== null && onlogout}
168
+ <UserToast {user} {onlogout} />
169
+ {:else if onlogin}
170
+ <LoginButton {onlogin} label="Log in to Join" />
167
171
  {/if}
168
172
  </Row>
169
173
  {/if}
@@ -22,6 +22,8 @@ interface HeaderProps {
22
22
  searchQueryDataKey?: string;
23
23
  defaultNav?: boolean;
24
24
  authFeatures?: boolean;
25
+ onlogin?: (() => Promise<void>) | null;
26
+ onlogout?: (() => Promise<void>) | null;
25
27
  nav?: HeaderNavigation[];
26
28
  }
27
29
  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.7",
3
+ "version": "0.1.9",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",