@r2digisolutions/components 0.23.1 → 0.24.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.
- package/dist/components/atoms/BrandMark/BrandMark.svelte +47 -7
- package/dist/components/atoms/BrandMark/BrandMark.svelte.d.ts +4 -0
- package/dist/components/atoms/Slider/Slider.svelte +19 -15
- package/dist/components/atoms/Slider/Slider.svelte.d.ts +2 -0
- package/dist/components/atoms/VerifiedBadge/VerifiedBadge.svelte +76 -0
- package/dist/components/atoms/VerifiedBadge/VerifiedBadge.svelte.d.ts +12 -0
- package/dist/components/molecules/AuthCard/AuthCard.svelte +19 -4
- package/dist/components/molecules/AuthCard/AuthCard.svelte.d.ts +4 -0
- package/dist/components/molecules/CanvasElementsPanel/CanvasElementsPanel.svelte +90 -26
- package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +176 -5
- package/dist/components/molecules/Combobox/Combobox.svelte +2 -2
- package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +121 -33
- package/dist/components/molecules/FormSection/FormSection.svelte +25 -28
- package/dist/components/molecules/ImageEditor/ImageEditor.svelte +183 -0
- package/dist/components/molecules/ImageEditor/ImageEditor.svelte.d.ts +19 -0
- package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +58 -35
- package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte +293 -39
- package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte.d.ts +6 -1
- package/dist/components/molecules/MediaStage/MediaStage.svelte +302 -245
- package/dist/components/molecules/MentionInput/MentionInput.svelte +332 -120
- package/dist/components/molecules/MentionInput/MentionInput.svelte.d.ts +13 -2
- package/dist/components/molecules/Select/Select.svelte +14 -1
- package/dist/components/molecules/Select/Select.svelte.d.ts +3 -0
- package/dist/components/molecules/UserMenu/UserMenu.svelte +30 -27
- package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte +200 -17
- package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte.d.ts +14 -0
- package/dist/components/organisms/AppShell/AppShell.svelte +7 -1
- package/dist/components/organisms/AppShell/AppShell.svelte.d.ts +2 -0
- package/dist/components/organisms/AuthShell/AuthShell.svelte +61 -29
- package/dist/components/organisms/AuthShell/AuthShell.svelte.d.ts +4 -0
- package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +156 -7
- package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte.d.ts +5 -0
- package/dist/components/organisms/Navbar/Navbar.svelte +2 -2
- package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte +343 -140
- package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte.d.ts +25 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +17 -0
- package/dist/utils/canvasDocument.d.ts +56 -4
- package/dist/utils/canvasDocument.js +91 -2
- package/dist/utils/canvasExport.d.ts +1 -1
- package/dist/utils/canvasExport.js +15 -25
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { onDestroy } from 'svelte';
|
|
2
|
+
import { onDestroy, type Snippet } from 'svelte';
|
|
3
3
|
|
|
4
4
|
interface ProfileMedia {
|
|
5
5
|
file: File;
|
|
@@ -21,12 +21,33 @@
|
|
|
21
21
|
coverSrc?: string;
|
|
22
22
|
/** Existing remote avatar URL (shown when no local File is selected). */
|
|
23
23
|
avatarSrc?: string;
|
|
24
|
+
/** Events and banners only need the cover strip. */
|
|
25
|
+
showAvatar?: boolean;
|
|
26
|
+
/** `contain` shows the whole image inside the cover frame. */
|
|
27
|
+
coverFit?: 'cover' | 'contain';
|
|
28
|
+
emptyTitle?: string;
|
|
29
|
+
dropTitle?: string;
|
|
30
|
+
editLabel?: string;
|
|
31
|
+
changeLabel?: string;
|
|
32
|
+
frameLabel?: string;
|
|
33
|
+
removeLabel?: string;
|
|
34
|
+
/** Text links under the avatar once a local cover / avatar is selected. */
|
|
35
|
+
removeCoverLabel?: string;
|
|
36
|
+
removeAvatarLabel?: string;
|
|
37
|
+
avatarEmptyLabel?: string;
|
|
24
38
|
accept?: string;
|
|
25
39
|
maxCoverMb?: number;
|
|
26
40
|
maxAvatarMb?: number;
|
|
27
41
|
disabled?: boolean;
|
|
28
42
|
class?: string;
|
|
29
43
|
onchange?: (value: ProfileHeaderValue) => void;
|
|
44
|
+
/** Top-right actions once a cover exists. The cover itself still replaces the file. */
|
|
45
|
+
onframe?: () => void;
|
|
46
|
+
onedit?: () => void;
|
|
47
|
+
/** Profile identity (name, badges…) rendered beside the avatar, like a public header. */
|
|
48
|
+
details?: Snippet;
|
|
49
|
+
/** Right-aligned actions on the avatar row (e.g. "View public page"). */
|
|
50
|
+
actions?: Snippet;
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
let {
|
|
@@ -36,12 +57,27 @@
|
|
|
36
57
|
avatarHelperText = 'Avatar · square image recommended',
|
|
37
58
|
coverSrc = '',
|
|
38
59
|
avatarSrc = '',
|
|
60
|
+
showAvatar = true,
|
|
61
|
+
coverFit = 'cover',
|
|
62
|
+
emptyTitle = 'Add cover photo',
|
|
63
|
+
dropTitle = 'Drop cover photo',
|
|
64
|
+
editLabel = 'Edit cover',
|
|
65
|
+
changeLabel = 'Change',
|
|
66
|
+
frameLabel = 'Adjust',
|
|
67
|
+
removeLabel = 'Remove',
|
|
68
|
+
removeCoverLabel = 'Remove cover',
|
|
69
|
+
removeAvatarLabel = 'Remove photo',
|
|
70
|
+
avatarEmptyLabel = 'Photo',
|
|
39
71
|
accept = 'image/*',
|
|
40
72
|
maxCoverMb = 10,
|
|
41
73
|
maxAvatarMb = 5,
|
|
42
74
|
disabled = false,
|
|
43
75
|
class: className = '',
|
|
44
|
-
onchange
|
|
76
|
+
onchange,
|
|
77
|
+
onframe,
|
|
78
|
+
onedit,
|
|
79
|
+
details,
|
|
80
|
+
actions
|
|
45
81
|
}: ProfileHeaderUploaderProps = $props();
|
|
46
82
|
|
|
47
83
|
let cover = $state<ProfileMedia | null>(null);
|
|
@@ -90,6 +126,10 @@
|
|
|
90
126
|
return null;
|
|
91
127
|
}
|
|
92
128
|
|
|
129
|
+
export function replaceCover(file: File) {
|
|
130
|
+
setCover(file);
|
|
131
|
+
}
|
|
132
|
+
|
|
93
133
|
function setCover(file: File | null) {
|
|
94
134
|
if (file) {
|
|
95
135
|
const err = validateImage(file, maxCoverMb);
|
|
@@ -126,6 +166,15 @@
|
|
|
126
166
|
if (avatarInput) avatarInput.value = '';
|
|
127
167
|
}
|
|
128
168
|
|
|
169
|
+
function dragStillInside(event: DragEvent) {
|
|
170
|
+
const next = event.relatedTarget;
|
|
171
|
+
return (
|
|
172
|
+
next instanceof Node &&
|
|
173
|
+
event.currentTarget instanceof Node &&
|
|
174
|
+
event.currentTarget.contains(next)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
129
178
|
function handleCoverDrop(e: DragEvent) {
|
|
130
179
|
e.preventDefault();
|
|
131
180
|
coverDragging = false;
|
|
@@ -148,7 +197,7 @@
|
|
|
148
197
|
});
|
|
149
198
|
</script>
|
|
150
199
|
|
|
151
|
-
<div class={['flex w-full flex-col
|
|
200
|
+
<div class={['gap-3 flex w-full flex-col', className]}>
|
|
152
201
|
{#if label}
|
|
153
202
|
<div id={labelId} class="text-sm font-medium text-primary">{label}</div>
|
|
154
203
|
{/if}
|
|
@@ -167,25 +216,30 @@
|
|
|
167
216
|
if (file) setCover(file);
|
|
168
217
|
}}
|
|
169
218
|
/>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
219
|
+
{#if showAvatar}
|
|
220
|
+
<input
|
|
221
|
+
bind:this={avatarInput}
|
|
222
|
+
id={avatarInputId}
|
|
223
|
+
type="file"
|
|
224
|
+
{accept}
|
|
225
|
+
{disabled}
|
|
226
|
+
class="sr-only"
|
|
227
|
+
tabindex={-1}
|
|
228
|
+
aria-hidden="true"
|
|
229
|
+
onchange={(e) => {
|
|
230
|
+
const file = (e.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
|
231
|
+
if (file) setAvatar(file);
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
{/if}
|
|
184
235
|
|
|
185
236
|
<div
|
|
186
|
-
class="
|
|
237
|
+
class="rounded-xl border-border bg-surface-elevated shadow-sm relative border"
|
|
187
238
|
aria-labelledby={label ? labelId : undefined}
|
|
188
|
-
aria-describedby={[
|
|
239
|
+
aria-describedby={[
|
|
240
|
+
coverHelperText || avatarHelperText ? helperId : '',
|
|
241
|
+
errorMessage ? errorId : ''
|
|
242
|
+
]
|
|
189
243
|
.filter(Boolean)
|
|
190
244
|
.join(' ') || undefined}
|
|
191
245
|
>
|
|
@@ -205,7 +259,10 @@
|
|
|
205
259
|
if (!disabled) coverDragging = true;
|
|
206
260
|
}}
|
|
207
261
|
ondragover={(e) => e.preventDefault()}
|
|
208
|
-
ondragleave={() =>
|
|
262
|
+
ondragleave={(e) => {
|
|
263
|
+
if (dragStillInside(e)) return;
|
|
264
|
+
coverDragging = false;
|
|
265
|
+
}}
|
|
209
266
|
ondrop={handleCoverDrop}
|
|
210
267
|
onkeydown={(e) => {
|
|
211
268
|
if (disabled) return;
|
|
@@ -216,44 +273,149 @@
|
|
|
216
273
|
}}
|
|
217
274
|
onclick={() => !disabled && coverInput?.click()}
|
|
218
275
|
class={[
|
|
219
|
-
'group relative aspect-3/1
|
|
220
|
-
'
|
|
276
|
+
'group min-h-36 relative aspect-3/1 w-full overflow-hidden transition-colors outline-none',
|
|
277
|
+
showAvatar ? 'rounded-t-xl' : 'rounded-xl',
|
|
278
|
+
'focus-visible:ring-brand-500/40 focus-visible:ring-2 focus-visible:ring-inset',
|
|
221
279
|
coverDragging ? 'bg-brand-500/10' : 'bg-surface-overlay',
|
|
222
280
|
disabled ? 'cursor-not-allowed opacity-60' : 'cursor-pointer'
|
|
223
281
|
]}
|
|
224
282
|
>
|
|
225
283
|
{#if hasCoverMedia}
|
|
226
|
-
<img
|
|
227
|
-
|
|
284
|
+
<img
|
|
285
|
+
src={coverDisplayUrl}
|
|
286
|
+
alt=""
|
|
287
|
+
class={['h-full w-full', coverFit === 'contain' ? 'object-contain' : 'object-cover']}
|
|
288
|
+
/>
|
|
289
|
+
{#if !disabled && onedit}
|
|
290
|
+
<div
|
|
291
|
+
class="inset-0 from-black/35 p-3 pointer-events-none absolute flex items-start justify-end bg-linear-to-b via-transparent to-transparent"
|
|
292
|
+
>
|
|
293
|
+
<div class="gap-1.5 pointer-events-auto flex flex-wrap items-center justify-end">
|
|
294
|
+
{#if onframe}
|
|
295
|
+
<button
|
|
296
|
+
type="button"
|
|
297
|
+
class="gap-1.5 rounded-lg bg-white/95 px-2 py-1.5 text-xs font-medium text-primary shadow-sm backdrop-blur dark:bg-neutral-900/95 inline-flex items-center"
|
|
298
|
+
onclick={(event) => {
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
onframe?.();
|
|
301
|
+
}}
|
|
302
|
+
>
|
|
303
|
+
<svg
|
|
304
|
+
class="h-3.5 w-3.5"
|
|
305
|
+
viewBox="0 0 24 24"
|
|
306
|
+
fill="none"
|
|
307
|
+
stroke="currentColor"
|
|
308
|
+
stroke-width="2"
|
|
309
|
+
aria-hidden="true"
|
|
310
|
+
>
|
|
311
|
+
<path
|
|
312
|
+
d="M6 3v4M18 3v4M6 17v4M18 17v4M3 6h4M3 18h4M17 6h4M17 18h4"
|
|
313
|
+
stroke-linecap="round"
|
|
314
|
+
/>
|
|
315
|
+
</svg>
|
|
316
|
+
{frameLabel}
|
|
317
|
+
</button>
|
|
318
|
+
{/if}
|
|
319
|
+
<button
|
|
320
|
+
type="button"
|
|
321
|
+
class="gap-1.5 rounded-lg bg-white/95 px-2 py-1.5 text-xs font-medium text-primary shadow-sm backdrop-blur dark:bg-neutral-900/95 inline-flex items-center"
|
|
322
|
+
onclick={(event) => {
|
|
323
|
+
event.stopPropagation();
|
|
324
|
+
onedit();
|
|
325
|
+
}}
|
|
326
|
+
>
|
|
327
|
+
<svg
|
|
328
|
+
class="h-3.5 w-3.5"
|
|
329
|
+
viewBox="0 0 24 24"
|
|
330
|
+
fill="none"
|
|
331
|
+
stroke="currentColor"
|
|
332
|
+
stroke-width="2"
|
|
333
|
+
aria-hidden="true"
|
|
334
|
+
>
|
|
335
|
+
<path d="M12 20h9" stroke-linecap="round" />
|
|
336
|
+
<path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4Z" stroke-linejoin="round" />
|
|
337
|
+
</svg>
|
|
338
|
+
{editLabel}
|
|
339
|
+
</button>
|
|
340
|
+
<button
|
|
341
|
+
type="button"
|
|
342
|
+
class="gap-1.5 rounded-lg bg-white/95 px-2 py-1.5 text-xs font-medium text-primary shadow-sm backdrop-blur dark:bg-neutral-900/95 inline-flex items-center"
|
|
343
|
+
onclick={(event) => {
|
|
344
|
+
event.stopPropagation();
|
|
345
|
+
coverInput?.click();
|
|
346
|
+
}}
|
|
347
|
+
>
|
|
348
|
+
<svg
|
|
349
|
+
class="h-3.5 w-3.5"
|
|
350
|
+
viewBox="0 0 24 24"
|
|
351
|
+
fill="none"
|
|
352
|
+
stroke="currentColor"
|
|
353
|
+
stroke-width="2"
|
|
354
|
+
aria-hidden="true"
|
|
355
|
+
>
|
|
356
|
+
<rect x="3" y="5" width="18" height="14" rx="2" />
|
|
357
|
+
<circle cx="9" cy="10" r="1.5" />
|
|
358
|
+
<path d="m21 16-5-5-8 8" stroke-linejoin="round" />
|
|
359
|
+
</svg>
|
|
360
|
+
{changeLabel}
|
|
361
|
+
</button>
|
|
362
|
+
<button
|
|
363
|
+
type="button"
|
|
364
|
+
class="gap-1.5 rounded-lg bg-white/95 px-2 py-1.5 text-xs font-medium text-red-600 shadow-sm backdrop-blur dark:bg-neutral-900/95 inline-flex items-center"
|
|
365
|
+
onclick={(event) => {
|
|
366
|
+
event.stopPropagation();
|
|
367
|
+
setCover(null);
|
|
368
|
+
}}
|
|
369
|
+
>
|
|
370
|
+
<svg
|
|
371
|
+
class="h-3.5 w-3.5"
|
|
372
|
+
viewBox="0 0 24 24"
|
|
373
|
+
fill="none"
|
|
374
|
+
stroke="currentColor"
|
|
375
|
+
stroke-width="2"
|
|
376
|
+
aria-hidden="true"
|
|
377
|
+
>
|
|
378
|
+
<path
|
|
379
|
+
d="M4 7h16M9 7V5h6v2M8 7l1 13h6l1-13"
|
|
380
|
+
stroke-linecap="round"
|
|
381
|
+
stroke-linejoin="round"
|
|
382
|
+
/>
|
|
383
|
+
</svg>
|
|
384
|
+
{removeLabel}
|
|
385
|
+
</button>
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
{:else if !disabled}
|
|
228
389
|
<div
|
|
229
|
-
class="
|
|
390
|
+
class="inset-0 from-black/35 p-3 absolute flex items-start justify-end bg-linear-to-b via-transparent to-transparent opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"
|
|
230
391
|
>
|
|
231
392
|
<span
|
|
232
|
-
class="
|
|
393
|
+
class="gap-1.5 rounded-lg bg-white/95 px-2.5 py-1.5 text-xs font-medium text-primary shadow-sm backdrop-blur dark:bg-neutral-900/95 inline-flex items-center"
|
|
233
394
|
>
|
|
234
|
-
|
|
235
|
-
<path
|
|
236
|
-
stroke-linecap="round"
|
|
237
|
-
stroke-linejoin="round"
|
|
238
|
-
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931z"
|
|
239
|
-
/>
|
|
240
|
-
</svg>
|
|
241
|
-
Edit cover
|
|
395
|
+
{editLabel}
|
|
242
396
|
</span>
|
|
243
397
|
</div>
|
|
244
398
|
{/if}
|
|
245
399
|
{:else}
|
|
246
|
-
<div
|
|
400
|
+
<div
|
|
401
|
+
class="inset-0 gap-2 px-4 absolute flex flex-col items-center justify-center text-center"
|
|
402
|
+
>
|
|
247
403
|
<div
|
|
248
404
|
class={[
|
|
249
|
-
'
|
|
405
|
+
'h-10 w-10 rounded-lg flex items-center justify-center',
|
|
250
406
|
coverDragging
|
|
251
407
|
? 'bg-brand-600 text-white'
|
|
252
408
|
: 'bg-brand-100 text-brand-700 dark:bg-brand-500/15 dark:text-brand-300'
|
|
253
409
|
]}
|
|
254
410
|
aria-hidden="true"
|
|
255
411
|
>
|
|
256
|
-
<svg
|
|
412
|
+
<svg
|
|
413
|
+
class="h-5 w-5"
|
|
414
|
+
fill="none"
|
|
415
|
+
viewBox="0 0 24 24"
|
|
416
|
+
stroke="currentColor"
|
|
417
|
+
stroke-width="1.75"
|
|
418
|
+
>
|
|
257
419
|
<path
|
|
258
420
|
stroke-linecap="round"
|
|
259
421
|
stroke-linejoin="round"
|
|
@@ -262,7 +424,7 @@
|
|
|
262
424
|
</svg>
|
|
263
425
|
</div>
|
|
264
426
|
<p class="text-sm font-medium text-primary">
|
|
265
|
-
{coverDragging ?
|
|
427
|
+
{coverDragging ? dropTitle : emptyTitle}
|
|
266
428
|
</p>
|
|
267
429
|
<p class="text-xs text-secondary">{coverHelperText}</p>
|
|
268
430
|
</div>
|
|
@@ -270,124 +432,165 @@
|
|
|
270
432
|
|
|
271
433
|
{#if coverDragging}
|
|
272
434
|
<div
|
|
273
|
-
class="pointer-events-none absolute
|
|
435
|
+
class="inset-0 ring-brand-500/50 pointer-events-none absolute ring-2 ring-inset"
|
|
274
436
|
aria-hidden="true"
|
|
275
437
|
></div>
|
|
276
438
|
{/if}
|
|
277
439
|
</div>
|
|
278
440
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
<div class="-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
?
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
e
|
|
294
|
-
e.stopPropagation();
|
|
295
|
-
if (!disabled) avatarDragging = true;
|
|
296
|
-
}}
|
|
297
|
-
ondragover={(e) => {
|
|
298
|
-
e.preventDefault();
|
|
299
|
-
e.stopPropagation();
|
|
300
|
-
}}
|
|
301
|
-
ondragleave={(e) => {
|
|
302
|
-
e.stopPropagation();
|
|
303
|
-
avatarDragging = false;
|
|
304
|
-
}}
|
|
305
|
-
ondrop={(e) => {
|
|
306
|
-
e.stopPropagation();
|
|
307
|
-
handleAvatarDrop(e);
|
|
308
|
-
}}
|
|
309
|
-
onkeydown={(e) => {
|
|
310
|
-
if (disabled) return;
|
|
311
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
441
|
+
{#if showAvatar}
|
|
442
|
+
<!-- Avatar overlapping cover -->
|
|
443
|
+
<div class="px-4 pb-4 pt-0 relative">
|
|
444
|
+
<div class="-mt-10 gap-4 sm:-mt-12 flex items-end">
|
|
445
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
446
|
+
<div
|
|
447
|
+
role="button"
|
|
448
|
+
tabindex={disabled ? -1 : 0}
|
|
449
|
+
aria-label={hasAvatarMedia
|
|
450
|
+
? avatar
|
|
451
|
+
? `Change profile photo, ${avatar.name}`
|
|
452
|
+
: 'Change profile photo'
|
|
453
|
+
: 'Upload profile photo'}
|
|
454
|
+
aria-disabled={disabled || undefined}
|
|
455
|
+
ondragenter={(e) => {
|
|
312
456
|
e.preventDefault();
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{
|
|
457
|
+
e.stopPropagation();
|
|
458
|
+
if (!disabled) avatarDragging = true;
|
|
459
|
+
}}
|
|
460
|
+
ondragover={(e) => {
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
e.stopPropagation();
|
|
463
|
+
}}
|
|
464
|
+
ondragleave={(e) => {
|
|
465
|
+
e.stopPropagation();
|
|
466
|
+
if (dragStillInside(e)) return;
|
|
467
|
+
avatarDragging = false;
|
|
468
|
+
}}
|
|
469
|
+
ondrop={(e) => {
|
|
470
|
+
e.stopPropagation();
|
|
471
|
+
handleAvatarDrop(e);
|
|
472
|
+
}}
|
|
473
|
+
onkeydown={(e) => {
|
|
474
|
+
if (disabled) return;
|
|
475
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
476
|
+
e.preventDefault();
|
|
477
|
+
avatarInput?.click();
|
|
478
|
+
}
|
|
479
|
+
}}
|
|
480
|
+
onclick={(e) => {
|
|
481
|
+
e.stopPropagation();
|
|
482
|
+
if (!disabled) avatarInput?.click();
|
|
483
|
+
}}
|
|
484
|
+
class={[
|
|
485
|
+
'group h-20 w-20 border-surface-elevated bg-surface-overlay shadow-md sm:h-24 sm:w-24 relative z-10 shrink-0 overflow-hidden rounded-full border-4 transition outline-none',
|
|
486
|
+
'focus-visible:ring-brand-500/40 focus-visible:ring-offset-surface-elevated focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
487
|
+
avatarDragging ? 'ring-brand-500 ring-2' : '',
|
|
488
|
+
disabled ? 'cursor-not-allowed opacity-60' : 'cursor-pointer'
|
|
489
|
+
]}
|
|
490
|
+
>
|
|
491
|
+
{#if hasAvatarMedia}
|
|
492
|
+
<img src={avatarDisplayUrl} alt="" class="h-full w-full object-cover" />
|
|
493
|
+
{#if !disabled}
|
|
494
|
+
<div
|
|
495
|
+
class="inset-0 bg-black/45 absolute flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"
|
|
496
|
+
>
|
|
497
|
+
<span
|
|
498
|
+
class="h-8 w-8 bg-white text-primary shadow-sm inline-flex items-center justify-center rounded-full"
|
|
499
|
+
aria-hidden="true"
|
|
500
|
+
>
|
|
501
|
+
<svg
|
|
502
|
+
class="h-4 w-4"
|
|
503
|
+
fill="none"
|
|
504
|
+
viewBox="0 0 24 24"
|
|
505
|
+
stroke="currentColor"
|
|
506
|
+
stroke-width="2"
|
|
507
|
+
>
|
|
508
|
+
<path
|
|
509
|
+
stroke-linecap="round"
|
|
510
|
+
stroke-linejoin="round"
|
|
511
|
+
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931z"
|
|
512
|
+
/>
|
|
513
|
+
</svg>
|
|
514
|
+
</span>
|
|
515
|
+
</div>
|
|
516
|
+
{/if}
|
|
517
|
+
{:else}
|
|
330
518
|
<div
|
|
331
|
-
class="
|
|
519
|
+
class="gap-0.5 text-secondary flex h-full w-full flex-col items-center justify-center"
|
|
332
520
|
>
|
|
333
|
-
<
|
|
334
|
-
class="
|
|
335
|
-
|
|
521
|
+
<svg
|
|
522
|
+
class="h-6 w-6"
|
|
523
|
+
fill="none"
|
|
524
|
+
viewBox="0 0 24 24"
|
|
525
|
+
stroke="currentColor"
|
|
526
|
+
stroke-width="1.75"
|
|
336
527
|
>
|
|
337
|
-
<
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
</span>
|
|
528
|
+
<path
|
|
529
|
+
stroke-linecap="round"
|
|
530
|
+
stroke-linejoin="round"
|
|
531
|
+
d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0"
|
|
532
|
+
/>
|
|
533
|
+
</svg>
|
|
534
|
+
<span class="font-medium text-[10px]">{avatarEmptyLabel}</span>
|
|
345
535
|
</div>
|
|
346
536
|
{/if}
|
|
347
|
-
|
|
348
|
-
<div class="flex h-full w-full flex-col items-center justify-center gap-0.5 text-secondary">
|
|
349
|
-
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.75">
|
|
350
|
-
<path
|
|
351
|
-
stroke-linecap="round"
|
|
352
|
-
stroke-linejoin="round"
|
|
353
|
-
d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0"
|
|
354
|
-
/>
|
|
355
|
-
</svg>
|
|
356
|
-
<span class="text-[10px] font-medium">Photo</span>
|
|
357
|
-
</div>
|
|
358
|
-
{/if}
|
|
359
|
-
</div>
|
|
537
|
+
</div>
|
|
360
538
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
539
|
+
<!-- With `details`, only the avatar overlaps the cover; the text stays on the card
|
|
540
|
+
surface so it never has to compete with the cover image for contrast. -->
|
|
541
|
+
<div
|
|
542
|
+
class={[
|
|
543
|
+
'min-w-0 flex-1',
|
|
544
|
+
details
|
|
545
|
+
? 'mt-10 gap-4 pt-2 sm:mt-12 flex flex-wrap items-center justify-between self-start'
|
|
546
|
+
: 'pb-1'
|
|
547
|
+
]}
|
|
548
|
+
>
|
|
549
|
+
{#if details}
|
|
550
|
+
<div class="min-w-0 flex-1">
|
|
551
|
+
{@render details()}
|
|
552
|
+
</div>
|
|
553
|
+
{/if}
|
|
554
|
+
{#if actions && details}
|
|
555
|
+
<div class="gap-2 flex shrink-0 flex-wrap items-center justify-end">
|
|
556
|
+
{@render actions()}
|
|
557
|
+
</div>
|
|
558
|
+
{/if}
|
|
559
|
+
{#if hasLocalMedia}
|
|
560
|
+
<div class={['gap-2 flex flex-wrap items-center', details ? 'w-full' : '']}>
|
|
561
|
+
{#if cover && !disabled}
|
|
562
|
+
<button
|
|
563
|
+
type="button"
|
|
564
|
+
onclick={() => setCover(null)}
|
|
565
|
+
class="rounded-lg px-2 py-1 text-xs font-medium text-secondary hover:bg-surface-overlay hover:text-primary transition"
|
|
566
|
+
>
|
|
567
|
+
{removeCoverLabel}
|
|
568
|
+
</button>
|
|
569
|
+
{/if}
|
|
570
|
+
{#if avatar && !disabled}
|
|
571
|
+
<button
|
|
572
|
+
type="button"
|
|
573
|
+
onclick={() => setAvatar(null)}
|
|
574
|
+
class="rounded-lg px-2 py-1 text-xs font-medium text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40 transition"
|
|
575
|
+
>
|
|
576
|
+
{removeAvatarLabel}
|
|
577
|
+
</button>
|
|
578
|
+
{/if}
|
|
579
|
+
</div>
|
|
580
|
+
{:else if !details}
|
|
581
|
+
<p id={helperId} class="text-xs text-secondary leading-relaxed">
|
|
582
|
+
{avatarHelperText}
|
|
583
|
+
</p>
|
|
584
|
+
{/if}
|
|
585
|
+
</div>
|
|
586
|
+
{#if actions && !details}
|
|
587
|
+
<div class="pb-1 gap-2 flex shrink-0 flex-wrap items-center justify-end">
|
|
588
|
+
{@render actions()}
|
|
382
589
|
</div>
|
|
383
|
-
{:else}
|
|
384
|
-
<p id={helperId} class="text-xs text-secondary leading-relaxed">
|
|
385
|
-
{avatarHelperText}
|
|
386
|
-
</p>
|
|
387
590
|
{/if}
|
|
388
591
|
</div>
|
|
389
592
|
</div>
|
|
390
|
-
|
|
593
|
+
{/if}
|
|
391
594
|
</div>
|
|
392
595
|
|
|
393
596
|
{#if errorMessage}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
1
2
|
interface ProfileHeaderValue {
|
|
2
3
|
cover: File | null;
|
|
3
4
|
avatar: File | null;
|
|
@@ -11,13 +12,36 @@ interface ProfileHeaderUploaderProps {
|
|
|
11
12
|
coverSrc?: string;
|
|
12
13
|
/** Existing remote avatar URL (shown when no local File is selected). */
|
|
13
14
|
avatarSrc?: string;
|
|
15
|
+
/** Events and banners only need the cover strip. */
|
|
16
|
+
showAvatar?: boolean;
|
|
17
|
+
/** `contain` shows the whole image inside the cover frame. */
|
|
18
|
+
coverFit?: 'cover' | 'contain';
|
|
19
|
+
emptyTitle?: string;
|
|
20
|
+
dropTitle?: string;
|
|
21
|
+
editLabel?: string;
|
|
22
|
+
changeLabel?: string;
|
|
23
|
+
frameLabel?: string;
|
|
24
|
+
removeLabel?: string;
|
|
25
|
+
/** Text links under the avatar once a local cover / avatar is selected. */
|
|
26
|
+
removeCoverLabel?: string;
|
|
27
|
+
removeAvatarLabel?: string;
|
|
28
|
+
avatarEmptyLabel?: string;
|
|
14
29
|
accept?: string;
|
|
15
30
|
maxCoverMb?: number;
|
|
16
31
|
maxAvatarMb?: number;
|
|
17
32
|
disabled?: boolean;
|
|
18
33
|
class?: string;
|
|
19
34
|
onchange?: (value: ProfileHeaderValue) => void;
|
|
35
|
+
/** Top-right actions once a cover exists. The cover itself still replaces the file. */
|
|
36
|
+
onframe?: () => void;
|
|
37
|
+
onedit?: () => void;
|
|
38
|
+
/** Profile identity (name, badges…) rendered beside the avatar, like a public header. */
|
|
39
|
+
details?: Snippet;
|
|
40
|
+
/** Right-aligned actions on the avatar row (e.g. "View public page"). */
|
|
41
|
+
actions?: Snippet;
|
|
20
42
|
}
|
|
21
|
-
declare const ProfileHeaderUploader: import("svelte").Component<ProfileHeaderUploaderProps, {
|
|
43
|
+
declare const ProfileHeaderUploader: import("svelte").Component<ProfileHeaderUploaderProps, {
|
|
44
|
+
replaceCover: (file: File) => void;
|
|
45
|
+
}, "">;
|
|
22
46
|
type ProfileHeaderUploader = ReturnType<typeof ProfileHeaderUploader>;
|
|
23
47
|
export default ProfileHeaderUploader;
|