@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/__tests__/pages/__snapshots__/home.test.tsx.snap +769 -1261
  3. package/components/section/ArticleSlice.tsx +17 -43
  4. package/components/section/CollectionBlock.tsx +38 -6
  5. package/components/section/__tests__/ArticleSlice.test.tsx +37 -51
  6. package/components/section/__tests__/CollectionBlock.test.tsx +63 -13
  7. package/components/section/__tests__/pageBlock.test.tsx +8 -4
  8. package/components/section/index.tsx +17 -12
  9. package/components/section/layouts/Lead.tsx +36 -15
  10. package/components/section/layouts/Rows.tsx +67 -0
  11. package/components/section/layouts/{SectionRow.tsx → SectionTitle.tsx} +24 -52
  12. package/components/section/layouts/__tests__/Lead.test.tsx +31 -6
  13. package/components/section/layouts/__tests__/Rows.test.tsx +28 -0
  14. package/components/section/layouts/__tests__/SectionTitle.test.tsx +36 -0
  15. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +274 -315
  16. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +942 -0
  17. package/components/section/layouts/gridUtils.ts +12 -9
  18. package/components/section/layouts/index.tsx +2 -1
  19. package/components/section/layouts/types.ts +5 -1
  20. package/components/section/{pageBlock.ts → pageBlock.tsx} +5 -2
  21. package/components/teaser/index.tsx +7 -6
  22. package/components/teaser/teaserVariants.ts +2 -0
  23. package/components/teaser/variants/horizontal.ts +14 -0
  24. package/cypress/e2e/account/account-subscription.spec.js +2 -2
  25. package/cypress/support/commands.js +2 -2
  26. package/helpers/mocks/getPageMock.ts +2 -59
  27. package/next.config.js +4 -0
  28. package/package.json +16 -10
  29. package/pages/account/cancellation/index.tsx +2 -0
  30. package/pages/api/feed.ts +19 -0
  31. package/theme/render-custom-theme.ts +1 -0
  32. package/components/section/layouts/Row.tsx +0 -28
  33. package/components/section/layouts/__tests__/SectionRow.test.tsx +0 -56
  34. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +0 -4542
@@ -2,17 +2,20 @@
2
2
  // xsColumnGutter="space000" padding on left and right of cells
3
3
  // xsRowGutter="space000" margin-top of cells
4
4
 
5
+ // TODO: figure out column gutters
6
+
5
7
  export const outerGridOverride = {
6
- xlRowGutter: 'space000',
7
- mdRowGutter: 'space060',
8
- xsRowGutter: 'space070',
9
- lgMargin: 'space050',
10
- xsMargin: 'space040',
8
+ rowGap: {
9
+ xs: 'space070',
10
+ md: 'space060',
11
+ xl: 'space000',
12
+ },
11
13
  }
12
14
 
13
15
  export const innerGridOverride = {
14
- xlRowGutter: 'space050',
15
- mdRowGutter: 'space060',
16
- xsRowGutter: 'space070',
17
- xsMargin: 'space000',
16
+ rowGap: {
17
+ xs: 'space070',
18
+ md: 'space060',
19
+ xl: 'space050',
20
+ },
18
21
  }
@@ -1,3 +1,4 @@
1
1
  export * from './Lead'
2
- export * from './SectionRow'
2
+ export * from './SectionTitle'
3
3
  export * from './FallBack'
4
+ export * from './Rows'
@@ -1,6 +1,10 @@
1
+ import { MQ } from 'newskit'
1
2
  import { ArticleSlice } from '../../../helpers/global-types'
3
+ import { VariantsName } from '../../teaser/teaserVariants'
2
4
 
3
5
  export type LayoutProps = {
4
- slice: ArticleSlice
6
+ slice?: ArticleSlice
5
7
  sectionURL?: string
8
+ variant?: VariantsName
9
+ colums?: MQ<string>
6
10
  }
@@ -1,13 +1,16 @@
1
+ import React from 'react'
1
2
  import CollectionBlock from './CollectionBlock'
2
3
  import { CollectionBlock as Collection } from '../../helpers/global-types'
3
4
  /*
4
5
  We are using collections from the page schema but there are other block types that could be implemented (image, paragraph, tweet and more).
5
6
  See the schema for the full list
6
7
  */
