@financial-times/cp-content-pipeline-ui 6.6.3 → 6.7.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/components/Clip/client/index.d.ts +2 -0
  3. package/lib/components/Clip/client/index.js +25 -0
  4. package/lib/components/Clip/client/index.js.map +1 -1
  5. package/lib/components/Clip/components/Container.js +2 -2
  6. package/lib/components/Clip/components/Container.js.map +1 -1
  7. package/lib/components/Clip/template/index.js +0 -1
  8. package/lib/components/Clip/template/index.js.map +1 -1
  9. package/lib/components/Clip/test/index.spec.js +30 -0
  10. package/lib/components/Clip/test/index.spec.js.map +1 -1
  11. package/lib/components/Expander/client/index.d.ts +49 -0
  12. package/lib/components/Expander/client/index.js +124 -0
  13. package/lib/components/Expander/client/index.js.map +1 -0
  14. package/lib/components/Expander/index.d.ts +15 -0
  15. package/lib/components/Expander/index.js +27 -0
  16. package/lib/components/Expander/index.js.map +1 -0
  17. package/lib/components/Expander/test/client/index.spec.d.ts +1 -0
  18. package/lib/components/Expander/test/client/index.spec.js +103 -0
  19. package/lib/components/Expander/test/client/index.spec.js.map +1 -0
  20. package/lib/components/Expander/test/index.spec.d.ts +1 -0
  21. package/lib/components/Expander/test/index.spec.js +57 -0
  22. package/lib/components/Expander/test/index.spec.js.map +1 -0
  23. package/lib/components/Expander/test/snapshot.spec.d.ts +1 -0
  24. package/lib/components/Expander/test/snapshot.spec.js +63 -0
  25. package/lib/components/Expander/test/snapshot.spec.js.map +1 -0
  26. package/lib/components/ImageSet/index.js +1 -1
  27. package/lib/components/ImageSet/index.js.map +1 -1
  28. package/lib/components/LiveBlogPost/client/index.d.ts +5 -0
  29. package/lib/components/LiveBlogPost/client/index.js +12 -0
  30. package/lib/components/LiveBlogPost/client/index.js.map +1 -0
  31. package/lib/components/LiveBlogPost/index.js +9 -21
  32. package/lib/components/LiveBlogPost/index.js.map +1 -1
  33. package/lib/components/LiveBlogWrapper/index.js +1 -1
  34. package/lib/components/LiveBlogWrapper/index.js.map +1 -1
  35. package/lib/components/Recommended/index.js +1 -1
  36. package/lib/components/Recommended/index.js.map +1 -1
  37. package/lib/components/RichText/index.d.ts +1 -1
  38. package/lib/components/Table/index.js +1 -1
  39. package/lib/components/Table/index.js.map +1 -1
  40. package/lib/components/Video/index.js +1 -1
  41. package/lib/components/Video/index.js.map +1 -1
  42. package/lib/components/YoutubeVideo/index.js +1 -1
  43. package/lib/components/YoutubeVideo/index.js.map +1 -1
  44. package/lib/stories/Clip.stories.d.ts +2 -1
  45. package/lib/stories/Clip.stories.js +5 -5
  46. package/lib/stories/Clip.stories.js.map +1 -1
  47. package/lib/stories/Expander.stories.d.ts +54 -0
  48. package/lib/stories/Expander.stories.js +142 -0
  49. package/lib/stories/Expander.stories.js.map +1 -0
  50. package/package.json +3 -5
  51. package/src/components/Clip/client/index.ts +37 -0
  52. package/src/components/Clip/client/main.scss +28 -0
  53. package/src/components/Clip/components/Container.tsx +10 -3
  54. package/src/components/Clip/template/index.ts +0 -1
  55. package/src/components/Clip/test/__snapshots__/snapshot.spec.tsx.snap +8 -8
  56. package/src/components/Clip/test/index.spec.ts +45 -0
  57. package/src/components/Expander/client/index.ts +197 -0
  58. package/src/components/Expander/client/main.scss +162 -0
  59. package/src/components/Expander/index.tsx +74 -0
  60. package/src/components/Expander/test/__snapshots__/snapshot.spec.tsx.snap +225 -0
  61. package/src/components/Expander/test/client/index.spec.tsx +129 -0
  62. package/src/components/Expander/test/index.spec.tsx +77 -0
  63. package/src/components/Expander/test/snapshot.spec.tsx +73 -0
  64. package/src/components/ImageSet/index.tsx +1 -0
  65. package/src/components/LiveBlogPost/client/index.ts +9 -0
  66. package/src/components/LiveBlogPost/index.tsx +29 -42
  67. package/src/components/LiveBlogWrapper/index.tsx +1 -0
  68. package/src/components/Recommended/index.tsx +1 -0
  69. package/src/components/Table/index.tsx +1 -0
  70. package/src/components/Video/index.tsx +4 -1
  71. package/src/components/YoutubeVideo/index.tsx +4 -1
  72. package/src/stories/Clip.stories.tsx +3 -2
  73. package/src/stories/Expander.stories.scss +3 -0
  74. package/src/stories/Expander.stories.tsx +159 -0
  75. package/tsconfig.tsbuildinfo +1 -1
