@streamscloud/embeddable 16.0.7-1772046586256 → 16.0.7-1772050914349
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/articles/article/fields/types.d.ts +1 -2
- package/dist/core/media/media-item-url.service.js +1 -1
- package/dist/ui/media-items/media-item-view/cmp.media-item-view.svelte +48 -0
- package/dist/ui/media-items/media-item-view/cmp.media-item-view.svelte.d.ts +2 -0
- package/dist/ui/media-items/media-items-gallery/cmp.media-items-gallery.svelte +8 -4
- package/dist/ui/media-items/media-items-gallery/cmp.media-items-gallery.svelte.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ArticleFieldType, GalleryFieldMode, MediaFormat, TextFieldMode, TextFieldWeight } from '../../../core/enums';
|
|
2
|
-
import type { MediaType } from '../../../core/enums';
|
|
1
|
+
import type { ArticleFieldType, GalleryFieldMode, MediaFormat, MediaType, TextFieldMode, TextFieldWeight } from '../../../core/enums';
|
|
3
2
|
export type ArticleFieldMediaItem = {
|
|
4
3
|
type: MediaType;
|
|
5
4
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const getMediaItemImageUrl = (media) =>
|
|
1
|
+
export const getMediaItemImageUrl = (media) => media.type === 'IMAGE' ? media.url : (media.thumbnailUrl ?? '');
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
<script lang="ts">import { getMediaItemImageUrl } from '../types';
|
|
2
|
+
import IconDelete from '@fluentui/svg-icons/icons/delete_20_regular.svg?raw';
|
|
3
|
+
import IconEdit from '@fluentui/svg-icons/icons/edit_20_regular.svg?raw';
|
|
4
|
+
import { Icon } from '@streamscloud/kit/ui/icon';
|
|
2
5
|
import { Image } from '@streamscloud/kit/ui/image';
|
|
3
6
|
import { ProportionalContainer } from '@streamscloud/kit/ui/proportional-container';
|
|
4
7
|
import { Video } from '@streamscloud/kit/ui/video';
|
|
5
8
|
let { media, ratio = 0, inert = false, on } = $props();
|
|
9
|
+
const editable = $derived(!!on?.edit || !!on?.remove);
|
|
6
10
|
const handleClick = (e) => {
|
|
7
11
|
if (on?.click) {
|
|
8
12
|
e.stopPropagation();
|
|
9
13
|
on.click();
|
|
10
14
|
}
|
|
11
15
|
};
|
|
16
|
+
const handleEdit = (e) => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
on?.edit?.();
|
|
19
|
+
};
|
|
20
|
+
const handleRemove = (e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
on?.remove?.();
|
|
23
|
+
};
|
|
12
24
|
const parsedRatio = $derived.by(() => {
|
|
13
25
|
if (!ratio || ratio === 'fit-parent') {
|
|
14
26
|
return 0;
|
|
@@ -45,6 +57,20 @@ const parsedRatio = $derived.by(() => {
|
|
|
45
57
|
{:else}
|
|
46
58
|
{@render mediaView()}
|
|
47
59
|
{/if}
|
|
60
|
+
{#if editable}
|
|
61
|
+
<div class="media-item-view__actions">
|
|
62
|
+
{#if on?.edit}
|
|
63
|
+
<button type="button" class="media-item-view__action" onclick={handleEdit} aria-label="edit">
|
|
64
|
+
<Icon src={IconEdit} />
|
|
65
|
+
</button>
|
|
66
|
+
{/if}
|
|
67
|
+
{#if on?.remove}
|
|
68
|
+
<button type="button" class="media-item-view__action" onclick={handleRemove} aria-label="remove">
|
|
69
|
+
<Icon src={IconDelete} />
|
|
70
|
+
</button>
|
|
71
|
+
{/if}
|
|
72
|
+
</div>
|
|
73
|
+
{/if}
|
|
48
74
|
</div>
|
|
49
75
|
{/if}
|
|
50
76
|
|
|
@@ -74,6 +100,28 @@ const parsedRatio = $derived.by(() => {
|
|
|
74
100
|
height: 100%;
|
|
75
101
|
cursor: pointer;
|
|
76
102
|
}
|
|
103
|
+
.media-item-view__actions {
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: 0.3125rem;
|
|
106
|
+
right: 0.3125rem;
|
|
107
|
+
opacity: 0;
|
|
108
|
+
transition: opacity ease-in-out 0.6s;
|
|
109
|
+
display: flex;
|
|
110
|
+
padding: 0 0.3125rem;
|
|
111
|
+
background: light-dark(#f2f2f3, #111827);
|
|
112
|
+
border-radius: 0.1875rem;
|
|
113
|
+
--sc-kit--icon--color: light-dark(#1f2937, #ffffff);
|
|
114
|
+
}
|
|
115
|
+
.media-item-view__action {
|
|
116
|
+
padding: 0.3125rem;
|
|
117
|
+
transition: transform 0.3s;
|
|
118
|
+
}
|
|
119
|
+
.media-item-view__action:hover {
|
|
120
|
+
transform: scale(1.2);
|
|
121
|
+
}
|
|
77
122
|
.media-item-view--clickable {
|
|
78
123
|
cursor: pointer;
|
|
124
|
+
}
|
|
125
|
+
.media-item-view:hover .media-item-view__actions {
|
|
126
|
+
opacity: 1;
|
|
79
127
|
}</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script lang="ts">import {} from '../
|
|
2
|
-
import {
|
|
1
|
+
<script lang="ts">import { MediaItemView } from '../media-item-view';
|
|
2
|
+
import {} from '../types';
|
|
3
3
|
import { GalleryLayout } from './gallery-layout';
|
|
4
4
|
import { openMediaViewer } from '@streamscloud/kit/ui/media-viewer-dialog';
|
|
5
5
|
let { media, singleImageRatio = 0, inert = false, on } = $props();
|
|
@@ -52,7 +52,9 @@ const handleGalleryItemClick = (index) => {
|
|
|
52
52
|
ratio={singleImageRatio}
|
|
53
53
|
inert={inert}
|
|
54
54
|
on={{
|
|
55
|
-
click: on?.click ? () => on?.click(0) : undefined
|
|
55
|
+
click: on?.click ? () => on?.click?.(0) : undefined,
|
|
56
|
+
edit: on?.edit ? () => on?.edit?.(0) : undefined,
|
|
57
|
+
remove: on?.remove ? () => on?.remove?.(0) : undefined
|
|
56
58
|
}} />
|
|
57
59
|
{:else}
|
|
58
60
|
<div class="gallery-container" inert={inert}>
|
|
@@ -62,7 +64,9 @@ const handleGalleryItemClick = (index) => {
|
|
|
62
64
|
media={media[index]}
|
|
63
65
|
ratio="fit-parent"
|
|
64
66
|
on={{
|
|
65
|
-
click: () => handleGalleryItemClick(index)
|
|
67
|
+
click: () => handleGalleryItemClick(index),
|
|
68
|
+
edit: on?.edit ? () => on?.edit?.(index) : undefined,
|
|
69
|
+
remove: on?.remove ? () => on?.remove?.(index) : undefined
|
|
66
70
|
}} />
|
|
67
71
|
</div>
|
|
68
72
|
{/snippet}
|
|
@@ -5,7 +5,9 @@ type Props = {
|
|
|
5
5
|
singleImageRatio?: number | MediaFormat;
|
|
6
6
|
inert?: boolean;
|
|
7
7
|
on?: {
|
|
8
|
-
click
|
|
8
|
+
click?: (index: number) => void;
|
|
9
|
+
edit?: (index: number) => void;
|
|
10
|
+
remove?: (index: number) => void;
|
|
9
11
|
};
|
|
10
12
|
};
|
|
11
13
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|