@financial-times/cp-content-pipeline-ui 7.10.0 → 7.11.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.
@@ -1,45 +1,82 @@
1
- import React from 'react'
2
- import Byline from '../Byline'
3
- import type { ArticleQuery } from '@financial-times/cp-content-pipeline-client'
4
- import ftDateFormat from '@financial-times/ft-date-format'
1
+ import React from "react"
2
+ import Byline from "../Byline"
3
+ import type { ArticleQuery } from "@financial-times/cp-content-pipeline-client"
4
+ import ftDateFormat from "@financial-times/ft-date-format"
5
5
 
6
6
  type ArticleInfoProps = {
7
- content: ArticleQuery['content']
7
+ content: ArticleQuery["content"]
8
8
  }
9
9
 
10
10
  const ArticleInfo: React.FC<React.PropsWithChildren<ArticleInfoProps>> = ({
11
11
  children,
12
12
  content,
13
13
  }) => {
14
- const isLiveBlogPackage = content.__typename === 'LiveBlogPackage'
14
+ const isLiveBlogPackage = content.__typename === "LiveBlogPackage"
15
+ const formattedFirstPublishedDate = ftDateFormat.format(
16
+ new Date(content.firstPublishedDate),
17
+ "date"
18
+ )
15
19
  const formattedPublishedDate = ftDateFormat.format(
16
20
  new Date(content.publishedTimestamp),
17
- 'date'
21
+ "date"
18
22
  )
19
23
 
24
+ const displayPublishedDate = content.publishedDate && !isLiveBlogPackage
25
+ const displayUpdatedDate =
26
+ new Date(content.firstPublishedDate).getTime() !==
27
+ content.publishedTimestamp
28
+ const isPublishedMoreThanOneDayAgo =
29
+ Date.now() - new Date(content.firstPublishedDate).getTime() >
30
+ 24 * 60 * 60 * 1000
31
+
20
32
  return (
21
33
  <div className="article-info">
22
- <div className="article-info__time-byline">
23
- {content.byline && content.__typename !== 'Audio' && (
24
- <Byline
25
- structuredContent={content.byline}
26
- showEditedBy={isLiveBlogPackage}
27
- />
28
- )}
29
- {content.publishedDate && !isLiveBlogPackage && (
30
- <>
31
- {' '}
32
- <time
33
- data-o-component="o-date"
34
- className="article-info__timestamp o-date"
35
- dateTime={content.publishedDate}
36
- >
37
- {formattedPublishedDate}
38
- </time>
39
- </>
40
- )}
34
+ <div className="article-info__time-byline-row">
35
+ <div className="article-info__time-byline-content">
36
+ {content.byline && content.__typename !== "Audio" && (
37
+ <Byline
38
+ structuredContent={content.byline}
39
+ showEditedBy={isLiveBlogPackage}
40
+ />
41
+ )}
42
+ </div>
43
+ {!displayPublishedDate && children}
41
44
  </div>
42
- {children}
45
+ {displayPublishedDate && (
46
+ <div className="article-info__time-byline-row">
47
+ <div className="article-info__time-byline-content">
48
+ <p className="article-info__timestamp-item">
49
+ Published
50
+ <time
51
+ data-o-component="o-date"
52
+ {...(isPublishedMoreThanOneDayAgo
53
+ ? { "data-o-date-format": "MMM d yyyy" }
54
+ : {})}
55
+ className="article-info__timestamp o-date"
56
+ dateTime={content.firstPublishedDate}
57
+ >
58
+ {formattedFirstPublishedDate}
59
+ </time>
60
+ </p>
61
+ {displayUpdatedDate && (
62
+ <p className="article-info__timestamp-item article-info__updated-timestamp">
63
+ Updated
64
+ <time
65
+ data-o-component="o-date"
66
+ data-o-date-format={
67
+ isPublishedMoreThanOneDayAgo ? "MMM d yyyy, HH:mm" : "HH:mm"
68
+ }
69
+ className="article-info__timestamp o-date"
70
+ dateTime={content.publishedDate}
71
+ >
72
+ {formattedPublishedDate}
73
+ </time>
74
+ </p>
75
+ )}
76
+ </div>
77
+ {children}
78
+ </div>
79
+ )}
43
80
  </div>
44
81
  )
45
82
  }
