@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,588 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`dotcom-ui-header/src/components/StickyHeader renders as a logged in user 1`] = `
4
+ <header
5
+ aria-hidden="true"
6
+ className="o-header o-header--simple o-header--sticky o--if-js"
7
+ data-o-component="o-header"
8
+ data-o-header--sticky={true}
9
+ >
10
+ <div
11
+ className="o-header__row o-header__top"
12
+ data-trackable="header-sticky"
13
+ >
14
+ <div
15
+ className="o-header__container"
16
+ >
17
+ <div
18
+ className="o-header__top-wrapper"
19
+ >
20
+ <div
21
+ className="o-header__top-column o-header__top-column--left"
22
+ >
23
+ <a
24
+ aria-controls="o-header-drawer"
25
+ className="o-header__top-icon-link o-header__top-icon-link--menu"
26
+ data-trackable="drawer-toggle"
27
+ href="#"
28
+ tabIndex={-1}
29
+ >
30
+ <span
31
+ className="o-header__top-link-label"
32
+ >
33
+ Menu
34
+ </span>
35
+ </a>
36
+ <a
37
+ aria-controls="o-header-search-sticky"
38
+ className="o-header__top-icon-link o-header__top-icon-link--search"
39
+ data-trackable="search-toggle"
40
+ href="#"
41
+ tabIndex={-1}
42
+ >
43
+ <span
44
+ className="o-header__top-link-label"
45
+ >
46
+ Search
47
+ </span>
48
+ </a>
49
+ </div>
50
+ <div
51
+ className="o-header__top-column o-header__top-column--center"
52
+ >
53
+ <div
54
+ className="o-header__top-takeover"
55
+ >
56
+ <div
57
+ className="o-header__nav"
58
+ >
59
+ <ul
60
+ className="o-header__nav-list o-header__nav-list--left"
61
+ data-trackable="primary-nav"
62
+ >
63
+ <li
64
+ className="o-header__nav-item"
65
+ >
66
+ <a
67
+ className="o-header__nav-link o-header__nav-link--primary"
68
+ data-trackable="Home"
69
+ href="/"
70
+ tabIndex={-1}
71
+ >
72
+ Home
73
+ </a>
74
+ </li>
75
+ <li
76
+ className="o-header__nav-item"
77
+ >
78
+ <a
79
+ className="o-header__nav-link o-header__nav-link--primary"
80
+ data-trackable="World"
81
+ href="/world"
82
+ tabIndex={-1}
83
+ >
84
+ World
85
+ </a>
86
+ </li>
87
+ <li
88
+ className="o-header__nav-item"
89
+ >
90
+ <a
91
+ className="o-header__nav-link o-header__nav-link--primary"
92
+ data-trackable="UK"
93
+ href="/world/uk"
94
+ tabIndex={-1}
95
+ >
96
+ UK
97
+ </a>
98
+ </li>
99
+ <li
100
+ className="o-header__nav-item"
101
+ >
102
+ <a
103
+ className="o-header__nav-link o-header__nav-link--primary"
104
+ data-trackable="Companies"
105
+ href="/companies"
106
+ tabIndex={-1}
107
+ >
108
+ Companies
109
+ </a>
110
+ </li>
111
+ <li
112
+ className="o-header__nav-item"
113
+ >
114
+ <a
115
+ className="o-header__nav-link o-header__nav-link--primary"
116
+ data-trackable="Tech"
117
+ href="/technology"
118
+ tabIndex={-1}
119
+ >
120
+ Tech
121
+ </a>
122
+ </li>
123
+ <li
124
+ className="o-header__nav-item"
125
+ >
126
+ <a
127
+ className="o-header__nav-link o-header__nav-link--primary"
128
+ data-trackable="Markets"
129
+ href="/markets"
130
+ tabIndex={-1}
131
+ >
132
+ Markets
133
+ </a>
134
+ </li>
135
+ <li
136
+ className="o-header__nav-item"
137
+ >
138
+ <a
139
+ className="o-header__nav-link o-header__nav-link--primary"
140
+ data-trackable="Graphics"
141
+ href="/graphics"
142
+ tabIndex={-1}
143
+ >
144
+ Graphics
145
+ </a>
146
+ </li>
147
+ <li
148
+ className="o-header__nav-item"
149
+ >
150
+ <a
151
+ className="o-header__nav-link o-header__nav-link--primary"
152
+ data-trackable="Opinion"
153
+ href="/opinion"
154
+ tabIndex={-1}
155
+ >
156
+ Opinion
157
+ </a>
158
+ </li>
159
+ <li
160
+ className="o-header__nav-item"
161
+ >
162
+ <a
163
+ className="o-header__nav-link o-header__nav-link--primary"
164
+ data-trackable="Work & Careers"
165
+ href="/work-careers"
166
+ tabIndex={-1}
167
+ >
168
+ Work & Careers
169
+ </a>
170
+ </li>
171
+ <li
172
+ className="o-header__nav-item"
173
+ >
174
+ <a
175
+ className="o-header__nav-link o-header__nav-link--primary"
176
+ data-trackable="Life & Arts"
177
+ href="/life-arts"
178
+ tabIndex={-1}
179
+ >
180
+ Life & Arts
181
+ </a>
182
+ </li>
183
+ <li
184
+ className="o-header__nav-item"
185
+ >
186
+ <a
187
+ className="o-header__nav-link o-header__nav-link--primary"
188
+ data-trackable="HTSI"
189
+ href="https://howtospendit.ft.com/"
190
+ tabIndex={-1}
191
+ >
192
+ HTSI
193
+ </a>
194
+ </li>
195
+ </ul>
196
+ </div>
197
+ </div>
198
+ <a
199
+ className="o-header__top-logo o-header__hide--L"
200
+ data-trackable="logo"
201
+ href="/"
202
+ tabIndex={-1}
203
+ title="Go to Financial Times homepage"
204
+ >
205
+ <span
206
+ className="o-header__visually-hidden"
207
+ >
208
+ Financial Times
209
+ </span>
210
+ </a>
211
+ </div>
212
+ <div
213
+ className="o-header__top-column o-header__top-column--right"
214
+ >
215
+ <a
216
+ className="o-header__top-button o-header__top-button--hide-m"
217
+ data-trackable="Subscribe"
218
+ href="/products?segmentId=#"
219
+ role="button"
220
+ >
221
+ Subscribe
222
+ </a>
223
+ <a
224
+ className="o-header__top-icon-link o-header__top-icon-link--myft "
225
+ data-trackable="my-ft"
226
+ href="/myft"
227
+ tabIndex={-1}
228
+ >
229
+ <span
230
+ className="o-header__visually-hidden"
231
+ >
232
+ myFT
233
+ </span>
234
+ </a>
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ <div
240
+ className="o-header__row o-header__search o-header__search--sticky"
241
+ data-o-header-search={true}
242
+ data-trackable="header-search"
243
+ id="o-header-search-sticky"
244
+ >
245
+ <div
246
+ className="o-header__container"
247
+ >
248
+ <form
249
+ action="/search"
250
+ aria-label="Site search"
251
+ className="o-header__search-form"
252
+ data-n-topic-search={true}
253
+ data-n-topic-search-categories="concepts,equities"
254
+ data-n-topic-search-view-all={true}
255
+ role="search"
256
+ >
257
+ <label
258
+ className="o-header__visually-hidden"
259
+ htmlFor="o-header-search-term-sticky"
260
+ >
261
+ Search the
262
+ <abbr
263
+ title="Financial Times"
264
+ >
265
+ FT
266
+ </abbr>
267
+ </label>
268
+ <input
269
+ autoCapitalize="off"
270
+ autoComplete="off"
271
+ autoCorrect="off"
272
+ className="o-header__search-term"
273
+ data-n-topic-search-input={true}
274
+ data-trackable="search-term"
275
+ id="o-header-search-term-sticky"
276
+ name="q"
277
+ placeholder="Search the FT"
278
+ spellCheck={false}
279
+ type="text"
280
+ />
281
+ <button
282
+ className="o-header__search-submit"
283
+ data-trackable="search-submit"
284
+ type="submit"
285
+ >
286
+ Search
287
+ </button>
288
+ <button
289
+ aria-controls="o-header-search-sticky"
290
+ className="o-header__search-close o--if-js"
291
+ data-trackable="close"
292
+ title="Close search bar"
293
+ type="button"
294
+ >
295
+ <span
296
+ className="o-header__visually-hidden"
297
+ >
298
+ Close search bar
299
+ </span>
300
+ </button>
301
+ </form>
302
+ </div>
303
+ </div>
304
+ </header>
305
+ `;
306
+
307
+ exports[`dotcom-ui-header/src/components/StickyHeader renders as an anonymous user 1`] = `
308
+ <header
309
+ aria-hidden="true"
310
+ className="o-header o-header--simple o-header--sticky o--if-js"
311
+ data-o-component="o-header"
312
+ data-o-header--sticky={true}
313
+ >
314
+ <div
315
+ className="o-header__row o-header__top"
316
+ data-trackable="header-sticky"
317
+ >
318
+ <div
319
+ className="o-header__container"
320
+ >
321
+ <div
322
+ className="o-header__top-wrapper"
323
+ >
324
+ <div
325
+ className="o-header__top-column o-header__top-column--left"
326
+ >
327
+ <a
328
+ aria-controls="o-header-drawer"
329
+ className="o-header__top-icon-link o-header__top-icon-link--menu"
330
+ data-trackable="drawer-toggle"
331
+ href="#"
332
+ tabIndex={-1}
333
+ >
334
+ <span
335
+ className="o-header__top-link-label"
336
+ >
337
+ Menu
338
+ </span>
339
+ </a>
340
+ <a
341
+ aria-controls="o-header-search-sticky"
342
+ className="o-header__top-icon-link o-header__top-icon-link--search"
343
+ data-trackable="search-toggle"
344
+ href="#"
345
+ tabIndex={-1}
346
+ >
347
+ <span
348
+ className="o-header__top-link-label"
349
+ >
350
+ Search
351
+ </span>
352
+ </a>
353
+ </div>
354
+ <div
355
+ className="o-header__top-column o-header__top-column--center"
356
+ >
357
+ <div
358
+ className="o-header__top-takeover"
359
+ >
360
+ <div
361
+ className="o-header__nav"
362
+ >
363
+ <ul
364
+ className="o-header__nav-list o-header__nav-list--left"
365
+ data-trackable="primary-nav"
366
+ >
367
+ <li
368
+ className="o-header__nav-item"
369
+ >
370
+ <a
371
+ className="o-header__nav-link o-header__nav-link--primary"
372
+ data-trackable="Home"
373
+ href="/"
374
+ tabIndex={-1}
375
+ >
376
+ Home
377
+ </a>
378
+ </li>
379
+ <li
380
+ className="o-header__nav-item"
381
+ >
382
+ <a
383
+ className="o-header__nav-link o-header__nav-link--primary"
384
+ data-trackable="World"
385
+ href="/world"
386
+ tabIndex={-1}
387
+ >
388
+ World
389
+ </a>
390
+ </li>
391
+ <li
392
+ className="o-header__nav-item"
393
+ >
394
+ <a
395
+ className="o-header__nav-link o-header__nav-link--primary"
396
+ data-trackable="UK"
397
+ href="/world/uk"
398
+ tabIndex={-1}
399
+ >
400
+ UK
401
+ </a>
402
+ </li>
403
+ <li
404
+ className="o-header__nav-item"
405
+ >
406
+ <a
407
+ className="o-header__nav-link o-header__nav-link--primary"
408
+ data-trackable="Companies"
409
+ href="/companies"
410
+ tabIndex={-1}
411
+ >
412
+ Companies
413
+ </a>
414
+ </li>
415
+ <li
416
+ className="o-header__nav-item"
417
+ >
418
+ <a
419
+ className="o-header__nav-link o-header__nav-link--primary"
420
+ data-trackable="Tech"
421
+ href="/technology"
422
+ tabIndex={-1}
423
+ >
424
+ Tech
425
+ </a>
426
+ </li>
427
+ <li
428
+ className="o-header__nav-item"
429
+ >
430
+ <a
431
+ className="o-header__nav-link o-header__nav-link--primary"
432
+ data-trackable="Markets"
433
+ href="/markets"
434
+ tabIndex={-1}
435
+ >
436
+ Markets
437
+ </a>
438
+ </li>
439
+ <li
440
+ className="o-header__nav-item"
441
+ >
442
+ <a
443
+ className="o-header__nav-link o-header__nav-link--primary"
444
+ data-trackable="Graphics"
445
+ href="/graphics"
446
+ tabIndex={-1}
447
+ >
448
+ Graphics
449
+ </a>
450
+ </li>
451
+ <li
452
+ className="o-header__nav-item"
453
+ >
454
+ <a
455
+ className="o-header__nav-link o-header__nav-link--primary"
456
+ data-trackable="Opinion"
457
+ href="/opinion"
458
+ tabIndex={-1}
459
+ >
460
+ Opinion
461
+ </a>
462
+ </li>
463
+ <li
464
+ className="o-header__nav-item"
465
+ >
466
+ <a
467
+ className="o-header__nav-link o-header__nav-link--primary"
468
+ data-trackable="Work & Careers"
469
+ href="/work-careers"
470
+ tabIndex={-1}
471
+ >
472
+ Work & Careers
473
+ </a>
474
+ </li>
475
+ <li
476
+ className="o-header__nav-item"
477
+ >
478
+ <a
479
+ className="o-header__nav-link o-header__nav-link--primary"
480
+ data-trackable="Life & Arts"
481
+ href="/life-arts"
482
+ tabIndex={-1}
483
+ >
484
+ Life & Arts
485
+ </a>
486
+ </li>
487
+ <li
488
+ className="o-header__nav-item"
489
+ >
490
+ <a
491
+ className="o-header__nav-link o-header__nav-link--primary"
492
+ data-trackable="HTSI"
493
+ href="https://howtospendit.ft.com/"
494
+ tabIndex={-1}
495
+ >
496
+ HTSI
497
+ </a>
498
+ </li>
499
+ </ul>
500
+ </div>
501
+ </div>
502
+ <a
503
+ className="o-header__top-logo o-header__hide--L"
504
+ data-trackable="logo"
505
+ href="/"
506
+ tabIndex={-1}
507
+ title="Go to Financial Times homepage"
508
+ >
509
+ <span
510
+ className="o-header__visually-hidden"
511
+ >
512
+ Financial Times
513
+ </span>
514
+ </a>
515
+ </div>
516
+ <div
517
+ className="o-header__top-column o-header__top-column--right"
518
+ />
519
+ </div>
520
+ </div>
521
+ </div>
522
+ <div
523
+ className="o-header__row o-header__search o-header__search--sticky"
524
+ data-o-header-search={true}
525
+ data-trackable="header-search"
526
+ id="o-header-search-sticky"
527
+ >
528
+ <div
529
+ className="o-header__container"
530
+ >
531
+ <form
532
+ action="/search"
533
+ aria-label="Site search"
534
+ className="o-header__search-form"
535
+ data-n-topic-search={true}
536
+ data-n-topic-search-categories="concepts,equities"
537
+ data-n-topic-search-view-all={true}
538
+ role="search"
539
+ >
540
+ <label
541
+ className="o-header__visually-hidden"
542
+ htmlFor="o-header-search-term-sticky"
543
+ >
544
+ Search the
545
+ <abbr
546
+ title="Financial Times"
547
+ >
548
+ FT
549
+ </abbr>
550
+ </label>
551
+ <input
552
+ autoCapitalize="off"
553
+ autoComplete="off"
554
+ autoCorrect="off"
555
+ className="o-header__search-term"
556
+ data-n-topic-search-input={true}
557
+ data-trackable="search-term"
558
+ id="o-header-search-term-sticky"
559
+ name="q"
560
+ placeholder="Search the FT"
561
+ spellCheck={false}
562
+ type="text"
563
+ />
564
+ <button
565
+ className="o-header__search-submit"
566
+ data-trackable="search-submit"
567
+ type="submit"
568
+ >
569
+ Search
570
+ </button>
571
+ <button
572
+ aria-controls="o-header-search-sticky"
573
+ className="o-header__search-close o--if-js"
574
+ data-trackable="close"
575
+ title="Close search bar"
576
+ type="button"
577
+ >
578
+ <span
579
+ className="o-header__visually-hidden"
580
+ >
581
+ Close search bar
582
+ </span>
583
+ </button>
584
+ </form>
585
+ </div>
586
+ </div>
587
+ </header>
588
+ `;
@@ -0,0 +1,107 @@
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
+ })