@financial-times/dotcom-ui-header 7.2.7 → 7.3.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.
Files changed (30) 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/drawer/topLevelPartials.js +17 -18
  4. package/dist/node/components/navigation/partials.d.ts +8 -0
  5. package/dist/node/components/search/partials.d.ts +5 -0
  6. package/dist/node/components/sticky/partials.d.ts +10 -0
  7. package/dist/node/components/sub-navigation/partials.d.ts +4 -0
  8. package/dist/node/components/svg-components/BrandFtMasthead.d.ts +6 -0
  9. package/dist/node/components/top/partials.d.ts +24 -0
  10. package/dist/node/index.d.ts +38 -0
  11. package/dist/node/utils.d.ts +2 -0
  12. package/dist/tsconfig.tsbuildinfo +2124 -0
  13. package/package.json +10 -8
  14. package/screenshots/header-navigation.png +0 -0
  15. package/screenshots/header-sub-navigation.png +0 -0
  16. package/screenshots/header-top-search.png +0 -0
  17. package/scripts/convertSvgsToReactComponents.js +0 -23
  18. package/src/components/drawer/additionalPartials.tsx +0 -105
  19. package/src/components/drawer/topLevelPartials.tsx +0 -165
  20. package/src/components/navigation/partials.tsx +0 -192
  21. package/src/components/search/partials.tsx +0 -52
  22. package/src/components/sticky/partials.tsx +0 -164
  23. package/src/components/sub-navigation/partials.tsx +0 -106
  24. package/src/components/svg-components/BrandFtMasthead.tsx +0 -16
  25. package/src/components/top/partials.tsx +0 -189
  26. package/src/header.scss +0 -29
  27. package/src/index.tsx +0 -123
  28. package/src/interfaces.d.ts +0 -19
  29. package/src/utils.ts +0 -5
  30. package/styles.scss +0 -14
