@financial-times/dotcom-ui-header 10.1.0 → 10.3.0

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.
@@ -46,19 +46,23 @@ exports[`dotcom-ui-header/src/components/StickyHeader renders ASK FT button 1`]
46
46
  Search
47
47
  </span>
48
48
  </a>
49
- <a
50
- className="ft-header__ask-ft-button ft-header__top-ask-ft-button"
51
- data-trackable="ask-ft-button-sticky"
52
- href="https://ask.ft.com"
53
- id="ask-ft-button-sticky"
54
- title="ASK FT"
49
+ <div
50
+ className="o-header__drawer-actions"
55
51
  >
56
- <span
57
- className="ft-header__ask-ft-button-label"
52
+ <a
53
+ className="ft-header__ask-ft-button ft-header__top-ask-ft-button"
54
+ data-trackable="ask-ft-button-sticky"
55
+ href="https://ask.ft.com"
56
+ id="ask-ft-button-sticky"
57
+ title="ASK FT"
58
58
  >
59
- Ask FT
60
- </span>
61
- </a>
59
+ <span
60
+ className="ft-header__ask-ft-button-label"
61
+ >
62
+ Ask FT
63
+ </span>
64
+ </a>
65
+ </div>
62
66
  </div>
63
67
  <div
64
68
  className="o-header__top-column o-header__top-column--center"
@@ -268,49 +272,60 @@ exports[`dotcom-ui-header/src/components/StickyHeader renders ASK FT button 1`]
268
272
  role="search"
269
273
  >
270
274
  <label
271
- className="o-header__visually-hidden"
275
+ className="o-header__search-term o-forms-field o-forms-field--optional"
272
276
  htmlFor="o-header-search-term-sticky"
273
277
  >
274
- Search the
275
- <abbr
276
- title="Financial Times"
278
+ <span
279
+ className="o-forms-title o-header__visually-hidden"
277
280
  >
278
- FT
279
- </abbr>
280
- </label>
281
- <input
282
- autoCapitalize="off"
283
- autoComplete="off"
284
- autoCorrect="off"
285
- className="o-header__search-term"
286
- data-n-topic-search-input={true}
287
- data-trackable="search-term"
288
- id="o-header-search-term-sticky"
289
- name="q"
290
- placeholder="Search the FT"
291
- spellCheck={false}
292
- type="text"
293
- />
294
- <button
295
- className="o-header__search-submit"
296
- data-trackable="search-submit"
297
- type="submit"
298
- >
299
- Search
300
- </button>
301
- <button
302
- aria-controls="o-header-search-sticky"
303
- className="o-header__search-close o--if-js"
304
- data-trackable="close"
305
- title="Close search bar"
306
- type="button"
307
- >
281
+ <span
282
+ className="o-forms-title__main"
283
+ >
284
+ Search the
285
+ <abbr
286
+ title="Financial Times"
287
+ >
288
+ FT
289
+ </abbr>
290
+ </span>
291
+ </span>
308
292
  <span
309
- className="o-header__visually-hidden"
293
+ className="o-forms-input o-forms-input--text o-forms-input--suffix"
310
294
  >
311
- Close search bar
295
+ <input
296
+ autoCapitalize="off"
297
+ autoComplete="off"
298
+ autoCorrect="off"
299
+ className="o-header__search-term"
300
+ data-n-topic-search-input={true}
301
+ data-trackable="search-term"
302
+ id="o-header-search-term-sticky"
303
+ name="q"
304
+ placeholder="Search for stories, topics or securities"
305
+ spellCheck={false}
306
+ type="text"
307
+ />
308
+ <button
309
+ className="o-header__search-submit"
310
+ type="submit"
311
+ >
312
+ Search
313
+ </button>
314
+ <button
315
+ aria-controls="o-header-search-sticky"
316
+ className="o-header__search-close o--if-js"
317
+ data-trackable="close"
318
+ title="Close search bar"
319
+ type="button"
320
+ >
321
+ <span
322
+ className="o-header__visually-hidden"
323
+ >
324
+ Close search bar
325
+ </span>
326
+ </button>
312
327
  </span>