@@ -763,6 +763,51 @@ describe('Clip', () => {
763
763
  clip.videoEl.addEventListener('playing', listener)
764
764
  clip.videoEl.play()
765
765
  })
766
+
767
+ it('shows loading indicator when waiting event is triggered', (done) => {
768
+ const clip = clips[0]
769
+ const spy = jest.spyOn(clip, 'fadeIn')
770
+
771
+ clip.videoEl.dispatchEvent(new Event('waiting'))
772
+
773
+ setTimeout(() => {
774
+ expect(clip.containerEl.classList.contains('cp-clip--loading')).toBe(
775
+ true
776
+ )
777
+ expect(spy).toHaveBeenCalled()
778
+ done()
779
+ }, 100)
780
+ })
781
+
782
+ it('hides loading indicator when canplay event is triggered', (done) => {
783
+ const clip = clips[0]
784
+ const spy = jest.spyOn(clip, 'fadeOut')
785
+
786
+ clip.videoEl.dispatchEvent(new Event('canplay'))
787
+
788
+ setTimeout(() => {
789
+ expect(clip.containerEl.classList.contains('cp-clip--loading')).toBe(
790
+ false
791
+ )
792
+ expect(spy).toHaveBeenCalledWith(true)
793
+ done()
794
+ }, 100)
795
+ })
796
+
797
+ it('hides loading indicator when canplaythrough event is triggered', (done) => {
798
+ const clip = clips[0]
799
+ const spy = jest.spyOn(clip, 'fadeOut')
800
+
801
+ clip.videoEl.dispatchEvent(new Event('canplaythrough'))
802
+
803
+ setTimeout(() => {
804
+ expect(clip.containerEl.classList.contains('cp-clip--loading')).toBe(
805
+ false
806
+ )
807
+ expect(spy).toHaveBeenCalledWith(true)
808
+ done()
809
+ }, 100)
810
+ })
766
811
  })
767
812
 