@@ -620,7 +620,6 @@ class Clip extends ClipInterface {
620
620
  this.resizeControls()
621
621
  this.togglePlayPauseButton()
622
622
  if (this.opts.autoShowClosedCaptions) {
623
- this.videoEl.setAttribute('crossorigin', 'true')
624
623
  this.showCaptionsByDefault()
625
624
  }
626
625
  this.containerEl.classList.remove(
@@ -90,6 +90,7 @@ export const ClipTag: React.FC<ClipTagProps> = ({
90
90
  poster={poster}
91
91
  preload={preload}
92
92
  id={`clip-${id}`}
93
+ crossOrigin="anonymous"
93
94
  >
94
95
  {clip?.dataSource?.map(({ binaryUrl, mediaType }, index) => {
95
96
  return (
@@ -45,6 +45,7 @@ exports[`Clip Snapshot component rendered on server full-grid default render 1`]
45
45
  poster=\\"\\"
46
46
  preload=\\"auto\\"
47
47
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
48
+ crossorigin=\\"anonymous\\"
48
49
  style=\\"height: fit-content; width: 100%\\"
49
50
  >
50
51
  <source
@@ -114,6 +115,7 @@ exports[`Clip Snapshot component rendered on server full-grid render with attrib
114
115
  poster=\\"\\"
115
116
  preload=\\"auto\\"
116
117
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
118
+ crossorigin=\\"anonymous\\"
117
119
  style=\\"height: fit-content; width: 100%\\"
118
120
  >
119
121
  <source
@@ -203,6 +205,7 @@ exports[`Clip Snapshot component rendered on server in-line render 1`] = `
203
205
  poster=\\"\\"
204
206
  preload=\\"auto\\"
205
207
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
208
+ crossorigin=\\"anonymous\\"
206
209
  style=\\"height: fit-content; width: 100%\\"
207
210
  >
208
211
  <source
@@ -270,6 +273,7 @@ exports[`Clip Snapshot component rendered on server in-line render with attribut
270
273
  poster=\\"\\"
271
274
  preload=\\"auto\\"
272
275
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
276
+ crossorigin=\\"anonymous\\"
273
277
  style=\\"height: fit-content; width: 100%\\"
274
278
  >
275
279
  <source
@@ -363,6 +367,7 @@ exports[`Clip Snapshot component rendered on server mid-grid default render 1`]
363
367
  poster=\\"\\"
364
368
  preload=\\"auto\\"
365
369
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
370
+ crossorigin=\\"anonymous\\"
366
371
  style=\\"height: fit-content; width: 100%\\"
367
372
  >
368
373
  <source
@@ -437,6 +442,7 @@ exports[`Clip Snapshot component rendered on server mid-grid render with attribu
437
442
  poster=\\"\\"
438
443
  preload=\\"auto\\"
439
444
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
445
+ crossorigin=\\"anonymous\\"
440
446
  style=\\"height: fit-content; width: 100%\\"
441
447
  >
442
448
  <source
@@ -533,6 +539,7 @@ exports[`Clip Snapshot component rendered on server renders multiple video sourc
533
539
  poster=\\"https://whatever/1080x1920.jpg\\"
534
540
  preload=\\"auto\\"
535
541
  id=\\"clip-84d7e1b0-e8b2-4ffc-a798-306f29dc9d52\\"
542
+ crossorigin=\\"anonymous\\"
536
543
  style=\\"aspect-ratio: 1920/1080; width: 100%\\"
537
544
  >
538
545
  <source
@@ -638,6 +645,7 @@ exports[`Clip Snapshot component rendered on server supports new Origami images,
638
645
  poster=\\"\\"
639
646
  preload=\\"auto\\"
640
647
  id=\\"clip-localhost:8080/fakevideo.mpg\\"
648
+ crossorigin=\\"anonymous\\"
641
649
  style=\\"height: fit-content; width: 100%\\"
642
650
  >
643
651
  <source
@@ -172,7 +172,6 @@ describe('Clip', () => {
172
172
  it('should play closed captions by default when available', () => {
173
173
  clipInstance.videoEl.dispatchEvent(new Event('playing'))
174
174
  expect(clipInstance.videoEl.textTracks[0]?.mode).toBe('showing')
175
- expect(clipInstance.videoEl.getAttribute('crossorigin')).toBe('true')
176
175
  const closedCaptionIcon = document.querySelector('.cp-clip__closed-caption')
177
176
  expect(
178
177
  closedCaptionIcon?.getAttribute('data-display-closed-captions')
@@ -186,6 +186,7 @@ describe('Clip', () => {
186
186
  expect(clip.opts.systemTitle).toBe(
187
187
  clip.containerEl.getAttribute('data-cp-clip-system-title')
188
188
  )
189
+ expect(clip.videoEl.crossOrigin).toBe('anonymous')
189
190
  })
190
191
 
191
192
  it('dispatches an analytics mount event when the component is initialised', () => {