313
- </button>
328
+ </label>
314
329
  </form>
315
330
  </div>
316
331
  </div>
@@ -572,49 +587,60 @@ exports[`dotcom-ui-header/src/components/StickyHeader renders as a logged in use
572
587
  role="search"
573
588
  >
574
589
  <label
575
- className="o-header__visually-hidden"
590
+ className="o-header__search-term o-forms-field o-forms-field--optional"
576
591
  htmlFor="o-header-search-term-sticky"
577
592
  >
578
- Search the
579
- <abbr
580
- title="Financial Times"
593
+ <span
594
+ className="o-forms-title o-header__visually-hidden"
581
595
  >
582
- FT
583
- </abbr>
584
- </label>
585
- <input
586
- autoCapitalize="off"
587
- autoComplete="off"
588
- autoCorrect="off"
589
- className="o-header__search-term"
590
- data-n-topic-search-input={true}
591
- data-trackable="search-term"
592
- id="o-header-search-term-sticky"
593
- name="q"
594
- placeholder="Search the FT"
595
- spellCheck={false}
596
- type="text"
597
- />
598
- <button
599
- className="o-header__search-submit"
600
- data-trackable="search-submit"
601
- type="submit"
602
- >
603
- Search
604
- </button>
605
- <button
606
- aria-controls="o-header-search-sticky"
607
- className="o-header__search-close o--if-js"
608
- data-trackable="close"
609
- title="Close search bar"
610
- type="button"
611
- >
596
+ <span
597
+ className="o-forms-title__main"
598
+ >
599
+ Search the
600
+ <abbr
601
+ title="Financial Times"
602
+ >
603
+ FT
604
+ </abbr>
605
+ </span>
606
+ </span>
612
607
  <span
613
- className="o-header__visually-hidden"
608
+ className="o-forms-input o-forms-input--text o-forms-input--suffix"
614
609
  >
615
- Close search bar
610
+ <input
611
+ autoCapitalize="off"
612
+ autoComplete="off"
613
+ autoCorrect="off"
614
+ className="o-header__search-term"
615
+ data-n-topic-search-input={true}
616
+ data-trackable="search-term"
617
+ id="o-header-search-term-sticky"
618
+ name="q"
619
+ placeholder="Search for stories, topics or securities"
620
+ spellCheck={false}
621
+ type="text"
622
+ />
623
+ <button
624
+ className="o-header__search-submit"
625
+ type="submit"
626
+ >
627
+ Search
628
+ </button>
629
+ <button
630
+ aria-controls="o-header-search-sticky"
631
+ className="o-header__search-close o--if-js"
632
+ data-trackable="close"
633
+ title="Close search bar"
634
+ type="button"
635
+ >
636
+ <span
637
+ className="o-header__visually-hidden"
638
+ >
639
+ Close search bar
640
+ </span>
641
+ </button>
616
642
  </span>
617
- </button>
643
+ </label>
618
644
  </form>
619
645
  </div>
620
646
  </div>
@@ -875,49 +901,60 @@ exports[`dotcom-ui-header/src/components/StickyHeader renders as an anonymous us
875
901
  role="search"
876
902
  >
877
903
  <label
878
- className="o-header__visually-hidden"
904
+ className="o-header__search-term o-forms-field o-forms-field--optional"
879
905
  htmlFor="o-header-search-term-sticky"
880
906
  >
881
- Search the
882
- <abbr
883
- title="Financial Times"
907
+ <span
908
+ className="o-forms-title o-header__visually-hidden"
884
909
  >
885
- FT
886
- </abbr>
887
- </label>
888
- <input
889
- autoCapitalize="off"
890
- autoComplete="off"
891
- autoCorrect="off"
892
- className="o-header__search-term"
893
- data-n-topic-search-input={true}
894
- data-trackable="search-term"
895
- id="o-header-search-term-sticky"
896
- name="q"
897
- placeholder="Search the FT"
898
- spellCheck={false}
899
- type="text"
900
- />
901
- <button
902
- className="o-header__search-submit"
903
- data-trackable="search-submit"
904
- type="submit"
905
- >
906
- Search
907
- </button>
908
- <button
909
- aria-controls="o-header-search-sticky"
910
- className="o-header__search-close o--if-js"
911
- data-trackable="close"
912
- title="Close search bar"
913
- type="button"
914
- >
910
+ <span
911
+ className="o-forms-title__main"
912
+ >
913
+ Search the
914
+ <abbr
915
+ title="Financial Times"
916
+ >
917
+ FT
918
+ </abbr>
919
+ </span>
920
+ </span>
915
921
  <span
916
- className="o-header__visually-hidden"
922
+ className="o-forms-input o-forms-input--text o-forms-input--suffix"
917
923
  >
918
- Close search bar
924
+ <input
925
+ autoCapitalize="off"
926
+ autoComplete="off"
927
+ autoCorrect="off"
928
+ className="o-header__search-term"
929
+ data-n-topic-search-input={true}
930
+ data-trackable="search-term"
931
+ id="o-header-search-term-sticky"
932
+ name="q"
933
+ placeholder="Search for stories, topics or securities"
934
+ spellCheck={false}
935
+ type="text"
936
+ />
937
+ <button
938
+ className="o-header__search-submit"
939
+ type="submit"
940
+ >
941
+ Search
942
+ </button>
943
+ <button
944
+ aria-controls="o-header-search-sticky"
945
+ className="o-header__search-close o--if-js"
946
+ data-trackable="close"
947
+ title="Close search bar"
948
+ type="button"
949
+ >
950
+ <span
951
+ className="o-header__visually-hidden"
952
+ >
953
+ Close search bar
954
+ </span>
955
+ </button>
919
956
  </span>
920
- </button>
957
+ </label>
921
958
  </form>
922
959
  </div>
923
960
  </div>
@@ -29,7 +29,7 @@ describe('dotcom-ui-header/src/components/drawer', () => {
29
29
  const { container } = render(<Subject {...fixture} />)
30
30
 
31
31
  expect(container.getElementsByClassName('o-header__drawer-current-edition')[0].innerHTML).toContain(
32
- 'UK Edition'
32
+ 'UK'
33
33
  )
34
34
  })
35
35
 
@@ -37,7 +37,7 @@ describe('dotcom-ui-header/src/components/drawer', () => {
37
37
  const { container } = render(<Subject {...fixture} />)
38
38
 
39
39
  const [firstLink] = Array.from(container.getElementsByClassName('o-header__drawer-menu-link'))
40
- expect(firstLink.innerHTML).toContain('Switch to International Edition')
40
+ expect(firstLink.innerHTML).toContain('International')
41
41
  })
42
42
  })
