@financial-times/dotcom-ui-header 7.3.0 → 7.3.2

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 (42) hide show
  1. package/dist/node/components/drawer/additionalPartials.d.ts +11 -0
  2. package/dist/node/components/drawer/topLevelPartials.d.ts +3 -0
  3. package/dist/node/components/navigation/partials.d.ts +8 -0
  4. package/dist/node/components/search/partials.d.ts +5 -0
  5. package/dist/node/components/sticky/partials.d.ts +10 -0
  6. package/dist/node/components/sub-navigation/partials.d.ts +4 -0
  7. package/dist/node/components/svg-components/BrandFtMasthead.d.ts +6 -0
  8. package/dist/node/components/top/partials.d.ts +24 -0
  9. package/dist/node/index.d.ts +38 -0
  10. package/dist/node/utils.d.ts +2 -0
  11. package/dist/tsconfig.tsbuildinfo +2124 -0
  12. package/package.json +12 -6
  13. package/src/__stories__/demos.scss +28 -0
  14. package/src/__stories__/story-data/actionsUK.ts +5 -0
  15. package/src/__stories__/story-data/anon.ts +24 -0
  16. package/src/__stories__/story-data/drawerUK.ts +968 -0
  17. package/src/__stories__/story-data/editionsInternational.ts +8 -0
  18. package/src/__stories__/story-data/editionsUK.ts +8 -0
  19. package/src/__stories__/story-data/index.ts +41 -0
  20. package/src/__stories__/story-data/navbarRight.ts +19 -0
  21. package/src/__stories__/story-data/navbarRightAnon.ts +19 -0
  22. package/src/__stories__/story-data/navbarSimple.ts +24 -0
  23. package/src/__stories__/story-data/navbarUK.ts +996 -0
  24. package/src/__stories__/story-data/profile.ts +44 -0
  25. package/src/__stories__/story-data/subNavigationProfile.ts +27 -0
  26. package/src/__stories__/story-data/subNavigationUK.ts +37 -0
  27. package/src/__stories__/story-data/user.ts +13 -0
  28. package/src/__stories__/story.tsx +163 -0
  29. package/src/__test__/components/Drawer.spec.tsx +19 -0
  30. package/src/__test__/components/MainHeader.spec.tsx +26 -0
  31. package/src/__test__/components/NoOutboundLinks.spec.tsx +19 -0
  32. package/src/__test__/components/StickyHeader.spec.tsx +19 -0
  33. package/src/__test__/components/__snapshots__/Drawer.spec.tsx.snap +2718 -0
  34. package/src/__test__/components/__snapshots__/MainHeader.spec.tsx.snap +5547 -0
  35. package/src/__test__/components/__snapshots__/NoOutboundLinks.spec.tsx.snap +337 -0
  36. package/src/__test__/components/__snapshots__/StickyHeader.spec.tsx.snap +588 -0
  37. package/src/__test__/enzyme/component.spec.tsx +107 -0
  38. package/src/__test__/enzyme/drawer.spec.tsx +114 -0
  39. package/screenshots/header-navigation.png +0 -0
  40. package/screenshots/header-sub-navigation.png +0 -0
  41. package/screenshots/header-top-search.png +0 -0
  42. package/scripts/convertSvgsToReactComponents.js +0 -23
