@financial-times/cp-content-pipeline-ui 6.7.0 → 6.7.2

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/Byline/index.js +1 -1
  3. package/lib/components/Byline/index.js.map +1 -1
  4. package/lib/components/Clip/components/Container.js +2 -2
  5. package/lib/components/Clip/components/Container.js.map +1 -1
  6. package/lib/components/Clip/template/index.js +1 -0
  7. package/lib/components/Clip/template/index.js.map +1 -1
  8. package/lib/components/ImageSet/index.js +1 -1
  9. package/lib/components/ImageSet/index.js.map +1 -1
  10. package/lib/components/LiveBlogPost/index.js +21 -9
  11. package/lib/components/LiveBlogPost/index.js.map +1 -1
  12. package/lib/components/LiveBlogWrapper/index.js +1 -1
  13. package/lib/components/LiveBlogWrapper/index.js.map +1 -1
  14. package/lib/components/Recommended/index.js +1 -1
  15. package/lib/components/Recommended/index.js.map +1 -1
  16. package/lib/components/RichText/index.d.ts +1 -1
  17. package/lib/components/Table/index.js +1 -1
  18. package/lib/components/Table/index.js.map +1 -1
  19. package/lib/components/Video/index.js +1 -1
  20. package/lib/components/Video/index.js.map +1 -1
  21. package/lib/components/YoutubeVideo/index.js +1 -1
  22. package/lib/components/YoutubeVideo/index.js.map +1 -1
  23. package/lib/stories/Clip.stories.d.ts +1 -2
  24. package/lib/stories/Clip.stories.js +5 -5
  25. package/lib/stories/Clip.stories.js.map +1 -1
  26. package/package.json +5 -2
  27. package/src/components/Byline/index.tsx +8 -4
  28. package/src/components/Clip/components/Container.tsx +3 -10
  29. package/src/components/Clip/template/index.ts +1 -0
  30. package/src/components/Clip/test/__snapshots__/snapshot.spec.tsx.snap +8 -8
  31. package/src/components/ImageSet/index.tsx +0 -1
  32. package/src/components/LiveBlogPost/index.tsx +42 -29
  33. package/src/components/LiveBlogWrapper/index.tsx +0 -1
  34. package/src/components/Recommended/index.tsx +0 -1
  35. package/src/components/Table/index.tsx +0 -1
  36. package/src/components/Video/index.tsx +1 -4
  37. package/src/components/YoutubeVideo/index.tsx +1 -4
  38. package/src/stories/Clip.stories.tsx +2 -3
  39. package/tsconfig.tsbuildinfo +1 -1
  40. package/lib/components/Expander/client/index.d.ts +0 -49
  41. package/lib/components/Expander/client/index.js +0 -124
  42. package/lib/components/Expander/client/index.js.map +0 -1
  43. package/lib/components/Expander/index.d.ts +0 -15
  44. package/lib/components/Expander/index.js +0 -27
  45. package/lib/components/Expander/index.js.map +0 -1
  46. package/lib/components/Expander/test/client/index.spec.d.ts +0 -1
  47. package/lib/components/Expander/test/client/index.spec.js +0 -103
  48. package/lib/components/Expander/test/client/index.spec.js.map +0 -1
  49. package/lib/components/Expander/test/index.spec.d.ts +0 -1
  50. package/lib/components/Expander/test/index.spec.js +0 -57
  51. package/lib/components/Expander/test/index.spec.js.map +0 -1
  52. package/lib/components/Expander/test/snapshot.spec.d.ts +0 -1
  53. package/lib/components/Expander/test/snapshot.spec.js +0 -63
  54. package/lib/components/Expander/test/snapshot.spec.js.map +0 -1
  55. package/lib/components/LiveBlogPost/client/index.d.ts +0 -5
  56. package/lib/components/LiveBlogPost/client/index.js +0 -12
  57. package/lib/components/LiveBlogPost/client/index.js.map +0 -1
  58. package/lib/stories/Expander.stories.d.ts +0 -54
  59. package/lib/stories/Expander.stories.js +0 -142
  60. package/lib/stories/Expander.stories.js.map +0 -1
  61. package/src/components/Expander/client/index.ts +0 -197
  62. package/src/components/Expander/client/main.scss +0 -162
  63. package/src/components/Expander/index.tsx +0 -74
  64. package/src/components/Expander/test/__snapshots__/snapshot.spec.tsx.snap +0 -225
  65. package/src/components/Expander/test/client/index.spec.tsx +0 -129
  66. package/src/components/Expander/test/index.spec.tsx +0 -77
  67. package/src/components/Expander/test/snapshot.spec.tsx +0 -73
  68. package/src/components/LiveBlogPost/client/index.ts +0 -9
  69. package/src/stories/Expander.stories.scss +0 -3
  70. package/src/stories/Expander.stories.tsx +0 -159
