@times-components/ts-components 1.16.2 → 1.18.0
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/CHANGELOG.md +38 -0
- package/README.md +7 -0
- package/dist/components/article-flag/ArticleFlag.d.ts +22 -0
- package/dist/components/article-flag/ArticleFlag.js +43 -0
- package/dist/components/article-flag/{LiveArticleFlag.stories.d.ts → ArticleFlag.stories.d.ts} +0 -0
- package/dist/components/article-flag/ArticleFlag.stories.js +29 -0
- package/dist/components/article-flag/LiveArticleFlag.d.ts +4 -0
- package/dist/components/article-flag/LiveArticleFlag.js +7 -5
- package/dist/components/article-flag/__tests__/ArticleFlag.test.d.ts +1 -0
- package/dist/components/article-flag/__tests__/ArticleFlag.test.js +75 -0
- package/dist/components/article-flag/__tests__/LiveArticleFlag.test.js +14 -4
- package/dist/components/article-flag/__tests__/getActiveFlags.test.d.ts +1 -0
- package/dist/components/article-flag/__tests__/getActiveFlags.test.js +36 -0
- package/dist/components/article-flag/getActiveFlags.d.ts +3 -0
- package/dist/components/article-flag/getActiveFlags.js +9 -0
- package/dist/components/article-flag/styles.d.ts +12 -3
- package/dist/components/article-flag/styles.js +38 -4
- package/dist/components/inline-dialog/InlineDialog.d.ts +7 -0
- package/dist/components/inline-dialog/InlineDialog.js +7 -0
- package/dist/components/inline-dialog/InlineDialog.stories.d.ts +1 -0
- package/dist/components/inline-dialog/InlineDialog.stories.js +8 -0
- package/dist/components/inline-dialog/__tests__/InlineDialog.test.d.ts +1 -0
- package/dist/components/inline-dialog/__tests__/InlineDialog.test.js +17 -0
- package/dist/components/inline-dialog/styles.d.ts +4 -0
- package/dist/components/inline-dialog/styles.js +50 -0
- package/dist/components/inline-message/styles.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -2
- package/jest.config.js +4 -4
- package/package.json +6 -6
- package/rnw.js +1 -1
- package/src/components/article-flag/ArticleFlag.stories.tsx +48 -0
- package/src/components/article-flag/ArticleFlag.tsx +118 -0
- package/src/components/article-flag/LiveArticleFlag.tsx +17 -5
- package/src/components/article-flag/__tests__/ArticleFlag.test.tsx +111 -0
- package/src/components/article-flag/__tests__/LiveArticleFlag.test.tsx +19 -3
- package/src/components/article-flag/__tests__/__snapshots__/ArticleFlag.test.tsx.snap +394 -0
- package/src/components/article-flag/__tests__/__snapshots__/LiveArticleFlag.test.tsx.snap +46 -4
- package/src/components/article-flag/__tests__/getActiveFlags.test.ts +38 -0
- package/src/components/article-flag/getActiveFlags.ts +14 -0
- package/src/components/article-flag/styles.ts +41 -3
- package/src/components/inline-dialog/InlineDialog.stories.tsx +17 -0
- package/src/components/inline-dialog/InlineDialog.tsx +17 -0
- package/src/components/inline-dialog/__tests__/InlineDialog.test.tsx +21 -0
- package/src/components/inline-dialog/__tests__/__snapshots__/InlineDialog.test.tsx.snap +26 -0
- package/src/components/inline-dialog/styles.ts +51 -0
- package/src/components/inline-message/__tests__/__snapshots__/InlineMessage.test.tsx.snap +1 -1
- package/src/components/inline-message/styles.ts +1 -1
- package/src/components/latest-from-section/__tests__/__snapshots__/LatestFromSection.test.tsx.snap +3 -0
- package/src/components/newsletter-puff/__tests__/__snapshots__/InlineNewsletterPuff.test.tsx.snap +4 -0
- package/src/components/newsletter-puff/__tests__/__snapshots__/PreviewNewsletterPuff.test.tsx.snap +1 -0
- package/src/index.ts +15 -1
- package/src/types/externs.d.ts +1 -0
- package/dist/components/article-flag/LiveArticleFlag.stories.js +0 -7
- package/src/components/article-flag/LiveArticleFlag.stories.tsx +0 -7
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ArticleFlag does not render article flags if there are none 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div />
|
|
6
|
+
</body>
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`ArticleFlag renders a red article flag 1`] = `
|
|
10
|
+
<body>
|
|
11
|
+
<div>
|
|
12
|
+
<div
|
|
13
|
+
class="sc-bdVaJa fXEEbM"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
class="sc-htpNat ZOZQE"
|
|
17
|
+
color="red"
|
|
18
|
+
/>
|
|
19
|
+
<div
|
|
20
|
+
aria-label="Coloured Red Flag"
|
|
21
|
+
class="sc-ifAKCX dTECV"
|
|
22
|
+
color="red"
|
|
23
|
+
data-testid="flag-Coloured Red"
|
|
24
|
+
>
|
|
25
|
+
coloured red
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</body>
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
exports[`ArticleFlag renders an article flag 1`] = `
|
|
33
|
+
<body>
|
|
34
|
+
<div>
|
|
35
|
+
<div
|
|
36
|
+
class="sc-bdVaJa fXEEbM"
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
class="sc-htpNat qvwfW"
|
|
40
|
+
color=""
|
|
41
|
+
/>
|
|
42
|
+
<div
|
|
43
|
+
aria-label="No Colour Flag"
|
|
44
|
+
class="sc-ifAKCX juPnZa"
|
|
45
|
+
color=""
|
|
46
|
+
data-testid="flag-No Colour"
|
|
47
|
+
>
|
|
48
|
+
no colour
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</body>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`ArticleFlag renders multiple article flags 1`] = `
|
|
56
|
+
<body>
|
|
57
|
+
<div>
|
|
58
|
+
<div
|
|
59
|
+
class="sc-gzVnrw kpMYNz"
|
|
60
|
+
>
|
|
61
|
+
<div
|
|
62
|
+
class="sc-bZQynM fMCtl"
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
class="sc-bdVaJa fXEEbM"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
class="sc-htpNat fugARQ"
|
|
69
|
+
color="#3C81BE"
|
|
70
|
+
/>
|
|
71
|
+
<div
|
|
72
|
+
aria-label="updated Flag"
|
|
73
|
+
class="sc-ifAKCX hSeRZN"
|
|
74
|
+
color="#3C81BE"
|
|
75
|
+
data-testid="flag-updated"
|
|
76
|
+
>
|
|
77
|
+
updated
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
<div
|
|
82
|
+
class="sc-bZQynM fMCtl"
|
|
83
|
+
>
|
|
84
|
+
<div
|
|
85
|
+
class="sc-bdVaJa fXEEbM"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
class="sc-htpNat dZoUoM"
|
|
89
|
+
color="#C51D24"
|
|
90
|
+
/>
|
|
91
|
+
<div
|
|
92
|
+
aria-label="exclusive Flag"
|
|
93
|
+
class="sc-ifAKCX fupmhj"
|
|
94
|
+
color="#C51D24"
|
|
95
|
+
data-testid="flag-exclusive"
|
|
96
|
+
>
|
|
97
|
+
exclusive
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
<div
|
|
102
|
+
class="sc-bZQynM fMCtl"
|
|
103
|
+
>
|
|
104
|
+
<div
|
|
105
|
+
class="sc-bdVaJa fXEEbM"
|
|
106
|
+
>
|
|
107
|
+
<div
|
|
108
|
+
class="sc-htpNat jkDJOE"
|
|
109
|
+
color="#E34605"
|
|
110
|
+
/>
|
|
111
|
+
<div
|
|
112
|
+
aria-label="new Flag"
|
|
113
|
+
class="sc-ifAKCX iquuBv"
|
|
114
|
+
color="#E34605"
|
|
115
|
+
data-testid="flag-new"
|
|
116
|
+
>
|
|
117
|
+
new
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
<div
|
|
122
|
+
class="sc-bZQynM fMCtl"
|
|
123
|
+
>
|
|
124
|
+
<div
|
|
125
|
+
class="sc-bdVaJa fXEEbM"
|
|
126
|
+
>
|
|
127
|
+
<div
|
|
128
|
+
class="sc-htpNat gaRHEk"
|
|
129
|
+
color="#4D4D4D"
|
|
130
|
+
/>
|
|
131
|
+
<div
|
|
132
|
+
aria-label="sponsored Flag"
|
|
133
|
+
class="sc-ifAKCX fzZyiZ"
|
|
134
|
+
color="#4D4D4D"
|
|
135
|
+
data-testid="flag-sponsored"
|
|
136
|
+
>
|
|
137
|
+
sponsored
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
<div
|
|
142
|
+
class="sc-bZQynM fMCtl"
|
|
143
|
+
>
|
|
144
|
+
<div
|
|
145
|
+
class="sc-bdVaJa fXEEbM"
|
|
146
|
+
>
|
|
147
|
+
<div
|
|
148
|
+
class="sc-htpNat fRxTiY"
|
|
149
|
+
color="#696969"
|
|
150
|
+
/>
|
|
151
|
+
<div
|
|
152
|
+
aria-label="long read Flag"
|
|
153
|
+
class="sc-ifAKCX cRBzVF"
|
|
154
|
+
color="#696969"
|
|
155
|
+
data-testid="flag-long read"
|
|
156
|
+
>
|
|
157
|
+
long read
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</body>
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
exports[`ArticleFlag renders multiple article flags in a container 1`] = `
|
|
167
|
+
<body>
|
|
168
|
+
<div>
|
|
169
|
+
<div
|
|
170
|
+
class="sc-htoDjs gNxXwX"
|
|
171
|
+
>
|
|
172
|
+
<div
|
|
173
|
+
class="sc-gzVnrw kpMYNz"
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
class="sc-bZQynM fMCtl"
|
|
177
|
+
>
|
|
178
|
+
<div
|
|
179
|
+
class="sc-bdVaJa fXEEbM"
|
|
180
|
+
>
|
|
181
|
+
<div
|
|
182
|
+
class="sc-htpNat fugARQ"
|
|
183
|
+
color="#3C81BE"
|
|
184
|
+
/>
|
|
185
|
+
<div
|
|
186
|
+
aria-label="updated Flag"
|
|
187
|
+
class="sc-ifAKCX hSeRZN"
|
|
188
|
+
color="#3C81BE"
|
|
189
|
+
data-testid="flag-updated"
|
|
190
|
+
>
|
|
191
|
+
updated
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<div
|
|
196
|
+
class="sc-bZQynM fMCtl"
|
|
197
|
+
>
|
|
198
|
+
<div
|
|
199
|
+
class="sc-bdVaJa fXEEbM"
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
class="sc-htpNat dZoUoM"
|
|
203
|
+
color="#C51D24"
|
|
204
|
+
/>
|
|
205
|
+
<div
|
|
206
|
+
aria-label="exclusive Flag"
|
|
207
|
+
class="sc-ifAKCX fupmhj"
|
|
208
|
+
color="#C51D24"
|
|
209
|
+
data-testid="flag-exclusive"
|
|
210
|
+
>
|
|
211
|
+
exclusive
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
<div
|
|
216
|
+
class="sc-bZQynM fMCtl"
|
|
217
|
+
>
|
|
218
|
+
<div
|
|
219
|
+
class="sc-bdVaJa fXEEbM"
|
|
220
|
+
>
|
|
221
|
+
<div
|
|
222
|
+
class="sc-htpNat jkDJOE"
|
|
223
|
+
color="#E34605"
|
|
224
|
+
/>
|
|
225
|
+
<div
|
|
226
|
+
aria-label="new Flag"
|
|
227
|
+
class="sc-ifAKCX iquuBv"
|
|
228
|
+
color="#E34605"
|
|
229
|
+
data-testid="flag-new"
|
|
230
|
+
>
|
|
231
|
+
new
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
<div
|
|
236
|
+
class="sc-bZQynM fMCtl"
|
|
237
|
+
>
|
|
238
|
+
<div
|
|
239
|
+
class="sc-bdVaJa fXEEbM"
|
|
240
|
+
>
|
|
241
|
+
<div
|
|
242
|
+
class="sc-htpNat gaRHEk"
|
|
243
|
+
color="#4D4D4D"
|
|
244
|
+
/>
|
|
245
|
+
<div
|
|
246
|
+
aria-label="sponsored Flag"
|
|
247
|
+
class="sc-ifAKCX fzZyiZ"
|
|
248
|
+
color="#4D4D4D"
|
|
249
|
+
data-testid="flag-sponsored"
|
|
250
|
+
>
|
|
251
|
+
sponsored
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
<div
|
|
256
|
+
class="sc-bZQynM fMCtl"
|
|
257
|
+
>
|
|
258
|
+
<div
|
|
259
|
+
class="sc-bdVaJa fXEEbM"
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
262
|
+
class="sc-htpNat fRxTiY"
|
|
263
|
+
color="#696969"
|
|
264
|
+
/>
|
|
265
|
+
<div
|
|
266
|
+
aria-label="long read Flag"
|
|
267
|
+
class="sc-ifAKCX cRBzVF"
|
|
268
|
+
color="#696969"
|
|
269
|
+
data-testid="flag-long read"
|
|
270
|
+
>
|
|
271
|
+
long read
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</body>
|
|
279
|
+
`;
|
|
280
|
+
|
|
281
|
+
exports[`ArticleFlag renders the exclusive article flag 1`] = `
|
|
282
|
+
<body>
|
|
283
|
+
<div>
|
|
284
|
+
<div
|
|
285
|
+
class="sc-bdVaJa fXEEbM"
|
|
286
|
+
>
|
|
287
|
+
<div
|
|
288
|
+
class="sc-htpNat dZoUoM"
|
|
289
|
+
color="#C51D24"
|
|
290
|
+
/>
|
|
291
|
+
<div
|
|
292
|
+
aria-label="exclusive Flag"
|
|
293
|
+
class="sc-ifAKCX fupmhj"
|
|
294
|
+
color="#C51D24"
|
|
295
|
+
data-testid="flag-exclusive"
|
|
296
|
+
>
|
|
297
|
+
exclusive
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</body>
|
|
302
|
+
`;
|
|
303
|
+
|
|
304
|
+
exports[`ArticleFlag renders the long read article flag 1`] = `
|
|
305
|
+
<body>
|
|
306
|
+
<div>
|
|
307
|
+
<div
|
|
308
|
+
class="sc-bdVaJa fXEEbM"
|
|
309
|
+
>
|
|
310
|
+
<div
|
|
311
|
+
class="sc-htpNat fRxTiY"
|
|
312
|
+
color="#696969"
|
|
313
|
+
/>
|
|
314
|
+
<div
|
|
315
|
+
aria-label="long read Flag"
|
|
316
|
+
class="sc-ifAKCX cRBzVF"
|
|
317
|
+
color="#696969"
|
|
318
|
+
data-testid="flag-long read"
|
|
319
|
+
>
|
|
320
|
+
long read
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
</div>
|
|
324
|
+
</body>
|
|
325
|
+
`;
|
|
326
|
+
|
|
327
|
+
exports[`ArticleFlag renders the new article flag 1`] = `
|
|
328
|
+
<body>
|
|
329
|
+
<div>
|
|
330
|
+
<div
|
|
331
|
+
class="sc-bdVaJa fXEEbM"
|
|
332
|
+
>
|
|
333
|
+
<div
|
|
334
|
+
class="sc-htpNat jkDJOE"
|
|
335
|
+
color="#E34605"
|
|
336
|
+
/>
|
|
337
|
+
<div
|
|
338
|
+
aria-label="new Flag"
|
|
339
|
+
class="sc-ifAKCX iquuBv"
|
|
340
|
+
color="#E34605"
|
|
341
|
+
data-testid="flag-new"
|
|
342
|
+
>
|
|
343
|
+
new
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
</body>
|
|
348
|
+
`;
|
|
349
|
+
|
|
350
|
+
exports[`ArticleFlag renders the sponsored article flag 1`] = `
|
|
351
|
+
<body>
|
|
352
|
+
<div>
|
|
353
|
+
<div
|
|
354
|
+
class="sc-bdVaJa fXEEbM"
|
|
355
|
+
>
|
|
356
|
+
<div
|
|
357
|
+
class="sc-htpNat gaRHEk"
|
|
358
|
+
color="#4D4D4D"
|
|
359
|
+
/>
|
|
360
|
+
<div
|
|
361
|
+
aria-label="sponsored Flag"
|
|
362
|
+
class="sc-ifAKCX fzZyiZ"
|
|
363
|
+
color="#4D4D4D"
|
|
364
|
+
data-testid="flag-sponsored"
|
|
365
|
+
>
|
|
366
|
+
sponsored
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
</div>
|
|
370
|
+
</body>
|
|
371
|
+
`;
|
|
372
|
+
|
|
373
|
+
exports[`ArticleFlag renders the updated article flag 1`] = `
|
|
374
|
+
<body>
|
|
375
|
+
<div>
|
|
376
|
+
<div
|
|
377
|
+
class="sc-bdVaJa fXEEbM"
|
|
378
|
+
>
|
|
379
|
+
<div
|
|
380
|
+
class="sc-htpNat fugARQ"
|
|
381
|
+
color="#3C81BE"
|
|
382
|
+
/>
|
|
383
|
+
<div
|
|
384
|
+
aria-label="updated Flag"
|
|
385
|
+
class="sc-ifAKCX hSeRZN"
|
|
386
|
+
color="#3C81BE"
|
|
387
|
+
data-testid="flag-updated"
|
|
388
|
+
>
|
|
389
|
+
updated
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
</div>
|
|
393
|
+
</body>
|
|
394
|
+
`;
|
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[
|
|
3
|
+
exports[`LiveArticleFlag should render the base live article flag 1`] = `
|
|
4
4
|
<body>
|
|
5
5
|
<div>
|
|
6
6
|
<div
|
|
7
|
-
class="sc-
|
|
7
|
+
class="sc-bwzfXH WFEid"
|
|
8
8
|
>
|
|
9
9
|
<div
|
|
10
|
-
class="sc-
|
|
10
|
+
class="sc-bxivhb hmIbmT"
|
|
11
11
|
>
|
|
12
12
|
◆
|
|
13
13
|
</div>
|
|
14
14
|
<div
|
|
15
|
-
class="sc-
|
|
15
|
+
class="sc-EHOje jboioV"
|
|
16
|
+
>
|
|
17
|
+
BASE
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</body>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
exports[`LiveArticleFlag should render the breaking article flag 1`] = `
|
|
25
|
+
<body>
|
|
26
|
+
<div>
|
|
27
|
+
<div
|
|
28
|
+
class="sc-bwzfXH WFEid"
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
class="sc-bxivhb hmIbmT"
|
|
32
|
+
>
|
|
33
|
+
◆
|
|
34
|
+
</div>
|
|
35
|
+
<div
|
|
36
|
+
class="sc-EHOje jboioV"
|
|
37
|
+
>
|
|
38
|
+
BREAKING
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</body>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`LiveArticleFlag should render the live article flag 1`] = `
|
|
46
|
+
<body>
|
|
47
|
+
<div>
|
|
48
|
+
<div
|
|
49
|
+
class="sc-bwzfXH WFEid"
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
class="sc-bxivhb hmIbmT"
|
|
53
|
+
>
|
|
54
|
+
◆
|
|
55
|
+
</div>
|
|
56
|
+
<div
|
|
57
|
+
class="sc-EHOje jboioV"
|
|
16
58
|
>
|
|
17
59
|
LIVE
|
|
18
60
|
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import mockDate from 'mockdate';
|
|
2
|
+
import getActiveFlags from '../getActiveFlags';
|
|
3
|
+
|
|
4
|
+
describe('get active flags function', () => {
|
|
5
|
+
// GMT: Thursday, 14 March 2019 16:22:54
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
mockDate.set(1552580574000);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
mockDate.reset();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns only active flags', () => {
|
|
15
|
+
const flags = [
|
|
16
|
+
{ expiryTime: '2020-03-13T12:00:00.000Z', type: 'UPDATED' },
|
|
17
|
+
{ expiryTime: '2019-03-14T12:00:00.000Z', type: 'EXCLUSIVE' }
|
|
18
|
+
];
|
|
19
|
+
expect(getActiveFlags(flags)).toEqual([flags[0]]);
|
|
20
|
+
});
|
|
21
|
+
it('returns no flags when all have expired', () => {
|
|
22
|
+
const flags = [
|
|
23
|
+
{ expiryTime: '2019-03-14T16:22:54.000Z', type: 'UPDATED' },
|
|
24
|
+
{ expiryTime: '2019-03-14T12:00:00.000Z', type: 'EXCLUSIVE' }
|
|
25
|
+
];
|
|
26
|
+
expect(getActiveFlags(flags)).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
it('returns flags when expiry time is null', () => {
|
|
29
|
+
const flags = [
|
|
30
|
+
{ expiryTime: null, type: 'UPDATED' },
|
|
31
|
+
{ expiryTime: null, type: 'EXCLUSIVE' }
|
|
32
|
+
];
|
|
33
|
+
expect(getActiveFlags(flags)).toEqual(flags);
|
|
34
|
+
});
|
|
35
|
+
it('returns no flags when no flags are provided', () => {
|
|
36
|
+
expect(getActiveFlags([])).toEqual([]);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlagType } from './ArticleFlag';
|
|
2
|
+
|
|
3
|
+
const getActiveArticleFlags: (flags: FlagType) => FlagType = flags => {
|
|
4
|
+
if (!flags) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return flags.filter(
|
|
8
|
+
flag =>
|
|
9
|
+
flag.expiryTime === null ||
|
|
10
|
+
new Date().getTime() < new Date(flag.expiryTime).getTime()
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default getActiveArticleFlags;
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { fonts } from '@times-components/styleguide';
|
|
3
|
+
import { FlagType } from './ArticleFlag';
|
|
4
|
+
import { gqlRgbaToStyle } from '@times-components/utils';
|
|
3
5
|
|
|
4
|
-
export const
|
|
6
|
+
export const ArticleFlagContainer = styled.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const LiveArticleFlagContainer = styled.div`
|
|
5
13
|
display: flex;
|
|
6
14
|
padding: 2px 6px;
|
|
7
15
|
background-color: #9f0000;
|
|
8
16
|
align-items: baseline;
|
|
9
17
|
`;
|
|
10
18
|
|
|
11
|
-
export const
|
|
19
|
+
export const ArticleFlagBullet = styled.div`
|
|
20
|
+
border-radius: 2.5px;
|
|
21
|
+
height: 5px;
|
|
22
|
+
width: 5px;
|
|
23
|
+
background-color: ${({ color }) => gqlRgbaToStyle(color) || color};
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const LiveDiamondContainer = styled.div`
|
|
12
27
|
margin-right: 4px;
|
|
13
28
|
color: #ffffff;
|
|
14
29
|
line-height: 16px;
|
|
15
30
|
`;
|
|
16
31
|
|
|
17
|
-
export const
|
|
32
|
+
export const ArticleFlagTextContainer = styled.div`
|
|
33
|
+
font-family: TimesDigitalW04-RegularSC;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
font-weight: 400;
|
|
36
|
+
letter-spacing: 0.6px;
|
|
37
|
+
line-height: 12px;
|
|
38
|
+
margin-left: 5px;
|
|
39
|
+
color: ${({ color }) => gqlRgbaToStyle(color) || color};
|
|
40
|
+
`;
|
|
41
|
+
export const LiveArticleFlagTextContainer = styled.div`
|
|
18
42
|
font-family: ${fonts.supporting};
|
|
19
43
|
color: #ffffff;
|
|
20
44
|
font-weight: 500;
|
|
@@ -22,3 +46,17 @@ export const Title = styled.div`
|
|
|
22
46
|
letter-spacing: 0.1em;
|
|
23
47
|
line-height: 16px;
|
|
24
48
|
`;
|
|
49
|
+
|
|
50
|
+
export const FlagPadding = styled.div<{ allFlags: FlagType }>`
|
|
51
|
+
margin-right: ${({ allFlags }) => (allFlags.length > 1 ? '15px' : 0)};
|
|
52
|
+
`;
|
|
53
|
+
export const Flags = styled.div`
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: row;
|
|
56
|
+
flex-wrap: wrap;
|
|
57
|
+
margin-bottom: 10px;
|
|
58
|
+
`;
|
|
59
|
+
export const FlagsContainer = styled.div`
|
|
60
|
+
margin-bottom: 15px;
|
|
61
|
+
margin-top: 5px;
|
|
62
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { storiesOf } from '@storybook/react';
|
|
3
|
+
import { InlineDialog } from './InlineDialog';
|
|
4
|
+
import { action } from '@storybook/addon-actions';
|
|
5
|
+
|
|
6
|
+
storiesOf('Typescript Component/InlineDialog', module).add('default', () => {
|
|
7
|
+
return (
|
|
8
|
+
<InlineDialog
|
|
9
|
+
title="Join the conversation"
|
|
10
|
+
buttonText="Subscribe Now"
|
|
11
|
+
onClick={() => action('InlineDialog')('click')}
|
|
12
|
+
>
|
|
13
|
+
Commenting is only for subscribers. If you would like to comment, please
|
|
14
|
+
sign up.
|
|
15
|
+
</InlineDialog>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Container, Title, Description, Button } from './styles';
|
|
3
|
+
|
|
4
|
+
export const InlineDialog: FC<{
|
|
5
|
+
title: string;
|
|
6
|
+
buttonText: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
}> = ({ title, href = '#', onClick, buttonText, children }) => (
|
|
10
|
+
<Container>
|
|
11
|
+
<Title>{title}</Title>
|
|
12
|
+
<Description>{children}</Description>
|
|
13
|
+
<Button href={href} onClick={onClick}>
|
|
14
|
+
{buttonText}
|
|
15
|
+
</Button>
|
|
16
|
+
</Container>
|
|
17
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
import { InlineDialog } from '../InlineDialog';
|
|
6
|
+
|
|
7
|
+
describe('<InlineDialog>', () => {
|
|
8
|
+
it('should render the component', () => {
|
|
9
|
+
const onClick = jest.fn();
|
|
10
|
+
const { baseElement, getByText } = render(
|
|
11
|
+
<InlineDialog title="Title" buttonText="Button" onClick={onClick} />
|
|
12
|
+
);
|
|
13
|
+
expect(getByText('Title')).toBeTruthy();
|
|
14
|
+
const button = getByText('Button');
|
|
15
|
+
fireEvent.click(button);
|
|
16
|
+
expect(onClick).toHaveBeenCalled();
|
|
17
|
+
expect(button).toBeTruthy();
|
|
18
|
+
|
|
19
|
+
expect(baseElement).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<InlineDialog> should render the component 1`] = `
|
|
4
|
+
<body>
|
|
5
|
+
<div>
|
|
6
|
+
<div
|
|
7
|
+
class="sc-bdVaJa dmvPpj"
|
|
8
|
+
>
|
|
9
|
+
<div
|
|
10
|
+
class="sc-bwzfXH mYYIt"
|
|
11
|
+
>
|
|
12
|
+
Title
|
|
13
|
+
</div>
|
|
14
|
+
<div
|
|
15
|
+
class="sc-htpNat dBfnu"
|
|
16
|
+
/>
|
|
17
|
+
<a
|
|
18
|
+
class="sc-bxivhb bTkHyz"
|
|
19
|
+
href="#"
|
|
20
|
+
>
|
|
21
|
+
Button
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
`;
|