@newskit-render/core 1.45.0 → 1.49.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 +96 -0
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +769 -1261
- package/components/section/ArticleSlice.tsx +17 -43
- package/components/section/CollectionBlock.tsx +38 -6
- package/components/section/__tests__/ArticleSlice.test.tsx +37 -51
- package/components/section/__tests__/CollectionBlock.test.tsx +63 -13
- package/components/section/__tests__/pageBlock.test.tsx +8 -4
- package/components/section/index.tsx +17 -12
- package/components/section/layouts/Lead.tsx +36 -15
- package/components/section/layouts/Rows.tsx +67 -0
- package/components/section/layouts/{SectionRow.tsx → SectionTitle.tsx} +24 -52
- package/components/section/layouts/__tests__/Lead.test.tsx +31 -6
- package/components/section/layouts/__tests__/Rows.test.tsx +28 -0
- package/components/section/layouts/__tests__/SectionTitle.test.tsx +36 -0
- package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +274 -315
- package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +942 -0
- package/components/section/layouts/gridUtils.ts +12 -9
- package/components/section/layouts/index.tsx +2 -1
- package/components/section/layouts/types.ts +5 -1
- package/components/section/{pageBlock.ts → pageBlock.tsx} +5 -2
- package/components/teaser/index.tsx +7 -6
- package/components/teaser/teaserVariants.ts +2 -0
- package/components/teaser/variants/horizontal.ts +14 -0
- package/cypress/e2e/account/account-subscription.spec.js +2 -2
- package/cypress/support/commands.js +2 -2
- package/helpers/mocks/getPageMock.ts +2 -59
- package/next.config.js +4 -0
- package/package.json +16 -10
- package/pages/account/cancellation/index.tsx +2 -0
- package/pages/api/feed.ts +19 -0
- package/theme/render-custom-theme.ts +1 -0
- package/components/section/layouts/Row.tsx +0 -28
- package/components/section/layouts/__tests__/SectionRow.test.tsx +0 -56
- package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +0 -4542
|
@@ -1,46 +1,23 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Block
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from '../../helpers/global-types'
|
|
7
|
-
import { Lead, SectionRow, FallBack } from './layouts'
|
|
8
|
-
import { SectionContext } from './SectionContext'
|
|
2
|
+
import { Block } from 'newskit'
|
|
3
|
+
import { ArticleSlice as Slice } from '../../helpers/global-types'
|
|
4
|
+
import { Lead, LeadFullWidth, FallBack } from './layouts'
|
|
5
|
+
import { Row3, BasicRow } from './layouts/Rows'
|
|
9
6
|
|
|
10
|
-
const sliceBlockBuilder = (slice: Slice
|
|
11
|
-
const sectionURL = collection?.link?.url || '/uncategorized'
|
|
12
|
-
/* add layout to case statments when ready */
|
|
7
|
+
const sliceBlockBuilder = (slice: Slice) => {
|
|
13
8
|
const sliceTypes = {
|
|
9
|
+
LEAD_1_FULL_WIDTH: <LeadFullWidth slice={slice} />,
|
|
14
10
|
SUPPLEMENT_LEAD_AND_4_STACK: <Lead slice={slice} />,
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
{({ isIndexPage }) => (
|
|
18
|
-
<SectionRow
|
|
19
|
-
slice={slice}
|
|
20
|
-
collection={collection}
|
|
21
|
-
sectionURL={sectionURL}
|
|
22
|
-
showTitle={!isIndexPage}
|
|
23
|
-
/>
|
|
24
|
-
)}
|
|
25
|
-
</SectionContext.Consumer>
|
|
11
|
+
SECONDARY_2_AND_2: (
|
|
12
|
+
<BasicRow slice={slice} colums={{ xs: '1fr', md: '1fr 1fr' }} />
|
|
26
13
|
),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isDarkBackground
|
|
35
|
-
addTopSpace={isIndexPage}
|
|
36
|
-
titleBarColour={
|
|
37
|
-
(isIndexPage &&
|
|
38
|
-
`${getColorCssFromTheme('color', 'transparent')}`) as string
|
|
39
|
-
}
|
|
40
|
-
titleBarStylePreset={(isIndexPage && 'inkContrast') as string}
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
43
|
-
</SectionContext.Consumer>
|
|
14
|
+
SECONDARY_3: <Row3 slice={slice} />,
|
|
15
|
+
SECONDARY_4: (
|
|
16
|
+
<BasicRow
|
|
17
|
+
slice={slice}
|
|
18
|
+
colums={{ xs: '1fr', md: '1fr 1fr', lg: '1fr 1fr 1fr 1fr' }}
|
|
19
|
+
variant="horizontal"
|
|
20
|
+
/>
|
|
44
21
|
),
|
|
45
22
|
default: <FallBack slice={slice} />,
|
|
46
23
|
}
|
|
@@ -48,13 +25,10 @@ const sliceBlockBuilder = (slice: Slice, collection: CollectionBlock) => {
|
|
|
48
25
|
return sliceTypes[slice.name] || sliceTypes.default
|
|
49
26
|
}
|
|
50
27
|
|
|
51
|
-
const ArticleSlice: React.FC<{ slice: Slice
|
|
52
|
-
slice,
|
|
53
|
-
collection,
|
|
54
|
-
}) => (
|
|
28
|
+
const ArticleSlice: React.FC<{ slice: Slice }> = ({ slice }) => (
|
|
55
29
|
<>
|
|
30
|
+
{sliceBlockBuilder(slice)}
|
|
56
31
|
<Block spaceStack="space070" />
|
|
57
|
-
{sliceBlockBuilder(slice, collection)}
|
|
58
32
|
</>
|
|
59
33
|
)
|
|
60
34
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { Block } from 'newskit'
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import {
|
|
3
4
|
CollectionBlock as Collection,
|
|
4
5
|
ArticleSlice as Slice,
|
|
5
6
|
} from '../../helpers/global-types'
|
|
6
7
|
import ArticleSlice from './ArticleSlice'
|
|
8
|
+
import { SectionTitle } from './layouts'
|
|
9
|
+
import { SectionContext } from './SectionContext'
|
|
7
10
|
|
|
8
11
|
const collectionSliceOptions = (type: string) => {
|
|
9
12
|
const sliceTypes = {
|
|
10
|
-
slice: (slice: Slice,
|
|
11
|
-
<ArticleSlice slice={slice} collection={collection} key={i} />
|
|
12
|
-
),
|
|
13
|
+
slice: (slice: Slice, i: number) => <ArticleSlice slice={slice} key={i} />,
|
|
13
14
|
'topic-author-slice': () => null,
|
|
14
15
|
default: () => null,
|
|
15
16
|
}
|
|
@@ -17,9 +18,40 @@ const collectionSliceOptions = (type: string) => {
|
|
|
17
18
|
return sliceTypes[type] || sliceTypes.default
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
collection
|
|
22
|
-
|
|
21
|
+
type CollectionBlockProps = {
|
|
22
|
+
collection: Collection
|
|
23
|
+
index: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const CollectionBlock: React.FC<CollectionBlockProps> = ({
|
|
27
|
+
collection,
|
|
28
|
+
index,
|
|
29
|
+
}) => {
|
|
30
|
+
const sectionURL = collection?.link?.url || '/uncategorized'
|
|
31
|
+
const titleBarColors = ['', 'teal050', 'purple050', 'neutral050']
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
{index !== 0 && (
|
|
36
|
+
<SectionContext.Consumer>
|
|
37
|
+
{
|
|
38
|
+
({ isIndexPage }) =>
|
|
39
|
+
!isIndexPage && (
|
|
40
|
+
<SectionTitle
|
|
41
|
+
title={collection.title}
|
|
42
|
+
sectionURL={sectionURL}
|
|
43
|
+
titleBarColour={titleBarColors[index]}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
/* eslint-disable-next-line */
|
|
47
|
+
}
|
|
48
|
+
</SectionContext.Consumer>
|
|
49
|
+
)}
|
|
50
|
+
{collection.children.map((slice, i) =>
|
|
51
|
+
collectionSliceOptions(slice.type)(slice, i)
|
|
52
|
+
)}
|
|
53
|
+
</>
|
|
23
54
|
)
|
|
55
|
+
}
|
|
24
56
|
|
|
25
57
|
export default CollectionBlock
|
|
@@ -11,7 +11,6 @@ describe('ArticleSlice', () => {
|
|
|
11
11
|
ArticleSlice,
|
|
12
12
|
{
|
|
13
13
|
slice: getPageMock.page.body[0].children[0] as ArticleSliceType,
|
|
14
|
-
collection: getPageMock.page.body[0],
|
|
15
14
|
}
|
|
16
15
|
)
|
|
17
16
|
expect(getByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')).toBeInTheDocument()
|
|
@@ -25,80 +24,69 @@ describe('ArticleSlice', () => {
|
|
|
25
24
|
ArticleSlice,
|
|
26
25
|
{
|
|
27
26
|
slice: getPageMock.page.body[0].children[1] as ArticleSliceType,
|
|
28
|
-
collection: getPageMock.page.body[0],
|
|
29
27
|
}
|
|
30
28
|
)
|
|
31
|
-
expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
|
|
32
29
|
expect(getByTestId('SECONDARY_4-Grid')).toBeInTheDocument()
|
|
33
30
|
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
|
|
34
31
|
expect(getAllByRole('link').length).toEqual(4)
|
|
35
32
|
})
|
|
36
33
|
|
|
37
34
|
test('Handle SECONDARY_4 article-block Index Page', () => {
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
})
|
|
54
|
-
expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
|
|
35
|
+
const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
|
|
36
|
+
SectionContext.Provider,
|
|
37
|
+
{
|
|
38
|
+
value: {
|
|
39
|
+
isIndexPage: true,
|
|
40
|
+
},
|
|
41
|
+
children: (
|
|
42
|
+
<ArticleSlice
|
|
43
|
+
slice={getPageMock.page.body[0].children[1] as ArticleSliceType}
|
|
44
|
+
/>
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
55
49
|
expect(getByTestId('SECONDARY_4-Grid')).toBeInTheDocument()
|
|
56
50
|
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
|
|
57
51
|
expect(getAllByRole('link').length).toEqual(4)
|
|
58
52
|
})
|
|
59
53
|
|
|
60
|
-
test('Handle
|
|
54
|
+
test('Handle SECONDARY_2_AND_2 article-block Homepage', () => {
|
|
61
55
|
const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
|
|
62
56
|
ArticleSlice,
|
|
63
57
|
{
|
|
64
58
|
slice: getPageMock.page.body[0].children[5] as ArticleSliceType,
|
|
65
|
-
collection: getPageMock.page.body[0],
|
|
66
59
|
}
|
|
67
60
|
)
|
|
68
|
-
|
|
69
|
-
expect(getByTestId('
|
|
70
|
-
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(
|
|
71
|
-
expect(getAllByRole('link').length).toEqual(
|
|
61
|
+
|
|
62
|
+
expect(getByTestId('SECONDARY_2_AND_2-Grid')).toBeInTheDocument()
|
|
63
|
+
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
|
|
64
|
+
expect(getAllByRole('link').length).toEqual(2)
|
|
72
65
|
})
|
|
73
66
|
|
|
74
|
-
test('Handle
|
|
75
|
-
const {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
expect(
|
|
92
|
-
expect(queryByTestId('addTopSpace')).toBeInTheDocument()
|
|
93
|
-
expect(getByTestId('SECONDARY_4_ODD-Grid')).toBeInTheDocument()
|
|
94
|
-
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
|
|
95
|
-
expect(getAllByRole('link').length).toEqual(4)
|
|
67
|
+
test('Handle SECONDARY_2_AND_2 article-block Index Page', () => {
|
|
68
|
+
const { getByTestId, getAllByTestId, getAllByRole } = renderWithTheme(
|
|
69
|
+
SectionContext.Provider,
|
|
70
|
+
{
|
|
71
|
+
value: {
|
|
72
|
+
isIndexPage: true,
|
|
73
|
+
},
|
|
74
|
+
children: (
|
|
75
|
+
<ArticleSlice
|
|
76
|
+
slice={getPageMock.page.body[0].children[5] as ArticleSliceType}
|
|
77
|
+
/>
|
|
78
|
+
),
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
expect(getByTestId('SECONDARY_2_AND_2-Grid')).toBeInTheDocument()
|
|
83
|
+
expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
|
|
84
|
+
expect(getAllByRole('link').length).toEqual(2)
|
|
96
85
|
})
|
|
97
86
|
|
|
98
87
|
test('Unhandled article-block', () => {
|
|
99
88
|
const { getByText } = renderWithTheme(ArticleSlice, {
|
|
100
89
|
slice: getPageMock.page.body[0].children[2] as ArticleSliceType,
|
|
101
|
-
collection: getPageMock.page.body[0],
|
|
102
90
|
})
|
|
103
91
|
expect(getByText('Layout: LEAD_1_AND_1')).toBeInTheDocument()
|
|
104
92
|
expect(getByText('test headline').closest('a')).toHaveAttribute(
|
|
@@ -114,7 +102,6 @@ describe('ArticleSlice', () => {
|
|
|
114
102
|
test('Unhandled Layout other blocks', () => {
|
|
115
103
|
const { getByText } = renderWithTheme(ArticleSlice, {
|
|
116
104
|
slice: getPageMock.page.body[0].children[3] as ArticleSliceType,
|
|
117
|
-
collection: getPageMock.page.body[0],
|
|
118
105
|
})
|
|
119
106
|
|
|
120
107
|
expect(getByText('Layout: LEAD_1_AND_1')).toBeInTheDocument()
|
|
@@ -128,7 +115,6 @@ describe('ArticleSlice', () => {
|
|
|
128
115
|
ArticleSlice,
|
|
129
116
|
{
|
|
130
117
|
slice: getPageMock.page.body[0].children[4] as ArticleSliceType,
|
|
131
|
-
collection: getPageMock.page.body[0],
|
|
132
118
|
}
|
|
133
119
|
)
|
|
134
120
|
|
|
@@ -1,33 +1,83 @@
|
|
|
1
|
+
import React from 'react'
|
|
1
2
|
import CollectionBlock from '../CollectionBlock'
|
|
2
3
|
import { getPageMock } from '../../../helpers/mocks'
|
|
4
|
+
import { CollectionBlock as Collection } from '../../../helpers/global-types'
|
|
5
|
+
import { renderWithTheme } from '../../../helpers/test-utils'
|
|
6
|
+
import { SectionContext } from '../SectionContext'
|
|
3
7
|
|
|
4
|
-
jest.mock('../ArticleSlice', () =>
|
|
5
|
-
return jest.fn(() => {})
|
|
6
|
-
})
|
|
8
|
+
jest.mock('../ArticleSlice', () => () => <div data-testid="article-slice" />)
|
|
7
9
|
|
|
8
10
|
describe('CollectionBlock', () => {
|
|
9
|
-
test('
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
test('renders section title with articles', () => {
|
|
12
|
+
const { getByTestId, getAllByTestId } = renderWithTheme(
|
|
13
|
+
SectionContext.Provider,
|
|
14
|
+
{
|
|
15
|
+
value: {
|
|
16
|
+
isIndexPage: false,
|
|
17
|
+
},
|
|
18
|
+
children: (
|
|
19
|
+
<CollectionBlock collection={getPageMock.page.body[0]} index={1} />
|
|
20
|
+
),
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
|
|
25
|
+
expect(getAllByTestId('article-slice').length).toEqual(6)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('should not render section title', () => {
|
|
29
|
+
const { queryByTestId } = renderWithTheme(SectionContext.Provider, {
|
|
30
|
+
value: {
|
|
31
|
+
isIndexPage: true,
|
|
32
|
+
},
|
|
33
|
+
children: (
|
|
34
|
+
<CollectionBlock collection={getPageMock.page.body[0]} index={1} />
|
|
35
|
+
),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('should not render section title when index is 0', () => {
|
|
42
|
+
const { queryByTestId } = renderWithTheme(SectionContext.Provider, {
|
|
43
|
+
value: {
|
|
44
|
+
isIndexPage: false,
|
|
45
|
+
},
|
|
46
|
+
children: (
|
|
47
|
+
<CollectionBlock collection={getPageMock.page.body[0]} index={0} />
|
|
48
|
+
),
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
|
|
16
52
|
})
|
|
53
|
+
|
|
17
54
|
test('should handle topic-author-slice', () => {
|
|
18
55
|
const topic = {
|
|
19
56
|
...getPageMock.page.body[0],
|
|
20
57
|
}
|
|
21
58
|
topic.children[0].type = 'topic-author-slice'
|
|
22
59
|
topic.children[1].type = 'topic-author-slice'
|
|
23
|
-
|
|
60
|
+
|
|
61
|
+
const { getAllByTestId } = renderWithTheme(CollectionBlock, {
|
|
62
|
+
collection: topic as Collection,
|
|
63
|
+
index: 1,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
expect(getAllByTestId('article-slice').length).toEqual(4)
|
|
24
67
|
})
|
|
25
|
-
|
|
68
|
+
|
|
69
|
+
test('should handle topic-author-slice', () => {
|
|
26
70
|
const topic = {
|
|
27
71
|
...getPageMock.page.body[0],
|
|
28
72
|
}
|
|
29
73
|
topic.children[0].type = 'unknown'
|
|
30
74
|
topic.children[1].type = 'unknown'
|
|
31
|
-
|
|
75
|
+
|
|
76
|
+
const { getAllByTestId } = renderWithTheme(CollectionBlock, {
|
|
77
|
+
collection: topic as Collection,
|
|
78
|
+
index: 1,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
expect(getAllByTestId('article-slice').length).toEqual(4)
|
|
32
82
|
})
|
|
33
83
|
})
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
1
2
|
import pageBlock from '../pageBlock'
|
|
2
3
|
import { getPageMock } from '../../../helpers/mocks'
|
|
4
|
+
import CollectionBlock from '../CollectionBlock'
|
|
3
5
|
|
|
4
|
-
jest.mock('../CollectionBlock', () =>
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
jest.mock('../CollectionBlock', () => () => (
|
|
7
|
+
<div data-testid="collectionBlock" />
|
|
8
|
+
))
|
|
7
9
|
|
|
8
10
|
describe('test pageBlock', () => {
|
|
9
11
|
const collection = getPageMock.page.body[0]
|
|
10
12
|
test('pageBlock returns CollectionBlock', () => {
|
|
11
|
-
expect(pageBlock('collection')(collection)).
|
|
13
|
+
expect(pageBlock('collection')(collection, 0)).toStrictEqual(
|
|
14
|
+
<CollectionBlock collection={collection} index={0} />
|
|
15
|
+
)
|
|
12
16
|
})
|
|
13
17
|
|
|
14
18
|
test('pageBlock returns null', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Cell } from 'newskit'
|
|
2
|
+
import { Block, Cell } from 'newskit'
|
|
3
3
|
import { UserData } from '@newskit-render/my-account'
|
|
4
4
|
import { Page } from '../../helpers/global-types'
|
|
5
5
|
import Layout from '../layout'
|
|
@@ -17,16 +17,21 @@ const SectionPage: React.FC<{
|
|
|
17
17
|
page: Page
|
|
18
18
|
isIndexPage?: boolean
|
|
19
19
|
user?: UserData
|
|
20
|
-
}> = ({ page, user, isIndexPage = false }) =>
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
20
|
+
}> = ({ page, user, isIndexPage = false }) => {
|
|
21
|
+
return (
|
|
22
|
+
<SectionContext.Provider value={{ isIndexPage }}>
|
|
23
|
+
<Layout dataTestId="SectionGrid" gridOverride={gridOverride} user={user}>
|
|
24
|
+
<Cell xs={12} md={10} mdOffset={1} data-testid="SectionCell">
|
|
25
|
+
<Block spaceStack="space070" />
|
|
26
|
+
{isIndexPage && <SectionTitleBar title={page.title} />}
|
|
27
|
+
{Array.isArray(page.body) &&
|
|
28
|
+
page.body.map((block, i) =>
|
|
29
|
+
pageBlock(block.type as string)(block, i)
|
|
30
|
+
)}
|
|
31
|
+
</Cell>
|
|
32
|
+
</Layout>
|
|
33
|
+
</SectionContext.Provider>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
export default SectionPage
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { GridLayout, Block } from 'newskit'
|
|
3
3
|
import { outerGridOverride, innerGridOverride } from './gridUtils'
|
|
4
4
|
import { getBlock } from './Block'
|
|
5
5
|
import { LayoutProps } from './types'
|
|
6
6
|
|
|
7
7
|
export const Lead: React.FC<LayoutProps> = ({ slice }) => (
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
<GridLayout
|
|
9
|
+
{...outerGridOverride}
|
|
10
|
+
columns={{ lg: '2fr 1fr' }}
|
|
11
|
+
columnGap="space050"
|
|
12
|
+
data-testid={`${slice.name}-Grid`}
|
|
13
|
+
>
|
|
14
|
+
<Block data-testid="featureVerticalCell">
|
|
10
15
|
{getBlock(slice.children[0], 'featureVertical')}
|
|
11
|
-
</
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
</Block>
|
|
17
|
+
<GridLayout
|
|
18
|
+
columnGap={{ md: '20px' }}
|
|
19
|
+
columns={{ xs: '1fr', md: '1fr 1fr', lg: '1fr' }}
|
|
20
|
+
justifyContent={{ lg: 'stretch' }}
|
|
21
|
+
alignContent={{ lg: 'space-between' }}
|
|
22
|
+
overrides={{ height: '100%' }}
|
|
23
|
+
{...innerGridOverride}
|
|
24
|
+
>
|
|
25
|
+
{slice.children.slice(1).map((block, i) => {
|
|
26
|
+
return (
|
|
27
|
+
<Block
|
|
28
|
+
/* eslint-disable-next-line */
|
|
29
|
+
key={`titleVerticalCell-${i}`}
|
|
30
|
+
data-testid={`titleVerticalCell-${i}`}
|
|
31
|
+
>
|
|
32
|
+
{getBlock(block, 'horizontal')}
|
|
33
|
+
</Block>
|
|
34
|
+
)
|
|
35
|
+
})}
|
|
36
|
+
</GridLayout>
|
|
37
|
+
</GridLayout>
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
export const LeadFullWidth: React.FC<LayoutProps> = ({ slice }) => (
|
|
41
|
+
<Block data-testid={`${slice.name}-Grid`}>
|
|
42
|
+
{getBlock(slice.children[0], 'featureVertical')}
|
|
43
|
+
</Block>
|
|
23
44
|
)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Block, GridLayout } from 'newskit'
|
|
3
|
+
import { LayoutProps } from './types'
|
|
4
|
+
import { outerGridOverride } from './gridUtils'
|
|
5
|
+
import { getBlock } from './Block'
|
|
6
|
+
|
|
7
|
+
export const BasicRow: React.FC<LayoutProps> = ({
|
|
8
|
+
slice,
|
|
9
|
+
colums,
|
|
10
|
+
variant = 'titleTeaserVertical',
|
|
11
|
+
}) => (
|
|
12
|
+
<GridLayout
|
|
13
|
+
columns={colums}
|
|
14
|
+
columnGap="space050"
|
|
15
|
+
data-testid={`${slice.name}-Grid`}
|
|
16
|
+
{...outerGridOverride}
|
|
17
|
+
>
|
|
18
|
+
{slice.children.map((block, i) => (
|
|
19
|
+
<Block
|
|
20
|
+
key={('article' in block && block.article.id) || i}
|
|
21
|
+
data-testid={`titleTeaserVertical-${i}`}
|
|
22
|
+
>
|
|
23
|
+
{getBlock(block, variant)}
|
|
24
|
+
</Block>
|
|
25
|
+
))}
|
|
26
|
+
</GridLayout>
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export const Row3: React.FC<LayoutProps> = ({ slice }) => (
|
|
30
|
+
<GridLayout
|
|
31
|
+
areas={{
|
|
32
|
+
xs: `
|
|
33
|
+
"A"
|
|
34
|
+
"B"
|
|
35
|
+
"C"
|
|
36
|
+
`,
|
|
37
|
+
md: `
|
|
38
|
+
"A B"
|
|
39
|
+
"A C"
|
|
40
|
+
`,
|
|
41
|
+
lg: `
|
|
42
|
+
"A B C"
|
|
43
|
+
`,
|
|
44
|
+
}}
|
|
45
|
+
rowGap={{ xs: 'space010', md: 'space040' }}
|
|
46
|
+
columnGap={{ md: 'space050', lg: 'space050' }}
|
|
47
|
+
data-testid={`${slice.name}-Grid`}
|
|
48
|
+
>
|
|
49
|
+
{
|
|
50
|
+
(Areas) =>
|
|
51
|
+
Object.entries(Areas).map((Area, i) => {
|
|
52
|
+
const AreaComp = Area[1]
|
|
53
|
+
const block = slice.children[i]
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<AreaComp
|
|
57
|
+
key={('article' in block && block.article.id) || i}
|
|
58
|
+
data-testid={`titleTeaserVertical-${i}`}
|
|
59
|
+
>
|
|
60
|
+
{getBlock(block, 'horizontal')}
|
|
61
|
+
</AreaComp>
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
/* eslint-disable-next-line */
|
|
65
|
+
}
|
|
66
|
+
</GridLayout>
|
|
67
|
+
)
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
styled,
|
|
4
|
-
getColorCssFromTheme,
|
|
5
|
-
Block,
|
|
6
|
-
Divider,
|
|
7
|
-
BlockProps,
|
|
8
|
-
} from 'newskit'
|
|
9
2
|
import { NextLink } from '@newskit-render/shared-components'
|
|
3
|
+
import { Block, Divider, getColorCssFromTheme, styled } from 'newskit'
|
|
10
4
|
import { LayoutProps } from './types'
|
|
11
|
-
import { CollectionBlock } from '../../../helpers/global-types'
|
|
12
5
|
import StyledIconFilledChevronRight from '../../common/icons/StyledIconFilledChevronRight'
|
|
13
6
|
import SectionTitleBar from '../../common/SectionTitleBar'
|
|
14
|
-
import Row from './Row'
|
|
15
|
-
|
|
16
|
-
type StyledBackground = BlockProps & {
|
|
17
|
-
isDarkBackground?: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const StyledBackgroundBlock = styled(Block)<StyledBackground>`
|
|
21
|
-
background: ${(props) =>
|
|
22
|
-
props.isDarkBackground
|
|
23
|
-
? getColorCssFromTheme('color', 'interface030')
|
|
24
|
-
: getColorCssFromTheme('color', 'transparent')};
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
const StyledDivider = styled(Divider)`
|
|
28
|
-
${getColorCssFromTheme('background', 'transparent')};
|
|
29
|
-
${getColorCssFromTheme('borderColor', 'transparent')};
|
|
30
|
-
`
|
|
31
7
|
|
|
32
8
|
const link = (href: string, stylePreset?: string) => (
|
|
33
9
|
<NextLink
|
|
@@ -44,42 +20,38 @@ const link = (href: string, stylePreset?: string) => (
|
|
|
44
20
|
</NextLink>
|
|
45
21
|
)
|
|
46
22
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
const StyledDivider = styled(Divider)`
|
|
24
|
+
${getColorCssFromTheme('background', 'transparent')};
|
|
25
|
+
${getColorCssFromTheme('borderColor', 'transparent')};
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
type SectionTitleProps = {
|
|
29
|
+
title: string
|
|
52
30
|
titleBarStylePreset?: string
|
|
53
31
|
titleBarColour?: string
|
|
32
|
+
addTopSpace?: boolean
|
|
54
33
|
} & LayoutProps
|
|
55
34
|
|
|
56
|
-
export const
|
|
57
|
-
|
|
58
|
-
collection,
|
|
35
|
+
export const SectionTitle: React.FC<SectionTitleProps> = ({
|
|
36
|
+
title,
|
|
59
37
|
sectionURL,
|
|
60
|
-
isDarkBackground,
|
|
61
|
-
showTitle = true,
|
|
62
|
-
addTopSpace,
|
|
63
38
|
titleBarStylePreset,
|
|
64
39
|
titleBarColour,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
40
|
+
addTopSpace,
|
|
41
|
+
}) => {
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
{addTopSpace && (
|
|
45
|
+
<Block spaceStack="space060" data-testid="addTopSpace">
|
|
46
|
+
<StyledDivider />
|
|
47
|
+
</Block>
|
|
48
|
+
)}
|
|
73
49
|
<SectionTitleBar
|
|
74
|
-
title={
|
|
50
|
+
title={title}
|
|
75
51
|
actionItem={() => link(sectionURL as string, titleBarStylePreset)}
|
|
76
52
|
stylePreset={titleBarStylePreset}
|
|
77
53
|
colour={titleBarColour}
|
|
78
54
|
/>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</Block>
|
|
83
|
-
<StyledDivider />
|
|
84
|
-
</StyledBackgroundBlock>
|
|
85
|
-
)
|
|
55
|
+
</>
|
|
56
|
+
)
|
|
57
|
+
}
|