blob: ad8e4bca03b286cac4214620189ad8ba5df58642 (
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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<script lang="ts" context="module">
import type {
ShelfModel,
TitledParagraph,
} from '@jet-app/app-store/api/models';
export function isTitledParagraphItem(
item: ShelfModel | string,
): item is TitledParagraph {
return typeof item !== 'string' && 'text' in item;
}
</script>
<script lang="ts">
import { sanitizeHtml } from '@amp/web-app-components/src/utils/sanitize-html';
import LineClamp from '@amp/web-app-components/src/components/LineClamp/LineClamp.svelte';
import { getNumericDateFromDateString } from '@amp/web-app-components/src/utils/date';
import { getJet } from '~/jet/svelte';
import { getI18n } from '~/stores/i18n';
export let item: TitledParagraph;
const i18n = getI18n();
const jet = getJet();
const isDetailView = item.style === 'detail';
const dateForDisplay = jet.localization.timeAgo(
new Date(item.secondarySubtitle),
);
const dateForAttribute = getNumericDateFromDateString(
item.secondarySubtitle,
);
let isTruncated = true;
</script>
<article class:detail={isDetailView} class:overview={!isDetailView}>
<div class="container">
<p>
{#if item.text}
{#if !isTruncated || isDetailView}
{item.text}
{:else}
<LineClamp
clamp={5}
observe
on:resize={({ detail }) =>
(isTruncated = detail.truncated)}
>
{@html sanitizeHtml(item.text)}
</LineClamp>
{#if isTruncated}
<button on:click={() => (isTruncated = false)}>
{$i18n.t('ASE.Web.AppStore.More')}
</button>
{/if}
{/if}
{/if}
</p>
<div class="metadata">
<h4>{item.primarySubtitle}</h4>
<time datetime={dateForAttribute}>{dateForDisplay}</time>
</div>
</div>
</article>
<style lang="scss">
@use '@amp/web-shared-styles/sasskit-stylekit/ac-sasskit-config';
@use 'ac-sasskit/core/locale' as *;
article {
display: flex;
flex-direction: column-reverse;
font: var(--body-tall);
color: var(--systemPrimary);
margin: 0 var(--bodyGutter);
@media (--range-small-up) {
flex-direction: row;
}
}
.container {
display: flex;
width: 100%;
}
p {
position: relative;
display: flex;
flex-direction: column;
white-space: break-spaces;
font: var(--body-tall);
}
.metadata {
display: flex;
flex-direction: column;
justify-content: flex-start;
margin: 0 0 8px 8px;
text-align: end;
color: var(--systemSecondary);
}
h4 {
font: var(--body-tall);
}
button {
--gradient-direction: 270deg;
position: absolute;
bottom: 0;
display: flex;
justify-content: end;
color: var(--keyColor);
inset-inline-end: 0;
padding-inline-start: 20px;
background: linear-gradient(
var(--gradient-direction),
var(--pageBg) 72%,
transparent 100%
);
@include rtl {
--gradient-direction: 90deg;
}
}
time {
color: var(--systemSecondary);
white-space: nowrap;
}
.detail {
flex-direction: column-reverse;
margin: 0;
padding: 16px 0 0;
border-top: 1px solid var(--systemGray4);
}
.detail .metadata {
gap: 2px;
}
.detail h4 {
font: var(--body-emphasized-tall);
color: var(--systemPrimary);
}
.overview .container {
@media (--range-medium-up) {
width: 66%;
}
}
.overview .metadata {
flex-grow: 1;
gap: 4px;
}
.overview p {
@media (--range-small-up) {
width: 66%;
}
@media (--range-large-up) {
width: 50%;
}
}
.detail .container {
justify-content: space-between;
}
</style>
|