7
-
8
+ // CollectionBlock(collection, i)
8
9
  const pageBlock = (type: string) => {
9
10
  const blockTypes = {
10
- collection: (collection: Collection) => CollectionBlock(collection),
11
+ collection: (collection: Collection, i: number) => (
12
+ <CollectionBlock collection={collection} index={i} />
13
+ ),
11
14
  image: () => null,
12
15
  paragraph: () => null,
13
16
  tweet: () => null,
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Card, Block, TextBlock, ImageProps } from 'newskit'
2
+ import { Card, Block, TextBlock, ImageProps, Headline } from 'newskit'
3
3
  import teaserVariants, { VariantsName } from './teaserVariants'
4
4
 
5
5
  export interface TeaserProps {
@@ -29,13 +29,14 @@ const Teaser: React.FC<TeaserProps> = ({
29
29
  overrides={presets.card}
30
30
  >
31
31
  <Block spaceStack={presets.title.spaceStack}>
32
- <TextBlock
33
- as="h3"
34
- stylePreset={presets.title.stylePreset}
35
- typographyPreset={presets.title.typographyPreset}
32
+ <Headline
33
+ overrides={{
34
+ typographyPreset: presets.title.typographyPreset,
35
+ }}
36
+ headingAs="h3"
36
37
  >
37
38
  {title}
38
- </TextBlock>
39
+ </Headline>
39
40
  </Block>
40
41
  {teaser && presets.teaser && (
41
42
  <Block spaceStack={presets.teaser.spaceStack}>
@@ -1,6 +1,7 @@
1
1
  import titleTeaserVertical from './variants/titleTeaserVariant'
2
2
  import titleVertical from './variants/titleVertical'
3
3
  import featureVertical from './variants/featureVariant'
4
+ import horizontal from './variants/horizontal'
4
5
  import { VariantsObject } from './variant-types'
5
6
 
6
7
  const base: VariantsObject = {
@@ -21,6 +22,7 @@ const base: VariantsObject = {
21
22
 
22
23
  const teaserVariants = {
23
24
  base,
25
+ horizontal,
24
26
  titleTeaserVertical,
25
27
  titleVertical,
26
28
  featureVertical,
@@ -0,0 +1,14 @@
1
+ import { VariantsObject } from '../variant-types'
2
+
3
+ const horizontalVariant: VariantsObject = {
4
+ layout: 'horizontal',
5
+ card: {
6
+ horizontalRatio: '1:1',
7
+ },
8
+ title: {
9
+ stylePreset: 'inkContrast',
10
+ spaceStack: 'space020',
11
+ },
12
+ }
13
+
14
+ export default horizontalVariant
@@ -81,9 +81,9 @@ describe('Account Subscription & Cancellation', () => {
81
81
  cy.contains(
82
82
  'All your subscription details, including payment info and transactions.'
83
83
  )
84
- cy.contains('4AAA038742030')
84
+ cy.contains('4AAA038786047')
85
85
  cy.contains('************1111')
86
- cy.contains('expiry date 01/31')
86
+ cy.contains('expiry date 01/24')
87
87
 
88
88
  cy.get('a[href="/account/cancellation"]').should('be.visible').click()
89
89
 
@@ -23,8 +23,8 @@ const userMap = {
23
23
  password: 'Ad45p0-swq151@',
24
24
  },
25
25
  withSub: {
26
- username: 'render.e2e.sub@yopmail.com',
27
- password: 'Ad45p0-swq151@',
26
+ username: 'render-e2e-sub@yopmail.com',
27
+ password: 'testing123',
28
28
  },
29
29
  paypalSub: {
30
30
  username: 'render-paypal-payment@yopmail.com',
@@ -8,6 +8,7 @@ const data = {
8
8
  id: '123a',
9
9
  name: 'name',
10
10
  type: 'collection',
11
+ title: 'Section 1',
11
12
  link: {
12
13
  url: '/section-one',
13
14
  },
@@ -302,7 +303,7 @@ const data = {
302
303
  ],
303
304
  },
304
305
  {
305
- name: 'SECONDARY_4_ODD',
306
+ name: 'SECONDARY_2_AND_2',
306
307
  type: 'slice',
307
308
  children: [
308
309
  {
@@ -363,64 +364,6 @@ const data = {
363
364
  },
364
365
  },
365
366
  },
366
- {
367
- type: 'article-block',
368
- article: {
369
- id: 'demo-3',
370
- slug: 'some-location',
371
- headline: 'test headline 3',
372
- categories: [
373
- {
374
- slug: 'catagory-one',
375
- },
376
- ],
377
- summary: {
378
- children: [
379
- {
380
- text: 'teaser test text 3',
381
- },
382
- ],
383
- },
384
- media: {
385
- crops: [
386
- {
387
- url:
388
- 'https://www.thesun.co.uk/wp-content/uploads/2022/03/SPORT-PREVIEW-Amadou-Onana-to-WHU.jpg?strip=all&w=620&h=413&crop=1',
389
- alt: 'image alt 3',
390
- },
391
- ],
392
- },
393
- },
394
- },
395
- {
396
- type: 'article-block',
397
- article: {
398
- id: 'demo-4',
399
- slug: 'some-location',
400
- headline: 'test headline 4',
401
- categories: [
402
- {
403
- slug: 'catagory-one',
404
- },
405
- ],
406
- summary: {
407
- children: [
408
- {
409
- text: 'teaser test text 4',
410
- },
411
- ],
412
- },
413
- media: {
414
- crops: [
415
- {
416
- url:
417
- 'https://www.thesun.co.uk/wp-content/uploads/2022/03/SPORT-PREVIEW-Amadou-Onana-to-WHU.jpg?strip=all&w=620&h=413&crop=1',
418
- alt: 'image alt 3',
419
- },
420
- ],
421
- },
422
- },
423
- },
424
367
  ],
425
368
  },
426
369
  ],
package/next.config.js CHANGED
@@ -41,6 +41,10 @@ module.exports = withBundleAnalyzer(
41
41
  source: '/news-sitemap.xml',
42
42
  destination: '/api/news-sitemap',
43
43
  },
44
+ {
45
+ source: '/feed',
46
+ destination: '/api/feed',
47
+ },
44
48
  ]
45
49
  },
46
50
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "1.45.0",
3
+ "version": "1.49.0",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -33,15 +33,15 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@apollo/client": "3.4.16",
36
- "@newskit-render/api": "^0.18.1",
37
- "@newskit-render/auth": "^0.31.3",
38
- "@newskit-render/checkout": "^0.26.4",
39
- "@newskit-render/feature-flags": "^0.13.0",
40
- "@newskit-render/feed": "^0.5.3",
41
- "@newskit-render/my-account": "^0.152.4",
42
- "@newskit-render/shared-components": "^0.45.1",
43
- "@newskit-render/standalone-components": "^0.2.1",
44
- "@newskit-render/validation": "^0.39.1",
36
+ "@newskit-render/api": "^0.21.0",
37
+ "@newskit-render/auth": "^0.33.0",
38
+ "@newskit-render/checkout": "^0.28.0",
39
+ "@newskit-render/feature-flags": "^0.15.0",
40
+ "@newskit-render/feed": "^0.8.0",
41
+ "@newskit-render/my-account": "^0.155.0",
42
+ "@newskit-render/shared-components": "^0.48.0",
43
+ "@newskit-render/standalone-components": "^0.5.0",
44
+ "@newskit-render/validation": "^0.41.0",
45
45
  "cross-fetch": "3.1.5",
46
46
  "graphql": "15.6.0",
47
47
  "newrelic": "7.1.0",
@@ -107,6 +107,12 @@
107
107
  "access": "public"
108
108
  },
109
109
  "resolutions": {
110
+ "@types/react": "^17.0.1",
111
+ "@types/react-dom": "^17.0.2",
110
112
  "newskit/react-hook-form": "7.8.4"
113
+ },
114
+ "overrides": {
115
+ "@types/react": "^17.0.1",
116
+ "@types/react-dom": "^17.0.2"
111
117
  }
112
118
  }
@@ -3,6 +3,7 @@ import { Cancellation, getProviderProps } from '@newskit-render/my-account'
3
3
  import newrelic from 'newrelic'
4
4
  import { AppContext } from '../../../app-context/AppContext'
5
5
  import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
6
+ import validation from '../../../validation'
6
7
 
7
8
  const AccountCancellation = (props) => {
8
9
  const { theme, setTheme } = useContext(AppContext)
@@ -11,6 +12,7 @@ const AccountCancellation = (props) => {
11
12
  <Cancellation
12
13
  {...props}
13
14
  customTheme={theme}
15
+ validation={validation}
14
16
  themeDropdownObject={themeDropdownObject}
15
17
  />
16
18
  )
@@ -0,0 +1,19 @@
1
+ import { NextApiRequest, NextApiResponse } from 'next'
2
+ import { rssFeed, UpdatePeriod } from '@newskit-render/feed'
3
+
4
+ const handler = async (req: NextApiRequest, res: NextApiResponse) =>
5
+ rssFeed({
6
+ res,
7
+ titeAttributes: {
8
+ title: 'Demo Site',
9
+ link: `${process.env.SITE_HOST}/feed`,
10
+ description: 'Newskit Render Demo site',
11
+ lastBuildDate: new Date().toUTCString(),
12
+ language: 'en-US',
13
+ updatePeriod: 'hourly' as UpdatePeriod,
14
+ updateFrequency: 1,
15
+ logoUrl: `${process.env.SITE_HOST}/favicon.ico`,
16
+ },
17
+ })
18
+
19
+ export default handler
@@ -39,6 +39,7 @@ export const renderCustomLightTheme = createTheme({
39
39
  backgroundColor: '{{colors.white}}',
40
40
  borderRadius: '{{borders.borderRadiusRounded020}}',
41
41
  color: '{{colors.inkBase}}',
42
+ whiteSpace: 'nowrap',
42
43
  },
43
44
  visited: {
44
45
  color: '{{colors.inkBase}}',
@@ -1,28 +0,0 @@
1
- import React from 'react'
2
- import { Grid, Cell } from 'newskit'
3
- import { LayoutProps } from './types'
4
- import { outerGridOverride } from './gridUtils'
5
- import { getBlock } from './Block'
6
-
7
- const Row: React.FC<LayoutProps> = ({ slice }) => (
8
- <Grid {...outerGridOverride} data-testid={`${slice.name}-Grid`}>
9
- {slice.children.map((block, i) => (
10
- <Cell
11
- xs={12}
12
- md={6}
13
- xl={3}
14
- key={
15
- ('article' in block && block.article.id) ||
16
- ('author' in block && block.author.id) ||
17
- ('accountId' in block && block.id) ||
18
- i
19
- }
20
- data-testid={`titleTeaserVertical-${i}`}
21
- >
22
- {getBlock(block, 'titleTeaserVertical')}
23
- </Cell>
24
- ))}
25
- </Grid>
26
- )
27
-
28
- export default Row
@@ -1,56 +0,0 @@
1
- import { renderWithTheme } from '../../../../helpers/test-utils'
2
- import { SectionRow } from '../SectionRow'
3
- import { getPageMock } from '../../../../helpers/mocks'
4
- import { ArticleSlice } from '../../../../helpers/global-types'
5
-
6
- describe('SectionRow', () => {
7
- test('SectionRow with title', () => {
8
- const { asFragment } = renderWithTheme(SectionRow, {
9
- slice: getPageMock.page.body[0].children[1] as ArticleSlice,
10
- sectionURL: getPageMock.page.body[0].link.url,
11
- collection: getPageMock.page.body[0],
12
- })
13
- expect(asFragment()).toMatchSnapshot()
14
- })
15
-
16
- test('SectionRow without title', () => {
17
- const { asFragment } = renderWithTheme(SectionRow, {
18
- slice: getPageMock.page.body[0].children[1] as ArticleSlice,
19
- sectionURL: getPageMock.page.body[0].link.url,
20
- collection: getPageMock.page.body[0],
21
- showTitle: false,
22
- })
23
- expect(asFragment()).toMatchSnapshot()
24
- })
25
-
26
- test('SectionRow isDarkBackground', () => {
27
- const { asFragment } = renderWithTheme(SectionRow, {
28
- slice: getPageMock.page.body[0].children[1] as ArticleSlice,
29
- sectionURL: getPageMock.page.body[0].link.url,
30
- collection: getPageMock.page.body[0],
31
- isDarkBackground: true,
32
- })
33
- expect(asFragment()).toMatchSnapshot()
34
- })
35
-
36
- test('SectionRow without extra space', () => {
37
- const { asFragment } = renderWithTheme(SectionRow, {
38
- slice: getPageMock.page.body[0].children[1] as ArticleSlice,
39
- sectionURL: getPageMock.page.body[0].link.url,
40
- collection: getPageMock.page.body[0],
41
- addTopSpace: true,
42
- })
43
- expect(asFragment()).toMatchSnapshot()
44
- })
45
-
46
- test('SectionRow alternative titlebar', () => {
47
- const { asFragment } = renderWithTheme(SectionRow, {
48
- slice: getPageMock.page.body[0].children[1] as ArticleSlice,
49
- sectionURL: getPageMock.page.body[0].link.url,
50
- collection: getPageMock.page.body[0],
51
- titleBarStylePreset: 'inkContrast',
52
- titleBarColour: 'transparent',
53
- })
54
- expect(asFragment()).toMatchSnapshot()
55
- })
56
- })