768
813
  describe('Captions, credits, and descriptions', () => {
@@ -0,0 +1,197 @@
1
+ /**
2
+ * trackEntireRead
3
+ * @description Track the entire read of a truncated post
4
+ * @param {HTMLElement} post - The post element
5
+ */
6
+ class TrackEntireRead {
7
+ private observer: IntersectionObserver | null = null
8
+ private readElement: Element | null
9
+ // data can be any key value pair that needs to be tracked
10
+ private data: Record<string, string>
11
+ constructor(readElement: Element, data: Record<string, string>) {
12
+ this.readElement = readElement as Element
13
+ this.data = data
14
+ this.init()
15
+ }
16
+
17
+ private init() {
18
+ //Intersection observer that observes readElement and when in view tracks the entire read
19
+ this.observer = new IntersectionObserver((entries) => {
20
+ entries.forEach((entry) => {
21
+ if (entry.isIntersecting) {
22
+ this.handleEntireRead()
23
+ this.observer?.disconnect()
24
+ }
25
+ })
26
+ })
27
+ this.observer.observe(this.readElement as Element)
28
+ }
29
+
30
+ private handleEntireRead = () => {
31
+ const trackingData = {
32
+ action: 'entire_read',
33
+ ...this.data,
34
+ }
35
+ const event = new CustomEvent('oTracking.event', {
36
+ detail: trackingData,
37
+ bubbles: true,
38
+ })
39
+ document.body.dispatchEvent(event)
40
+ }
41
+
42
+ destroy(): void {
43
+ this.observer?.disconnect()
44
+ this.observer = null
45
+ }
46
+ }
47
+ export class ExpanderClient {
48
+ /**
49
+ * The container element for all the elements that should be showned or be hidden.
50
+ */
51
+ private container: Element | null
52
+
53
+ /**
54
+ * An optional element to which the expander will dispatch the events to.
55
+ * If not provided, events will not be dispatched.
56
+ */
57
+ private dispatchBoundary?: Element | Document | null
58
+
59
+ /**
60
+ * Element that will be showned at the end of the content when the expander is expanded.
61
+ * We use this to track when the entire post is read.
62
+ */
63
+ private endContent: Element | null
64
+
65
+ /**
66
+ * Track the entire read of a truncated post
67
+ */
68
+ private trackingEntireRead: TrackEntireRead
69
+
70
+ /**
71
+ * The button that will expand the content
72
+ */
73
+ private expanderButton: HTMLElement | null
74
+
75
+ /**
76
+ * The button that will collapse the content
77
+ */
78
+ private collapserButton: HTMLElement | null
79
+
80
+ /**
81
+ * The tracking data that will be sent when the entire post is read
82
+ */
83
+ private trackingData: Record<string, string>
84
+
85
+ /**
86
+ *
87
+ * @param el
88
+ * @param dispatchBoundary
89
+ */
90
+
91
+ constructor(
92
+ el: Element,
93
+ dispatchBoundary?: Element | Document | null,
94
+ trackingData?: Record<string, string>
95
+ ) {
96
+ this.container = el
97
+ this.trackingData = trackingData || {}
98
+ this.expanderButton = el.querySelector(
99
+ '.cp-expander__expand [data-action="expand"]'
100
+ ) as HTMLElement
101
+ this.collapserButton = el.querySelector(
102
+ '.cp-expander__collapse [data-action="collapse"]'
103
+ ) as HTMLElement
104
+ this.endContent = el.querySelector('.cp-expander__collapse')
105
+
106
+ this.expanderButton?.addEventListener('click', this.handleExpand)
107
+ this.collapserButton?.addEventListener('click', this.handleCollapse)
108
+
109
+ this.container.classList.replace(
110
+ 'cp-expander--not-initialised',
111
+ 'cp-expander--initialised'
112
+ )
113
+ this.dispatchBoundary = dispatchBoundary || this.container
114
+ ;(this.trackingData['post_id'] =
115
+ this.container
116
+ .querySelector('[data-trackable-context-truncated-id]')
117
+ ?.getAttribute('data-trackable-context-truncated-id') || ''),
118
+ (this.trackingEntireRead = new TrackEntireRead(
119
+ this.endContent as Element,
120
+ this.trackingData
121
+ ))
122
+ }
123
+
124
+ expand() {
125
+ this.container?.setAttribute('data-state', 'expanded')
126
+ this.dispatchBoundary?.dispatchEvent(
127
+ new CustomEvent('expander:expanded', {
128
+ bubbles: true,
129
+ detail: {
130
+ component: this.container,
131
+ },
132
+ })
133
+ )
134
+ }
135
+
136
+ collapse() {
137
+ this.container?.setAttribute('data-state', 'collapsed')
138
+ this.container?.scrollIntoView()
139
+ this.dispatchBoundary?.dispatchEvent(
140
+ new CustomEvent('expander:collapsed', {
141
+ bubbles: true,
142
+ detail: {
143
+ component: this.container,
144
+ },
145
+ })
146
+ )
147
+ }
148
+
149
+ private handleExpand = (e: Event) => {
150
+ e.preventDefault()
151
+ this.expand()
152
+ this.expanderButton?.setAttribute('aria-expanded', 'true')
153
+ this.expanderButton?.setAttribute('aria-hidden', 'true')
154
+ this.collapserButton?.setAttribute('aria-expanded', 'true')
155
+ this.collapserButton?.setAttribute('aria-hidden', 'false')
156
+ }
157
+ private handleCollapse = (e: Event) => {
158
+ e.preventDefault()
159
+ this.collapse()
160
+ this.expanderButton?.setAttribute('aria-expanded', 'false')
161
+ this.expanderButton?.setAttribute('aria-hidden', 'false')
162
+ this.collapserButton?.setAttribute('aria-expanded', 'false')
163
+ this.collapserButton?.setAttribute('aria-hidden', 'true')
164
+ }
165
+
166
+ destroy(): void {
167
+ this.container?.setAttribute('data-state', 'collapsed')
168
+ this.container
169
+ ?.querySelector('.cp-expander__expand')
170
+ ?.removeEventListener('click', this.expand)
171
+ this.container
172
+ ?.querySelector('.cp-expander__collapse')
173
+ ?.removeEventListener('click', this.collapse)
174
+ this.container?.classList.remove('cp-expander--initialised')
175
+ this.trackingEntireRead.destroy()
176
+ }
177
+
178
+ static init(data?: {
179
+ rootElement?: HTMLElement | null
180
+ dispatchBoundary?: Element | Document | null
181
+ trackingData?: Record<string, string>
182
+ }): ExpanderClient[] {
183
+ const { rootElement, dispatchBoundary, trackingData } = data || {}
184
+ const root = rootElement || document.body
185
+
186
+ return (Array.from(
187
+ root.querySelectorAll(
188
+ ':not(.cp-expander--initialised)[data-component="expander"]'
189
+ )
190
+ )?.map((el: Element) => {
191
+ if (!el.classList.contains('expander--initialised')) {
192
+ return new ExpanderClient(el, dispatchBoundary, trackingData)
193
+ }
194
+ }) || []) as ExpanderClient[]
195
+ }
196
+ }
197
+ export default ExpanderClient
@@ -0,0 +1,162 @@
1
+ @import '@financial-times/o-icons/main';
2
+ @import '@financial-times/o-colors/main';
3
+ @import '@financial-times/o-grid/main';
4
+ @import '@financial-times/o-spacing/main';
5
+
6
+ $numberIntroductoryElements: 1;
7
+ $dataComponentVisibleElements: (
8
+ 'clip-set',
9
+ 'recommended',
10
+ 'flourish',
11
+ 'image-set',
12
+ 'video',
13
+ 'youtube-video',
14
+ 'table'
15
+ );
16
+ $alwaysVisibleComponentSelectors: ();
17
+
18
+ @each $component-name in $dataComponentVisibleElements {
19
+ $alwaysVisibleComponentSelectors: append(
20
+ $alwaysVisibleComponentSelectors,
21
+ '[data-component="#{$component-name}"]'
22
+ );
23
+ }
24
+ @mixin AlwaysVisibleElements {
25
+ @each $component in $alwaysVisibleComponentSelectors {
26
+ #{$component} {
27
+ display: block;
28
+ }
29
+ }
30
+ }
31
+ @mixin IntroductoryElements {
32
+ & > :nth-child(-n + #{$numberIntroductoryElements + 1}):not(.cp-expander__expand) {
33
+ display: block;
34
+ order:1
35
+ }
36
+ & > :nth-child(n + #{$numberIntroductoryElements + 1}) {
37
+ order:3
38
+ }
39
+ }
40
+ @mixin expandeAndCollapse {
41
+ &[data-state='expanded'] {
42
+ .cp-expander-content {
43
+ // Show all the hidden children...
44
+ & > * {
45
+ display: block;
46
+ }
47
+ > .cp-expander__expand {
48
+ display: none;
49
+ }
50
+ }
51
+
52
+
53
+ }
54
+
55
+ &[data-state='collapsed'] {
56
+ .cp-expander-content {
57
+ // Hide everything that comes after the expander...
58
+ // ... except the always visible children
59
+ & > * {
60
+ display: none;
61
+ }
62
+ &:target > * {
63
+ display: block;
64
+ }
65
+
66
+ > .cp-expander__expand {
67
+ display: block;
68
+ order: 2;
69
+ }
70
+
71
+ > .cp-expander__collapse {
72
+ display: none;
73
+ }
74
+
75
+ @include AlwaysVisibleElements;
76
+
77
+ @include IntroductoryElements;
78
+
79
+ }
80
+
81
+ }
82
+ }
83
+
84
+ @mixin InnerStyles {
85
+
86
+ &.cp-expander--not-initialised {
87
+
88
+ .cp-expander__expand,
89
+ .cp-expander__collapse {
90
+ display: none;
91
+ }
92
+
93
+ .cp-expander-content {
94
+ // Target is used for the Core experience.
95
+ // It permits us to hide elements server-side via CSS preventing Cumulative Shift but it is also a fully functional solution without Javascript
96
+ &:target{
97
+ .cp-expander__collapse{
98
+ display: block;
99
+ }
100
+ .cp-expander__expand{
101
+ display: none;
102
+ }
103
+ }
104
+ }
105
+ }
106
+ .cp-expander__expand,
107
+ .cp-expander__collapse {
108
+ display: block;
109
+ padding-bottom: oSpacingByName('s6');
110
+ > a {
111
+ $icon-color: oColorsByName('ft-grey');
112
+ --_o-typography-body-color: $icon-color;
113
+ font-feature-settings: 'clig' off, 'liga' off;
114
+
115
+ @include oTypographyBody();
116
+ font-weight: 400;
117
+ text-decoration: none;
118
+ font-size: 20px;
119
+ &:hover {
120
+
121
+ cursor: pointer;
122
+ }
123
+
124
+ &:after {
125
+ content: '';
126
+ @include oIconsContent('arrow-down', $icon-color, $size: 20);
127
+ padding: 0 4px;
128
+ vertical-align: middle;
129
+ }
130
+ }
131
+ }
132
+
133
+ .cp-expander__collapse a:after {
134
+ transform: rotate(180deg);
135
+ }
136
+
137
+ .cp-expander-content {
138
+ display: flex;
139
+ flex-direction: column;
140
+ }
141
+
142
+ @include expandeAndCollapse;
143
+
144
+
145
+ }
146
+
147
+ .cp-expander{
148
+ &.cp-expander--mobile-only {
149
+ .cp-expander__expand,
150
+ .cp-expander__collapse {
151
+ display: none;
152
+ }
153
+ @include oGridRespondTo($until: S) {
154
+ @include InnerStyles;
155
+ }
156
+ }
157
+
158
+ &.cp-expander--all-resolutions {
159
+ @include InnerStyles;
160
+ }
161
+ }
162
+
@@ -0,0 +1,74 @@
1
+ import classnames from 'classnames'
2
+ import React from 'react'
3
+
4
+ export interface ExpanderProps extends React.PropsWithChildren {
5
+ /** The initial state of the expander */
6
+ state?: 'expanded' | 'collapsed'
7
+ /** The label for the Expand CTA */
8
+ expandLabel?: string
9
+ /** The label for the collapse CTA */
10
+ collapseLabel?: string
11
+ /** Show the expander only on mobile resolutions */
12
+ onlyMobile?: boolean
13
+ /** Id of the component */
14
+ id: string
15
+ }
16
+ // React functional component with children
17
+ export const ExpanderServer: React.FC<ExpanderProps> = ({
18
+ state = 'collapsed', // default value for "state
19
+ children,
20
+ id,
21
+ expandLabel = 'Expand',
22
+ collapseLabel = 'Collapse',
23
+ onlyMobile = false,
24
+ }) => {
25
+ return (
26
+ <div
27
+ className={classnames({
28
+ 'cp-expander': true,
29
+ 'cp-expander--mobile-only': onlyMobile,
30
+ 'cp-expander--all-resolutions': !onlyMobile,
31
+ 'cp-expander--not-initialised': true,
32
+ })}
33
+ data-component="expander"
34
+ data-state={state}
35
+ id={`${id}__container`}
36
+ >
37
+ <div id={id} className="cp-expander-content" aria-describedby={id}>
38
+ <div className="cp-expander__expand">
39
+ <a
40
+ data-trackable="truncated-post"
41
+ data-trackable-context-truncated-post="expand"
42
+ data-trackable-context-truncated-id={id}
43
+ className="cp-expander__link"
44
+ href={`#${id}`}
45
+ aria-expanded={state === 'expanded' ? true : false}
46
+ aria-controls={id}
47
+ aria-hidden={state === 'expanded' ? true : false}
48
+ data-action="expand"
49
+ >
50
+ {expandLabel}
51
+ </a>
52
+ </div>
53
+ {children}
54
+ <div className="cp-expander__collapse">
55
+ <a
56
+ data-trackable="truncated-post"
57
+ data-trackable-context-truncated-post="collapse"
58
+ data-trackable-context-truncated-id={id}
59
+ href={`#${id}__container`}
60
+ className="cp-expander__link"
61
+ aria-expanded={state === 'expanded' ? true : false}
62
+ aria-controls={id}
63
+ aria-hidden={state === 'expanded' ? false : true}
64
+ data-action="collapse"
65
+ >
66
+ {collapseLabel}
67
+ </a>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ )
72
+ }
73
+
74
+ export default ExpanderServer
@@ -0,0 +1,225 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Expander Snapshot component rendered on server default render 1`] = `
4
+ <div
5
+ className="cp-expander cp-expander--all-resolutions cp-expander--not-initialised"
6
+ data-component="expander"
7
+ data-state="collapsed"
8
+ id="test-id__container"
9
+ >
10
+ <div
11
+ aria-describedby="test-id"
12
+ className="cp-expander-content"
13
+ id="test-id"
14
+ >
15
+ <div
16
+ className="cp-expander__expand"
17
+ >
18
+ <a
19
+ aria-controls="test-id"
20
+ aria-expanded={false}
21
+ aria-hidden={false}
22
+ className="cp-expander__link"
23
+ data-action="expand"
24
+ data-trackable="truncated-post"
25
+ data-trackable-context-truncated-id="test-id"
26
+ data-trackable-context-truncated-post="expand"
27
+ href="#test-id"
28
+ >
29
+ Expand
30
+ </a>
31
+ </div>
32
+ <div>
33
+ Children 1
34
+ </div>
35
+ <div>
36
+ Children 2
37
+ </div>
38
+ <div
39
+ className="cp-expander__collapse"
40
+ >
41
+ <a
42
+ aria-controls="test-id"
43
+ aria-expanded={false}
44
+ aria-hidden={true}
45
+ className="cp-expander__link"
46
+ data-action="collapse"
47
+ data-trackable="truncated-post"
48
+ data-trackable-context-truncated-id="test-id"
49
+ data-trackable-context-truncated-post="collapse"
50
+ href="#test-id__container"
51
+ >
52
+ Collapse
53
+ </a>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ `;
58
+
59
+ exports[`Expander Snapshot component rendered on server only on mobile 1`] = `
60
+ <div
61
+ className="cp-expander cp-expander--mobile-only cp-expander--not-initialised"
62
+ data-component="expander"
63
+ data-state="collapsed"
64
+ id="test-id__container"
65
+ >
66
+ <div
67
+ aria-describedby="test-id"
68
+ className="cp-expander-content"
69
+ id="test-id"
70
+ >
71
+ <div
72
+ className="cp-expander__expand"
73
+ >
74
+ <a
75
+ aria-controls="test-id"
76
+ aria-expanded={false}
77
+ aria-hidden={false}
78
+ className="cp-expander__link"
79
+ data-action="expand"
80
+ data-trackable="truncated-post"
81
+ data-trackable-context-truncated-id="test-id"
82
+ data-trackable-context-truncated-post="expand"
83
+ href="#test-id"
84
+ >
85
+ Expand
86
+ </a>
87
+ </div>
88
+ <div>
89
+ Children 1
90
+ </div>
91
+ <div>
92
+ Children 2
93
+ </div>
94
+ <div
95
+ className="cp-expander__collapse"
96
+ >
97
+ <a
98
+ aria-controls="test-id"
99
+ aria-expanded={false}
100
+ aria-hidden={true}
101
+ className="cp-expander__link"
102
+ data-action="collapse"
103
+ data-trackable="truncated-post"
104
+ data-trackable-context-truncated-id="test-id"
105
+ data-trackable-context-truncated-post="collapse"
106
+ href="#test-id__container"
107
+ >
108
+ Collapse
109
+ </a>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ `;
114
+
115
+ exports[`Expander Snapshot component rendered on server with different labels 1`] = `
116
+ <div
117
+ className="cp-expander cp-expander--all-resolutions cp-expander--not-initialised"
118
+ data-component="expander"
119
+ data-state="collapsed"
120
+ id="test-id__container"
121
+ >
122
+ <div
123
+ aria-describedby="test-id"
124
+ className="cp-expander-content"
125
+ id="test-id"
126
+ >
127
+ <div
128
+ className="cp-expander__expand"
129
+ >
130
+ <a
131
+ aria-controls="test-id"
132
+ aria-expanded={false}
133
+ aria-hidden={false}
134
+ className="cp-expander__link"
135
+ data-action="expand"
136
+ data-trackable="truncated-post"
137
+ data-trackable-context-truncated-id="test-id"
138
+ data-trackable-context-truncated-post="expand"
139
+ href="#test-id"
140
+ >
141
+ Open
142
+ </a>
143
+ </div>
144
+ <div>
145
+ Children 1
146
+ </div>
147
+ <div>
148
+ Children 2
149
+ </div>
150
+ <div
151
+ className="cp-expander__collapse"
152
+ >
153
+ <a
154
+ aria-controls="test-id"
155
+ aria-expanded={false}
156
+ aria-hidden={true}
157
+ className="cp-expander__link"
158
+ data-action="collapse"
159
+ data-trackable="truncated-post"
160
+ data-trackable-context-truncated-id="test-id"
161
+ data-trackable-context-truncated-post="collapse"
162
+ href="#test-id__container"
163
+ >
164
+ Close
165
+ </a>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ `;
170
+
171
+ exports[`Expander Snapshot component rendered on server with different state 1`] = `
172
+ <div
173
+ className="cp-expander cp-expander--all-resolutions cp-expander--not-initialised"
174
+ data-component="expander"
175
+ data-state="expanded"
176
+ id="test-id__container"
177
+ >
178
+ <div
179
+ aria-describedby="test-id"
180
+ className="cp-expander-content"
181
+ id="test-id"
182
+ >
183
+ <div
184
+ className="cp-expander__expand"
185
+ >
186
+ <a
187
+ aria-controls="test-id"
188
+ aria-expanded={true}
189
+ aria-hidden={true}
190
+ className="cp-expander__link"
191
+ data-action="expand"
192
+ data-trackable="truncated-post"
193
+ data-trackable-context-truncated-id="test-id"
194
+ data-trackable-context-truncated-post="expand"
195
+ href="#test-id"
196
+ >
197
+ Expand
198
+ </a>
199
+ </div>
200
+ <div>
201
+ Children 1
202
+ </div>
203
+ <div>
204
+ Children 2
205
+ </div>
206
+ <div
207
+ className="cp-expander__collapse"
208
+ >
209
+ <a
210
+ aria-controls="test-id"
211
+ aria-expanded={true}
212
+ aria-hidden={false}
213
+ className="cp-expander__link"
214
+ data-action="collapse"
215
+ data-trackable="truncated-post"
216
+ data-trackable-context-truncated-id="test-id"
217
+ data-trackable-context-truncated-post="collapse"
218
+ href="#test-id__container"
219
+ >
220
+ Collapse
221
+ </a>
222
+ </div>
223
+ </div>
224
+ </div>
225
+ `;