@financial-times/dotcom-ui-header 9.0.0-beta.8 → 9.0.1
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/browser.js +3 -7
- package/dist/node/components/drawer/additionalPartials.d.ts +6 -6
- package/dist/node/components/drawer/additionalPartials.js +10 -5
- package/dist/node/components/drawer/topLevelPartials.d.ts +2 -2
- package/dist/node/components/navigation/partials.d.ts +6 -6
- package/dist/node/components/search/partials.d.ts +2 -2
- package/dist/node/components/sticky/partials.d.ts +5 -5
- package/dist/node/components/sticky/partials.js +4 -8
- package/dist/node/components/sub-navigation/partials.d.ts +2 -2
- package/dist/node/components/svg-components/BrandFtMasthead.d.ts +2 -2
- package/dist/node/components/top/partials.d.ts +10 -12
- package/dist/node/components/top/partials.js +8 -14
- package/dist/node/index.d.ts +7 -7
- package/dist/node/index.js +2 -2
- package/dist/node/utils.js +2 -1
- package/dist/tsconfig.tsbuildinfo +1410 -567
- package/package.json +5 -5
- package/src/__test__/components/__snapshots__/MainHeader.spec.tsx.snap +3 -3
- package/src/__test__/output/component.spec.tsx +113 -0
- package/src/__test__/output/drawer.spec.tsx +124 -0
- package/src/components/sticky/partials.tsx +16 -16
- package/src/components/top/partials.tsx +17 -21
- package/src/index.tsx +2 -14
- package/styles.scss +4 -8
- package/src/__test__/enzyme/component.spec.tsx +0 -107
- package/src/__test__/enzyme/drawer.spec.tsx +0 -114
- package/src/enhanced-search/customList.js +0 -160
- package/src/enhanced-search/enhancedSearch.js +0 -59
- package/src/enhanced-search/styles.scss +0 -136
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-ui-header",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "component.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@financial-times/dotcom-types-navigation": "^9.0.
|
|
25
|
+
"@financial-times/dotcom-types-navigation": "^9.0.1",
|
|
26
26
|
"n-topic-search": "^4.0.0",
|
|
27
27
|
"n-ui-foundations": "^9.0.0"
|
|
28
28
|
},
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@svgr/core": "^5.0.0",
|
|
32
32
|
"camelcase": "^6.0.0",
|
|
33
33
|
"check-engine": "^1.10.1",
|
|
34
|
-
"@financial-times/o-header": "^11.
|
|
35
|
-
"react": "^16.8.6"
|
|
34
|
+
"@financial-times/o-header": "^11.0.4"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|
|
38
37
|
"@financial-times/o-header": "^11.0.4",
|
|
39
38
|
"@financial-times/logo-images": "^1.10.1",
|
|
40
|
-
"react": "
|
|
39
|
+
"react": "17.x || 18.x",
|
|
40
|
+
"react-dom": "17.x || 18.x"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": "16.x || 18.x",
|
|
@@ -54,7 +54,7 @@ exports[`dotcom-ui-header/src/components/MainHeader renders a right aligned subn
|
|
|
54
54
|
<a
|
|
55
55
|
className="o-header__top-logo"
|
|
56
56
|
data-trackable="logo"
|
|
57
|
-
href="
|
|
57
|
+
href="/"
|
|
58
58
|
style={
|
|
59
59
|
Object {
|
|
60
60
|
"backgroundImage": "none",
|
|
@@ -1897,7 +1897,7 @@ exports[`dotcom-ui-header/src/components/MainHeader renders as a logged in user
|
|
|
1897
1897
|
<a
|
|
1898
1898
|
className="o-header__top-logo"
|
|
1899
1899
|
data-trackable="logo"
|
|
1900
|
-
href="
|
|
1900
|
+
href="/"
|
|
1901
1901
|
style={
|
|
1902
1902
|
Object {
|
|
1903
1903
|
"backgroundImage": "none",
|
|
@@ -3745,7 +3745,7 @@ exports[`dotcom-ui-header/src/components/MainHeader renders as an anonymous user
|
|
|
3745
3745
|
<a
|
|
3746
3746
|
className="o-header__top-logo"
|
|
3747
3747
|
data-trackable="logo"
|
|
3748
|
-
href="
|
|
3748
|
+
href="/"
|
|
3749
3749
|
style={
|
|
3750
3750
|
Object {
|
|
3751
3751
|
"backgroundImage": "none",
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import { render } from '@testing-library/react'
|
|
6
|
+
|
|
7
|
+
import dataFixture from '../../__stories__/story-data/index'
|
|
8
|
+
import { Header } from '../../index'
|
|
9
|
+
|
|
10
|
+
// data.currentPath to enable the mobile header
|
|
11
|
+
const headerFixture = {
|
|
12
|
+
...dataFixture,
|
|
13
|
+
data: { ...dataFixture.data, currentPath: '/' }
|
|
14
|
+
}
|
|
15
|
+
const subscribedUserFixture = { ...dataFixture, showUserNavigation: true, userIsSubscribed: true }
|
|
16
|
+
const loggedInUserFixture = { ...dataFixture, showUserNavigation: true }
|
|
17
|
+
const anonymousUserFixture = {
|
|
18
|
+
...dataFixture,
|
|
19
|
+
userIsAnonymous: true,
|
|
20
|
+
userIsLoggedIn: false,
|
|
21
|
+
showUserNavigation: true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const commonHeader = <Header {...headerFixture} />
|
|
25
|
+
const subscribedUserHeader = <Header {...subscribedUserFixture} />
|
|
26
|
+
const loggedInUserHeader = <Header {...loggedInUserFixture} />
|
|
27
|
+
const anonymousUserHeader = <Header {...anonymousUserFixture} />
|
|
28
|
+
|
|
29
|
+
describe('dotcom-ui-header', () => {
|
|
30
|
+
it('renders the expected common header elements', () => {
|
|
31
|
+
const { container } = render(commonHeader)
|
|
32
|
+
|
|
33
|
+
const logo = container.querySelector('div[data-trackable="header-top"] .o-header__top-logo')
|
|
34
|
+
expect(logo?.hasChildNodes()).toBe(true)
|
|
35
|
+
|
|
36
|
+
const myFtLink = container.querySelector('div[data-trackable="header-top"] .o-header__top-icon-link--myft')
|
|
37
|
+
expect(myFtLink?.innerHTML).toContain('myFT')
|
|
38
|
+
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('renders an inlined SVG logo image', () => {
|
|
42
|
+
const { container } = render(commonHeader)
|
|
43
|
+
|
|
44
|
+
const logo = container.querySelector('div[data-trackable="header-top"] .o-header__top-logo')
|
|
45
|
+
expect(logo?.hasChildNodes()).toBe(true)
|
|
46
|
+
expect(logo?.innerHTML).toContain('Financial Times')
|
|
47
|
+
expect(logo?.querySelector('div[data-trackable="header-top"] .o-header__top-logo svg')).not.toBeNull()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('renders the sticky header', () => {
|
|
51
|
+
const { container } = render(commonHeader)
|
|
52
|
+
const header = container.querySelector('.o-header--sticky')
|
|
53
|
+
expect(header).not.toBeNull()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('renders the mobile header', () => {
|
|
57
|
+
const { container } = render(commonHeader)
|
|
58
|
+
const mobileHeader = container.querySelector('#o-header-nav-mobile')
|
|
59
|
+
expect(mobileHeader).not.toBeNull()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe('When the user is subscribed', () => {
|
|
63
|
+
it('renders the expected logged in user header links', () => {
|
|
64
|
+
const { container } = render(subscribedUserHeader)
|
|
65
|
+
|
|
66
|
+
expect(container.querySelector('a[data-trackable="Portfolio"]')).not.toBeNull()
|
|
67
|
+
expect(container.querySelector('a[data-trackable="Settings & Account"]')).not.toBeNull()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('does not render sign in link', () => {
|
|
71
|
+
const { container } = render(subscribedUserHeader)
|
|
72
|
+
|
|
73
|
+
expect(container.querySelector('a[data-trackable="Subscribe"]')).toBeNull()
|
|
74
|
+
expect(container.querySelector('a[data-trackable="Sign In"]')).toBeNull()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('When the user is logged in', () => {
|
|
79
|
+
it('renders the expected logged in user header links', () => {
|
|
80
|
+
const { container } = render(loggedInUserHeader)
|
|
81
|
+
|
|
82
|
+
expect(container.querySelector('a[data-trackable="Portfolio"]')).not.toBeNull()
|
|
83
|
+
expect(container.querySelector('a[data-trackable="Settings & Account"]')).not.toBeNull()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('does not render sign in link', () => {
|
|
87
|
+
const { container } = render(loggedInUserHeader)
|
|
88
|
+
|
|
89
|
+
expect(container.querySelector('a[data-trackable="Subscribe"]')).not.toBeNull()
|
|
90
|
+
expect(container.querySelector('a[data-trackable="Sign In"]')).toBeNull()
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
describe('When the user is anonymous', () => {
|
|
95
|
+
it('renders the expected anonymous user header links', () => {
|
|
96
|
+
const { container } = render(anonymousUserHeader)
|
|
97
|
+
|
|
98
|
+
expect(
|
|
99
|
+
container.querySelector('.o-header__top-column .o-header__top-column--right a[data-trackable="Subscribe"]')
|
|
100
|
+
).not.toBeNull()
|
|
101
|
+
expect(
|
|
102
|
+
container.querySelector('.o-header__top-column .o-header__top-column--right a[data-trackable="Sign In"]')
|
|
103
|
+
).not.toBeNull()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('does not render the logged in user header links', () => {
|
|
107
|
+
const { container } = render(anonymousUserHeader)
|
|
108
|
+
|
|
109
|
+
expect(container.querySelector('a[data-trackable="Portfolio"]')).toBeNull()
|
|
110
|
+
expect(container.querySelector('a[data-trackable="Settings & Account"]')).toBeNull()
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import { render } from '@testing-library/react'
|
|
6
|
+
|
|
7
|
+
import navigationData from '../../__stories__/story-data/index'
|
|
8
|
+
import { Drawer as Subject } from '../../'
|
|
9
|
+
|
|
10
|
+
const fixture = {
|
|
11
|
+
data: { ...navigationData.data, currentPath: '/world' }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const loggedInUserFixture = {
|
|
15
|
+
...fixture,
|
|
16
|
+
userIsAnonymous: false,
|
|
17
|
+
userIsLoggedIn: true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const anonymousUserFixture = {
|
|
21
|
+
...fixture,
|
|
22
|
+
userIsAnonymous: true,
|
|
23
|
+
userIsLoggedIn: false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('dotcom-ui-header/src/components/drawer', () => {
|
|
27
|
+
describe('editions', () => {
|
|
28
|
+
it('renders the current edition text', () => {
|
|
29
|
+
const { container } = render(<Subject {...fixture} />)
|
|
30
|
+
|
|
31
|
+
expect(container.getElementsByClassName('o-header__drawer-current-edition')[0].innerHTML).toContain(
|
|
32
|
+
'UK Edition'
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('renders the alternative edition link', () => {
|
|
37
|
+
const { container } = render(<Subject {...fixture} />)
|
|
38
|
+
|
|
39
|
+
const [firstLink] = Array.from(container.getElementsByClassName('o-header__drawer-menu-link'))
|
|
40
|
+
expect(firstLink.innerHTML).toContain('Switch to International Edition')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
describe('navigation links', () => {
|
|
45
|
+
it('renders the primary link section title', () => {
|
|
46
|
+
const { container } = render(<Subject {...fixture} />)
|
|
47
|
+
|
|
48
|
+
const [firstLink] = Array.from(container.getElementsByClassName('o-header__drawer-menu-item--heading'))
|
|
49
|
+
expect(firstLink.innerHTML).toContain('Top sections')
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('renders the secondary link section title', () => {
|
|
53
|
+
const { container } = render(<Subject {...fixture} />)
|
|
54
|
+
|
|
55
|
+
const secondLink = Array.from(
|
|
56
|
+
container.getElementsByClassName('o-header__drawer-menu-item--heading')
|
|
57
|
+
)[1]
|
|
58
|
+
expect(secondLink.innerHTML).toContain('FT recommends')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('renders the tertiary link section divider', () => {
|
|
62
|
+
const { container } = render(<Subject {...fixture} />)
|
|
63
|
+
|
|
64
|
+
const [li] = Array.from(container.getElementsByClassName('o-header__drawer-menu-list--divide'))
|
|
65
|
+
expect(li.children[0].innerHTML).toContain('myFT')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('renders primary link subsections', () => {
|
|
69
|
+
const { container } = render(<Subject {...fixture} />)
|
|
70
|
+
|
|
71
|
+
const parentHeaders = Array.from(
|
|
72
|
+
container.getElementsByClassName('o-header__drawer-menu-link--parent')
|
|
73
|
+
).filter((header) => header.innerHTML.includes('Companies'))
|
|
74
|
+
|
|
75
|
+
expect(parentHeaders.length).toBe(1)
|
|
76
|
+
|
|
77
|
+
const toggleHeaders = Array.from(
|
|
78
|
+
container.getElementsByClassName('o-header__drawer-menu-toggle')
|
|
79
|
+
).filter((header) => header.innerHTML.includes('Show more Companies'))
|
|
80
|
+
|
|
81
|
+
expect(toggleHeaders.length).toBe(1)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('highlights the current page', () => {
|
|
85
|
+
const { container } = render(<Subject {...fixture} />)
|
|
86
|
+
const currentPage = container.querySelector('[aria-current="page"]')
|
|
87
|
+
expect(currentPage?.innerHTML).toContain('World')
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('user menu', () => {
|
|
92
|
+
describe('for a logged in user', () => {
|
|
93
|
+
it('renders sign out link', () => {
|
|
94
|
+
const { container } = render(<Subject {...loggedInUserFixture} />)
|
|
95
|
+
|
|
96
|
+
const signOutLink = container.querySelector('a[data-trackable="Sign Out"]')
|
|
97
|
+
expect(signOutLink?.innerHTML).toContain('Sign Out')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('renders settings and account link', () => {
|
|
101
|
+
const { container } = render(<Subject {...loggedInUserFixture} />)
|
|
102
|
+
|
|
103
|
+
const signOutLink = container.querySelector('a[data-trackable="Settings & Account"]')
|
|
104
|
+
expect(signOutLink?.innerHTML).toContain('Settings & Account')
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
describe('for an anonymous user', () => {
|
|
109
|
+
it('renders sign in link', () => {
|
|
110
|
+
const { container } = render(<Subject {...anonymousUserFixture} />)
|
|
111
|
+
|
|
112
|
+
const signInLink = container.querySelector('a[data-trackable="Sign In"')
|
|
113
|
+
expect(signInLink?.innerHTML).toContain('Sign In')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('renders subscribe link', () => {
|
|
117
|
+
const { container } = render(<Subject {...anonymousUserFixture} />)
|
|
118
|
+
|
|
119
|
+
const subscribeLink = container.querySelector('a[data-trackable="Subscribe"]')
|
|
120
|
+
expect(subscribeLink?.innerHTML).toContain('Subscribe')
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { SubscribeButton, SignInLink } from '../top/partials'
|
|
6
6
|
import { THeaderProps } from '../../interfaces'
|
|
7
|
-
import { TNavMenuItem } from '@financial-times/dotcom-types-navigation'
|
|
8
7
|
|
|
9
8
|
const StickyHeaderWrapper = (props: THeaderProps & { children: React.ReactNode }) => (
|
|
10
9
|
<header
|
|
@@ -89,19 +88,16 @@ const NavListRightAnonSticky = (props: THeaderProps) => {
|
|
|
89
88
|
)
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
const MyFtSticky = ({ className
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
</a>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
91
|
+
const MyFtSticky = ({ className }: { className?: string }) => (
|
|
92
|
+
<a
|
|
93
|
+
className={`o-header__top-icon-link o-header__top-icon-link--myft ${className}`}
|
|
94
|
+
href="/myft"
|
|
95
|
+
data-trackable="my-ft"
|
|
96
|
+
tabIndex={-1}
|
|
97
|
+
>
|
|
98
|
+
<span className="o-header__visually-hidden">myFT</span>
|
|
99
|
+
</a>
|
|
100
|
+
)
|
|
105
101
|
|
|
106
102
|
const TopWrapperSticky = (props) => (
|
|
107
103
|
<div className="o-header__row o-header__top" data-trackable="header-sticky">
|
|
@@ -133,9 +129,13 @@ const NavListRightLoggedInSticky = (props: THeaderProps) => {
|
|
|
133
129
|
return (
|
|
134
130
|
<React.Fragment>
|
|
135
131
|
{!props.userIsSubscribed && subscribeAction && (
|
|
136
|
-
<SubscribeButton
|
|
132
|
+
<SubscribeButton
|
|
133
|
+
item={subscribeAction}
|
|
134
|
+
variant="sticky"
|
|
135
|
+
className="o-header__top-button--hide-m"
|
|
136
|
+
/>
|
|
137
137
|
)}
|
|
138
|
-
<MyFtSticky className=""
|
|
138
|
+
<MyFtSticky className="" />
|
|
139
139
|
</React.Fragment>
|
|
140
140
|
)
|
|
141
141
|
}
|
|
@@ -39,21 +39,18 @@ const SearchIcon = () => (
|
|
|
39
39
|
</a>
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
const MyFt = ({ className
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</a>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
42
|
+
const MyFt = ({ className }: { className?: string }) => (
|
|
43
|
+
<a
|
|
44
|
+
className={`o-header__top-icon-link o-header__top-icon-link--myft ${className}`}
|
|
45
|
+
id="o-header-top-link-myft"
|
|
46
|
+
href="/myft"
|
|
47
|
+
data-trackable="my-ft"
|
|
48
|
+
data-tour-stage="myFt"
|
|
49
|
+
aria-label="My F T"
|
|
50
|
+
>
|
|
51
|
+
<span className="o-header__visually-hidden">myFT</span>
|
|
52
|
+
</a>
|
|
53
|
+
)
|
|
57
54
|
|
|
58
55
|
const TopWrapper = (props) => (
|
|
59
56
|
<div className="o-header__row o-header__top" data-trackable="header-top">
|
|
@@ -70,13 +67,13 @@ const TopColumnLeft = () => (
|
|
|
70
67
|
</div>
|
|
71
68
|
)
|
|
72
69
|
|
|
73
|
-
const TopColumnCenter = (
|
|
70
|
+
const TopColumnCenter = () => (
|
|
74
71
|
<div className="o-header__top-column o-header__top-column--center">
|
|
75
72
|
<a
|
|
76
73
|
className="o-header__top-logo"
|
|
77
74
|
style={{ backgroundImage: 'none' }}
|
|
78
75
|
data-trackable="logo"
|
|
79
|
-
href=
|
|
76
|
+
href="/"
|
|
80
77
|
title="Go to Financial Times homepage"
|
|
81
78
|
>
|
|
82
79
|
<BrandFtMastheadSvg title="Financial Times" />
|
|
@@ -103,7 +100,7 @@ const TopColumnRightLoggedIn = (props: THeaderProps) => {
|
|
|
103
100
|
className="o-header__top-button--hide-m"
|
|
104
101
|
/>
|
|
105
102
|
)}
|
|
106
|
-
<MyFt className=""
|
|
103
|
+
<MyFt className="" />
|
|
107
104
|
</div>
|
|
108
105
|
)
|
|
109
106
|
}
|
|
@@ -165,7 +162,7 @@ const TopColumnRightAnon = ({ items, variant }: { items: TNavMenuItem[]; variant
|
|
|
165
162
|
{signInAction && (
|
|
166
163
|
<SignInLink item={signInAction} variant={variant} className="o-header__top-link--hide-m" />
|
|
167
164
|
)}
|
|
168
|
-
<MyFt className="o-header__top-icon-link--show-m"
|
|
165
|
+
<MyFt className="o-header__top-icon-link--show-m" />
|
|
169
166
|
</div>
|
|
170
167
|
)
|
|
171
168
|
}
|
|
@@ -175,8 +172,7 @@ const TopColumnRight = (props: THeaderProps) => {
|
|
|
175
172
|
return <TopColumnRightLoggedIn {...props} />
|
|
176
173
|
} else {
|
|
177
174
|
const userNavAnonItems = props.data['navbar-right-anon'].items
|
|
178
|
-
|
|
179
|
-
return <TopColumnRightAnon items={userNavAnonItems.concat(userNavAccountItems)} variant={props.variant} />
|
|
175
|
+
return <TopColumnRightAnon items={userNavAnonItems} variant={props.variant} />
|
|
180
176
|
}
|
|
181
177
|
}
|
|
182
178
|
|
package/src/index.tsx
CHANGED
|
@@ -45,16 +45,10 @@ function MainHeader(props: THeaderProps) {
|
|
|
45
45
|
{includeUserActionsNav ? <UserActionsNav {...props} /> : null}
|
|
46
46
|
<TopWrapper>
|
|
47
47
|
<TopColumnLeft />
|
|
48
|
-
{props.showLogoLink ?
|
|
49
|
-
<TopColumnCenter url={props.data.editions.current.url} />
|
|
50
|
-
) : (
|
|
51
|
-
<TopColumnCenterNoLink />
|
|
52
|
-
)}
|
|
48
|
+
{props.showLogoLink ? <TopColumnCenter /> : <TopColumnCenterNoLink />}
|
|
53
49
|
<TopColumnRight {...props} />
|
|
54
50
|
</TopWrapper>
|
|
55
|
-
|
|
56
51
|
<Search instance="primary" />
|
|
57
|
-
|
|
58
52
|
<MobileNav {...props} />
|
|
59
53
|
<NavDesktop>
|
|
60
54
|
<NavListLeft {...props} />
|
|
@@ -116,13 +110,7 @@ function NoOutboundLinksHeader(props: THeaderProps) {
|
|
|
116
110
|
return (
|
|
117
111
|
<HeaderWrapper {...props}>
|
|
118
112
|
{includeUserActionsNav ? <UserActionsNav {...props} /> : null}
|
|
119
|
-
<TopWrapper>
|
|
120
|
-
{props.showLogoLink ? (
|
|
121
|
-
<TopColumnCenter url={props.data.editions.current.url} />
|
|
122
|
-
) : (
|
|
123
|
-
<TopColumnCenterNoLink />
|
|
124
|
-
)}
|
|
125
|
-
</TopWrapper>
|
|
113
|
+
<TopWrapper>{props.showLogoLink ? <TopColumnCenter /> : <TopColumnCenterNoLink />}</TopWrapper>
|
|
126
114
|
<NavDesktop>{props.showUserNavigation ? <NavListRight {...props} /> : null}</NavDesktop>
|
|
127
115
|
{includeSubNavigation ? <SubNavigation {...props} /> : null}
|
|
128
116
|
</HeaderWrapper>
|
package/styles.scss
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
// This will be overridden by dotcom-ui-layout, it's necessary here for storybook builds
|
|
2
2
|
$system-code: 'page-kit-header' !default;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
@import 'n-ui-foundations/mixins';
|
|
4
|
+
@import "n-ui-foundations/mixins";
|
|
6
5
|
|
|
7
6
|
// We don't need the sub-brand or transparent header styles so disable them.
|
|
8
7
|
// TODO: move drawer styles into a separate stylesheet which can be lazy loaded?
|
|
9
|
-
@import
|
|
8
|
+
@import "@financial-times/o-header/main";
|
|
10
9
|
@include oHeader(('top', 'nav', 'subnav', 'search', 'megamenu', 'drawer', 'anon', 'sticky', 'simple'));
|
|
11
10
|
|
|
12
|
-
@import
|
|
11
|
+
@import "src/header";
|
|
13
12
|
|
|
14
|
-
@import
|
|
13
|
+
@import "n-topic-search/main";
|
|
15
14
|
@include nTopicSearch;
|
|
16
|
-
|
|
17
|
-
@import './src/enhanced-search/styles';
|
|
18
|
-
@include enhancedSearch;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*/
|
|
4
|
-
import 'jest-enzyme'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import { mount } from 'enzyme'
|
|
7
|
-
|
|
8
|
-
import dataFixture from '../../__stories__/story-data/index'
|
|
9
|
-
import { Header } from '../../index'
|
|
10
|
-
|
|
11
|
-
// data.currentPath to enable the mobile header
|
|
12
|
-
const headerFixture = {
|
|
13
|
-
...dataFixture,
|
|
14
|
-
data: { ...dataFixture.data, currentPath: '/' }
|
|
15
|
-
}
|
|
16
|
-
const subscribedUserFixture = { ...dataFixture, showUserNavigation: true, userIsSubscribed: true }
|
|
17
|
-
const loggedInUserFixture = { ...dataFixture, showUserNavigation: true }
|
|
18
|
-
const anonymousUserFixture = {
|
|
19
|
-
...dataFixture,
|
|
20
|
-
userIsAnonymous: true,
|
|
21
|
-
userIsLoggedIn: false,
|
|
22
|
-
showUserNavigation: true
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const commonHeader = <Header {...headerFixture} />
|
|
26
|
-
const subscribedUserHeader = <Header {...subscribedUserFixture} />
|
|
27
|
-
const loggedInUserHeader = <Header {...loggedInUserFixture} />
|
|
28
|
-
const anonymousUserHeader = <Header {...anonymousUserFixture} />
|
|
29
|
-
|
|
30
|
-
describe('dotcom-ui-header', () => {
|
|
31
|
-
const header = mount(commonHeader)
|
|
32
|
-
|
|
33
|
-
it('renders the expected common header elements', () => {
|
|
34
|
-
expect(header).not.toBeEmptyRender()
|
|
35
|
-
expect(header.find('div[data-trackable="header-top"] .o-header__top-logo')).toExist()
|
|
36
|
-
expect(
|
|
37
|
-
header.find(
|
|
38
|
-
'div[data-trackable="header-top"] .o-header__top-icon-link--search .o-header__top-link-label'
|
|
39
|
-
)
|
|
40
|
-
).toExist()
|
|
41
|
-
expect(
|
|
42
|
-
header.find('div[data-trackable="header-top"] .o-header__top-icon-link--menu .o-header__top-link-label')
|
|
43
|
-
).toExist()
|
|
44
|
-
expect(header.find('div[data-trackable="header-top"] .o-header__top-icon-link--myft')).toExist()
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('renders an inlined SVG logo image', () => {
|
|
48
|
-
expect(header.find('div[data-trackable="header-top"] .o-header__top-logo svg')).toExist()
|
|
49
|
-
expect(header.find('div[data-trackable="header-top"] .o-header__top-logo title')).toHaveText(
|
|
50
|
-
'Financial Times'
|
|
51
|
-
)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('renders the sticky header', () => {
|
|
55
|
-
expect(header.find('.o-header--sticky')).toExist()
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('renders the mobile header', () => {
|
|
59
|
-
expect(header.find('#o-header-nav-mobile')).toExist()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('When the user is subscribed', () => {
|
|
63
|
-
const header = mount(subscribedUserHeader)
|
|
64
|
-
|
|
65
|
-
it('renders the expected logged in user header links', () => {
|
|
66
|
-
expect(header.find('a[data-trackable="Portfolio"]')).toExist()
|
|
67
|
-
expect(header.find('a[data-trackable="Settings & Account"]')).toExist()
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('does not render sign in link', () => {
|
|
71
|
-
expect(header.find('a[data-trackable="Subscribe"]')).not.toExist()
|
|
72
|
-
expect(header.find('a[data-trackable="Sign In"]')).not.toExist()
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
describe('When the user is logged in', () => {
|
|
77
|
-
const header = mount(loggedInUserHeader)
|
|
78
|
-
|
|
79
|
-
it('renders the expected logged in user header links', () => {
|
|
80
|
-
expect(header.find('a[data-trackable="Portfolio"]')).toExist()
|
|
81
|
-
expect(header.find('a[data-trackable="Settings & Account"]')).toExist()
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('does not render sign in link', () => {
|
|
85
|
-
expect(header.find('a[data-trackable="Subscribe"]')).toExist()
|
|
86
|
-
expect(header.find('a[data-trackable="Sign In"]')).not.toExist()
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
describe('When the user is anonymous', () => {
|
|
91
|
-
const header = mount(anonymousUserHeader)
|
|
92
|
-
|
|
93
|
-
it('renders the expected anonymous user header links', () => {
|
|
94
|
-
expect(
|
|
95
|
-
header.find('.o-header__top-column .o-header__top-column--right a[data-trackable="Subscribe"]')
|
|
96
|
-
).toExist()
|
|
97
|
-
expect(
|
|
98
|
-
header.find('.o-header__top-column .o-header__top-column--right a[data-trackable="Sign In"]')
|
|
99
|
-
).toExist()
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('does not render the logged in user header links', () => {
|
|
103
|
-
expect(header.find('a[data-trackable="Portfolio"]')).not.toExist()
|
|
104
|
-
expect(header.find('a[data-trackable="Settings & Account"]')).not.toExist()
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
})
|