@financial-times/dotcom-ui-header 9.3.4 → 9.4.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/README.md +1 -0
- package/dist/node/components/ask-ft/askFtButton.d.ts +7 -0
- package/dist/node/components/ask-ft/askFtButton.js +10 -0
- package/dist/node/components/drawer/topLevelPartials.js +5 -3
- package/dist/node/components/navigation/partials.js +4 -8
- package/dist/node/components/sticky/partials.d.ts +1 -1
- package/dist/node/components/sticky/partials.js +4 -2
- package/dist/node/components/top/partials.d.ts +2 -3
- package/dist/node/components/top/partials.js +16 -29
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +4 -3
- package/dist/tsconfig.tsbuildinfo +27 -12
- package/package.json +2 -2
- package/src/__stories__/story-data/index.ts +4 -0
- package/src/__stories__/story-data/navbarRight.ts +2 -2
- package/src/__stories__/story-data/navbarTopRight.ts +19 -0
- package/src/__stories__/story-data/navbarTopRightAnon.ts +19 -0
- package/src/__stories__/story-data/profile.ts +4 -0
- package/src/__stories__/story.tsx +7 -43
- package/src/__test__/components/Drawer.spec.tsx +6 -0
- package/src/__test__/components/MainHeader.spec.tsx +6 -0
- package/src/__test__/components/StickyHeader.spec.tsx +6 -0
- package/src/__test__/components/__snapshots__/Drawer.spec.tsx.snap +1377 -0
- package/src/__test__/components/__snapshots__/MainHeader.spec.tsx.snap +1873 -35
- package/src/__test__/components/__snapshots__/StickyHeader.spec.tsx.snap +318 -0
- package/src/__test__/output/component.spec.tsx +13 -10
- package/src/components/ask-ft/askFtButton.tsx +19 -0
- package/src/components/drawer/topLevelPartials.tsx +10 -2
- package/src/components/navigation/partials.tsx +0 -14
- package/src/components/sticky/partials.tsx +10 -6
- package/src/components/top/partials.tsx +23 -85
- package/src/header.scss +43 -1
- package/src/index.tsx +4 -3
- package/src/interfaces.d.ts +1 -6
package/README.md
CHANGED
|
@@ -76,6 +76,7 @@ All header components with the exception of `<LogoOnly />` require the following
|
|
|
76
76
|
| showSubNavigation | boolean | true | true | Show the sub-navigation component which may include the crumbtrail |
|
|
77
77
|
| showStickyHeader | boolean | true | true | Enable rendering of the sticky header component |
|
|
78
78
|
| showMegaNav | boolean | true | true | Enable rendering of the drop-down "mega-nav" |
|
|
79
|
+
| showAskButton | boolean | true | false | Enable rendering of the ASK button |
|
|
79
80
|
| data | object | false | | Navigation data for rendering the header links fetched from the navigation API |
|
|
80
81
|
|
|
81
82
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AskFtButton = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const AskFtButton = ({ id, className, dataTrackable }) => (react_1.default.createElement("a", { id: id, className: `ft-header__ask-ft-button ${className}`, "data-trackable": dataTrackable, href: "https://ask.ft.com", title: "ASK FT" },
|
|
9
|
+
react_1.default.createElement("span", { className: "ft-header__ask-ft-button-label" }, "Ask FT")));
|
|
10
|
+
exports.AskFtButton = AskFtButton;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.IncludeDrawer = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const additionalPartials_1 = require("./additionalPartials");
|
|
9
|
+
const askFtButton_1 = require("../ask-ft/askFtButton");
|
|
9
10
|
const IncludeDrawer = (props) => react_1.default.createElement(Drawer, Object.assign({}, props));
|
|
10
11
|
exports.IncludeDrawer = IncludeDrawer;
|
|
11
12
|
const Drawer = (props) => {
|
|
@@ -17,7 +18,7 @@ const Drawer = (props) => {
|
|
|
17
18
|
react_1.default.createElement("div", { className: "o-header__drawer-inner" },
|
|
18
19
|
react_1.default.createElement(DrawerTools, Object.assign({}, editions)),
|
|
19
20
|
!props.userIsSubscribed && subscribeAction && react_1.default.createElement(additionalPartials_1.SubscribeButton, Object.assign({}, subscribeAction)),
|
|
20
|
-
react_1.default.createElement(Search,
|
|
21
|
+
react_1.default.createElement(Search, Object.assign({}, props)),
|
|
21
22
|
react_1.default.createElement("nav", { className: "o-header__drawer-menu", "aria-label": "Edition switcher" }, editions && react_1.default.createElement(additionalPartials_1.EditionsSwitcher, Object.assign({}, editions))),
|
|
22
23
|
react_1.default.createElement("nav", { className: "o-header__drawer-menu o-header__drawer-menu--primary" },
|
|
23
24
|
primary ? react_1.default.createElement(SectionPrimary, Object.assign({}, primary)) : null,
|
|
@@ -31,14 +32,15 @@ const DrawerTools = (props) => (react_1.default.createElement("div", { className
|
|
|
31
32
|
react_1.default.createElement("a", { className: "o-header__drawer-tools-logo", href: "/", "data-trackable": "logo" },
|
|
32
33
|
react_1.default.createElement("span", { className: "o-header__visually-hidden" }, "Financial Times")),
|
|
33
34
|
props.current && react_1.default.createElement("p", { className: "o-header__drawer-current-edition" }, `${props.current.name} Edition`)));
|
|
34
|
-
const Search = () => (react_1.default.createElement("div", { className: "o-header__drawer-search" },
|
|
35
|
+
const Search = (props) => (react_1.default.createElement("div", { className: "o-header__drawer-search" },
|
|
35
36
|
react_1.default.createElement("form", { className: "o-header__drawer-search-form", action: "/search", role: "search", "aria-label": "Site search", "data-n-topic-search": true, "data-n-topic-search-categories": "concepts,equities", "data-n-topic-search-view-all": true },
|
|
36
37
|
react_1.default.createElement("label", { className: "o-header__visually-hidden", htmlFor: "o-header-drawer-search-term" },
|
|
37
38
|
"Search the ",
|
|
38
39
|
react_1.default.createElement("abbr", { title: "Financial Times" }, "FT")),
|
|
39
40
|
react_1.default.createElement("input", { className: "o-header__drawer-search-term", id: "o-header-drawer-search-term", name: "q", type: "text", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: false, placeholder: "Search the FT", "data-trackable": "search-term", "data-n-topic-search-input": true }),
|
|
40
41
|
react_1.default.createElement("button", { className: "o-header__drawer-search-submit", type: "submit", "data-trackable": "search-submit" },
|
|
41
|
-
react_1.default.createElement("span", { className: "o-header__visually-hidden" }, "Search"))
|
|
42
|
+
react_1.default.createElement("span", { className: "o-header__visually-hidden" }, "Search")),
|
|
43
|
+
props.showAskButton && (react_1.default.createElement(askFtButton_1.AskFtButton, { className: "ft-header__drawer-ask-ft-button", id: "ask-ft-button-drawer", dataTrackable: "ask-ft-button-drawer" })))));
|
|
42
44
|
const SectionPrimary = (props) => {
|
|
43
45
|
var _a;
|
|
44
46
|
const sectionId = props.label.toLowerCase().replace(' ', '-');
|
|
@@ -31,18 +31,14 @@ const NavListLeft = (props) => (react_1.default.createElement("ul", { className:
|
|
|
31
31
|
})));
|
|
32
32
|
exports.NavListLeft = NavListLeft;
|
|
33
33
|
const NavListRight = (props) => {
|
|
34
|
-
return props.userIsLoggedIn ? (react_1.default.createElement(NavListRightLoggedIn, { items: props.data['navbar-right'].items
|
|
34
|
+
return props.userIsLoggedIn ? (react_1.default.createElement(NavListRightLoggedIn, { items: props.data['navbar-right'].items })) : null;
|
|
35
35
|
};
|
|
36
36
|
exports.NavListRight = NavListRight;
|
|
37
|
-
const NavListRightLoggedIn = ({ items,
|
|
38
|
-
/**
|
|
39
|
-
* Accounts entry test
|
|
40
|
-
* In this rendering theres a hacky solution to replace "Settings & Account" with "MyFT Feed"
|
|
41
|
-
* Once the test is concluded the real data should be updated accordingly and the hack removed
|
|
42
|
-
*/
|
|
37
|
+
const NavListRightLoggedIn = ({ items, }) => {
|
|
43
38
|
return (react_1.default.createElement("ul", { "data-component": "nav-list--right", className: "o-header__nav-list o-header__nav-list--right", "data-trackable": "user-nav" }, items.map((item, index) => {
|
|
44
39
|
var _a;
|
|
45
|
-
return (react_1.default.createElement("li", { className: "o-header__nav-item", key: `link-${index}` },
|
|
40
|
+
return (react_1.default.createElement("li", { className: "o-header__nav-item", key: `link-${index}` },
|
|
41
|
+
react_1.default.createElement("a", { className: "o-header__nav-link", href: (_a = item.url) !== null && _a !== void 0 ? _a : undefined, "data-trackable": item.label }, item.label)));
|
|
46
42
|
})));
|
|
47
43
|
};
|
|
48
44
|
const MegaNav = ({ label, meganav, index }) => {
|
|
@@ -4,7 +4,7 @@ declare const StickyHeaderWrapper: (props: THeaderProps & {
|
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
}) => React.JSX.Element;
|
|
6
6
|
declare const TopWrapperSticky: (props: any) => React.JSX.Element;
|
|
7
|
-
declare const TopColumnLeftSticky: () => React.JSX.Element;
|
|
7
|
+
declare const TopColumnLeftSticky: (props: Pick<THeaderProps, 'showAskButton'>) => React.JSX.Element;
|
|
8
8
|
declare const TopColumnCenterSticky: (props: THeaderProps) => React.JSX.Element;
|
|
9
9
|
declare const TopColumnRightSticky: (props: THeaderProps) => React.JSX.Element;
|
|
10
10
|
export { StickyHeaderWrapper, TopWrapperSticky, TopColumnLeftSticky, TopColumnCenterSticky, TopColumnRightSticky };
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
exports.TopColumnRightSticky = exports.TopColumnCenterSticky = exports.TopColumnLeftSticky = exports.TopWrapperSticky = exports.StickyHeaderWrapper = void 0;
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const partials_1 = require("../top/partials");
|
|
11
|
+
const askFtButton_1 = require("../ask-ft/askFtButton");
|
|
11
12
|
const StickyHeaderWrapper = (props) => (react_1.default.createElement("header", { className: `o-header o-header--simple o-header--sticky o--if-js`, "data-o-component": "o-header", "data-o-header--sticky": true, "aria-hidden": "true" }, props.children));
|
|
12
13
|
exports.StickyHeaderWrapper = StickyHeaderWrapper;
|
|
13
14
|
const DrawerIconSticky = () => (react_1.default.createElement("a", { href: "#", className: "o-header__top-icon-link o-header__top-icon-link--menu", "aria-controls": "o-header-drawer", "data-trackable": "drawer-toggle", tabIndex: -1 },
|
|
@@ -37,10 +38,11 @@ const TopWrapperSticky = (props) => (react_1.default.createElement("div", { clas
|
|
|
37
38
|
react_1.default.createElement("div", { className: "o-header__container" },
|
|
38
39
|
react_1.default.createElement("div", { className: "o-header__top-wrapper" }, props.children))));
|
|
39
40
|
exports.TopWrapperSticky = TopWrapperSticky;
|
|
40
|
-
const TopColumnLeftSticky = () => {
|
|
41
|
+
const TopColumnLeftSticky = (props) => {
|
|
41
42
|
return (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--left" },
|
|
42
43
|
react_1.default.createElement(DrawerIconSticky, null),
|
|
43
|
-
react_1.default.createElement(SearchIconSticky, null)
|
|
44
|
+
react_1.default.createElement(SearchIconSticky, null),
|
|
45
|
+
props.showAskButton && (react_1.default.createElement(askFtButton_1.AskFtButton, { className: "ft-header__top-ask-ft-button", id: "ask-ft-button-sticky", dataTrackable: "ask-ft-button-sticky" }))));
|
|
44
46
|
};
|
|
45
47
|
exports.TopColumnLeftSticky = TopColumnLeftSticky;
|
|
46
48
|
const TopColumnCenterSticky = (props) => {
|
|
@@ -3,7 +3,7 @@ import { THeaderProps } from '../../interfaces';
|
|
|
3
3
|
import { TNavMenuItem } from '@financial-times/dotcom-types-navigation';
|
|
4
4
|
declare const HeaderWrapper: (props: any) => React.JSX.Element;
|
|
5
5
|
declare const TopWrapper: (props: any) => React.JSX.Element;
|
|
6
|
-
declare const TopColumnLeft: () => React.JSX.Element;
|
|
6
|
+
declare const TopColumnLeft: (props: Pick<THeaderProps, 'showAskButton'>) => React.JSX.Element;
|
|
7
7
|
declare const TopColumnCenter: () => React.JSX.Element;
|
|
8
8
|
declare const TopColumnCenterNoLink: () => React.JSX.Element;
|
|
9
9
|
declare const SignInLink: ({ item, variant, className }: {
|
|
@@ -16,10 +16,9 @@ declare const SubscribeButton: ({ item, variant, className }: {
|
|
|
16
16
|
variant?: string | undefined;
|
|
17
17
|
className?: string | undefined;
|
|
18
18
|
}) => React.JSX.Element;
|
|
19
|
-
declare const TopColumnRightAnon: ({ items, variant
|
|
19
|
+
declare const TopColumnRightAnon: ({ items, variant }: {
|
|
20
20
|
items: TNavMenuItem[];
|
|
21
21
|
variant?: string | undefined;
|
|
22
|
-
experimentalAccountEntryTest?: boolean | undefined;
|
|
23
22
|
}) => React.JSX.Element;
|
|
24
23
|
declare const TopColumnRight: (props: THeaderProps) => React.JSX.Element;
|
|
25
24
|
export { HeaderWrapper, TopWrapper, TopColumnLeft, TopColumnCenter, TopColumnCenterNoLink, TopColumnRight, TopColumnRightAnon, SubscribeButton, SignInLink };
|
|
@@ -6,40 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SignInLink = exports.SubscribeButton = exports.TopColumnRightAnon = exports.TopColumnRight = exports.TopColumnCenterNoLink = exports.TopColumnCenter = exports.TopColumnLeft = exports.TopWrapper = exports.HeaderWrapper = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const BrandFtMasthead_1 = __importDefault(require("../svg-components/BrandFtMasthead"));
|
|
9
|
+
const askFtButton_1 = require("../ask-ft/askFtButton");
|
|
9
10
|
const HeaderWrapper = (props) => (react_1.default.createElement("header", { id: "site-navigation", className: `o-header o-header--${props.variant || 'simple'}`, "data-o-component": "o-header", "data-o-header--no-js": true, tabIndex: -1 }, props.children));
|
|
10
11
|
exports.HeaderWrapper = HeaderWrapper;
|
|
11
12
|
const DrawerIcon = () => (react_1.default.createElement("a", { href: "#o-header-drawer", className: "o-header__top-icon-link o-header__top-icon-link--menu", "aria-controls": "o-header-drawer", title: "Open side navigation menu", "data-trackable": "drawer-toggle" },
|
|
12
13
|
react_1.default.createElement("span", { className: "o-header__top-link-label" }, "Open side navigation menu")));
|
|
13
14
|
const SearchIcon = () => (react_1.default.createElement("a", { href: `#o-header-search-primary`, className: "o-header__top-icon-link o-header__top-icon-link--search", "aria-controls": `o-header-search-primary`, title: "Open search bar", "data-trackable": "search-toggle" },
|
|
14
15
|
react_1.default.createElement("span", { className: "o-header__top-link-label" }, "Open search bar")));
|
|
15
|
-
const
|
|
16
|
-
if (experimentalAccountEntryTest) {
|
|
17
|
-
return react_1.default.createElement(MyAccountLink, { signedIn: signedIn });
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return react_1.default.createElement(MyFtLogoLink, { className: className });
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const MyFtLogoLink = ({ className }) => (react_1.default.createElement("a", { className: `o-header__top-icon-link o-header__top-icon-link--myft ${className}`, id: "o-header-top-link-myft", href: "/myft", "data-trackable": "my-ft", "data-tour-stage": "myFt", "aria-label": "My F T" },
|
|
24
|
-
react_1.default.createElement("span", { className: "o-header__visually-hidden" }, "myFT")));
|
|
25
|
-
const MyAccountLink = ({ signedIn }) => {
|
|
16
|
+
const MyAccountLink = ({ item, signedIn }) => {
|
|
26
17
|
const classNames = 'o-header__top-link ft-header__top-link--myaccount';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return (react_1.default.createElement("a", { className: classNames, id: "o-header-top-link-signin", href: "/login?location=/", "data-trackable": "Sign In" },
|
|
33
|
-
react_1.default.createElement("span", null, "Sign In")));
|
|
34
|
-
}
|
|
18
|
+
const id = signedIn ? 'o-header-top-link-myaccount' : 'o-header-top-link-signin';
|
|
19
|
+
return (react_1.default.createElement("a", { className: classNames, id: id, href: item.url || undefined, "data-trackable": item.label },
|
|
20
|
+
react_1.default.createElement("span", null, item.label)));
|
|
35
21
|
};
|
|
36
22
|
const TopWrapper = (props) => (react_1.default.createElement("div", { className: "o-header__row o-header__top", "data-trackable": "header-top" },
|
|
37
23
|
react_1.default.createElement("div", { className: "o-header__container" },
|
|
38
24
|
react_1.default.createElement("div", { className: "o-header__top-wrapper" }, props.children))));
|
|
39
25
|
exports.TopWrapper = TopWrapper;
|
|
40
|
-
const TopColumnLeft = () => (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--left" },
|
|
26
|
+
const TopColumnLeft = (props) => (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--left" },
|
|
41
27
|
react_1.default.createElement(DrawerIcon, null),
|
|
42
|
-
react_1.default.createElement(SearchIcon, null)
|
|
28
|
+
react_1.default.createElement(SearchIcon, null),
|
|
29
|
+
props.showAskButton && (react_1.default.createElement(askFtButton_1.AskFtButton, { className: "ft-header__top-ask-ft-button", id: "ask-ft-button-header", dataTrackable: "ask-ft-button-header" }))));
|
|
43
30
|
exports.TopColumnLeft = TopColumnLeft;
|
|
44
31
|
const TopColumnCenter = () => (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--center" },
|
|
45
32
|
react_1.default.createElement("a", { className: "o-header__top-logo", style: { backgroundImage: 'none' }, "data-trackable": "logo", href: "/", title: "Go to Financial Times homepage" },
|
|
@@ -50,11 +37,12 @@ const TopColumnCenterNoLink = () => (react_1.default.createElement("div", { clas
|
|
|
50
37
|
react_1.default.createElement(BrandFtMasthead_1.default, { title: "Financial Times" }))));
|
|
51
38
|
exports.TopColumnCenterNoLink = TopColumnCenterNoLink;
|
|
52
39
|
const TopColumnRightLoggedIn = (props) => {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
const
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
const signInAction = (_b = (_a = props.data['navbar-top-right']) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b[0];
|
|
42
|
+
const subscribeAction = (_d = (_c = props.data['navbar-top-right']) === null || _c === void 0 ? void 0 : _c.items) === null || _d === void 0 ? void 0 : _d[1];
|
|
55
43
|
return (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--right" },
|
|
56
44
|
!props.userIsSubscribed && subscribeAction && (react_1.default.createElement(SubscribeButton, { item: subscribeAction, variant: props.variant, className: "o-header__top-button--hide-m" })),
|
|
57
|
-
react_1.default.createElement(
|
|
45
|
+
signInAction && react_1.default.createElement(MyAccountLink, { item: signInAction, signedIn: true })));
|
|
58
46
|
};
|
|
59
47
|
const SignInLink = ({ item, variant, className }) => {
|
|
60
48
|
var _a;
|
|
@@ -71,13 +59,12 @@ const SubscribeButton = ({ item, variant, className }) => {
|
|
|
71
59
|
role: "button", href: (_a = item.url) !== null && _a !== void 0 ? _a : undefined, "data-trackable": item.label }, setTabIndex), item.label));
|
|
72
60
|
};
|
|
73
61
|
exports.SubscribeButton = SubscribeButton;
|
|
74
|
-
const TopColumnRightAnon = ({ items, variant
|
|
62
|
+
const TopColumnRightAnon = ({ items, variant }) => {
|
|
75
63
|
// If user is anonymous the second list item is styled as a button
|
|
76
64
|
const [signInAction, subscribeAction] = items;
|
|
77
65
|
return (react_1.default.createElement("div", { className: "o-header__top-column o-header__top-column--right" },
|
|
78
66
|
subscribeAction && (react_1.default.createElement(SubscribeButton, { item: subscribeAction, variant: variant, className: "o-header__top-button--hide-m" })),
|
|
79
|
-
signInAction &&
|
|
80
|
-
react_1.default.createElement(TopRightAccountEntry, { className: "o-header__top-icon-link--show-m", signedIn: false, experimentalAccountEntryTest: experimentalAccountEntryTest })));
|
|
67
|
+
signInAction && react_1.default.createElement(MyAccountLink, { item: signInAction, signedIn: false })));
|
|
81
68
|
};
|
|
82
69
|
exports.TopColumnRightAnon = TopColumnRightAnon;
|
|
83
70
|
const TopColumnRight = (props) => {
|
|
@@ -85,8 +72,8 @@ const TopColumnRight = (props) => {
|
|
|
85
72
|
return react_1.default.createElement(TopColumnRightLoggedIn, Object.assign({}, props));
|
|
86
73
|
}
|
|
87
74
|
else {
|
|
88
|
-
const userNavAnonItems = props.data['navbar-right-anon'].items;
|
|
89
|
-
return
|
|
75
|
+
const userNavAnonItems = props.data['navbar-top-right-anon'].items;
|
|
76
|
+
return react_1.default.createElement(TopColumnRightAnon, { items: userNavAnonItems, variant: props.variant });
|
|
90
77
|
}
|
|
91
78
|
};
|
|
92
79
|
exports.TopColumnRight = TopColumnRight;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare namespace MainHeader {
|
|
|
12
12
|
showUserNavigation?: boolean | undefined;
|
|
13
13
|
showStickyHeader?: boolean | undefined;
|
|
14
14
|
showMegaNav?: boolean | undefined;
|
|
15
|
-
|
|
15
|
+
showAskButton?: boolean | undefined;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
declare function StickyHeader(props: THeaderProps): React.JSX.Element | null;
|
package/dist/node/index.js
CHANGED
|
@@ -17,7 +17,8 @@ const defaultProps = {
|
|
|
17
17
|
userIsAnonymous: true,
|
|
18
18
|
userIsLoggedIn: false,
|
|
19
19
|
showStickyHeader: true,
|
|
20
|
-
showMegaNav: true
|
|
20
|
+
showMegaNav: true,
|
|
21
|
+
showAskButton: false
|
|
21
22
|
};
|
|
22
23
|
function MainHeader(props) {
|
|
23
24
|
const includeUserActionsNav = props.showUserNavigation && !props.userIsLoggedIn;
|
|
@@ -25,7 +26,7 @@ function MainHeader(props) {
|
|
|
25
26
|
return (react_1.default.createElement(partials_1.HeaderWrapper, Object.assign({}, props),
|
|
26
27
|
includeUserActionsNav ? react_1.default.createElement(partials_2.UserActionsNav, Object.assign({}, props)) : null,
|
|
27
28
|
react_1.default.createElement(partials_1.TopWrapper, null,
|
|
28
|
-
react_1.default.createElement(partials_1.TopColumnLeft,
|
|
29
|
+
react_1.default.createElement(partials_1.TopColumnLeft, Object.assign({}, props)),
|
|
29
30
|
props.showLogoLink ? react_1.default.createElement(partials_1.TopColumnCenter, null) : react_1.default.createElement(partials_1.TopColumnCenterNoLink, null),
|
|
30
31
|
react_1.default.createElement(partials_1.TopColumnRight, Object.assign({}, props))),
|
|
31
32
|
react_1.default.createElement(partials_5.Search, { instance: "primary" }),
|
|
@@ -40,7 +41,7 @@ MainHeader.defaultProps = { ...defaultProps, showLogoLink: true };
|
|
|
40
41
|
function StickyHeader(props) {
|
|
41
42
|
return props.showStickyHeader ? (react_1.default.createElement(partials_3.StickyHeaderWrapper, Object.assign({}, props),
|
|
42
43
|
react_1.default.createElement(partials_3.TopWrapperSticky, null,
|
|
43
|
-
react_1.default.createElement(partials_3.TopColumnLeftSticky,
|
|
44
|
+
react_1.default.createElement(partials_3.TopColumnLeftSticky, Object.assign({}, props)),
|
|
44
45
|
react_1.default.createElement(partials_3.TopColumnCenterSticky, Object.assign({}, props)),
|
|
45
46
|
react_1.default.createElement(partials_3.TopColumnRightSticky, Object.assign({}, props))),
|
|
46
47
|
react_1.default.createElement(partials_5.Search, { instance: "sticky" }))) : null;
|
|
@@ -167,13 +167,13 @@
|
|
|
167
167
|
"affectsGlobalScope": true
|
|
168
168
|
},
|
|
169
169
|
"../../dotcom-types-navigation/index.d.ts": {
|
|
170
|
-
"version": "
|
|
171
|
-
"signature": "
|
|
170
|
+
"version": "656d366d5e48d86bff7a803885cfd9d31d37f6c777af0ffe3e1ee8d258bc4520",
|
|
171
|
+
"signature": "656d366d5e48d86bff7a803885cfd9d31d37f6c777af0ffe3e1ee8d258bc4520",
|
|
172
172
|
"affectsGlobalScope": false
|
|
173
173
|
},
|
|
174
174
|
"../src/interfaces.d.ts": {
|
|
175
|
-
"version": "
|
|
176
|
-
"signature": "
|
|
175
|
+
"version": "2fe58268385c91140d66300355fc27cb349306472adcac6a09fb484dc974a191",
|
|
176
|
+
"signature": "2fe58268385c91140d66300355fc27cb349306472adcac6a09fb484dc974a191",
|
|
177
177
|
"affectsGlobalScope": false
|
|
178
178
|
},
|
|
179
179
|
"../src/components/svg-components/BrandFtMasthead.tsx": {
|
|
@@ -181,9 +181,14 @@
|
|
|
181
181
|
"signature": "9d8d05b4e7f09ae6f6e59780e0717c60f7ec779c4173e07bfb9a82654fd87bbc",
|
|
182
182
|
"affectsGlobalScope": false
|
|
183
183
|
},
|
|
184
|
+
"../src/components/ask-ft/askFtButton.tsx": {
|
|
185
|
+
"version": "7b4e3416bf0157aeec6f682001193d80d87268eeb015a7d9e34c6691c38de2fe",
|
|
186
|
+
"signature": "478e79eef989a22fe3dc976337d53a5e3ea146b07304c45620b8b91560dd106b",
|
|
187
|
+
"affectsGlobalScope": false
|
|
188
|
+
},
|
|
184
189
|
"../src/components/top/partials.tsx": {
|
|
185
|
-
"version": "
|
|
186
|
-
"signature": "
|
|
190
|
+
"version": "5b3cba0308fdf6a8e0dfe933c890d3ff1353e89429c1e2be96cd63fcd558721f",
|
|
191
|
+
"signature": "52e9ca0196757edb87416ec63a0da3f2f6963cb4ca1fab821e487cf42fd0b4cf",
|
|
187
192
|
"affectsGlobalScope": false
|
|
188
193
|
},
|
|
189
194
|
"../src/utils.ts": {
|
|
@@ -192,13 +197,13 @@
|
|
|
192
197
|
"affectsGlobalScope": false
|
|
193
198
|
},
|
|
194
199
|
"../src/components/navigation/partials.tsx": {
|
|
195
|
-
"version": "
|
|
200
|
+
"version": "4490493cf4204f1c176bb27c8768968b6c03129e7665a9258e88ead48b0c2efe",
|
|
196
201
|
"signature": "fff57eecd77a2ff5847ac6a4139236fb1671b562d8f5b4f5aa16a2a101212dd0",
|
|
197
202
|
"affectsGlobalScope": false
|
|
198
203
|
},
|
|
199
204
|
"../src/components/sticky/partials.tsx": {
|
|
200
|
-
"version": "
|
|
201
|
-
"signature": "
|
|
205
|
+
"version": "9a0b683328c80d151d0b70b516597dbb365dd3f44ccb08fbd78a9c1509475ba9",
|
|
206
|
+
"signature": "8fbeb8e68c5be0e2f41a60731bb91f6c54327ecca0d18857c3feeaa06e1cd389",
|
|
202
207
|
"affectsGlobalScope": false
|
|
203
208
|
},
|
|
204
209
|
"../src/components/sub-navigation/partials.tsx": {
|
|
@@ -212,7 +217,7 @@
|
|
|
212
217
|
"affectsGlobalScope": false
|
|
213
218
|
},
|
|
214
219
|
"../src/components/drawer/topLevelPartials.tsx": {
|
|
215
|
-
"version": "
|
|
220
|
+
"version": "3561750723a43ff4eb0ed5a1da3bb56a14d3006ecfa27fab0dbb1852f8c3cd56",
|
|
216
221
|
"signature": "9d1b0a09950f10403acbd59a85db578c3d6d0eec6d4fd6b26deacd7fc69b5bb4",
|
|
217
222
|
"affectsGlobalScope": false
|
|
218
223
|
},
|
|
@@ -222,8 +227,8 @@
|
|
|
222
227
|
"affectsGlobalScope": false
|
|
223
228
|
},
|
|
224
229
|
"../src/index.tsx": {
|
|
225
|
-
"version": "
|
|
226
|
-
"signature": "
|
|
230
|
+
"version": "1590223c256c5d68b425be24b35676fdefdb9460dac8c04b7e6fbe4c9ce82477",
|
|
231
|
+
"signature": "09d351582aa153eefd5469b12224f3eb0306b746105e502d1eb609bb871a1b7e",
|
|
227
232
|
"affectsGlobalScope": false
|
|
228
233
|
},
|
|
229
234
|
"../../../node_modules/@types/aria-query/index.d.ts": {
|
|
@@ -1882,6 +1887,9 @@
|
|
|
1882
1887
|
"../../../node_modules/pretty-format/build/index.d.ts": [
|
|
1883
1888
|
"../../../node_modules/pretty-format/build/types.d.ts"
|
|
1884
1889
|
],
|
|
1890
|
+
"../src/components/ask-ft/askFtButton.tsx": [
|
|
1891
|
+
"../../../node_modules/@types/react/index.d.ts"
|
|
1892
|
+
],
|
|
1885
1893
|
"../src/components/drawer/additionalPartials.tsx": [
|
|
1886
1894
|
"../../../node_modules/@types/react/index.d.ts",
|
|
1887
1895
|
"../../dotcom-types-navigation/index.d.ts",
|
|
@@ -1890,6 +1898,7 @@
|
|
|
1890
1898
|
"../src/components/drawer/topLevelPartials.tsx": [
|
|
1891
1899
|
"../../../node_modules/@types/react/index.d.ts",
|
|
1892
1900
|
"../../dotcom-types-navigation/index.d.ts",
|
|
1901
|
+
"../src/components/ask-ft/askFtButton.tsx",
|
|
1893
1902
|
"../src/components/drawer/additionalPartials.tsx",
|
|
1894
1903
|
"../src/interfaces.d.ts"
|
|
1895
1904
|
],
|
|
@@ -1904,6 +1913,7 @@
|
|
|
1904
1913
|
],
|
|
1905
1914
|
"../src/components/sticky/partials.tsx": [
|
|
1906
1915
|
"../../../node_modules/@types/react/index.d.ts",
|
|
1916
|
+
"../src/components/ask-ft/askFtButton.tsx",
|
|
1907
1917
|
"../src/components/top/partials.tsx",
|
|
1908
1918
|
"../src/interfaces.d.ts"
|
|
1909
1919
|
],
|
|
@@ -1919,6 +1929,7 @@
|
|
|
1919
1929
|
"../src/components/top/partials.tsx": [
|
|
1920
1930
|
"../../../node_modules/@types/react/index.d.ts",
|
|
1921
1931
|
"../../dotcom-types-navigation/index.d.ts",
|
|
1932
|
+
"../src/components/ask-ft/askFtButton.tsx",
|
|
1922
1933
|
"../src/components/svg-components/BrandFtMasthead.tsx",
|
|
1923
1934
|
"../src/interfaces.d.ts"
|
|
1924
1935
|
],
|
|
@@ -2687,6 +2698,9 @@
|
|
|
2687
2698
|
"../../../node_modules/pretty-format/build/index.d.ts": [
|
|
2688
2699
|
"../../../node_modules/pretty-format/build/types.d.ts"
|
|
2689
2700
|
],
|
|
2701
|
+
"../src/components/ask-ft/askFtButton.tsx": [
|
|
2702
|
+
"../../../node_modules/@types/react/index.d.ts"
|
|
2703
|
+
],
|
|
2690
2704
|
"../src/components/drawer/additionalPartials.tsx": [
|
|
2691
2705
|
"../../../node_modules/@types/react/index.d.ts",
|
|
2692
2706
|
"../../dotcom-types-navigation/index.d.ts"
|
|
@@ -2939,6 +2953,7 @@
|
|
|
2939
2953
|
"../../../node_modules/typescript/lib/lib.es5.d.ts",
|
|
2940
2954
|
"../../../node_modules/typescript/lib/lib.esnext.intl.d.ts",
|
|
2941
2955
|
"../../dotcom-types-navigation/index.d.ts",
|
|
2956
|
+
"../src/components/ask-ft/askFtButton.tsx",
|
|
2942
2957
|
"../src/components/drawer/additionalPartials.tsx",
|
|
2943
2958
|
"../src/components/drawer/topLevelPartials.tsx",
|
|
2944
2959
|
"../src/components/navigation/partials.tsx",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/dotcom-ui-header",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.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.
|
|
25
|
+
"@financial-times/dotcom-types-navigation": "^9.4.1",
|
|
26
26
|
"n-topic-search": "^4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -4,6 +4,8 @@ import actionsUK from './actionsUK'
|
|
|
4
4
|
import editionsUK from './editionsUK'
|
|
5
5
|
import navbarRight from './navbarRight'
|
|
6
6
|
import navbarRightAnon from './navbarRightAnon'
|
|
7
|
+
import navbarTopRight from './navbarTopRight'
|
|
8
|
+
import navbarTopRightAnon from './navbarTopRightAnon'
|
|
7
9
|
import navbarSimple from './navbarSimple'
|
|
8
10
|
import navbarUK from './navbarUK'
|
|
9
11
|
import subNavigation from './subNavigationUK'
|
|
@@ -31,6 +33,8 @@ const data: THeaderProps = {
|
|
|
31
33
|
navbar: navbarUK,
|
|
32
34
|
'navbar-right': navbarRight,
|
|
33
35
|
'navbar-right-anon': navbarRightAnon,
|
|
36
|
+
'navbar-top-right': navbarTopRight,
|
|
37
|
+
'navbar-top-right-anon': navbarTopRightAnon,
|
|
34
38
|
'navbar-simple': navbarSimple,
|
|
35
39
|
subsections,
|
|
36
40
|
'subsections-right': [],
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TNavMenu } from '@financial-times/dotcom-types-navigation'
|
|
2
|
+
|
|
3
|
+
const data: TNavMenu = {
|
|
4
|
+
label: 'Navigation',
|
|
5
|
+
items: [
|
|
6
|
+
{
|
|
7
|
+
label: 'My Account',
|
|
8
|
+
url: '/myaccount',
|
|
9
|
+
submenu: null
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: 'Subscribe',
|
|
13
|
+
url: '/products?segmentId=#',
|
|
14
|
+
submenu: null
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default data
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TNavMenu } from '@financial-times/dotcom-types-navigation'
|
|
2
|
+
|
|
3
|
+
const data: TNavMenu = {
|
|
4
|
+
label: 'Navigation',
|
|
5
|
+
items: [
|
|
6
|
+
{
|
|
7
|
+
label: 'Sign In',
|
|
8
|
+
url: '/login?location=#',
|
|
9
|
+
submenu: null
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: 'Subscribe',
|
|
13
|
+
url: '/products?segmentId=#',
|
|
14
|
+
submenu: null
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default data
|
|
@@ -3,6 +3,8 @@ import drawerUK from './drawerUK'
|
|
|
3
3
|
import editionsUK from './editionsUK'
|
|
4
4
|
import navbarRight from './navbarRight'
|
|
5
5
|
import navbarRightAnon from './navbarRightAnon'
|
|
6
|
+
import navbarTopRight from './navbarTopRight'
|
|
7
|
+
import navbarTopRightAnon from './navbarTopRightAnon'
|
|
6
8
|
import navbarSimple from './navbarSimple'
|
|
7
9
|
import navbarUK from './navbarUK'
|
|
8
10
|
import subNavigation from './subNavigationProfile'
|
|
@@ -29,6 +31,8 @@ const data: THeaderProps = {
|
|
|
29
31
|
navbar: navbarUK,
|
|
30
32
|
'navbar-right': navbarRight,
|
|
31
33
|
'navbar-right-anon': navbarRightAnon,
|
|
34
|
+
'navbar-top-right': navbarTopRight,
|
|
35
|
+
'navbar-top-right-anon': navbarTopRightAnon,
|
|
32
36
|
'navbar-simple': navbarSimple,
|
|
33
37
|
subsections,
|
|
34
38
|
'subsections-right': [
|
|
@@ -52,47 +52,8 @@ DefaultHeaderWithDrawer.args = {
|
|
|
52
52
|
showUserNavigation: true,
|
|
53
53
|
userIsLoggedIn: false,
|
|
54
54
|
userIsSubscribed: false,
|
|
55
|
-
showLogoLink: false
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const DefaultHeaderWithDrawerEntryTestAnon = (args) => (
|
|
59
|
-
<OnReady callback={onReadyCallback}>
|
|
60
|
-
<HeaderSimple {...storyData} {...args} />
|
|
61
|
-
<Drawer {...storyData} {...args} />
|
|
62
|
-
</OnReady>
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
DefaultHeaderWithDrawerEntryTestAnon.story = {
|
|
66
|
-
name: 'Default header with drawer - Account entry test [Anon]'
|
|
67
|
-
}
|
|
68
|
-
DefaultHeaderWithDrawerEntryTestAnon.args = {
|
|
69
|
-
showSubNavigation: true,
|
|
70
|
-
showMegaNav: true,
|
|
71
|
-
showUserNavigation: true,
|
|
72
|
-
userIsLoggedIn: false,
|
|
73
|
-
userIsSubscribed: false,
|
|
74
|
-
showLogoLink: false,
|
|
75
|
-
experimentalAccountEntryTest: true
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const DefaultHeaderWithDrawerEntryTest = (args) => (
|
|
79
|
-
<OnReady callback={onReadyCallback}>
|
|
80
|
-
<HeaderSimple {...storyData} {...args} />
|
|
81
|
-
<Drawer {...storyData} {...args} />
|
|
82
|
-
</OnReady>
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
DefaultHeaderWithDrawerEntryTest.story = {
|
|
86
|
-
name: 'Default header with drawer - Account entry test'
|
|
87
|
-
}
|
|
88
|
-
DefaultHeaderWithDrawerEntryTest.args = {
|
|
89
|
-
showSubNavigation: true,
|
|
90
|
-
showMegaNav: true,
|
|
91
|
-
showUserNavigation: true,
|
|
92
|
-
userIsLoggedIn: true,
|
|
93
|
-
userIsSubscribed: false,
|
|
94
55
|
showLogoLink: false,
|
|
95
|
-
|
|
56
|
+
showAskButton: false
|
|
96
57
|
}
|
|
97
58
|
|
|
98
59
|
export const DefaultHeaderWithRightAlignedSubnav = (args) => (
|
|
@@ -110,7 +71,8 @@ DefaultHeaderWithRightAlignedSubnav.args = {
|
|
|
110
71
|
showMegaNav: true,
|
|
111
72
|
showUserNavigation: true,
|
|
112
73
|
userIsLoggedIn: true,
|
|
113
|
-
showLogoLink: false
|
|
74
|
+
showLogoLink: false,
|
|
75
|
+
showAskButton: false
|
|
114
76
|
}
|
|
115
77
|
|
|
116
78
|
export const LargeHeaderWithDrawer = (args) => (
|
|
@@ -131,7 +93,8 @@ LargeHeaderWithDrawer.args = {
|
|
|
131
93
|
showMegaNav: true,
|
|
132
94
|
showUserNavigation: true,
|
|
133
95
|
userIsLoggedIn: false,
|
|
134
|
-
variant: 'large-logo'
|
|
96
|
+
variant: 'large-logo',
|
|
97
|
+
showAskButton: false
|
|
135
98
|
}
|
|
136
99
|
|
|
137
100
|
export const _StickyHeader = (args) => (
|
|
@@ -148,7 +111,8 @@ _StickyHeader.args = {
|
|
|
148
111
|
showUserNavigation: true,
|
|
149
112
|
userIsLoggedIn: false,
|
|
150
113
|
userIsSubscribed: false,
|
|
151
|
-
showStickyHeader: false
|
|
114
|
+
showStickyHeader: false,
|
|
115
|
+
showAskButton: false
|
|
152
116
|
}
|
|
153
117
|
_StickyHeader.argTypes = {
|
|
154
118
|
currentPath: {
|
|
@@ -5,6 +5,7 @@ import { Drawer as Subject } from '../../index'
|
|
|
5
5
|
|
|
6
6
|
const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
|
|
7
7
|
const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
|
|
8
|
+
const propsAskFt = { ...fixture, showAskButton: true }
|
|
8
9
|
|
|
9
10
|
describe('dotcom-ui-header/src/components/Drawer', () => {
|
|
10
11
|
it('renders as an anonymous user', () => {
|
|
@@ -16,4 +17,9 @@ describe('dotcom-ui-header/src/components/Drawer', () => {
|
|
|
16
17
|
const tree = renderer.create(<Subject {...propsLoggedIn} />).toJSON()
|
|
17
18
|
expect(tree).toMatchSnapshot()
|
|
18
19
|
})
|
|
20
|
+
|
|
21
|
+
it('renders ASK FT button', () => {
|
|
22
|
+
const tree = renderer.create(<Subject {...propsAskFt} />).toJSON()
|
|
23
|
+
expect(tree).toMatchSnapshot()
|
|
24
|
+
})
|
|
19
25
|
})
|
|
@@ -7,6 +7,7 @@ import { MainHeader as Subject } from '../../index'
|
|
|
7
7
|
const propsAnonymous = { ...fixture, userIsAnonymous: true, userIsLoggedIn: false }
|
|
8
8
|
const propsLoggedIn = { ...fixture, userIsAnonymous: false, userIsLoggedIn: true }
|
|
9
9
|
const propsRightAligned = { ...profileFixture }
|
|
10
|
+
const propsAskFt = { ...fixture, showAskButton: true }
|
|
10
11
|
|
|
11
12
|
describe('dotcom-ui-header/src/components/MainHeader', () => {
|
|
12
13
|
it('renders as an anonymous user', () => {
|
|
@@ -23,4 +24,9 @@ describe('dotcom-ui-header/src/components/MainHeader', () => {
|
|
|
23
24
|
const tree = renderer.create(<Subject {...propsRightAligned} />).toJSON()
|
|
24
25
|
expect(tree).toMatchSnapshot()
|
|
25
26
|
})
|
|
27
|
+
|
|
28
|
+
it('renders ASK FT button', () => {
|
|
29
|
+
const tree = renderer.create(<Subject {...propsAskFt} />).toJSON()
|
|
30
|
+
expect(tree).toMatchSnapshot()
|
|
31
|
+
})
|
|
26
32
|
})
|