@@ -1,164 +0,0 @@
1
- /* WARN: This file looks similar to ../top/partials */
2
- /* This is the sticky header variant */
3
-
4
- import React from 'react'
5
- import { SubscribeButton, SignInLink } from '../top/partials'
6
- import { THeaderProps } from '../../interfaces'
7
-
8
- const StickyHeaderWrapper = (props: THeaderProps & { children: React.ReactNode }) => (
9
- <header
10
- className={`o-header o-header--simple o-header--sticky o--if-js`}
11
- data-o-component="o-header"
12
- data-o-header--sticky
13
- aria-hidden="true"
14
- >
15
- {props.children}
16
- </header>
17
- )
18
-
19
- const DrawerIconSticky = () => (
20
- <a
21
- href="#"
22
- className="o-header__top-icon-link o-header__top-icon-link--menu"
23
- aria-controls="o-header-drawer"
24
- data-trackable="drawer-toggle"
25
- tabIndex={-1}
26
- >
27
- <span className="o-header__top-link-label">Menu</span>
28
- </a>
29
- )
30
-
31
- const SearchIconSticky = () => (
32
- <a
33
- href="#"
34
- className="o-header__top-icon-link o-header__top-icon-link--search"
35
- aria-controls="o-header-search-sticky"
36
- data-trackable="search-toggle"
37
- tabIndex={-1}
38
- >
39
- <span className="o-header__top-link-label">Search</span>
40
- </a>
41
- )
42
-
43
- const Navigation = (props: THeaderProps) => (
44
- <div className="o-header__top-takeover">
45
- <div className="o-header__nav">
46
- <ul className="o-header__nav-list o-header__nav-list--left" data-trackable="primary-nav">
47
- {props.data.navbar.items.map((item, index) => (
48
- <li className="o-header__nav-item" key={`link-${index}`}>
49
- <a
50
- className="o-header__nav-link o-header__nav-link--primary"
51
- href={item.url ?? undefined}
52
- data-trackable={item.label}
53
- tabIndex={-1}
54
- >
55
- {item.label}
56
- </a>
57
- </li>
58
- ))}
59
- </ul>
60
- </div>
61
- </div>
62
- )
63
-
64
- const Logo = () => (
65
- <a
66
- className="o-header__top-logo o-header__hide--L"
67
- data-trackable="logo"
68
- href="/"
69
- title="Go to Financial Times homepage"
70
- tabIndex={-1}
71
- >
72
- <span className="o-header__visually-hidden">Financial Times</span>
73
- </a>
74
- )
75
-
76
- const NavListRightAnonSticky = (props: THeaderProps) => {
77
- // If user is anonymous the second list item is styled as a button
78
- const [signInAction, subscribeAction] = props.data['navbar-right-anon'].items
79
- return (
80
- <div className="o-header__nav">
81
- <div className="o-header__top-column o-header__top-column--right">
82
- {subscribeAction && (
83
- <SubscribeButton item={subscribeAction} variant="sticky" className="o-header__top-button--hide-m" />
84
- )}
85
- {signInAction && <SignInLink item={signInAction} variant="sticky" className="" />}
86
- </div>
87
- </div>
88
- )
89
- }
90
-
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
- )
101
-
102
- const TopWrapperSticky = (props) => (
103
- <div className="o-header__row o-header__top" data-trackable="header-sticky">
104
- <div className="o-header__container">
105
- <div className="o-header__top-wrapper">{props.children}</div>
106
- </div>
107
- </div>
108
- )
109
-
110
- const TopColumnLeftSticky = () => {
111
- return (
112
- <div className="o-header__top-column o-header__top-column--left">
113
- <DrawerIconSticky />
114
- <SearchIconSticky />
115
- </div>
116
- )
117
- }
118
- const TopColumnCenterSticky = (props: THeaderProps) => {
119
- return (
120
- <div className="o-header__top-column o-header__top-column--center">
121
- <Navigation {...props} />
122
- <Logo />
123
- </div>
124
- )
125
- }
126
-
127
- const NavListRightLoggedInSticky = (props: THeaderProps) => {
128
- const subscribeAction = props.data['navbar-right-anon'].items?.[1]
129
- return (
130
- <React.Fragment>
131
- {!props.userIsSubscribed && subscribeAction && (
132
- <SubscribeButton
133
- item={subscribeAction}
134
- variant={props.variant}
135
- className="o-header__top-button--hide-m"
136
- />
137
- )}
138
- <MyFtSticky className="" />
139
- </React.Fragment>
140
- )
141
- }
142
-
143
- // This behaviour is similar to `NavListRight` in '../navigation/partials' but:
144
- // - The sticky header renders either the `navbar-right-anon` data or the myFT component
145
- // - The normal header renders either the `navbar-right-anon` or the `navbar-right` data
146
- const TopColumnRightSticky = (props: THeaderProps) => {
147
- let children: JSX.Element | undefined = undefined
148
-
149
- if (props.userIsLoggedIn) {
150
- children = <NavListRightLoggedInSticky {...props} />
151
- } else if (props.showUserNavigation) {
152
- children = <NavListRightAnonSticky {...props} />
153
- }
154
-
155
- return <div className="o-header__top-column o-header__top-column--right">{children}</div>
156
- }
157
-
158
- export {
159
- StickyHeaderWrapper,
160
- TopWrapperSticky,
161
- TopColumnLeftSticky,
162
- TopColumnCenterSticky,
163
- TopColumnRightSticky
164
- }
@@ -1,106 +0,0 @@
1
- import React from 'react'
2
- import { ariaSelected } from '../../utils'
3
- import { THeaderProps } from '../../interfaces'
4
- import { TNavMenuItem } from '@financial-times/dotcom-types-navigation'
5
-
6
- const SubNavigation = (props: THeaderProps) => (
7
- <SubNavigationWrapper>
8
- <BreadCrumb items={props.data.breadcrumb} />
9
- <SubSections items={props.data.subsections} />
10
- <SubSections items={props.data['subsections-right']} rightAlignment={true} />
11
- </SubNavigationWrapper>
12
- )
13
-
14
- const SubNavigationWrapper = (props) => (
15
- <div
16
- className="o-header__subnav"
17
- role="navigation"
18
- aria-label="Sub navigation"
19
- data-o-header-subnav
20
- data-trackable="header-subnav"
21
- >
22
- <div className="o-header__container">
23
- <div className="o-header__subnav-wrap-outside">
24
- <div className="o-header__subnav-wrap-inside" data-o-header-subnav-wrapper>
25
- <div className="o-header__subnav-content">{props.children}</div>
26
- </div>
27
- {/* Implements subNavigation scrolling at smaller viewports */}
28
- <button
29
- className="o-header__subnav-button o-header__subnav-button--left"
30
- title="scroll left"
31
- aria-label="scroll left"
32
- aria-hidden="true"
33
- disabled
34
- />
35
- <button
36
- className="o-header__subnav-button o-header__subnav-button--right"
37
- title="scroll right"
38
- aria-label="scroll right"
39
- aria-hidden="true"
40
- disabled
41
- />
42
- </div>
43
- </div>
44
- </div>
45
- )
46
-
47
- const BreadCrumb = ({ items }: { items?: TNavMenuItem[] }) => (
48
- <ol
49
- className="o-header__subnav-list o-header__subnav-list--breadcrumb"
50
- aria-label="Breadcrumb"
51
- data-trackable="breadcrumb"
52
- >
53
- {items?.map((item, index) => {
54
- const selected = item.selected ? 'o-header__subnav-link--highlight' : ''
55
-
56
- return (
57
- <li className="o-header__subnav-item" key={`item-${index}`}>
58
- <a
59
- className={`o-header__subnav-link ${selected}`}
60
- href={item.url ?? undefined}
61
- {...ariaSelected(item)}
62
- data-trackable={item.label}
63
- >
64
- {item.label}
65
- </a>
66
- </li>
67
- )
68
- })}
69
- </ol>
70
- )
71
-
72
- const SubSections = ({ items, rightAlignment }: { items?: TNavMenuItem[]; rightAlignment?: boolean }) => {
73
- if (!items || items.length === 0) {
74
- return null
75
- }
76
-
77
- return (
78
- <ul
79
- className={
80
- 'o-header__subnav-list o-header__subnav-list--children' +
81
- (rightAlignment ? ' o-header__subnav-list--right' : '')
82
- }
83
- aria-label={rightAlignment ? 'Additional Sub Navigation' : 'Subsections'}
84
- data-trackable="subsections"
85
- >
86
- {items.map((item, index) => {
87
- const selected = item.selected ? 'o-header__subnav-link--highlight' : ''
88
-
89
- return (
90
- <li className="o-header__subnav-item" key={`item-${index}`}>
91
- <a
92
- className={`o-header__subnav-link ${selected}`}
93
- href={item.url ?? undefined}
94
- {...ariaSelected(item)}
95
- data-trackable={item.label}
96
- >
97
- {item.label}
98
- </a>
99
- </li>
100
- )
101
- })}
102
- </ul>
103
- )
104
- }
105
-
106
- export { SubNavigation }
@@ -1,16 +0,0 @@
1
- // **THIS IS AN AUTO-GENERATED FILE (`npm run build:svg-to-react`) - DO NOT EDIT MANUALLY.**
2
-
3
- import React from 'react'
4
-
5
- const BrandFtMasthead = ({ title, ...props }) => (
6
- <svg viewBox="0 0 1054 86" {...props}>
7
- {title === undefined ? <title>{'brand-ft-masthead'}</title> : title ? <title>{title}</title> : null}
8
- <path
9
- d="M26.177 72.609c0 5.938 1.697 7.295 12.554 7.295v3.732H.9v-3.732c7.464 0 10.01-.679 10.01-7.125V12.215c0-6.447-2.546-7.126-10.01-7.126V1.357h63.448l.34 22.563h-3.054C59.937 6.956 55.696 5.43 39.919 5.43H26.008v33.59h11.196c10.688 0 11.367-1.697 12.215-10.179h3.054v24.599h-3.054c-.848-8.482-1.527-10.01-12.215-10.01H26.008v29.18h.17zm46.314 11.027v-3.732c7.465 0 10.01-.679 10.01-7.125V12.215c0-6.447-2.545-7.126-10.01-7.126V1.357h35.287V5.09c-7.465 0-10.01.679-10.01 7.126v60.564c0 6.446 2.545 7.125 10.01 7.125v3.732H72.49zm115.36 1.357l-56.323-69.725V72.44c0 6.617 4.58 7.634 12.385 7.634v3.733h-29.858v-3.733c7.803 0 12.045-1.017 12.045-7.634V8.991c-3.563-3.732-6.108-3.902-12.045-3.902V1.357h26.465l43.09 55.475V12.554c0-6.616-4.58-7.634-12.384-7.634V1.357h30.027V5.09c-7.803 0-12.045 1.018-12.045 7.635v72.27h-1.357zm40.207-1.357h-29.689v-3.732c7.804 0 11.367-1.018 13.911-7.804L239.085.509h7.464l28.84 72.1c2.545 6.447 3.732 7.125 9.67 7.125v3.732h-34.438v-3.732c10.518 0 11.536-.848 8.99-7.125l-8.481-21.884h-25.787L217.71 71.93c-2.375 6.447 1.357 7.804 10.518 7.804v3.902h-.17zm-1.188-37.153h22.393l-11.705-29.518-10.688 29.518zm135.548 38.51l-56.153-69.725V72.44c0 6.617 4.58 7.634 12.384 7.634v3.733h-29.18v-3.733c7.126 0 11.367-1.017 11.367-7.634V9.161c-4.071-3.732-7.125-4.072-13.91-4.072V1.357h28.16l43.09 55.475V12.554c0-6.616-4.58-7.634-12.383-7.634V1.357h29.858V5.09c-7.804 0-12.045 1.018-12.045 7.635v72.27h-1.188zm83.297-83.805h2.036l1.187 24.598-3.053.17c-2.036-14.08-9.5-21.545-23.242-21.545-15.268 0-26.804 13.063-26.804 33.081 0 25.617 16.116 40.206 33.08 40.206 7.296 0 13.912-2.035 20.358-8.99l2.376 2.374c-5.26 7.465-15.608 13.742-29.52 13.742-20.696 0-41.732-15.608-41.732-41.734C380.4 17.813 399.57 0 422.813 0c11.027 0 16.795 4.75 19.848 4.75 1.357 0 2.375-1.187 3.054-3.562zm12.723 82.448v-3.732c7.465 0 10.01-.679 10.01-7.125V12.215c0-6.447-2.545-7.126-10.01-7.126V1.357h35.287V5.09c-7.464 0-10.01.679-10.01 7.126v60.564c0 6.446 2.546 7.125 10.01 7.125v3.732h-35.287zm68.538 0h-27.653v-3.732c6.108 0 9.331-1.018 11.876-7.804L538.003.509h7.464l28.84 72.1c2.545 6.447 3.733 7.125 9.67 7.125v3.732H549.54v-3.732c10.518 0 11.536-.848 8.991-7.125l-8.482-21.884h-25.786l-7.635 21.205c-2.375 6.447 1.358 7.804 10.519 7.804v3.902h-.17zm-1.188-37.153h22.394l-11.536-29.518-10.858 29.518zm63.957 37.153v-3.732c7.465 0 10.01-.679 10.01-7.125V12.215c0-6.447-2.545-7.126-10.01-7.126V1.357h35.117V5.09c-7.464 0-9.84.679-9.84 7.126v61.073c0 5.428 2.715 6.107 7.126 6.107h4.241c15.947 0 21.036-2.375 25.447-20.527l3.054.339-2.545 24.26h-62.6v.17zM760.75 1.357l.339 23.92h-3.054C756.34 7.634 752.098 5.43 736.32 5.43h-5.089v67.18c0 6.447 2.375 7.295 12.554 7.295v3.732h-40.376v-3.732c10.179 0 12.723-1.018 12.723-7.295V5.429h-5.089c-15.777 0-20.018 2.205-21.715 19.848h-3.053l.339-23.92h74.136zm7.973 82.28v-3.733c7.465 0 10.01-.679 10.01-7.125V12.215c0-6.447-2.545-7.126-10.01-7.126V1.357h35.287V5.09c-7.465 0-10.01.679-10.01 7.126v60.564c0 6.446 2.545 7.125 10.01 7.125v3.732h-35.287zM910.21 1.356V5.09c-7.465 0-10.688.34-10.01 6.956l6.447 61.073c.679 6.277 3.054 6.955 10.518 6.955v3.733h-35.117v-3.733c7.295 0 9.84-.678 9.331-6.955L884.762 8.99l-25.956 76.172h-1.018L832.34 8.822l-6.108 64.126c-.678 6.447 3.733 7.125 11.197 7.125v3.733h-27.483v-3.733c7.465 0 10.01-1.187 10.518-7.125l6.447-61.073c.679-6.446-2.545-6.955-10.01-6.955V1.357h28.84l17.305 56.153 18.661-56.153h28.5zm65.653 52.082h-3.053c-.849-8.482-1.527-10.01-12.215-10.01H948.04v29.859c0 5.428 2.715 6.107 7.125 6.107h6.786c15.947 0 21.036-2.375 25.447-20.527l3.054.339-2.884 24.26h-64.805v-3.733c7.464 0 10.009-.678 10.009-7.125V12.215c0-6.447-2.545-7.126-10.01-7.126V1.357h62.261l.34 20.527h-3.054c-1.866-14.59-5.598-16.286-21.885-16.286H948.21v33.42h12.554c10.687 0 11.366-1.696 12.214-10.178h3.054v24.599h-.17zm65.484 13.232c0-7.464-4.75-11.196-12.893-15.777l-13.063-6.786c-9.84-5.259-15.607-11.027-15.607-21.375C999.783 9.84 1010.81 0 1025.23 0c9.84 0 14.929 4.75 17.813 4.75 1.866 0 2.714-1.187 3.562-3.562h2.375l1.188 23.072-3.054.17c-1.696-11.198-9.67-19.85-20.866-19.85-8.483 0-14.081 5.09-14.081 12.215 0 7.804 5.937 11.027 12.554 14.59l11.196 5.937c10.519 5.768 17.983 11.536 17.983 22.563 0 14.59-12.554 24.939-28.161 24.939-11.028 0-16.456-5.26-19.34-5.26-1.866 0-2.884 1.697-3.732 4.242h-2.376l-1.696-24.43 3.054-.339c2.375 15.268 12.893 21.545 23.411 21.545 8.822-.17 16.286-4.071 16.286-13.91z"
10
- fill="#231F20"
11
- fillRule="evenodd"
12
- />
13
- </svg>
14
- )
15
-
16
- export default BrandFtMasthead
@@ -1,189 +0,0 @@
1
- import React from 'react'
2
- import { THeaderProps } from '../../interfaces'
3
- import BrandFtMastheadSvg from '../svg-components/BrandFtMasthead'
4
- import { TNavMenuItem } from '@financial-times/dotcom-types-navigation'
5
-
6
- const HeaderWrapper = (props) => (
7
- <header
8
- id="site-navigation"
9
- className={`o-header o-header--${props.variant || 'simple'}`}
10
- data-o-component="o-header"
11
- data-o-header--no-js={true}
12
- tabIndex={-1}
13
- >
14
- {props.children}
15
- </header>
16
- )
17
-
18
- const DrawerIcon = () => (
19
- <a
20
- href="#o-header-drawer"
21
- className="o-header__top-icon-link o-header__top-icon-link--menu"
22
- aria-controls="o-header-drawer"
23
- title="Open side navigation menu"
24
- data-trackable="drawer-toggle"
25
- >
26
- <span className="o-header__top-link-label">Open side navigation menu</span>
27
- </a>
28
- )
29
-
30
- const SearchIcon = () => (
31
- <a
32
- href={`#o-header-search-primary`}
33
- className="o-header__top-icon-link o-header__top-icon-link--search"
34
- aria-controls={`o-header-search-primary`}
35
- title="Open search bar"
36
- data-trackable="search-toggle"
37
- >
38
- <span className="o-header__top-link-label">Open search bar</span>
39
- </a>
40
- )
41
-
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
- )
54
-
55
- const TopWrapper = (props) => (
56
- <div className="o-header__row o-header__top" data-trackable="header-top">
57
- <div className="o-header__container">
58
- <div className="o-header__top-wrapper">{props.children}</div>
59
- </div>
60
- </div>
61
- )
62
-
63
- const TopColumnLeft = () => (
64
- <div className="o-header__top-column o-header__top-column--left">
65
- <DrawerIcon />
66
- <SearchIcon />
67
- </div>
68
- )
69
-
70
- const TopColumnCenter = () => (
71
- <div className="o-header__top-column o-header__top-column--center">
72
- <a
73
- className="o-header__top-logo"
74
- style={{ backgroundImage: 'none' }}
75
- data-trackable="logo"
76
- href="/"
77
- title="Go to Financial Times homepage"
78
- >
79
- <BrandFtMastheadSvg title="Financial Times" />
80
- </a>
81
- </div>
82
- )
83
-
84
- const TopColumnCenterNoLink = () => (
85
- <div className="o-header__top-column o-header__top-column--center">
86
- <div className="o-header__top-logo" style={{ backgroundImage: 'none' }}>
87
- <BrandFtMastheadSvg title="Financial Times" />
88
- </div>
89
- </div>
90
- )
91
-
92
- const TopColumnRightLoggedIn = (props: THeaderProps) => {
93
- const subscribeAction = props.data['navbar-right-anon']?.items?.[1]
94
- return (
95
- <div className="o-header__top-column o-header__top-column--right">
96
- {!props.userIsSubscribed && subscribeAction && (
97
- <SubscribeButton
98
- item={subscribeAction}
99
- variant={props.variant}
100
- className="o-header__top-button--hide-m"
101
- />
102
- )}
103
- <MyFt className="" />
104
- </div>
105
- )
106
- }
107
-
108
- const SignInLink = ({
109
- item,
110
- variant,
111
- className
112
- }: {
113
- item: TNavMenuItem
114
- variant?: string
115
- className?: string
116
- }) => {
117
- const setTabIndex = variant === 'sticky' ? { tabIndex: -1 } : null
118
- return (
119
- <a
120
- className={`o-header__top-link ${className}`}
121
- href={item.url ?? undefined}
122
- data-trackable={item.label}
123
- {...setTabIndex}
124
- >
125
- {item.label}
126
- </a>
127
- )
128
- }
129
- const SubscribeButton = ({
130
- item,
131
- variant,
132
- className
133
- }: {
134
- item: TNavMenuItem
135
- variant?: string
136
- className?: string
137
- }) => {
138
- const setTabIndex = variant === 'sticky' ? { tabIndex: -1 } : null
139
- return (
140
- <a
141
- className={`o-header__top-button ${className}`}
142
- // Added as the result of a DAC audit. This will be confusing for users of voice activation software
143
- // as it looks like a button but behaves like a link without this role.
144
- role="button"
145
- href={item.url ?? undefined}
146
- data-trackable={item.label}
147
- {...setTabIndex}
148
- >
149
- {item.label}
150
- </a>
151
- )
152
- }
153
-
154
- const TopColumnRightAnon = ({ items, variant }: { items: TNavMenuItem[]; variant?: string }) => {
155
- // If user is anonymous the second list item is styled as a button
156
- const [signInAction, subscribeAction] = items
157
- return (
158
- <div className="o-header__top-column o-header__top-column--right">
159
- {subscribeAction && (
160
- <SubscribeButton item={subscribeAction} variant={variant} className="o-header__top-button--hide-m" />
161
- )}
162
- {signInAction && (
163
- <SignInLink item={signInAction} variant={variant} className="o-header__top-link--hide-m" />
164
- )}
165
- <MyFt className="o-header__top-icon-link--show-m" />
166
- </div>
167
- )
168
- }
169
-
170
- const TopColumnRight = (props: THeaderProps) => {
171
- if (props.userIsLoggedIn) {
172
- return <TopColumnRightLoggedIn {...props} />
173
- } else {
174
- const userNavAnonItems = props.data['navbar-right-anon'].items
175
- return <TopColumnRightAnon items={userNavAnonItems} variant={props.variant} />
176
- }
177
- }
178
-
179
- export {
180
- HeaderWrapper,
181
- TopWrapper,
182
- TopColumnLeft,
183
- TopColumnCenter,
184
- TopColumnCenterNoLink,
185
- TopColumnRight,
186
- TopColumnRightAnon,
187
- SubscribeButton,
188
- SignInLink
189
- }
package/src/header.scss DELETED
@@ -1,29 +0,0 @@
1
- // Search
2
- // At the time of writing o-header duplicates search markup.
3
- // Once for a core experience, once for an enhanced experience.
4
- // The enhanced version is hidden until toggled with JavaScript.
5
- // Instead since we can rely on the `core` class we can use the
6
- // one enhanced experience search block and reveal for the core
7
- // experience if needed.
8
- .core [data-o-header-search] {
9
- display: block;
10
- }
11
-
12
- // z-indexes
13
- .o-header__mega {
14
- @include nUiZIndexFor('meganav');
15
- }
16
-
17
- .o-header__drawer {
18
- @include nUiZIndexFor('drawer');
19
- display: block;
20
- }
21
-
22
- .o-header--sticky {
23
- @include nUiZIndexFor('sticky-header');
24
- }
25
-
26
- // Search typeahead
27
- .n-typeahead {
28
- display: none;
29
- }
package/src/index.tsx DELETED
@@ -1,123 +0,0 @@
1
- import React from 'react'
2
- import {
3
- HeaderWrapper,
4
- TopWrapper,
5
- TopColumnLeft,
6
- TopColumnCenter,
7
- TopColumnCenterNoLink,
8
- TopColumnRight
9
- } from './components/top/partials'
10
- import {
11
- NavListLeft,
12
- NavListRight,
13
- NavDesktop,
14
- UserActionsNav,
15
- MobileNav
16
- } from './components/navigation/partials'
17
- import {
18
- StickyHeaderWrapper,
19
- TopWrapperSticky,
20
- TopColumnCenterSticky,
21
- TopColumnLeftSticky,
22
- TopColumnRightSticky
23
- } from './components/sticky/partials'
24
- import { SubNavigation } from './components/sub-navigation/partials'
25
- import { IncludeDrawer } from './components/drawer/topLevelPartials'
26
- import { Search } from './components/search/partials'
27
-
28
- import { THeaderProps, THeaderOptions } from './interfaces'
29
-
30
- const defaultProps: Partial<THeaderOptions> = {
31
- showSubNavigation: true,
32
- showUserNavigation: true,
33
- userIsAnonymous: true,
34
- userIsLoggedIn: false,
35
- showStickyHeader: true,
36
- showMegaNav: true
37
- }
38
-
39
- function MainHeader(props: THeaderProps) {
40
- const includeUserActionsNav = props.showUserNavigation && !props.userIsLoggedIn
41
- const includeSubNavigation = props.showSubNavigation && (props.data.breadcrumb || props.data.subsections)
42
-
43
- return (
44
- <HeaderWrapper {...props}>
45
- {includeUserActionsNav ? <UserActionsNav {...props} /> : null}
46
- <TopWrapper>
47
- <TopColumnLeft />
48
- {props.showLogoLink ? <TopColumnCenter /> : <TopColumnCenterNoLink />}
49
- <TopColumnRight {...props} />
50
- </TopWrapper>
51
- <Search instance="primary" />
52
- <MobileNav {...props} />
53
- <NavDesktop>
54
- <NavListLeft {...props} />
55
- {props.showUserNavigation ? <NavListRight {...props} /> : null}
56
- </NavDesktop>
57
- {includeSubNavigation ? <SubNavigation {...props} /> : null}
58
- </HeaderWrapper>
59
- )
60
- }
61
-
62
- MainHeader.defaultProps = { ...defaultProps, showLogoLink: true }
63
-
64
- function StickyHeader(props: THeaderProps) {
65
- return props.showStickyHeader ? (
66
- <StickyHeaderWrapper {...props}>
67
- <TopWrapperSticky>
68
- <TopColumnLeftSticky />
69
- <TopColumnCenterSticky {...props} />
70
- <TopColumnRightSticky {...props} />
71
- </TopWrapperSticky>
72
- <Search instance="sticky" />
73
- </StickyHeaderWrapper>
74
- ) : null
75
- }
76
-
77
- StickyHeader.defaultProps = defaultProps
78
-
79
- function Header(props: THeaderProps) {
80
- return (
81
- <React.Fragment>
82
- <MainHeader {...props} />
83
- <StickyHeader {...props} />
84
- </React.Fragment>
85
- )
86
- }
87
-
88
- Header.defaultProps = defaultProps
89
-
90
- function LogoOnly(props: Pick<THeaderProps, 'variant' | 'showLogoLink'>) {
91
- return (
92
- <HeaderWrapper {...props}>
93
- <TopWrapper>{props.showLogoLink ? <TopColumnCenter /> : <TopColumnCenterNoLink />}</TopWrapper>
94
- </HeaderWrapper>
95
- )
96
- }
97
-
98
- LogoOnly.defaultProps = defaultProps
99
-
100
- function Drawer(props: THeaderProps) {
101
- return <IncludeDrawer {...props} />
102
- }
103
-
104
- Drawer.defaultProps = defaultProps
105
-
106
- function NoOutboundLinksHeader(props: THeaderProps) {
107
- const includeUserActionsNav = props.showUserNavigation && !props.userIsLoggedIn
108
- const includeSubNavigation = props.showSubNavigation && (props.data.breadcrumb || props.data.subsections)
109
-
110
- return (
111
- <HeaderWrapper {...props}>
112
- {includeUserActionsNav ? <UserActionsNav {...props} /> : null}
113
- <TopWrapper>{props.showLogoLink ? <TopColumnCenter /> : <TopColumnCenterNoLink />}</TopWrapper>
114
- <NavDesktop>{props.showUserNavigation ? <NavListRight {...props} /> : null}</NavDesktop>
115
- {includeSubNavigation ? <SubNavigation {...props} /> : null}
116
- </HeaderWrapper>
117
- )
118
- }
119
-
120
- NoOutboundLinksHeader.defaultProps = defaultProps
121
-
122
- export { Header, MainHeader, StickyHeader, LogoOnly, NoOutboundLinksHeader, Drawer }
123
- export type { THeaderProps }
@@ -1,19 +0,0 @@
1
- import { TNavigationData } from '@financial-times/dotcom-types-navigation'
2
-
3
- export type THeaderOptions = {
4
- variant?: THeaderVariant
5
- userIsAnonymous?: boolean
6
- userIsLoggedIn?: boolean
7
- userIsSubscribed?: boolean
8
- showSubNavigation?: boolean
9
- showUserNavigation?: boolean
10
- showStickyHeader?: boolean
11
- showMegaNav?: boolean
12
- showLogoLink?: boolean
13
- }
14
-
15
- export type THeaderProps = THeaderOptions & {
16
- data: TNavigationData
17
- }
18
-
19
- export type THeaderVariant = 'simple' | 'large-logo'
package/src/utils.ts DELETED
@@ -1,5 +0,0 @@
1
- import { HTMLAttributes } from 'react'
2
-
3
- export const ariaSelected = (item): HTMLAttributes<HTMLElement> | null => {
4
- return item.selected ? { 'aria-label': `${item.label}, current page`, 'aria-current': 'page' } : null
5
- }
package/styles.scss DELETED
@@ -1,14 +0,0 @@
1
- // This will be overridden by dotcom-ui-layout, it's necessary here for storybook builds
2
- $system-code: 'page-kit-header' !default;
3
-
4
- @import "n-ui-foundations/mixins";
5
-
6
- // We don't need the sub-brand or transparent header styles so disable them.
7
- // TODO: move drawer styles into a separate stylesheet which can be lazy loaded?
8
- @import "@financial-times/o-header/main";
9
- @include oHeader(('top', 'nav', 'subnav', 'search', 'megamenu', 'drawer', 'anon', 'sticky', 'simple'));
10
-
11
- @import "src/header";
12
-
13
- @import "n-topic-search/main";
14
- @include nTopicSearch;