@newskit-render/core 2.31.0 → 2.32.0-alpha.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.
@@ -8,8 +8,8 @@ import {
8
8
  Paragraph,
9
9
  Divider,
10
10
  Block,
11
- Image,
12
11
  } from 'newskit'
12
+ import { Image } from '@newskit-render/shared-components'
13
13
  import { MainGrid } from '../layout/MainGrid'
14
14
  import NewsKitLogoShort from '../common/NewskitLogoShort'
15
15
  import NavLink from '../common/NavLink'
@@ -84,11 +84,7 @@ const Footer = () => {
84
84
  <Image
85
85
  alt=""
86
86
  src={`/assets/${clientNavigationLogos[theme.name].src}`}
87
- overrides={{
88
- width: clientNavigationLogos[theme.name].width,
89
- }}
90
- placeholderIcon={true}
91
- loading="lazy"
87
+ width={clientNavigationLogos[theme.name].width}
92
88
  />
93
89
  )}
94
90
  </Block>
@@ -42,11 +42,7 @@ export const getBlock = (
42
42
  url={teaserURL(
43
43
  ('article' in sliceBlock && sliceBlock.article) as ArticleTeaser
44
44
  )}
45
- media={{
46
- ...getMedia(media as Media),
47
- placeholderIcon: true,
48
- loading: 'lazy',
49
- }}
45
+ media={getMedia(media as Media)}
50
46
  title={headline as string}
51
47
  teaser={teaserSummary(summary as TeaserSummary)}
52
48
  />
@@ -16,15 +16,22 @@ exports[`Lead should render Lead 1`] = `
16
16
  <div
17
17
  class="css-x4egtb"
18
18
  >
19
- <picture
20
- class="css-vl2swp"
19
+ <figure
20
+ class="css-439ral"
21
21
  >
22
22
  <img
23
23
  alt=""
24
- class="css-ssxt4f"
24
+ data-nimg="fill"
25
+ decoding="async"
25
26
  loading="lazy"
27
+ sizes="(max-width: 768px) 100vw,
28
+ (max-width: 1200px) 50vw,
29
+ 33vw"
30
+ src="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75"
31
+ srcset="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=256&q=75 256w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=384&q=75 384w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=640&q=75 640w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=750&q=75 750w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=828&q=75 828w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1080&q=75 1080w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1200&q=75 1200w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1920&q=75 1920w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=2048&q=75 2048w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75 3840w"
32
+ style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; right: 0px; bottom: 0px; object-fit: contain; color: transparent; background-size: contain; background-position: 50% 50%; background-repeat: no-repeat;"
26
33
  />
27
- </picture>
34
+ </figure>
28
35
  </div>
29
36
  <div
30
37
  class="css-1shocxe"
@@ -67,15 +74,22 @@ exports[`Lead should render Lead 1`] = `
67
74
  <div
68
75
  class="css-1rsw0n0"
69
76
  >
70
- <picture
71
- class="css-vl2swp"
77
+ <figure
78
+ class="css-439ral"
72
79
  >
73
80
  <img
74
81
  alt=""
75
- class="css-ssxt4f"
82
+ data-nimg="fill"
83
+ decoding="async"
76
84
  loading="lazy"
85
+ sizes="(max-width: 768px) 100vw,
86
+ (max-width: 1200px) 50vw,
87
+ 33vw"
88
+ src="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75"
89
+ srcset="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=256&q=75 256w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=384&q=75 384w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=640&q=75 640w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=750&q=75 750w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=828&q=75 828w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1080&q=75 1080w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1200&q=75 1200w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1920&q=75 1920w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=2048&q=75 2048w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75 3840w"
90
+ style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; right: 0px; bottom: 0px; object-fit: contain; color: transparent; background-size: contain; background-position: 50% 50%; background-repeat: no-repeat;"
77
91
  />
78
- </picture>
92
+ </figure>
79
93
  </div>
80
94
  <div
81
95
  class="css-1r2lt0d"
@@ -115,15 +129,22 @@ exports[`Lead should render Lead 1`] = `
115
129
  <div
116
130
  class="css-1rsw0n0"
117
131
  >
118
- <picture
119
- class="css-vl2swp"
132
+ <figure
133
+ class="css-439ral"
120
134
  >
121
135
  <img
122
136
  alt=""
123
- class="css-ssxt4f"
137
+ data-nimg="fill"
138
+ decoding="async"
124
139
  loading="lazy"
140
+ sizes="(max-width: 768px) 100vw,
141
+ (max-width: 1200px) 50vw,
142
+ 33vw"
143
+ src="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75"
144
+ srcset="/_next/image?url=%2Fassets%2Fplchldr150x100.png&w=256&q=75 256w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=384&q=75 384w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=640&q=75 640w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=750&q=75 750w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=828&q=75 828w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1080&q=75 1080w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1200&q=75 1200w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=1920&q=75 1920w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=2048&q=75 2048w, /_next/image?url=%2Fassets%2Fplchldr150x100.png&w=3840&q=75 3840w"
145
+ style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; right: 0px; bottom: 0px; object-fit: contain; color: transparent; background-size: contain; background-position: 50% 50%; background-repeat: no-repeat;"
125
146
  />
126
- </picture>
147
+ </figure>
127
148
  </div>
128
149
  <div
129
150
  class="css-1r2lt0d"
@@ -12,35 +12,37 @@ describe('Teaser', () => {
12
12
  teaser:
13
13
  'Et libero, congue at condimentum. Id lobortis urna consectetur a, scelerisque lorem amet, magnis fringilla.',
14
14
  })
15
+ const imageBase64 =
16
+ '/_next/image?url=https%3A%2F%2Fplchldr.co%2Fi%2F288x192%3Fbg%3DF0F0F0%26fc%3D111111%26text%3Dimg&w=3840&q=75'
15
17
 
16
- test('titleTeaserVertical', () => {
18
+ it('titleTeaserVertical', () => {
17
19
  const teaserData = getTeaserData('titleTeaserVertical')
18
20
  const { getByText, getByAltText } = renderWithTheme(Teaser, teaserData)
19
21
  expect(getByAltText(teaserData.media.alt as string)).toHaveAttribute(
20
22
  'src',
21
- teaserData.media.src
23
+ imageBase64
22
24
  )
23
25
  expect(getByText(teaserData.title)).toBeInTheDocument()
24
26
  expect(getByText(teaserData.teaser as string)).toBeInTheDocument()
25
27
  })
26
28
 
27
- test('titleVertical', () => {
29
+ it('titleVertical', () => {
28
30
  const teaserData = getTeaserData('titleVertical')
29
31
  const { queryByText, getByAltText } = renderWithTheme(Teaser, teaserData)
30
32
  expect(getByAltText(teaserData.media.alt as string)).toHaveAttribute(
31
33
  'src',
32
- teaserData.media.src
34
+ imageBase64
33
35
  )
34
36
  expect(queryByText(teaserData.title)).toBeInTheDocument()
35
37
  expect(queryByText(teaserData.teaser as string)).not.toBeInTheDocument()
36
38
  })
37
39
 
38
- test('featureVertical', () => {
40
+ it('featureVertical', () => {
39
41
  const teaserData = getTeaserData('titleTeaserVertical')
40
42
  const { getByText, getByAltText } = renderWithTheme(Teaser, teaserData)
41
43
  expect(getByAltText(teaserData.media.alt as string)).toHaveAttribute(
42
44
  'src',
43
- teaserData.media.src
45
+ imageBase64
44
46
  )
45
47
  expect(getByText(teaserData.title)).toBeInTheDocument()
46
48
  expect(getByText(teaserData.teaser as string)).toBeInTheDocument()
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
- import { Card, Block, TextBlock, ImageProps, Headline } from 'newskit'
2
+ import { Card, Block, TextBlock, Headline } from 'newskit'
3
+ import { Image, getAspectRatio } from '@newskit-render/shared-components'
3
4
  import teaserVariants, { VariantsName } from './teaserVariants'
4
5
 
5
6
  export interface TeaserProps {
@@ -7,7 +8,11 @@ export interface TeaserProps {
7
8
  url?: string
8
9
  title: string
9
10
  teaser?: string
10
- media: ImageProps
11
+ media: {
12
+ src: string
13
+ alt?: string
14
+ loadingAspectRatio?: string
15
+ }
11
16
  }
12
17
 
13
18
  const Teaser: React.FC<TeaserProps> = ({
@@ -18,15 +23,18 @@ const Teaser: React.FC<TeaserProps> = ({
18
23
  media,
19
24
  }) => {
20
25
  const presets = teaserVariants[variant]
26
+
21
27
  return (
22
28
  <Card
23
29
  layout={presets.layout}
24
30
  href={url}
25
- media={{
26
- ...presets.media,
27
- ...media,
28
- loadingAspectRatio: media?.loadingAspectRatio,
29
- }}
31
+ media={() => (
32
+ <Image
33
+ aspectRatio={getAspectRatio(media.loadingAspectRatio)}
34
+ src={media.src}
35
+ alt={media.alt}
36
+ />
37
+ )}
30
38
  overrides={presets.card}
31
39
  >
32
40
  <Block spaceStack={presets.title.spaceStack}>
package/jest.config.js CHANGED
@@ -30,11 +30,10 @@ const customJestConfig = {
30
30
  testPathIgnorePatterns: [
31
31
  '<rootDir>/cypress/',
32
32
  '<rootDir>/node_modules/',
33
- '<rootDir>/.next/'
33
+ '<rootDir>/.next/',
34
34
  ],
35
- coveragePathIgnorePatterns: [
36
- '<rootDir>/config/environment.ts'
37
- ]
35
+ coveragePathIgnorePatterns: ['<rootDir>/config/environment.ts'],
36
+ testMatch: ['**/?(*.)+(test).[jt]s?(x)'],
38
37
  }
39
38
 
40
39
  // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
package/next.config.js CHANGED
@@ -1,63 +1,89 @@
1
1
  /* eslint-disable no-param-reassign */
2
- const path = require('path')
3
- const withTM = require('next-transpile-modules')([
4
- '@newskit-render/auth',
5
- '@newskit-render/my-account',
6
- '@newskit-render/validation',
7
- ])
8
- const withBundleAnalyzer = require('@next/bundle-analyzer')({
9
- enabled: process.env.ANALYZE === 'true',
10
- })
2
+ const { PHASE_PRODUCTION_SERVER } = require('next/constants')
11
3
 
12
- module.exports = withBundleAnalyzer(
13
- withTM({
14
- webpack: (config, options) => {
15
- if (options.isServer) {
16
- config.externals = ['react', ...config.externals]
17
- }
4
+ module.exports = (phase) => {
5
+ const images = {
6
+ remotePatterns: [
7
+ {
8
+ protocol: 'https',
9
+ hostname: 'www.thesun.co.uk',
10
+ pathname: '/wp-content/**',
11
+ },
12
+ {
13
+ protocol: 'https',
14
+ hostname: 'www.plchldr.co',
15
+ pathname: '/**',
16
+ },
17
+ ],
18
+ }
18
19
 
19
- config.resolve.alias.newskit = path.resolve(
20
- __dirname,
21
- '.',
22
- 'node_modules',
23
- 'newskit'
24
- )
25
- config.resolve.alias.react = path.resolve(
26
- __dirname,
27
- '.',
28
- 'node_modules',
29
- 'react'
30
- )
20
+ if (phase === PHASE_PRODUCTION_SERVER) {
21
+ return {
22
+ images,
23
+ }
24
+ }
31
25
 
32
- return config
33
- },
34
- async rewrites() {
35
- return [
36
- {
37
- source: '/sitemap.xml',
38
- destination: '/api/sitemap',
39
- },
40
- {
41
- source: '/pages-sitemap.xml',
42
- destination: '/api/pages-sitemap',
43
- },
44
- {
45
- source: '/competitions-sitemap.xml',
46
- destination: '/api/competitions-sitemap',
47
- },
48
- {
49
- source: '/news-sitemap.xml',
50
- destination: '/api/news-sitemap',
51
- },
52
- {
53
- source: '/feed',
54
- destination: '/api/feed',
55
- },
56
- {
57
- source: '/robots.txt',
58
- destination: '/api/robots',
59
- },
60
- ]
61
- },
26
+ const path = require('path')
27
+ const withTM = require('next-transpile-modules')([
28
+ '@newskit-render/auth',
29
+ '@newskit-render/my-account',
30
+ '@newskit-render/validation',
31
+ ])
32
+ const withBundleAnalyzer = require('@next/bundle-analyzer')({
33
+ enabled: process.env.ANALYZE === 'true',
62
34
  })
63
- )
35
+
36
+ return withBundleAnalyzer(
37
+ withTM({
38
+ webpack: (config, options) => {
39
+ if (options.isServer) {
40
+ config.externals = ['react', ...config.externals]
41
+ }
42
+
43
+ config.resolve.alias.newskit = path.resolve(
44
+ __dirname,
45
+ '.',
46
+ 'node_modules',
47
+ 'newskit'
48
+ )
49
+ config.resolve.alias.react = path.resolve(
50
+ __dirname,
51
+ '.',
52
+ 'node_modules',
53
+ 'react'
54
+ )
55
+
56
+ return config
57
+ },
58
+ images,
59
+ async rewrites() {
60
+ return [
61
+ {
62
+ source: '/sitemap.xml',
63
+ destination: '/api/sitemap',
64
+ },
65
+ {
66
+ source: '/pages-sitemap.xml',
67
+ destination: '/api/pages-sitemap',
68
+ },
69
+ {
70
+ source: '/competitions-sitemap.xml',
71
+ destination: '/api/competitions-sitemap',
72
+ },
73
+ {
74
+ source: '/news-sitemap.xml',
75
+ destination: '/api/news-sitemap',
76
+ },
77
+ {
78
+ source: '/feed',
79
+ destination: '/api/feed',
80
+ },
81
+ {
82
+ source: '/robots.txt',
83
+ destination: '/api/robots',
84
+ },
85
+ ]
86
+ },
87
+ })
88
+ )
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "2.31.0",
3
+ "version": "2.32.0-alpha.0",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -40,12 +40,12 @@
40
40
  "@emotion/styled": "11.10.4",
41
41
  "@newskit-render/api": "^1.5.3",
42
42
  "@newskit-render/auth": "^1.3.3",
43
- "@newskit-render/checkout": "^1.8.7",
43
+ "@newskit-render/checkout": "^1.9.0-alpha.0",
44
44
  "@newskit-render/feature-flags": "^1.4.3",
45
45
  "@newskit-render/feed": "^1.4.5",
46
- "@newskit-render/my-account": "^3.22.10",
47
- "@newskit-render/shared-components": "^1.23.0",
48
- "@newskit-render/standalone-components": "^1.14.7",
46
+ "@newskit-render/my-account": "^3.23.0-alpha.0",
47
+ "@newskit-render/shared-components": "^1.24.0-alpha.0",
48
+ "@newskit-render/standalone-components": "^1.15.0-alpha.0",
49
49
  "@newskit-render/validation": "^1.5.4",
50
50
  "cross-fetch": "3.1.5",
51
51
  "graphql": "15.6.0",
Binary file