@financial-times/cp-content-pipeline-ui 6.11.3-beta.0 → 6.11.3

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.
@@ -7,7 +7,6 @@ import classnames from 'classnames'
7
7
  import Headshot from '../Headshot'
8
8
  import Byline from '../Byline'
9
9
  import { StructuredTreeFragment } from '@financial-times/cp-content-pipeline-client'
10
- import parse from 'html-react-parser'
11
10
 
12
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
13
12
  //TODO: CI-1975 remove "any" types
@@ -37,6 +36,23 @@ const TruncatedPost = ({ id, children }: { id: string; children: any }) => {
37
36
  )
38
37
  }
39
38
 
39
+ const truncatedSelector = () => {
40
+ const prefix = '.x-live-blog-post__body >'
41
+ const selectors = [
42
+ 'p',
43
+ 'blockquote',
44
+ 'ul',
45
+ '.o-table-container',
46
+ '.n-content-recommended--single-story',
47
+ "[data-layout-name='card']",
48
+ '.n-content-big-number',
49
+ 'hr',
50
+ '.n-content-tweet',
51
+ "[data-layout-name='timeline']",
52
+ ]
53
+ return selectors.map((item) => `${prefix} ${item}`).join(',')
54
+ }
55
+
40
56
  export type LiveBlogPostProps = {
41
57
  id: string
42
58
  postId: string // Remove once wordpress is no longer in use
@@ -92,10 +108,31 @@ const LiveBlogPost = ({
92
108
  </TruncatedPost>
93
109
  )
94
110
  } else {
95
- const elements = bodyHTML || content ? parse(bodyHTML || content) : []
96
-
97
111
  // Content comes from next-es or wordpress
98
- postBody = <TruncatedPost id={id}>{elements}</TruncatedPost>
112
+ postBody = (
113
+ <div
114
+ className="x-live-blog-post__body n-content-body article--body"
115
+ dangerouslySetInnerHTML={{ __html: bodyHTML || content }}
116
+ />
117
+ )
118
+ // add pinned post old version when comming from next-es or wordpress
119
+ postBody = isPinned ? (
120
+ <div
121
+ data-o-component="o-expander"
122
+ className="o-expander"
123
+ data-o-expander-shrink-to="1"
124
+ data-o-expander-item-selector={truncatedSelector()}
125
+ data-o-expander-collapsed-toggle-text={'Expand post'}
126
+ data-o-expander-expanded-toggle-text={'Collapse post'}
127
+ >
128
+ <div className="o-expander__content">{postBody}</div>
129
+ <a className="o-expander__toggle o-expander__text--custom">
130
+ <span className="o-expander__visually-hidden">&nbsp;</span>
131
+ </a>
132
+ </div>
133
+ ) : (
134
+ postBody
135
+ )
99
136
  }
100
137
 
101
138
  const author = authors?.[0] ?? null