@newskit-render/core 2.30.9 → 2.31.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.
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.30.9](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.30.9-alpha.0...@newskit-render/core@2.30.9) (2022-12-12)
7
+
8
+ **Note:** Version bump only for package @newskit-render/core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.30.8](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@2.30.8-alpha.0...@newskit-render/core@2.30.8) (2022-12-08)
7
15
 
8
16
  **Note:** Version bump only for package @newskit-render/core
@@ -10,7 +10,7 @@ import {
10
10
  renderCustomDarkTheme as DarkTheme,
11
11
  } from '../../theme'
12
12
  import { AppContext } from '../../context'
13
- import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
13
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
14
14
  import { sectionLinks } from './navigation-links'
15
15
  import { pastDueBanner } from './banner-messages'
16
16
 
@@ -34,7 +34,7 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
34
34
  }
35
35
 
36
36
  const { theme, setTheme } = useContext(AppContext)
37
- const themeDropdownObject = createThemeDropdownObject(setTheme)
37
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
38
38
  const { ...restThemes } = themeDropdownObject.options
39
39
 
40
40
  const themeDropdownObjectUpdated = {
@@ -1,11 +1,15 @@
1
- import { createThemeDropdownObject } from '../createThemeDropdownObject'
1
+ import { useThemeDropdownObject } from '../useThemeDropdownObject'
2
+
3
+ jest.mock('react', () => ({
4
+ ...jest.requireActual('react'),
5
+ useState: jest.fn().mockReturnValue([false, {}]),
6
+ }))
2
7
 
3
8
  describe('createThemeDropdownObject', () => {
4
9
  const setTheme = jest.fn()
5
10
  test('should return themeDropdownObject', () => {
6
- const themeDropdownObject = createThemeDropdownObject(setTheme)
11
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
7
12
  expect(themeDropdownObject).toEqual({
8
- setTheme,
9
13
  clientHeaderImages: {
10
14
  'The-Sun': 'display-personalDetails-header-sun.svg',
11
15
  'Virgin-Radio': 'display-personalDetails-header-vr.svg',
@@ -29,6 +33,8 @@ describe('createThemeDropdownObject', () => {
29
33
  },
30
34
  },
31
35
  options: expect.any(Object),
36
+ themeDropdownOpen: false,
37
+ dropdown: expect.any(Function),
32
38
  })
33
39
  })
34
40
  })
@@ -1,3 +1,4 @@
1
+ import React, { useState } from 'react'
1
2
  import { UncompiledTheme } from 'newskit'
2
3
  import {
3
4
  sharedTheme,
@@ -5,6 +6,7 @@ import {
5
6
  virginRadioTheme,
6
7
  theSunTheme,
7
8
  ThemeDropdownObject,
9
+ ThemeDropdown,
8
10
  } from '@newskit-render/shared-components'
9
11
 
10
12
  const clientHeaderImages = {
@@ -31,19 +33,28 @@ const clientNavigationLogos = {
31
33
  },
32
34
  }
33
35
 
34
- export const createThemeDropdownObject = (
36
+ export const useThemeDropdownObject = (
35
37
  setTheme: (T: UncompiledTheme) => void
36
38
  ): ThemeDropdownObject => {
39
+ const [themeDropdownOpen, setThemeDropdownOpen] = useState(false)
37
40
  const themeDropdownObject = {
38
- setTheme,
39
41
  clientHeaderImages,
40
42
  clientNavigationLogos,
43
+ themeDropdownOpen,
41
44
  options: {
42
45
  sharedTheme,
43
46
  timesTheme,
44
47
  virginRadioTheme,
45
48
  theSunTheme,
46
49
  },
50
+ dropdown: (opts, customTheme) => (
51
+ <ThemeDropdown
52
+ options={opts}
53
+ theme={customTheme}
54
+ setTheme={setTheme}
55
+ setThemeDropdownVisibility={setThemeDropdownOpen}
56
+ />
57
+ ),
47
58
  }
48
59
  return themeDropdownObject
49
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "2.30.9",
3
+ "version": "2.31.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.6",
43
+ "@newskit-render/checkout": "^1.8.7-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.9",
47
- "@newskit-render/shared-components": "^1.22.5",
48
- "@newskit-render/standalone-components": "^1.14.6",
46
+ "@newskit-render/my-account": "^3.22.10-alpha.0",
47
+ "@newskit-render/shared-components": "^1.23.0-alpha.0",
48
+ "@newskit-render/standalone-components": "^1.14.7-alpha.0",
49
49
  "@newskit-render/validation": "^1.5.4",
50
50
  "cross-fetch": "3.1.5",
51
51
  "graphql": "15.6.0",
@@ -3,14 +3,14 @@ import newrelic from 'newrelic'
3
3
  import { AddField, NotFound, addComponentMap } from '@newskit-render/my-account'
4
4
  import validation from '../../../validation'
5
5
  import { AppContext } from '../../../context/app-context'
6
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
6
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
7
7
 
8
8
  const AccountAddField = (props) => {
9
9
  const doesAddPageExist = Object.keys(addComponentMap).includes(
10
10
  props.data.type
11
11
  )
12
12
  const { theme, setTheme } = useContext(AppContext)
13
- const themeDropdownObject = createThemeDropdownObject(setTheme)
13
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
14
14
 
15
15
  if (doesAddPageExist) {
16
16
  return (
@@ -4,12 +4,12 @@ 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
6
  import { AppContext } from '../../../context/app-context'
7
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
7
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
8
8
  import validation from '../../../validation'
9
9
 
10
10
  const AccountCancellation = (props) => {
11
11
  const { theme, setTheme } = useContext(AppContext)
12
- const themeDropdownObject = createThemeDropdownObject(setTheme)
12
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
13
13
  return (
14
14
  <Cancellation
15
15
  {...props}
@@ -10,14 +10,14 @@ import { initAndGetFeatureFlag } from '@newskit-render/feature-flags' // create-
10
10
  import { optimizelysdkKey } from '../../../config' // create-render-app effected
11
11
  import validation from '../../../validation'
12
12
  import { AppContext } from '../../../context/app-context'
13
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
13
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
14
14
 
15
15
  const AccountEditField = (props) => {
16
16
  const doesEditPageExist = Object.keys(editComponentMap).includes(
17
17
  props.data.type
18
18
  )
19
19
  const { theme, setTheme } = useContext(AppContext)
20
- const themeDropdownObject = createThemeDropdownObject(setTheme)
20
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
21
21
 
22
22
  if (doesEditPageExist) {
23
23
  return (
@@ -4,11 +4,11 @@ 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
6
  import { AppContext } from '../../../context/app-context'
7
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
7
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
8
8
 
9
9
  const AccountHolidayStop = (props) => {
10
10
  const { theme, setTheme } = useContext(AppContext)
11
- const themeDropdownObject = createThemeDropdownObject(setTheme)
11
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
12
12
  return (
13
13
  <HolidayStop
14
14
  {...props}
@@ -2,11 +2,11 @@ import { getProviderProps, HolidayStopList } from '@newskit-render/my-account'
2
2
  import newrelic from 'newrelic'
3
3
  import React, { useContext } from 'react'
4
4
  import { AppContext } from '../../../context/app-context'
5
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
5
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
6
 
7
7
  const AccountPreviousHolidayStops = (props) => {
8
8
  const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = createThemeDropdownObject(setTheme)
9
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
10
10
  return (
11
11
  <HolidayStopList
12
12
  {...props}
@@ -2,11 +2,11 @@ import { getProviderProps, HolidayStopList } from '@newskit-render/my-account'
2
2
  import newrelic from 'newrelic'
3
3
  import React, { useContext } from 'react'
4
4
  import { AppContext } from '../../../context/app-context'
5
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
5
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
6
 
7
7
  const AccountUpcomingHolidayStops = (props) => {
8
8
  const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = createThemeDropdownObject(setTheme)
9
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
10
10
  return (
11
11
  <HolidayStopList
12
12
  {...props}
@@ -4,11 +4,11 @@ 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
6
  import { AppContext } from '../../context/app-context'
7
- import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
7
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
8
8
 
9
9
  const AccountPersonalDetails = (props) => {
10
10
  const { theme, setTheme } = useContext(AppContext)
11
- const themeDropdownObject = createThemeDropdownObject(setTheme)
11
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
12
12
  return (
13
13
  <PersonalDetails
14
14
  {...props}
@@ -7,11 +7,11 @@ 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
9
  import { AppContext } from '../../../context/app-context'
10
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
10
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
11
11
 
12
12
  const AccountNewslettersAndAlerts = (props) => {
13
13
  const { theme, setTheme } = useContext(AppContext)
14
- const themeDropdownObject = createThemeDropdownObject(setTheme)
14
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
15
15
  return (
16
16
  <NewslettersAndAlerts
17
17
  {...props}
@@ -8,11 +8,11 @@ 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
10
  import { AppContext } from '../../../context/app-context'
11
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
11
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
12
12
 
13
13
  const AccountCancellation = (props) => {
14
14
  const { theme, setTheme } = useContext(AppContext)
15
- const themeDropdownObject = createThemeDropdownObject(setTheme)
15
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
16
16
  return (
17
17
  <Payment
18
18
  {...props}
@@ -7,11 +7,11 @@ 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
9
  import { AppContext } from '../../../context/app-context'
10
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
10
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
11
11
 
12
12
  const AccountSubscriptionAndBilling = (props) => {
13
13
  const { theme, setTheme } = useContext(AppContext)
14
- const themeDropdownObject = createThemeDropdownObject(setTheme)
14
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
15
15
  return (
16
16
  <SubscriptionAndBilling
17
17
  {...props}
@@ -2,11 +2,11 @@ import { AccountCreation, getProviderProps } from '@newskit-render/checkout'
2
2
  import React, { useContext } from 'react'
3
3
  import { AppContext } from '../../../context/app-context'
4
4
  import validation from '../../../validation'
5
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
5
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
6
6
 
7
7
  const AccountCreationPage = (props) => {
8
8
  const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = createThemeDropdownObject(setTheme)
9
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
10
10
 
11
11
  return (
12
12
  <AccountCreation
@@ -1,11 +1,11 @@
1
1
  import { PaymentDetails, getProviderProps } from '@newskit-render/checkout'
2
2
  import React, { useContext } from 'react'
3
3
  import { AppContext } from '../../../context/app-context'
4
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
4
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
5
5
 
6
6
  const PaymentDetailsPage = (props) => {
7
7
  const { theme, setTheme } = useContext(AppContext)
8
- const themeDropdownObject = createThemeDropdownObject(setTheme)
8
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
9
9
  return (
10
10
  <PaymentDetails
11
11
  {...props}
@@ -5,7 +5,7 @@ import {
5
5
  HelpHubArticlePage,
6
6
  helpHubArticleProvider,
7
7
  } from '@newskit-render/standalone-components'
8
- import { createThemeDropdownObject } from '../../../../helpers/createThemeDropdownObject'
8
+ import { useThemeDropdownObject } from '../../../../helpers/useThemeDropdownObject'
9
9
  import { AppContext } from '../../../../context'
10
10
  import { addCacheHeaders } from '../../../../helpers/addCacheHeaders'
11
11
 
@@ -15,7 +15,7 @@ const ArticlePage: React.FC<{
15
15
  content: string
16
16
  }> = (props) => {
17
17
  const { theme, setTheme } = useContext(AppContext)
18
- const themeDropdownObject = createThemeDropdownObject(setTheme)
18
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
19
19
 
20
20
  return (
21
21
  <HelpHubArticlePage
@@ -5,7 +5,7 @@ import {
5
5
  HelpHubLandingPage,
6
6
  helpHubLandingPageProvider,
7
7
  } from '@newskit-render/standalone-components'
8
- import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
8
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
9
9
  import { AppContext } from '../../context'
10
10
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
11
11
 
@@ -42,7 +42,7 @@ const LandingPage: React.FC<{
42
42
  credentials: AlgoliaCredentials
43
43
  }> = (props) => {
44
44
  const { theme, setTheme } = useContext(AppContext)
45
- const themeDropdownObject = createThemeDropdownObject(setTheme)
45
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
46
46
 
47
47
  return (
48
48
  <HelpHubLandingPage
@@ -6,7 +6,7 @@ import {
6
6
  Hit,
7
7
  helpHubResultsProvider,
8
8
  } from '@newskit-render/standalone-components'
9
- import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
9
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
10
10
  import { AppContext } from '../../context'
11
11
  import { addCacheHeaders } from '../../helpers/addCacheHeaders'
12
12
 
@@ -15,7 +15,7 @@ const ResultsPage: React.FC<{
15
15
  hits: Hit[]
16
16
  }> = (props) => {
17
17
  const { theme, setTheme } = useContext(AppContext)
18
- const themeDropdownObject = createThemeDropdownObject(setTheme)
18
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
19
19
 
20
20
  return (
21
21
  <HelpHubResultsPage
@@ -1,11 +1,11 @@
1
1
  import React, { useContext } from 'react'
2
2
  import { RSSConsoleCreateFeedPage } from '@newskit-render/standalone-components'
3
- import { createThemeDropdownObject } from '../../../helpers/createThemeDropdownObject'
3
+ import { useThemeDropdownObject } from '../../../helpers/useThemeDropdownObject'
4
4
  import { AppContext } from '../../../context'
5
5
 
6
6
  const LandingPage: React.FC = () => {
7
7
  const { theme, setTheme } = useContext(AppContext)
8
- const themeDropdownObject = createThemeDropdownObject(setTheme)
8
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
9
9
 
10
10
  return (
11
11
  <RSSConsoleCreateFeedPage
@@ -1,12 +1,12 @@
1
1
  import React, { useContext } from 'react'
2
2
  import { RSSConsoleFeedDetailsPage } from '@newskit-render/standalone-components'
3
+ import { useThemeDropdownObject } from '../../../../helpers/useThemeDropdownObject'
3
4
  import { useRouter } from 'next/router'
4
- import { createThemeDropdownObject } from '../../../../helpers/createThemeDropdownObject'
5
5
  import { AppContext } from '../../../../context'
6
6
 
7
7
  const LandingPage: React.FC = () => {
8
8
  const { theme, setTheme } = useContext(AppContext)
9
- const themeDropdownObject = createThemeDropdownObject(setTheme)
9
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
10
10
  const router = useRouter()
11
11
 
12
12
  return (
@@ -1,11 +1,11 @@
1
1
  import React, { useContext } from 'react'
2
2
  import { RSSConsoleFeedsListPage } from '@newskit-render/standalone-components'
3
- import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
3
+ import { useThemeDropdownObject } from '../../helpers/useThemeDropdownObject'
4
4
  import { AppContext } from '../../context'
5
5
 
6
6
  const LandingPage: React.FC = () => {
7
7
  const { theme, setTheme } = useContext(AppContext)
8
- const themeDropdownObject = createThemeDropdownObject(setTheme)
8
+ const themeDropdownObject = useThemeDropdownObject(setTheme)
9
9
 
10
10
  return (
11
11
  <RSSConsoleFeedsListPage