@newskit-render/core 2.38.2 → 2.39.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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.38.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.38.2-alpha.0...@newskit-render/core@2.38.2) (2023-01-09)
7
+
8
+ **Note:** Version bump only for package @newskit-render/core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.38.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.38.1-alpha.0...@newskit-render/core@2.38.1) (2023-01-06)
7
15
 
8
16
  **Note:** Version bump only for package @newskit-render/core
@@ -1,12 +1,17 @@
1
1
  import React, { useState } from 'react'
2
2
  import { UncompiledTheme } from 'newskit'
3
- import { sharedTheme } from '@newskit-render/shared-components'
3
+ import {
4
+ sharedTheme,
5
+ ThemeDropdownObject,
6
+ } from '@newskit-render/shared-components'
4
7
  import { useMultiTenancy } from '../multi-tenancy'
5
8
  import { themesMap } from '../../config'
9
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
6
10
 
7
11
  type AppContextType = {
8
12
  theme: UncompiledTheme
9
13
  setTheme: (T: UncompiledTheme) => void
14
+ themeDropdownObject: ThemeDropdownObject
10
15
  }
11
16
 
12
17
  const AppContext = React.createContext({
@@ -17,9 +22,10 @@ const AppContextProvider = ({ children }: { children: JSX.Element }) => {
17
22
  const { tenant } = useMultiTenancy()
18
23
  const tenantTheme = themesMap[tenant]
19
24
  const [theme, setTheme] = useState(tenantTheme)
25
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
20
26
 
21
27
  return (
22
- <AppContext.Provider value={{ theme, setTheme }}>
28
+ <AppContext.Provider value={{ theme, setTheme, themeDropdownObject }}>
23
29
  {children}
24
30
  </AppContext.Provider>
25
31
  )
@@ -19,16 +19,19 @@ describe('createThemeDropdownObject', () => {
19
19
  'The-Sun': {
20
20
  src: '/assets/navigationPrimary-brandMark-sun.svg',
21
21
  width: '115px',
22
+ height: '42px',
22
23
  top: '0',
23
24
  },
24
25
  'Virgin-Radio': {
25
26
  src: '/assets/navigationPrimary-brandMark-vr.svg',
26
27
  width: '150px',
28
+ height: '41px',
27
29
  top: '0',
28
30
  },
29
31
  'The-Times': {
30
32
  src: '/assets/navigationPrimary-brandMark-times.svg',
31
33
  width: '150px',
34
+ height: '40px',
32
35
  top: '0',
33
36
  },
34
37
  },
@@ -19,16 +19,19 @@ const clientNavigationLogos = {
19
19
  'The-Sun': {
20
20
  src: '/assets/navigationPrimary-brandMark-sun.svg',
21
21
  width: '115px',
22
+ height: '42px',
22
23
  top: '0',
23
24
  },
24
25
  'Virgin-Radio': {
25
26
  src: '/assets/navigationPrimary-brandMark-vr.svg',
26
27
  width: '150px',
28
+ height: '41px',
27
29
  top: '0',
28
30
  },
29
31
  'The-Times': {
30
32
  src: '/assets/navigationPrimary-brandMark-times.svg',
31
33
  width: '150px',
34
+ height: '40px',
32
35
  top: '0',
33
36
  },
34
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "2.38.2",
3
+ "version": "2.39.0",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -41,12 +41,12 @@
41
41
  "@emotion/styled": "11.10.4",
42
42
  "@newskit-render/api": "^1.6.0",
43
43
  "@newskit-render/auth": "^1.3.5",
44
- "@newskit-render/checkout": "^2.1.1",
44
+ "@newskit-render/checkout": "^2.2.0",
45
45
  "@newskit-render/feature-flags": "^1.4.6",
46
46
  "@newskit-render/feed": "^1.4.9",
47
- "@newskit-render/my-account": "^4.0.2",
48
- "@newskit-render/shared-components": "^2.0.2",
49
- "@newskit-render/standalone-components": "^2.1.1",
47
+ "@newskit-render/my-account": "^4.1.0",
48
+ "@newskit-render/shared-components": "^2.1.0",
49
+ "@newskit-render/standalone-components": "^2.1.2",
50
50
  "@newskit-render/validation": "^1.5.7",
51
51
  "cross-fetch": "3.1.5",
52
52
  "graphql": "16.6.0",
package/pages/_app.tsx CHANGED
@@ -42,11 +42,17 @@ function MyApp({ Component, pageProps, tenant }: MyAppProps) {
42
42
  </Head>
43
43
  <InstrumentationContextProvider>
44
44
  <AppContext.Consumer>
45
- {({ theme }) => (
45
+ {({ theme, themeDropdownObject }) => (
46
46
  <ThemeProvider theme={theme}>
47
47
  <Global styles={GlobalStyling} />
48
48
  <PageContainer>
49
- <Component {...pageProps} />
49
+ <Component
50
+ {...pageProps}
51
+ {...{
52
+ themeDropdownObject,
53
+ customTheme: theme,
54
+ }}
55
+ />
50
56
  </PageContainer>
51
57
  </ThemeProvider>
52
58
  )}
@@ -1,26 +1,15 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import newrelic from 'newrelic'
3
3
  import { AddField, NotFound, addComponentMap } from '@newskit-render/my-account'
4
4
  import validation from '../../../validation'
5
- import { AppContext } from '../../../context/app-context'
6
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
7
5
 
8
6
  const AccountAddField = (props) => {
9
7
  const doesAddPageExist = Object.keys(addComponentMap).includes(
10
8
  props.data.type
11
9
  )
12
- const { theme, setTheme } = useContext(AppContext)
13
- const themeDropdownObject = useThemeDropdownObject(setTheme)
14
10
 
15
11
  if (doesAddPageExist) {
16
- return (
17
- <AddField
18
- {...props}
19
- validation={validation}
20
- customTheme={theme}
21
- themeDropdownObject={themeDropdownObject}
22
- />
23
- )
12
+ return <AddField {...props} validation={validation} />
24
13
  }
25
14
  return <NotFound />
26
15
  }
@@ -1,24 +1,13 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import { Cancellation, getProviderProps } from '@newskit-render/my-account'
3
3
  import newrelic from 'newrelic'
4
4
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
5
5
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
6
- import { AppContext } from '../../../context/app-context'
7
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
8
6
  import validation from '../../../validation'
9
7
 
10
- const AccountCancellation = (props) => {
11
- const { theme, setTheme } = useContext(AppContext)
12
- const themeDropdownObject = useThemeDropdownObject(setTheme)
13
- return (
14
- <Cancellation
15
- {...props}
16
- customTheme={theme}
17
- validation={validation}
18
- themeDropdownObject={themeDropdownObject}
19
- />
20
- )
21
- }
8
+ const AccountCancellation = (props) => (
9
+ <Cancellation {...props} validation={validation} />
10
+ )
22
11
 
23
12
  export default AccountCancellation
24
13
 
@@ -1,4 +1,4 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import newrelic from 'newrelic'
3
3
  import {
4
4
  EditField,
@@ -9,25 +9,14 @@ import {
9
9
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
10
10
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
11
11
  import validation from '../../../validation'
12
- import { AppContext } from '../../../context/app-context'
13
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
14
12
 
15
13
  const AccountEditField = (props) => {
16
14
  const doesEditPageExist = Object.keys(editComponentMap).includes(
17
15
  props.data.type
18
16
  )
19
- const { theme, setTheme } = useContext(AppContext)
20
- const themeDropdownObject = useThemeDropdownObject(setTheme)
21
17
 
22
18
  if (doesEditPageExist) {
23
- return (
24
- <EditField
25
- {...props}
26
- validation={validation}
27
- customTheme={theme}
28
- themeDropdownObject={themeDropdownObject}
29
- />
30
- )
19
+ return <EditField {...props} validation={validation} />
31
20
  }
32
21
  return <NotFound />
33
22
  }
@@ -1,22 +1,10 @@
1
+ import React from 'react'
1
2
  import { getProviderProps, HolidayStop } from '@newskit-render/my-account'
2
3
  import newrelic from 'newrelic'
3
- import React, { useContext } from 'react'
4
4
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
5
5
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
6
- import { AppContext } from '../../../context/app-context'
7
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
8
6
 
9
- const AccountHolidayStop = (props) => {
10
- const { theme, setTheme } = useContext(AppContext)
11
- const themeDropdownObject = useThemeDropdownObject(setTheme)
12
- return (
13
- <HolidayStop
14
- {...props}
15
- customTheme={theme}
16
- themeDropdownObject={themeDropdownObject}
17
- />
18
- )
19
- }
7
+ const AccountHolidayStop = (props) => <HolidayStop {...props} />
20
8
 
21
9
  export default AccountHolidayStop
22
10
 
@@ -1,21 +1,10 @@
1
+ import React from 'react'
1
2
  import { getProviderProps, HolidayStopList } from '@newskit-render/my-account'
2
3
  import newrelic from 'newrelic'
3
- import React, { useContext } from 'react'
4
- import { AppContext } from '../../../context/app-context'
5
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
4
 
7
- const AccountPreviousHolidayStops = (props) => {
8
- const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = useThemeDropdownObject(setTheme)
10
- return (
11
- <HolidayStopList
12
- {...props}
13
- customTheme={theme}
14
- themeDropdownObject={themeDropdownObject}
15
- holidayStopType="previous"
16
- />
17
- )
18
- }
5
+ const AccountPreviousHolidayStops = (props) => (
6
+ <HolidayStopList {...props} holidayStopType="previous" />
7
+ )
19
8
 
20
9
  export default AccountPreviousHolidayStops
21
10
 
@@ -1,21 +1,10 @@
1
+ import React from 'react'
1
2
  import { getProviderProps, HolidayStopList } from '@newskit-render/my-account'
2
3
  import newrelic from 'newrelic'
3
- import React, { useContext } from 'react'
4
- import { AppContext } from '../../../context/app-context'
5
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
4
 
7
- const AccountUpcomingHolidayStops = (props) => {
8
- const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = useThemeDropdownObject(setTheme)
10
- return (
11
- <HolidayStopList
12
- {...props}
13
- customTheme={theme}
14
- themeDropdownObject={themeDropdownObject}
15
- holidayStopType="upcoming"
16
- />
17
- )
18
- }
5
+ const AccountUpcomingHolidayStops = (props) => (
6
+ <HolidayStopList {...props} holidayStopType="upcoming" />
7
+ )
19
8
 
20
9
  export default AccountUpcomingHolidayStops
21
10
 
@@ -1,22 +1,10 @@
1
+ import React from 'react'
1
2
  import newrelic from 'newrelic'
2
3
  import { PersonalDetails, getProviderProps } from '@newskit-render/my-account'
3
- import React, { useContext } from 'react'
4
4
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
5
5
  import { optimizelysdkKey } from '../../config' // create-render-app effected
6
- import { AppContext } from '../../context/app-context'
7
- import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
8
6
 
9
- const AccountPersonalDetails = (props) => {
10
- const { theme, setTheme } = useContext(AppContext)
11
- const themeDropdownObject = useThemeDropdownObject(setTheme)
12
- return (
13
- <PersonalDetails
14
- {...props}
15
- customTheme={theme}
16
- themeDropdownObject={themeDropdownObject}
17
- />
18
- )
19
- }
7
+ const AccountPersonalDetails = (props) => <PersonalDetails {...props} />
20
8
 
21
9
  export default AccountPersonalDetails
22
10
 
@@ -1,25 +1,15 @@
1
+ import React from 'react'
1
2
  import {
2
3
  NewslettersAndAlerts,
3
4
  getProviderProps,
4
5
  } from '@newskit-render/my-account'
5
6
  import newrelic from 'newrelic'
6
- import React, { useContext } from 'react'
7
7
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
8
8
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
9
- import { AppContext } from '../../../context/app-context'
10
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
11
9
 
12
- const AccountNewslettersAndAlerts = (props) => {
13
- const { theme, setTheme } = useContext(AppContext)
14
- const themeDropdownObject = useThemeDropdownObject(setTheme)
15
- return (
16
- <NewslettersAndAlerts
17
- {...props}
18
- customTheme={theme}
19
- themeDropdownObject={themeDropdownObject}
20
- />
21
- )
22
- }
10
+ const AccountNewslettersAndAlerts = (props) => (
11
+ <NewslettersAndAlerts {...props} />
12
+ )
23
13
 
24
14
  export default AccountNewslettersAndAlerts
25
15
 
@@ -1,26 +1,14 @@
1
+ import React from 'react'
1
2
  import newrelic from 'newrelic'
2
3
  import {
3
4
  Payment,
4
5
  getProviderProps,
5
6
  PaymentProvider,
6
7
  } from '@newskit-render/my-account'
7
- import React, { useContext } from 'react'
8
8
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
9
9
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
10
- import { AppContext } from '../../../context/app-context'
11
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
12
10
 
13
- const AccountCancellation = (props) => {
14
- const { theme, setTheme } = useContext(AppContext)
15
- const themeDropdownObject = useThemeDropdownObject(setTheme)
16
- return (
17
- <Payment
18
- {...props}
19
- customTheme={theme}
20
- themeDropdownObject={themeDropdownObject}
21
- />
22
- )
23
- }
11
+ const AccountCancellation = (props) => <Payment {...props} />
24
12
 
25
13
  export default AccountCancellation
26
14
 
@@ -1,25 +1,15 @@
1
+ import React from 'react'
1
2
  import {
2
3
  SubscriptionAndBilling,
3
4
  getProviderProps,
4
5
  } from '@newskit-render/my-account'
5
6
  import newrelic from 'newrelic'
6
- import React, { useContext } from 'react'
7
7
  import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-render-app effected
8
8
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
9
- import { AppContext } from '../../../context/app-context'
10
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
11
9
 
12
- const AccountSubscriptionAndBilling = (props) => {
13
- const { theme, setTheme } = useContext(AppContext)
14
- const themeDropdownObject = useThemeDropdownObject(setTheme)
15
- return (
16
- <SubscriptionAndBilling
17
- {...props}
18
- customTheme={theme}
19
- themeDropdownObject={themeDropdownObject}
20
- />
21
- )
22
- }
10
+ const AccountSubscriptionAndBilling = (props) => (
11
+ <SubscriptionAndBilling {...props} />
12
+ )
23
13
 
24
14
  export default AccountSubscriptionAndBilling
25
15
 
@@ -1,22 +1,10 @@
1
+ import React from 'react'
1
2
  import { AccountCreation, getProviderProps } from '@newskit-render/checkout'
2
- import React, { useContext } from 'react'
3
- import { AppContext } from '../../../context/app-context'
4
3
  import validation from '../../../validation'
5
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
4
 
7
- const AccountCreationPage = (props) => {
8
- const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = useThemeDropdownObject(setTheme)
10
-
11
- return (
12
- <AccountCreation
13
- {...props}
14
- customTheme={theme}
15
- themeDropdownObject={themeDropdownObject}
16
- validation={validation}
17
- />
18
- )
19
- }
5
+ const AccountCreationPage = (props) => (
6
+ <AccountCreation {...props} validation={validation} />
7
+ )
20
8
 
21
9
  export default AccountCreationPage
22
10
 
@@ -1,19 +1,7 @@
1
+ import React from 'react'
1
2
  import { PaymentDetails, getProviderProps } from '@newskit-render/checkout'
2
- import React, { useContext } from 'react'
3
- import { AppContext } from '../../../context/app-context'
4
- import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
5
3
 
6
- const PaymentDetailsPage = (props) => {
7
- const { theme, setTheme } = useContext(AppContext)
8
- const themeDropdownObject = useThemeDropdownObject(setTheme)
9
- return (
10
- <PaymentDetails
11
- {...props}
12
- customTheme={theme}
13
- themeDropdownObject={themeDropdownObject}
14
- />
15
- )
16
- }
4
+ const PaymentDetailsPage = (props) => <PaymentDetails {...props} />
17
5
 
18
6
  export default PaymentDetailsPage
19
7
 
@@ -1,30 +1,17 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import newrelic from 'newrelic'
3
3
  import {
4
4
  AlgoliaCredentials,
5
5
  HelpHubArticlePage,
6
6
  helpHubArticleProvider,
7
7
  } from '@newskit-render/standalone-components'
8
- import { useThemeDropdownObject } from '../../../../helpers/useThemeDropdownObject'
9
- import { AppContext } from '../../../../context'
10
8
  import { addCacheHeaders } from '../../../../helpers/addCacheHeaders'
11
9
 
12
10
  const ArticlePage: React.FC<{
13
11
  credentials: AlgoliaCredentials
14
12
  title: string
15
13
  content: string
16
- }> = (props) => {
17
- const { theme, setTheme } = useContext(AppContext)
18
- const themeDropdownObject = useThemeDropdownObject(setTheme)
19
-
20
- return (
21
- <HelpHubArticlePage
22
- {...props}
23
- customTheme={theme}
24
- themeDropdownObject={themeDropdownObject}
25
- />
26
- )
27
- }
14
+ }> = (props) => <HelpHubArticlePage {...props} />
28
15
 
29
16
  export default ArticlePage
30
17
 
@@ -1,12 +1,10 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import newrelic from 'newrelic'
3
3
  import {
4
4
  AlgoliaCredentials,
5
5
  HelpHubLandingPage,
6
6
  helpHubLandingPageProvider,
7
7
  } from '@newskit-render/standalone-components'
8
- import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
9
- import { AppContext } from '../../context'
10
8
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
11
9
 
12
10
  const mostReadArticles = [
@@ -40,19 +38,7 @@ const mostReadArticles = [
40
38
 
41
39
  const LandingPage: React.FC<{
42
40
  credentials: AlgoliaCredentials
43
- }> = (props) => {
44
- const { theme, setTheme } = useContext(AppContext)
45
- const themeDropdownObject = useThemeDropdownObject(setTheme)
46
-
47
- return (
48
- <HelpHubLandingPage
49
- {...props}
50
- context={{ mostReadArticles }}
51
- customTheme={theme}
52
- themeDropdownObject={themeDropdownObject}
53
- />
54
- )
55
- }
41
+ }> = (props) => <HelpHubLandingPage {...props} context={{ mostReadArticles }} />
56
42
 
57
43
  export default LandingPage
58
44
 
@@ -1,4 +1,4 @@
1
- import React, { useContext } from 'react'
1
+ import React from 'react'
2
2
  import newrelic from 'newrelic'
3
3
  import {
4
4
  HelpHubResultsPage,
@@ -6,25 +6,12 @@ import {
6
6
  Hit,
7
7
  helpHubResultsProvider,
8
8
  } from '@newskit-render/standalone-components'
9
- import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
10
- import { AppContext } from '../../context'
11
9
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
12
10
 
13
11
  const ResultsPage: React.FC<{
14
12
  credentials: AlgoliaCredentials
15
13
  hits: Hit[]
16
- }> = (props) => {
17
- const { theme, setTheme } = useContext(AppContext)
18
- const themeDropdownObject = useThemeDropdownObject(setTheme)
19
-
20
- return (
21
- <HelpHubResultsPage
22
- {...props}
23
- customTheme={theme}
24
- themeDropdownObject={themeDropdownObject}
25
- />
26
- )
27
- }
14
+ }> = (props) => <HelpHubResultsPage {...props} />
28
15
 
29
16
  export default ResultsPage
30
17
 
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @type {import('next').NextConfig}
3
+ */
4
+
5
+ /**
6
+ * Thes remotePatterns for external images ensure the app works with the Solutions Team's demo data.
7
+ * Once you are using your own data this should be remove or replaced with your own patterns.
8
+ */
9
+ const images = {
10
+ remotePatterns: [
11
+ {
12
+ protocol: 'https',
13
+ hostname: 'www.thesun.co.uk',
14
+ pathname: '/wp-content/**',
15
+ },
16
+ {
17
+ protocol: 'https',
18
+ hostname: 'www.plchldr.co',
19
+ pathname: '/**',
20
+ },
21
+ ],
22
+ }
23
+
24
+ const nextConfig = {
25
+ images,
26
+ async rewrites() {
27
+ return [
28
+ {
29
+ source: '/sitemap.xml',
30
+ destination: '/api/sitemap',
31
+ },
32
+ {
33
+ source: '/pages-sitemap.xml',
34
+ destination: '/api/pages-sitemap',
35
+ },
36
+ {
37
+ source: '/competitions-sitemap.xml',
38
+ destination: '/api/competitions-sitemap',
39
+ },
40
+ {
41
+ source: '/news-sitemap.xml',
42
+ destination: '/api/news-sitemap',
43
+ },
44
+ {
45
+ source: '/feed',
46
+ destination: '/api/feed',
47
+ },
48
+ {
49
+ source: '/robots.txt',
50
+ destination: '/api/robots',
51
+ },
52
+ ]
53
+ },
54
+ }
55
+
56
+ module.exports = nextConfig