43
43
 
@@ -7,13 +7,14 @@ export interface AskFtButtonProps {
7
7
  }
8
8
 
9
9
  export const AskFtButton = ({ id, className, dataTrackable }: AskFtButtonProps) => (
10
- <a
11
- id={id}
12
- className={`ft-header__ask-ft-button ${className}`}
13
- data-trackable={dataTrackable}
14
- href="https://ask.ft.com"
15
- title="ASK FT"
16
- >
17
- <span className="ft-header__ask-ft-button-label">Ask FT</span>
18
- </a>
10
+ <div className="o-header__drawer-actions">
11
+ <a
12
+ id={id}
13
+ className={`ft-header__ask-ft-button ${className}`}
14
+ data-trackable={dataTrackable}
15
+ href="https://ask.ft.com"
16
+ title="ASK FT">
17
+ <span className="ft-header__ask-ft-button-label">Ask FT</span>
18
+ </a>
19
+ </div>
19
20
  )
@@ -16,23 +16,20 @@ export const DrawerParentItem = ({ item, idSuffix }: TDrawerParentItemProps) =>
16
16
  className={`o-header__drawer-menu-link o-header__drawer-menu-link--${selected} o-header__drawer-menu-link--parent`}
17
17
  href={item.url ?? undefined}
18
18
  {...ariaSelected(item)}
19
- data-trackable={item.label}
20
- >
19
+ data-trackable={item.label}>
21
20
  {item.label}
22
21
  </a>
23
22
  <button
24
23
  className={`o-header__drawer-menu-toggle o-header__drawer-menu-toggle--${selected}`}
