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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
<script lang="ts" context="module">
import type {
TodayCard,
TodayCardMediaAppIcon,
} from '@jet-app/app-store/api/models';
export interface TodayCardWithMediAppIcon extends TodayCard {
media: TodayCardMediaAppIcon;
}
export function isSmallStoryCardWithMediaAppIcon(
item: TodayCard,
): item is TodayCardWithMediAppIcon {
return !!item.media && item.media.kind === 'appIcon';
}
</script>
<script lang="ts">
import { buildSrc } from '@amp/web-app-components/src/components/Artwork/utils/srcset';
import AppIcon from '~/components/AppIcon.svelte';
import Artwork from '~/components/Artwork.svelte';
import HoverWrapper from '~/components/HoverWrapper.svelte';
import LinkWrapper from '~/components/LinkWrapper.svelte';
import { colorAsString } from '~/utils/color';
export let item: TodayCardWithMediAppIcon;
$: artwork = item.heroMedia?.artworks[0];
$: appIcon = item.media.icon;
$: backgroundImage = appIcon
? buildSrc(
appIcon.template,
{
crop: 'bb',
width: 160,
height: 160,
fileType: 'webp',
},
{},
)
: undefined;
$: backgroundColor = appIcon.backgroundColor
? colorAsString(appIcon.backgroundColor)
: '#000';
</script>
<LinkWrapper action={item.clickAction}>
<HoverWrapper>
<div
class="container"
style:--background-color={backgroundColor}
style:--background-image={`url(${backgroundImage})`}
>
<div class="protection" />
{#if artwork}
<Artwork {artwork} profile="brick" />
{:else}
<div class="app-icon-container">
<div class="app-icon-normal">
<AppIcon
icon={appIcon}
profile="app-icon-medium"
fixedWidth={false}
/>
</div>
<div class="app-icon-glow">
<AppIcon
icon={appIcon}
profile="app-icon-medium"
fixedWidth={false}
/>
</div>
</div>
{/if}
</div>
</HoverWrapper>
<div class="text-container">
<h4>{item.heading}</h4>
<h3>{item.title}</h3>
</div>
</LinkWrapper>
<style lang="scss">
@use 'amp/stylekit/core/mixins/browser-targets' as *;
.container {
aspect-ratio: 16 / 9;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(
to bottom,
transparent 20%,
rgba(0, 0, 0, 0.33) 100%
),
var(--background-image), var(--background-color, #000);
background-size: cover;
background-position: center;
// Safari has issues rendering the overlaid `backdrop-filter` from `.proection` atop the
// background image of `.container`, so in Safari only we are forgoing the use of
// `var(--background-image)` and just using colors.
@include target-safari {
background: linear-gradient(
to bottom,
transparent 20%,
rgba(0, 0, 0, 0.33) 100%
),
var(--background-color, #000);
}
}
.protection {
position: absolute;
width: 100%;
height: 100%;
backdrop-filter: blur(80px) saturate(1.5);
}
.app-icon-container {
position: relative;
width: 80px;
}
.app-icon-normal {
position: relative;
z-index: 1;
filter: drop-shadow(0 0 13px rgba(0, 0, 0, 0.15));
}
.app-icon-glow {
position: absolute;
inset: 0;
width: 100%;
transform: scale(1.4);
filter: blur(25px);
}
.text-container {
margin-top: 8px;
}
h3 {
font: var(--title-3);
}
h4 {
margin-bottom: 2px;
font: var(--callout-emphasized);
color: var(--systemSecondary);
}
</style>
|