blob: f2524c6fa44151bc689e14c190e2b4212a121239 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<script lang="ts" context="module">
import type {
TodayCardMedia,
TodayCardMediaVideo,
Video as VideoModel,
} from '@jet-app/app-store/api/models';
export function isTodayCardMediaVideo(
media: TodayCardMedia,
): media is TodayCardMediaVideo {
return (
media.kind === 'video' ||
(media.kind === 'artwork' && 'videos' in media)
);
}
</script>
<script lang="ts">
import mediaQueries from '~/utils/media-queries';
import type { Profile as ArtworkProfile } from '~/components/Artwork.svelte';
import Video from '~/components/jet/Video.svelte';
import { colorAsString } from '~/utils/color';
export let media: TodayCardMediaVideo;
/**
* A `Profile` to override the default for the card's media
*/
export let artworkProfile: ArtworkProfile | undefined = undefined;
let videoToDisplay: VideoModel | undefined;
$: videoToDisplay = media.videos[0];
let profile: ArtworkProfile;
$: profile =
artworkProfile ??
($mediaQueries === 'small' ? 'card' : 'card-horizontal');
$: backgroundColor = videoToDisplay?.preview.backgroundColor
? colorAsString(videoToDisplay?.preview.backgroundColor)
: null;
</script>
{#if videoToDisplay}
<div class="video-wrapper" style:--background-color={backgroundColor}>
<Video
autoplay
loop
{profile}
useControls={false}
video={videoToDisplay}
/>
</div>
{/if}
<style>
.video-wrapper {
background: black;
aspect-ratio: 3/4;
width: 100%;
position: relative;
overflow: hidden;
border-radius: var(--today-card-border-radius);
background-color: var(--background-color);
}
@container (orientation: landscape) {
.video-wrapper {
aspect-ratio: 16/9;
height: 100%;
}
}
</style>
|