@@ -2,13 +2,10 @@ import React from 'react'
2
2
  import ShareButtons from './ShareButtons'
3
3
  import Timestamp from './Timestamp'
4
4
  import RichText from '../RichText'
5
- import Expander from '../Expander'
6
5
  import classnames from 'classnames'
7
6
  import Headshot from '../Headshot'
8
7
  import Byline from '../Byline'
9
8
  import { StructuredTreeFragment } from '@financial-times/cp-content-pipeline-client'
10
- import parse from 'html-react-parser'
11
-
12
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
13
10
  //TODO: CI-1975 remove "any" types
14
11
  // this has been ported from x-dash, and a lot of what is expected into these arguments will take a lot of digging
@@ -17,26 +14,6 @@ type indicators = {
17
14
  isOpinion?: boolean
18
15
  }
19
16
 
20
- const TruncatedPost = ({ id, children }: { id: string; children: any }) => {
21
- return (
22
- <div
23
- data-trackable="truncated-post"
24
- data-trackable-context-post={id}
25
- data-trackable-category="live-blog"
26
- className="x-live-blog-post__body n-content-body article--body"
27
- >
28
- <Expander
29
- expandLabel="Expand post"
30
- collapseLabel="Collapse post"
31
- onlyMobile={true}
32
- id={`truncated-${id}`}
33
- >
34
- {children}
35
- </Expander>
36
- </div>
37
- )
38
- }
39
-
40
17
  export type LiveBlogPostProps = {
41
18
  id: string
42
19
  postId: string // Remove once wordpress is no longer in use
@@ -62,6 +39,23 @@ export type LiveBlogPostProps = {
62
39
  authors: Array<any>
63
40
  }
64
41
 
42
+ const truncatedSelector = () => {
43
+ const prefix = '.x-live-blog-post__body >'
44
+ const selectors = [
45
+ 'p',
46
+ 'blockquote',
47
+ 'ul',
48
+ '.o-table-container',
49
+ '.n-content-recommended--single-story',
50
+ "[data-layout-name='card']",
51
+ '.n-content-big-number',
52
+ 'hr',
53
+ '.n-content-tweet',
54
+ "[data-layout-name='timeline']",
55
+ ]
56
+ return selectors.map((item) => `${prefix} ${item}`).join(',')
57
+ }
58
+
65
59
  const LiveBlogPost = ({
66
60
  id,
67
61
  postId, // Remove once wordpress is no longer in use
@@ -88,15 +82,18 @@ const LiveBlogPost = ({
88
82
  if (body && 'structured' in body) {
89
83
  // Content comes from cp-content-pipeline-api
90
84
  postBody = (
91
- <TruncatedPost id={id}>
85
+ <div className="x-live-blog-post__body n-content-body article--body">
92
86
  <RichText structuredContent={body.structured} />
93
- </TruncatedPost>
87
+ </div>
94
88
  )
95
89
  } else {
96
- const elements = parse(bodyHTML || content)
97
-
98
90
  // Content comes from next-es or wordpress
99
- postBody = <TruncatedPost id={id}>{elements}</TruncatedPost>
91
+ postBody = (
92
+ <div
93
+ className="x-live-blog-post__body n-content-body article--body"
94
+ dangerouslySetInnerHTML={{ __html: bodyHTML || content }}
95
+ />
96
+ )
100
97
  }
101
98
 
102
99
  const author = authors?.[0] ?? null
@@ -158,7 +155,23 @@ const LiveBlogPost = ({
158
155
  <div className="x-live-blog-post__breaking-news">Breaking news</div>
159
156
  )}
160
157
  {title && <h2 className="x-live-blog-post__title">{title}</h2>}
161
- {postBody}
158
+ {isPinned ? (
159
+ <div
160
+ data-o-component="o-expander"
161
+ className="o-expander"
162
+ data-o-expander-shrink-to="1"
163
+ data-o-expander-item-selector={truncatedSelector()}
164
+ data-o-expander-collapsed-toggle-text={'Expand post'}
165
+ data-o-expander-expanded-toggle-text={'Collapse post'}
166
+ >
167
+ <div className="o-expander__content">{postBody}</div>
168
+ <a className="o-expander__toggle o-expander__text--custom">
169
+ <span className="o-expander__visually-hidden">&nbsp;</span>
170
+ </a>
171
+ </div>
172
+ ) : (
173
+ postBody
174
+ )}
162
175
  <div className="x-live-blog-post__controls">
163
176
  {showShareButtons && (
164
177
  <ShareButtons
@@ -193,7 +193,6 @@ class BaseLiveBlogWrapper extends Component<LiveBlogWrapperTypes, stateTypes> {
193
193
  className="x-live-blog-wrapper"
194
194
  data-live-blog-wrapper-id={id}
195
195
  ref={liveBlogWrapperElementRef}
196
- data-component="live-blog-wrapper"
197
196
  >
198
197
  {postElements}
199
198
  </div>
@@ -25,7 +25,6 @@ export default function Recommended({
25
25
  className={classnames('n-content-recommended--single-story', {
26
26
  'n-content-recommended--inset': !isInLiveBlog,
27
27
  })}
28
- data-component="recommended"
29
28
  >
30
29
  {!isInLiveBlog && (
31
30
  <p className="n-content-recommended__title">{heading}</p>
@@ -22,7 +22,6 @@ export default function Table({
22
22
  'o-table-container--contracted': Boolean(collapseAfterHowManyRows),
23
23
  })}
24
24
  data-layout-width={layoutWidth}
25
- data-component="table"
26
25
  >
27
26
  <div
28
27
  className={classNames('o-table-overlay-wrapper', {
@@ -8,10 +8,7 @@ export default function Video({
8
8
  title,
9
9
  }: VideoFragment & ContentTreeWorkarounds.Video) {
10
10
  return (
11
- <div
12
- className="n-content-video n-content-video--internal"
13
- data-component="video"
14
- >
11
+ <div className="n-content-video n-content-video--internal">
15
12
  <div
16
13
  className="n-content-video__placeholder"
17
14
  data-o-component="o-video"
@@ -13,10 +13,7 @@ export default function YoutubeVideo({
13
13
  }
14
14
 
15
15
  return (
16
- <div
17
- className="n-content-video n-content-video--youtube"
18
- data-component="youtube-video"
19
- >
16
+ <div className="n-content-video n-content-video--youtube">
20
17
  <div className="n-content-video__placeholder">
21
18
  <iframe
22
19
  className="n-content-video__embedded"
@@ -1,9 +1,8 @@
1
- import ClipServer from '../components/Clip'
2
- import ClipClient from '../components/Clip/client'
3
1
  import React, { useEffect, ReactNode } from 'react'
4
2
  import oTracking from '@financial-times/o-tracking/main'
5
3
  import './Clip.stories.scss'
6
- import { ClipProps } from '../components/Clip/template/component'
4
+ import ClipClient from '../components/Clip/client'
5
+ import ClipServer, { ClipProps } from '../components/Clip/template/component'
7
6
 
8
7
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
9
8
  export default {