@atmo-dev/kit 0.17.0 → 0.18.1
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.
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
2
|
import { DropdownMenu } from 'bits-ui';
|
|
3
|
-
import { UserRound, LogOut } from '@sketchyicons/svelte';
|
|
3
|
+
import { UserRound, UserRoundPlus, LogOut } from '@sketchyicons/svelte';
|
|
4
4
|
import Avatar from './Avatar.svelte';
|
|
5
5
|
import Button from './Button.svelte';
|
|
6
6
|
import Icon from './Icon.svelte';
|
|
7
7
|
import { cn } from '../utils.js';
|
|
8
8
|
import { readTheme, observeTheme } from '../theme.js';
|
|
9
9
|
|
|
10
|
+
/** Another signed-in account that can be switched to. `did` identifies it; the rest is display only. */
|
|
11
|
+
export type AccountMenuAccount = {
|
|
12
|
+
did: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
handle?: string;
|
|
15
|
+
avatar?: string;
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
10
20
|
let {
|
|
11
21
|
name,
|
|
12
22
|
handle,
|
|
@@ -14,6 +24,9 @@
|
|
|
14
24
|
profileHref,
|
|
15
25
|
onprofile,
|
|
16
26
|
onsignout,
|
|
27
|
+
accounts = [],
|
|
28
|
+
onswitch,
|
|
29
|
+
onadd,
|
|
17
30
|
expanded = false,
|
|
18
31
|
open = $bindable(false),
|
|
19
32
|
label = 'Account menu',
|
|
@@ -23,6 +36,11 @@
|
|
|
23
36
|
handle?: string;
|
|
24
37
|
avatar?: string;
|
|
25
38
|
onsignout: () => void;
|
|
39
|
+
/** Other signed-in accounts, without the current one. */
|
|
40
|
+
accounts?: AccountMenuAccount[];
|
|
41
|
+
onswitch?: (did: string) => void;
|
|
42
|
+
/** Shows "Add account" when provided. */
|
|
43
|
+
onadd?: () => void;
|
|
26
44
|
expanded?: boolean;
|
|
27
45
|
open?: boolean;
|
|
28
46
|
label?: string;
|
|
@@ -42,6 +60,8 @@
|
|
|
42
60
|
});
|
|
43
61
|
const itemClass =
|
|
44
62
|
'min-h-11 w-full justify-start gap-3 px-3 text-sm text-base-950 dark:text-base-50 outline-none data-highlighted:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] dark:data-highlighted:bg-base-950 data-highlighted:text-base-950 dark:data-highlighted:text-base-50';
|
|
63
|
+
const separatorClass =
|
|
64
|
+
'-mx-1.5 my-1.5 h-px bg-base-300 dark:bg-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]';
|
|
45
65
|
</script>
|
|
46
66
|
|
|
47
67
|
<DropdownMenu.Root bind:open>
|
|
@@ -90,6 +110,48 @@
|
|
|
90
110
|
</Button>
|
|
91
111
|
{/snippet}
|
|
92
112
|
</DropdownMenu.Item>
|
|
113
|
+
{#if onswitch && accounts.length}
|
|
114
|
+
<DropdownMenu.Separator class={separatorClass} />
|
|
115
|
+
<DropdownMenu.Group aria-label="Switch account">
|
|
116
|
+
{#each accounts as account (account.did)}
|
|
117
|
+
{@const handle = account.handle?.replace(/^@/, '')}
|
|
118
|
+
{@const title = account.name || handle || account.did}
|
|
119
|
+
<DropdownMenu.Item onSelect={() => onswitch(account.did)} textValue={title}>
|
|
120
|
+
{#snippet child({ props })}
|
|
121
|
+
<Button
|
|
122
|
+
{...props}
|
|
123
|
+
variant="ghost"
|
|
124
|
+
aria-label={`Switch to ${title}`}
|
|
125
|
+
class={cn(itemClass, 'py-1.5')}
|
|
126
|
+
>
|
|
127
|
+
<Avatar name={title} src={account.avatar} size={20} aria-hidden="true" />
|
|
128
|
+
<span class="min-w-0 text-left">
|
|
129
|
+
<span class="block truncate">{title}</span>
|
|
130
|
+
{#if handle && handle !== title}<span
|
|
131
|
+
class="block truncate text-xs text-base-600 dark:text-base-400"
|
|
132
|
+
>@{handle}</span
|
|
133
|
+
>{/if}
|
|
134
|
+
</span>
|
|
135
|
+
</Button>
|
|
136
|
+
{/snippet}
|
|
137
|
+
</DropdownMenu.Item>
|
|
138
|
+
{/each}
|
|
139
|
+
</DropdownMenu.Group>
|
|
140
|
+
{/if}
|
|
141
|
+
{#if onadd}
|
|
142
|
+
{#if !(onswitch && accounts.length)}<DropdownMenu.Separator class={separatorClass} />{/if}
|
|
143
|
+
<DropdownMenu.Item onSelect={onadd} textValue="Add account">
|
|
144
|
+
{#snippet child({ props })}
|
|
145
|
+
<Button {...props} variant="ghost" class={itemClass}>
|
|
146
|
+
<Icon img={UserRoundPlus} size={20} class="text-base-600 dark:text-base-400" />Add
|
|
147
|
+
account
|
|
148
|
+
</Button>
|
|
149
|
+
{/snippet}
|
|
150
|
+
</DropdownMenu.Item>
|
|
151
|
+
{/if}
|
|
152
|
+
{#if onadd || (onswitch && accounts.length)}
|
|
153
|
+
<DropdownMenu.Separator class={separatorClass} />
|
|
154
|
+
{/if}
|
|
93
155
|
<DropdownMenu.Item onSelect={onsignout} textValue="Sign out">
|
|
94
156
|
{#snippet child({ props })}
|
|
95
157
|
<Button {...props} variant="ghost" class={itemClass}>
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
/** Another signed-in account that can be switched to. `did` identifies it; the rest is display only. */
|
|
2
|
+
export type AccountMenuAccount = {
|
|
3
|
+
did: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
handle?: string;
|
|
6
|
+
avatar?: string;
|
|
7
|
+
};
|
|
1
8
|
type $$ComponentProps = {
|
|
2
9
|
name: string;
|
|
3
10
|
handle?: string;
|
|
4
11
|
avatar?: string;
|
|
5
12
|
onsignout: () => void;
|
|
13
|
+
/** Other signed-in accounts, without the current one. */
|
|
14
|
+
accounts?: AccountMenuAccount[];
|
|
15
|
+
onswitch?: (did: string) => void;
|
|
16
|
+
/** Shows "Add account" when provided. */
|
|
17
|
+
onadd?: () => void;
|
|
6
18
|
expanded?: boolean;
|
|
7
19
|
open?: boolean;
|
|
8
20
|
label?: string;
|
|
@@ -74,19 +74,25 @@
|
|
|
74
74
|
$effect(() => {
|
|
75
75
|
const uri = firstLink;
|
|
76
76
|
const preview = linkPreview;
|
|
77
|
-
if (!preview || hasMedia
|
|
78
|
-
if (post.link
|
|
77
|
+
if (!preview || hasMedia) {
|
|
78
|
+
if (post.link) post.link = undefined;
|
|
79
|
+
loadingLink = false;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// The card outlives its link: deleting the URL, at once or a character at a time,
|
|
83
|
+
// leaves it attached. Only its own button, or another link, takes it away.
|
|
84
|
+
const shown = untrack(() => post.link?.uri);
|
|
85
|
+
if (!uri || uri === dismissed || uri === shown || shown?.startsWith(uri)) {
|
|
79
86
|
loadingLink = false;
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
|
-
if (untrack(() => post.link?.uri) === uri) return;
|
|
83
89
|
const controller = new AbortController();
|
|
84
90
|
const timer = setTimeout(async () => {
|
|
85
91
|
loadingLink = true;
|
|
86
92
|
const card = await preview(uri, controller.signal).catch(() => undefined);
|
|
87
93
|
if (controller.signal.aborted) return;
|
|
88
94
|
loadingLink = false;
|
|
89
|
-
post.link = card;
|
|
95
|
+
if (card) post.link = card;
|
|
90
96
|
}, 500);
|
|
91
97
|
return () => {
|
|
92
98
|
clearTimeout(timer);
|
|
@@ -164,8 +164,8 @@
|
|
|
164
164
|
const lengthOf = (post: Post) => graphemeLength(post.text.trim());
|
|
165
165
|
const hasMedia = (post: Post) => post.images.length > 0 || !!post.video || !!post.gif;
|
|
166
166
|
const isEmpty = (post: Post, index: number) =>
|
|
167
|
-
!lengthOf(post) && !hasMedia(post) && !(index === 0 && quote);
|
|
168
|
-
let dirty = $derived(posts.some((post, index) => !isEmpty(post, index)
|
|
167
|
+
!lengthOf(post) && !hasMedia(post) && !post.link && !(index === 0 && quote);
|
|
168
|
+
let dirty = $derived(posts.some((post, index) => !isEmpty(post, index)));
|
|
169
169
|
let missingAlt = $derived(
|
|
170
170
|
requireAlt && posts.some((p) => p.images.some((image) => !image.alt.trim()))
|
|
171
171
|
);
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export { default as IconRail } from './components/IconRail.svelte';
|
|
|
65
65
|
export type { IconRailItem } from './components/IconRail.svelte';
|
|
66
66
|
export { default as WorkspaceSidebar } from './components/WorkspaceSidebar.svelte';
|
|
67
67
|
export { default as AccountMenu } from './components/AccountMenu.svelte';
|
|
68
|
+
export type { AccountMenuAccount } from './components/AccountMenu.svelte';
|
|
68
69
|
export { default as LoginForm } from './components/login/LoginForm.svelte';
|
|
69
70
|
export type { LoginFormProps } from './components/login/LoginForm.svelte';
|
|
70
71
|
export { default as LoginDialog } from './components/login/LoginDialog.svelte';
|