@@ -0,0 +1,44 @@
1
+ import anon from './anon'
2
+ import drawerUK from './drawerUK'
3
+ import editionsUK from './editionsUK'
4
+ import navbarRight from './navbarRight'
5
+ import navbarRightAnon from './navbarRightAnon'
6
+ import navbarSimple from './navbarSimple'
7
+ import navbarUK from './navbarUK'
8
+ import subNavigation from './subNavigationProfile'
9
+ import user from './user'
10
+
11
+ import { THeaderProps } from '../../interfaces'
12
+
13
+ const breadcrumb = subNavigation.ancestors.concat(subNavigation.item)
14
+ const subsections = subNavigation.children
15
+
16
+ const data: THeaderProps = {
17
+ userIsAnonymous: false,
18
+ userIsLoggedIn: true,
19
+ showSubNavigation: true,
20
+ showUserNavigation: false,
21
+ showStickyHeader: true,
22
+ data: {
23
+ account: null,
24
+ anon,
25
+ breadcrumb,
26
+ drawer: drawerUK,
27
+ editions: editionsUK,
28
+ footer: null,
29
+ navbar: navbarUK,
30
+ 'navbar-right': navbarRight,
31
+ 'navbar-right-anon': navbarRightAnon,
32
+ 'navbar-simple': navbarSimple,
33
+ subsections,
34
+ 'subsections-right': [
35
+ {
36
+ label: 'Sign Out',
37
+ url: '#'
38
+ }
39
+ ],
40
+ user
41
+ }
42
+ }
43
+
44
+ export default data
@@ -0,0 +1,27 @@
1
+ import { TNavMenuItem } from '@financial-times/dotcom-types-navigation'
2
+
3
+ const item: TNavMenuItem = {
4
+ label: 'Settings & Account',
5
+ url: '/myaccount/personal-details',
6
+ selected: true,
7
+ submenu: null
8
+ }
9
+
10
+ const siblings: TNavMenuItem[] = []
11
+
12
+ const children: TNavMenuItem[] = [
13
+ {
14
+ label: 'Personal Details',
15
+ url: '/myaccount/personal-details',
16
+ submenu: null
17
+ },
18
+ {
19
+ label: 'Licence',
20
+ url: '/myaccount/licence',
21
+ submenu: null
22
+ }
23
+ ]
24
+
25
+ const ancestors: TNavMenuItem[] = []
26
+
27
+ export default { item, siblings, children, ancestors }
@@ -0,0 +1,37 @@
1
+ import { TNavMenuItem } from '@financial-times/dotcom-types-navigation'
2
+
3
+ const item: TNavMenuItem = {
4
+ label: 'UK',
5
+ url: '/world/uk',
6
+ selected: true,
7
+ submenu: null
8
+ }
9
+
10
+ const siblings: TNavMenuItem[] = []
11
+
12
+ const children: TNavMenuItem[] = [
13
+ {
14
+ label: 'UK Business & Economy',
15
+ url: '/uk-business-economy',
16
+ submenu: null
17
+ },
18
+ {
19
+ label: 'UK Politics & Policy',
20
+ url: '/world/uk/politics',
21
+ submenu: null
22
+ },
23
+ {
24
+ label: 'UK Companies',
25
+ url: '/companies/uk',
26
+ submenu: null
27
+ }
28
+ ]
29
+
30
+ const ancestors: TNavMenuItem[] = [
31
+ {
32
+ label: 'World',
33
+ url: '/world'
34
+ }
35
+ ]
36
+
37
+ export default { item, siblings, children, ancestors }
@@ -0,0 +1,13 @@
1
+ import { TNavMenu } from '@financial-times/dotcom-types-navigation'
2
+
3
+ const data: TNavMenu = {
4
+ label: 'User',
5
+ items: [
6
+ { label: 'Help Centre', url: 'http://help.ft.com', submenu: null },
7
+ { label: 'Settings & Account', url: 'https://www.ft.com/myaccount', submenu: null },
8
+ { label: 'Contact Preferences', url: '/myft/alerts', submenu: null },
9
+ { label: 'Sign Out', url: '/logout', submenu: null }
10
+ ]
11
+ }
12
+
13
+ export default data
@@ -0,0 +1,163 @@
1
+ import React from 'react'
2
+ import * as header from '../../browser.js'
3
+ import { OnReady } from '../../../../.storybook/components/OnReady'
4
+ import {
5
+ Header as HeaderSimple,
6
+ Header as HeaderLarge,
7
+ Drawer,
8
+ StickyHeader,
9
+ LogoOnly,
10
+ NoOutboundLinksHeader
11
+ } from '../../src'
12
+ import storyData from './story-data'
13
+ import profileStoryData from './story-data/profile'
14
+ import '../../styles.scss'
15
+ import './demos.scss'
16
+
17
+ const onReadyCallback = () => {
18
+ // Passing a cors-anywhere hostname to n-topic-search
19
+ // An 'origin' request header will be set on the subsequent fetch request to next-search-api
20
+ // This satisfies the api's cors rules allowing a response to be sent and rendered on localhost
21
+ header.init({ hostName: 'cors-anywhere.herokuapp.com/www.ft.com' })
22
+ }
23
+
24
+ export default {
25
+ title: 'FT / Header',
26
+ args: {
27
+ currentPath: '/'
28
+ },
29
+ argTypes: {
30
+ currentPath: {
31
+ control: {
32
+ type: 'radio',
33
+ options: { show: '/', hide: '/404' }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ export const DefaultHeaderWithDrawer = (args) => (
40
+ <OnReady callback={onReadyCallback}>
41
+ <HeaderSimple {...storyData} {...args} />
42
+ <Drawer {...storyData} {...args} />
43
+ </OnReady>
44
+ )
45
+
46
+ DefaultHeaderWithDrawer.story = {
47
+ name: 'Default header with drawer'
48
+ }
49
+ DefaultHeaderWithDrawer.args = {
50
+ showSubNavigation: true,
51
+ showMegaNav: true,
52
+ showUserNavigation: true,
53
+ userIsLoggedIn: false,
54
+ userIsSubscribed: false,
55
+ showLogoLink: false
56
+ }
57
+
58
+ export const DefaultHeaderWithRightAlignedSubnav = (args) => (
59
+ <OnReady callback={onReadyCallback}>
60
+ <HeaderSimple {...profileStoryData} {...args} />
61
+ <Drawer {...profileStoryData} {...args} />
62
+ </OnReady>
63
+ )
64
+
65
+ DefaultHeaderWithRightAlignedSubnav.story = {
66
+ name: 'Default header with right aligned subnav'
67
+ }
68
+ DefaultHeaderWithRightAlignedSubnav.args = {
69
+ showSubNavigation: true,
70
+ showMegaNav: true,
71
+ showUserNavigation: true,
72
+ userIsLoggedIn: true,
73
+ showLogoLink: false
74
+ }
75
+
76
+ export const LargeHeaderWithDrawer = (args) => (
77
+ <OnReady callback={onReadyCallback}>
78
+ <HeaderLarge {...storyData} {...args} />
79
+ <Drawer {...storyData} {...args} />
80
+ </OnReady>
81
+ )
82
+
83
+ LargeHeaderWithDrawer.story = {
84
+ name: 'Large header with drawer'
85
+ }
86
+ LargeHeaderWithDrawer.story = {
87
+ name: 'Default header with drawer'
88
+ }
89
+ LargeHeaderWithDrawer.args = {
90
+ showSubNavigation: true,
91
+ showMegaNav: true,
92
+ showUserNavigation: true,
93
+ userIsLoggedIn: false,
94
+ variant: 'large-logo'
95
+ }
96
+
97
+ export const _StickyHeader = (args) => (
98
+ <OnReady callback={() => header.init()}>
99
+ <StickyHeader {...storyData} {...args} />
100
+ <p className="demo-sticky-message demo-sticky-message--scroll">Scroll down</p>
101
+ </OnReady>
102
+ )
103
+
104
+ _StickyHeader.story = {
105
+ name: 'Sticky header'
106
+ }
107
+ _StickyHeader.args = {
108
+ showUserNavigation: true,
109
+ userIsLoggedIn: false,
110
+ userIsSubscribed: false,
111
+ showStickyHeader: false
112
+ }
113
+ _StickyHeader.argTypes = {
114
+ currentPath: {
115
+ table: {
116
+ disable: true
117
+ }
118
+ }
119
+ }
120
+
121
+ export const _LogoOnly = (args) => {
122
+ return <LogoOnly {...args} />
123
+ }
124
+
125
+ _LogoOnly.story = {
126
+ name: 'Logo only'
127
+ }
128
+ _LogoOnly.args = {
129
+ variant: 'simple',
130
+ showLogoLink: false
131
+ }
132
+ _LogoOnly.argTypes = {
133
+ variant: {
134
+ control: {
135
+ type: 'radio',
136
+ options: { default: 'simple', large: 'large' }
137
+ }
138
+ },
139
+ currentPath: {
140
+ table: {
141
+ disable: true
142
+ }
143
+ }
144
+ }
145
+
146
+ export const NoOutboundLinks = (args) => <NoOutboundLinksHeader {...storyData} {...args} />
147
+
148
+ NoOutboundLinks.story = {
149
+ name: 'No Outbound links'
150
+ }
151
+ NoOutboundLinks.args = {
152
+ showSubNavigation: true,
153
+ showUserNavigation: true,
154
+ userIsLoggedIn: false,
155
+ showLogoLink: false
156
+ }
157
+ NoOutboundLinks.argTypes = {
158
+ currentPath: {
159
+ table: {
160
+ disable: true
161
+ }
162
+ }
163
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import renderer from 'react-test-renderer'
3
+ import fixture from '../../__stories__/story-data/index'
4
+ import { Drawer as Subject } from '../../index'
5
+
6
+ const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
7
+ const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
8
+
9
+ describe('dotcom-ui-header/src/components/Drawer', () => {
10
+ it('renders as an anonymous user', () => {
11
+ const tree = renderer.create(<Subject {...propsAnonymous} />).toJSON()
12
+ expect(tree).toMatchSnapshot()
13
+ })
14
+
15
+ it('renders as a logged in user', () => {
16
+ const tree = renderer.create(<Subject {...propsLoggedIn} />).toJSON()
17
+ expect(tree).toMatchSnapshot()
18
+ })
19
+ })
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import renderer from 'react-test-renderer'
3
+ import fixture from '../../__stories__/story-data/index'
4
+ import profileFixture from '../../__stories__/story-data/profile'
5
+ import { MainHeader as Subject } from '../../index'
6
+
7
+ const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
8
+ const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
9
+ const propsRightAligned = { ...profileFixture }
10
+
11
+ describe('dotcom-ui-header/src/components/MainHeader', () => {
12
+ it('renders as an anonymous user', () => {
13
+ const tree = renderer.create(<Subject {...propsAnonymous} />).toJSON()
14
+ expect(tree).toMatchSnapshot()
15
+ })
16
+
17
+ it('renders as a logged in user', () => {
18
+ const tree = renderer.create(<Subject {...propsLoggedIn} />).toJSON()
19
+ expect(tree).toMatchSnapshot()
20
+ })
21
+
22
+ it('renders a right aligned subnav', () => {
23
+ const tree = renderer.create(<Subject {...propsRightAligned} />).toJSON()
24
+ expect(tree).toMatchSnapshot()
25
+ })
26
+ })
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import renderer from 'react-test-renderer'
3
+ import fixture from '../../__stories__/story-data/index'
4
+ import { NoOutboundLinksHeader as Subject } from '../../index'
5
+
6
+ const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
7
+ const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
8
+
9
+ describe('dotcom-ui-header/src/components/NoOutboundLinksHeader', () => {
10
+ it('renders as an anonymous user', () => {
11
+ const tree = renderer.create(<Subject {...propsAnonymous} />).toJSON()
12
+ expect(tree).toMatchSnapshot()
13
+ })
14
+
15
+ it('renders as a logged in user', () => {
16
+ const tree = renderer.create(<Subject {...propsLoggedIn} />).toJSON()
17
+ expect(tree).toMatchSnapshot()
18
+ })
19
+ })
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import renderer from 'react-test-renderer'
3
+ import fixture from '../../__stories__/story-data/index'
4
+ import { StickyHeader as Subject } from '../../index'
5
+
6
+ const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
7
+ const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
8
+
9
+ describe('dotcom-ui-header/src/components/StickyHeader', () => {
10
+ it('renders as an anonymous user', () => {
11
+ const tree = renderer.create(<Subject {...propsAnonymous} />).toJSON()
12
+ expect(tree).toMatchSnapshot()
13
+ })
14
+
15
+ it('renders as a logged in user', () => {
16
+ const tree = renderer.create(<Subject {...propsLoggedIn} />).toJSON()
17
+ expect(tree).toMatchSnapshot()
18
+ })
19
+ })