25
24
  aria-controls={`o-header-drawer-child-${idSuffix}`}
26
- data-trackable={`sub-level-toggle | ${item.label}`}
27
- >
25
+ data-trackable={`sub-level-toggle | ${item.label}`}>
28
26
  {`Show more ${item.label}`}
29
27
  </button>
30
28
  </div>
31
29
  <ul
32
30
  className="o-header__drawer-menu-list o-header__drawer-menu-list--child"
33
31
  id={`o-header-drawer-child-${idSuffix}`}
34
- data-trackable="sub-level"
35
- >
32
+ data-trackable="sub-level">
36
33
  {(item.submenu?.items as TNavMenuItem[]).map((item) => {
37
34
  const selected = item.selected ? 'selected' : 'unselected'
38
35
  return (
@@ -41,8 +38,7 @@ export const DrawerParentItem = ({ item, idSuffix }: TDrawerParentItemProps) =>
41
38
  className={`o-header__drawer-menu-link o-header__drawer-menu-link--${selected} o-header__drawer-menu-link--child`}
42
39
  href={item.url ?? undefined}
43
40
  data-trackable={item.label}
44
- {...ariaSelected(item)}
45
- >
41
+ {...ariaSelected(item)}>
46
42
  {item.label}
47
43
  </a>
48
44
  </li>
@@ -60,8 +56,7 @@ export const DrawerSingleItem = (item: TNavMenuItem) => {
60
56
  className={`o-header__drawer-menu-link o-header__drawer-menu-link--${selected}`}
61
57
  href={item.url ?? undefined}
62
58
  data-trackable={item.label}
63
- {...ariaSelected(item)}
64
- >
59
+ {...ariaSelected(item)}>
65
60
  {item.label}
66
61
  </a>
67
62
  )
@@ -74,27 +69,29 @@ export const DrawerSpecialItem = (item: TNavMenuItem) => {
74
69
  className={`o-header__drawer-menu-link o-header__drawer-menu-link--${selected} o-header__drawer-menu-link--secondary`}
75
70
  href={item.url ?? undefined}
76
71
  data-trackable={item.label}
77
- {...ariaSelected(item)}
78
- >
72
+ {...ariaSelected(item)}>
79
73
  {item.label}
80
74
  </a>
81
75
  )
82
76
  }
83
77
 
84
78
  export const EditionsSwitcher = (editions: TNavEditions) => (
85
- <ul className="o-header__drawer-menu-list">
86
- {editions.others.map(({ id, name, url }) => {
87
- const href = `${url}?edition=${id}`
88
- return (
89
- <li key={id} className="o-header__drawer-menu-item" data-trackable="edition-switcher">
90
- <a className="o-header__drawer-menu-link" href={href} data-trackable={id}>
91
- Switch to {name} Edition
92
- </a>
93
- </li>
94
- )
95
- })}
96
- </ul>
97
- )
79
+ <nav
80
+ className="o-header__drawer-menu o-header__drawer-edition-switcher"
81
+ aria-label="Edition switcher">
82
+ <span className="o-header__drawer-menu-item">Edition:</span>
83
+ <span className="o-header__drawer-menu-item o-header__drawer-current-edition">
84
+ {editions.current?.name}
85
+ </span>
86
+ <div className="o-header__drawer-divider"></div>
87
+ {editions.others?.map(({name, id, url}) => (
88
+ <a key={id} className="o-header__drawer-menu-link" href={`${url}?edition=${id}`}>
89
+ {name}
90
+ </a>
91
+ ))}
92
+ </nav>
93
+ );
94
+
98
95
 
99
96
  export const SubscribeButton = (action: TNavAction) => (
100
97
  <div className="o-header__drawer-actions">
@@ -28,15 +28,18 @@ const Drawer = (props: THeaderProps) => {
28
28
  data-o-header-drawer
29
29
  data-o-header-drawer--no-js
30
30
  data-trackable="drawer"
31
- data-trackable-terminate
32
- >
31
+ data-trackable-terminate>
33
32
  <div className="o-header__drawer-inner">
34
33
  <DrawerTools {...editions} />
34
+ <Search />
35
+ {props.showAskButton && (
36
+ <AskFtButton
37
+ className="ft-header__drawer-ask-ft-button"
38
+ id="ask-ft-button-drawer"
39
+ dataTrackable="ask-ft-button-drawer"
40
+ />
41
+ )}
35
42
  {!props.userIsSubscribed && subscribeAction && <SubscribeButton {...subscribeAction} />}
36
- <Search {...props} />
37
- <nav className="o-header__drawer-menu" aria-label="Edition switcher">
38
- {editions && <EditionsSwitcher {...editions} />}
39
- </nav>
40
43
  <nav className="o-header__drawer-menu o-header__drawer-menu--primary">
41
44
  {primary ? <SectionPrimary {...primary} /> : null}
42
45
  {secondary ? <SectionSecondary {...secondary} /> : null}
@@ -48,25 +51,21 @@ const Drawer = (props: THeaderProps) => {
48
51
  )
49
52
  }
50
53
 
51
- const DrawerTools = (props: TNavEditions) => (
54
+ const DrawerTools = (editions: TNavEditions) => (
52
55
  <div className="o-header__drawer-tools">
53
56
  <button
54
57
  type="button"
55
58
  className="o-header__drawer-tools-close"
56
59
  title="Close side navigation menu"
57
60
  aria-controls="o-header-drawer"
58
- data-trackable="close"
59
- >
61
+ data-trackable="close">
60
62
  <span className="o-header__visually-hidden">Close side navigation menu</span>
61
63
  </button>
62
- <a className="o-header__drawer-tools-logo" href="/" data-trackable="logo">
63
- <span className="o-header__visually-hidden">Financial Times</span>
64
- </a>
65
- {props.current && <p className="o-header__drawer-current-edition">{`${props.current.name} Edition`}</p>}
64
+ {editions && <EditionsSwitcher {...editions} />}
66
65
  </div>
67
66
  )
68
67
 
69
- const Search = (props: Pick<THeaderProps, 'showAskButton'>) => (
68
+ const Search = () => (
70
69
  <div className="o-header__drawer-search">
71
70
  <form
72
71
  className="o-header__drawer-search-form"
@@ -75,34 +74,31 @@ const Search = (props: Pick<THeaderProps, 'showAskButton'>) => (
75
74
  aria-label="Site search"
76
75
  data-n-topic-search
77
76
  data-n-topic-search-categories="concepts,equities"
78
- data-n-topic-search-view-all
79
- >
80
- <label className="o-header__visually-hidden" htmlFor="o-header-drawer-search-term">
81
- Search the <abbr title="Financial Times">FT</abbr>
77
+ data-n-topic-search-view-all>
78
+ <label htmlFor="o-header-drawer-search-term" className="o-forms-field o-forms-field--optional">
79
+ <span className="o-forms-title o-header__visually-hidden">
80
+ <span className="o-forms-title__main">
81
+ Search the <abbr title="Financial Times">FT</abbr>
82
+ </span>
83
+ </span>
84
+ <span className="o-forms-input o-forms-input--text o-forms-input--suffix">
85
+ <input
86
+ id="o-header-drawer-search-term"
87
+ name="q"
88
+ type="text"
89
+ autoComplete="off"
90
+ autoCorrect="off"
91
+ autoCapitalize="off"
92
+ spellCheck={false}
93
+ data-trackable="search-term"
94
+ data-n-topic-search-input
95
+ placeholder="Search for stories, topics or securities"
96
+ />
97
+ <button className="o-header__drawer-search-submit" type="submit" data-trackable="search-submit">
98
+ <span className="o-header__visually-hidden">Search</span>
99
+ </button>
100
+ </span>
82
101
  </label>
83
- <input
84
- className="o-header__drawer-search-term"
85
- id="o-header-drawer-search-term"
86
- name="q"
87
- type="text"
88
- autoComplete="off"
89
- autoCorrect="off"
90
- autoCapitalize="off"
91
- spellCheck={false}
92
- placeholder="Search the FT"
93
- data-trackable="search-term"
94
- data-n-topic-search-input
95
- />
96
- <button className="o-header__drawer-search-submit" type="submit" data-trackable="search-submit">
97
- <span className="o-header__visually-hidden">Search</span>
98
- </button>
99
- {props.showAskButton && (
100
- <AskFtButton
101
- className="ft-header__drawer-ask-ft-button"
102
- id="ask-ft-button-drawer"
103
- dataTrackable="ask-ft-button-drawer"
104
- />
105
- )}
106
102
  </form>
107
103
  </div>
108
104
  )
@@ -16,33 +16,41 @@ const Search = ({ instance }) => {
16
16
  data-n-topic-search
17
17
  data-n-topic-search-categories="concepts,equities"
18
18
  data-n-topic-search-view-all>
19
- <label className="o-header__visually-hidden" htmlFor={`o-header-search-term-${instance}`}>
20
- Search the <abbr title="Financial Times">FT</abbr>
19
+ <label
20
+ htmlFor={`o-header-search-term-${instance}`}
21
+ className="o-header__search-term o-forms-field o-forms-field--optional">
22
+ <span className="o-forms-title o-header__visually-hidden">
23
+ <span className="o-forms-title__main">
24
+ Search the <abbr title="Financial Times">FT</abbr>
25
+ </span>
26
+ </span>
27
+ <span className="o-forms-input o-forms-input--text o-forms-input--suffix">
28
+ <input
29
+ className="o-header__search-term"
30
+ id={`o-header-search-term-${instance}`}
31
+ name="q"
32
+ type="text"
33
+ autoComplete="off"
34
+ autoCorrect="off"
35
+ autoCapitalize="off"
36
+ spellCheck={false}
37
+ data-trackable="search-term"
38
+ data-n-topic-search-input
39
+ placeholder="Search for stories, topics or securities"
40
+ />
41
+ <button className="o-header__search-submit" type="submit">
42
+ Search
43
+ </button>
44
+ <button
45
+ className="o-header__search-close o--if-js"
46
+ type="button"
47
+ aria-controls={`o-header-search-${instance}`}
48
+ title="Close search bar"
49
+ data-trackable="close">
50
+ <span className="o-header__visually-hidden">Close search bar</span>
51
+ </button>
52
+ </span>
21
53
  </label>
22
- <input
23
- className="o-header__search-term"
24
- id={`o-header-search-term-${instance}`}
25
- name="q"
26
- type="text"
27
- autoComplete="off"
28
- autoCorrect="off"
29
- autoCapitalize="off"
30
- spellCheck={false}
31
- data-trackable="search-term"
32
- placeholder="Search the FT"
33
- data-n-topic-search-input
34
- />
35
- <button className="o-header__search-submit" type="submit" data-trackable="search-submit">
36
- Search
37
- </button>
38
- <button
39
- className="o-header__search-close o--if-js"
40
- type="button"
41
- aria-controls={`o-header-search-${instance}`}
42
- title="Close search bar"
43
- data-trackable="close">
44
- <span className="o-header__visually-hidden">Close search bar</span>
45
- </button>
46
54
  </form>
47
55
  </div>
48
56
  </div>
package/src/header.scss CHANGED
@@ -17,6 +17,9 @@
17
17
  .o-header__drawer {
18
18
  @include nUiZIndexFor('drawer');
19
19
  display: block;
20
+ .o-header__drawer-search {
21
+ margin-bottom: 8px;
22
+ }
20
23
  }
21
24
 
22
25
  .o-header--sticky {
@@ -67,5 +70,10 @@
67
70
  }
68
71
 
69
72
  .ft-header__drawer-ask-ft-button {
70
- margin-left: 16px;
73
+ display: block;
74
+ width: 100%;
75
+ box-sizing: border-box;
76
+ margin: 0;
77
+ text-align: center;
78
+
71
79
  }
package/styles.scss CHANGED
@@ -12,3 +12,8 @@ $system-code: 'page-kit-header' !default;
12
12
 
13
13
  @import "n-topic-search/main";
14
14
  @include nTopicSearch;
15
+ .n-topic-search {
16
+ @include oGridRespondTo($from: 'M') {
17
+ margin: 24px 0 0;
18
+ }
19
+ }