@internetarchive/ia-topnav 1.1.27 → 1.1.28-alpha1

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 (88) hide show
  1. package/.eslintrc +16 -16
  2. package/.storybook/.babelrc +15 -15
  3. package/.storybook/addons.js +7 -7
  4. package/.storybook/config.js +11 -11
  5. package/.storybook/webpack.config.js +5 -5
  6. package/LICENSE +661 -661
  7. package/README.md +144 -144
  8. package/index.d.ts +104 -104
  9. package/index.js +3 -3
  10. package/package.json +61 -61
  11. package/src/assets/img/hamburger.js +36 -36
  12. package/src/assets/img/ia-icon.js +33 -33
  13. package/src/assets/img/icon-audio.js +23 -23
  14. package/src/assets/img/icon-close.js +16 -16
  15. package/src/assets/img/icon-donate.js +15 -15
  16. package/src/assets/img/icon-ellipses.js +15 -15
  17. package/src/assets/img/icon-ia-logo.js +24 -24
  18. package/src/assets/img/icon-images.js +15 -15
  19. package/src/assets/img/icon-search.js +15 -15
  20. package/src/assets/img/icon-software.js +15 -15
  21. package/src/assets/img/icon-texts.js +15 -15
  22. package/src/assets/img/icon-upload.js +15 -15
  23. package/src/assets/img/icon-user.js +15 -15
  24. package/src/assets/img/icon-video.js +15 -15
  25. package/src/assets/img/icon-web.js +15 -15
  26. package/src/assets/img/icon.js +18 -18
  27. package/src/assets/img/icons.js +29 -29
  28. package/src/assets/img/user.js +38 -38
  29. package/src/assets/img/wordmark-stacked.js +13 -13
  30. package/src/data/menus.js +659 -659
  31. package/src/desktop-subnav.js +45 -45
  32. package/src/dropdown-menu.js +98 -98
  33. package/src/ia-topnav.js +309 -307
  34. package/src/lib/formatUrl.js +1 -1
  35. package/src/lib/location-handler.js +5 -5
  36. package/src/lib/query-handler.js +7 -7
  37. package/src/lib/toSentenceCase.js +8 -8
  38. package/src/login-button.js +79 -79
  39. package/src/media-button.js +113 -113
  40. package/src/media-menu.js +133 -133
  41. package/src/media-slider.js +104 -104
  42. package/src/media-subnav.js +112 -112
  43. package/src/more-slider.js +33 -33
  44. package/src/nav-search.js +125 -125
  45. package/src/primary-nav.js +210 -210
  46. package/src/save-page-form.js +59 -59
  47. package/src/search-menu.js +115 -115
  48. package/src/signed-out-dropdown.js +10 -10
  49. package/src/styles/base.js +48 -48
  50. package/src/styles/desktop-subnav.js +37 -37
  51. package/src/styles/dropdown-menu.js +139 -139
  52. package/src/styles/ia-topnav.js +88 -88
  53. package/src/styles/login-button.js +70 -70
  54. package/src/styles/media-button.js +153 -153
  55. package/src/styles/media-menu.js +70 -70
  56. package/src/styles/media-slider.js +81 -81
  57. package/src/styles/media-subnav.js +156 -156
  58. package/src/styles/more-slider.js +15 -15
  59. package/src/styles/nav-search.js +134 -134
  60. package/src/styles/primary-nav.js +254 -254
  61. package/src/styles/save-page-form.js +53 -53
  62. package/src/styles/search-menu.js +99 -99
  63. package/src/styles/signed-out-dropdown.js +31 -31
  64. package/src/styles/user-menu.js +31 -31
  65. package/src/styles/wayback-search.js +48 -48
  66. package/src/styles/wayback-slider.js +30 -30
  67. package/src/tracked-element.js +27 -27
  68. package/src/user-menu.js +42 -42
  69. package/src/wayback-search.js +18 -18
  70. package/src/wayback-slider.js +88 -88
  71. package/stories/topnav-element.stories.js +7 -7
  72. package/test/assets/img/hamburger.test.js +15 -15
  73. package/test/assets/img/user.test.js +15 -15
  74. package/test/data/menus.test.js +19 -19
  75. package/test/dropdown-menu.test.js +25 -25
  76. package/test/ia-icon.test.js +13 -13
  77. package/test/ia-topnav.test.js +273 -273
  78. package/test/login-button.test.js +15 -15
  79. package/test/media-button.test.js +19 -19
  80. package/test/media-menu.test.js +40 -40
  81. package/test/media-slider.test.js +57 -57
  82. package/test/more-slider.test.js +13 -13
  83. package/test/nav-search.test.js +61 -61
  84. package/test/primary-nav.test.js +82 -82
  85. package/test/save-page-form.test.js +35 -35
  86. package/test/search-menu.test.js +49 -49
  87. package/test/user-menu.test.js +33 -33
  88. package/test/wayback-slider.test.js +80 -80
@@ -1,45 +1,45 @@
1
- import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
- import TrackedElement from './tracked-element.js';
3
- import desktopSubnavCSS from './styles/desktop-subnav.js';
4
- import icons from './assets/img/icons.js';
5
- import formatUrl from './lib/formatUrl.js';
6
-
7
- class DesktopSubnav extends TrackedElement {
8
- static get styles() {
9
- return desktopSubnavCSS;
10
- }
11
-
12
- static get properties() {
13
- return {
14
- baseHost: { type: String },
15
- menuItems: { type: Array },
16
- };
17
- }
18
-
19
- get listItems() {
20
- return this.menuItems ? this.menuItems.map(link => (
21
- html`
22
- <li>
23
- <a class="${link.title.toLowerCase()}" href="${formatUrl(link.url, this.baseHost)}">${link.title}${DesktopSubnav.iconFor(link.title)}</a>
24
- </li>
25
- `
26
- )) : nothing;
27
- }
28
-
29
- static iconFor(title) {
30
- const subnavIcons = {
31
- Donate: icons.donate
32
- };
33
- return subnavIcons[title] ? subnavIcons[title] : html``;
34
- }
35
-
36
- render() {
37
- return html`
38
- <ul>
39
- ${this.listItems}
40
- </ul>
41
- `;
42
- }
43
- }
44
-
45
- customElements.define('desktop-subnav', DesktopSubnav);
1
+ import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
+ import TrackedElement from './tracked-element.js';
3
+ import desktopSubnavCSS from './styles/desktop-subnav.js';
4
+ import icons from './assets/img/icons.js';
5
+ import formatUrl from './lib/formatUrl.js';
6
+
7
+ class DesktopSubnav extends TrackedElement {
8
+ static get styles() {
9
+ return desktopSubnavCSS;
10
+ }
11
+
12
+ static get properties() {
13
+ return {
14
+ baseHost: { type: String },
15
+ menuItems: { type: Array },
16
+ };
17
+ }
18
+
19
+ get listItems() {
20
+ return this.menuItems ? this.menuItems.map(link => (
21
+ html`
22
+ <li>
23
+ <a class="${link.title.toLowerCase()}" href="${formatUrl(link.url, this.baseHost)}">${link.title}${DesktopSubnav.iconFor(link.title)}</a>
24
+ </li>
25
+ `
26
+ )) : nothing;
27
+ }
28
+
29
+ static iconFor(title) {
30
+ const subnavIcons = {
31
+ Donate: icons.donate
32
+ };
33
+ return subnavIcons[title] ? subnavIcons[title] : html``;
34
+ }
35
+
36
+ render() {
37
+ return html`
38
+ <ul>
39
+ ${this.listItems}
40
+ </ul>
41
+ `;
42
+ }
43
+ }
44
+
45
+ customElements.define('desktop-subnav', DesktopSubnav);
@@ -1,98 +1,98 @@
1
- import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
- import TrackedElement from './tracked-element.js';
3
- import dropdownMenuCSS from './styles/dropdown-menu.js';
4
- import formatUrl from './lib/formatUrl.js';
5
-
6
- class DropdownMenu extends TrackedElement {
7
- static get styles() {
8
- return dropdownMenuCSS;
9
- }
10
-
11
- static get properties() {
12
- return {
13
- baseHost: { type: String },
14
- config: { type: Object },
15
- hideSearch: { type: Boolean },
16
- menuItems: { type: Array },
17
- animate: { type: Boolean },
18
- open: { type: Boolean },
19
- };
20
- }
21
-
22
- constructor() {
23
- super();
24
- this.config = {};
25
- this.menuItems = [];
26
- this.open = false;
27
- this.animate = false;
28
- }
29
-
30
- get dropdownItems() {
31
- if (!this.menuItems) return nothing;
32
-
33
- if (!Array.isArray(this.menuItems[0])) {
34
- return this.dropdownSection(this.menuItems);
35
- }
36
- return this.menuItems.map((submenu, i) => {
37
- const joiner = i ? DropdownMenu.dropdownDivider : html``;
38
- return [joiner, ...this.dropdownSection(submenu)];
39
- });
40
- }
41
-
42
- static get dropdownDivider() {
43
- return html`<li role="presentation" class="divider"></li>`;
44
- }
45
-
46
- dropdownSection(submenu) {
47
- return submenu.map(item => (
48
- html`
49
- <li>${item.url ? this.dropdownLink(item) : DropdownMenu.dropdownText(item)}</li>
50
- `
51
- ));
52
- }
53
-
54
- dropdownLink(link) {
55
- return html`<a href="${formatUrl(link.url, this.baseHost)}" @click=${this.trackClick} data-event-click-tracking="${this.config.eventCategory}|Nav${link.analyticsEvent}">${link.title}</a>`;
56
- }
57
-
58
- static dropdownText(item) {
59
- return html`<span class="info-item">${item.title}</span>`;
60
- }
61
-
62
- get menuClass() {
63
- const hiddenClass = this.hideSearch ? ' search-hidden' : '';
64
- if (this.open) {
65
- return `open${hiddenClass}`;
66
- }
67
- if (this.animate) {
68
- return `closed${hiddenClass}`;
69
- }
70
- return `initial${hiddenClass}`;
71
- }
72
-
73
- get ariaHidden() {
74
- return Boolean(!this.open).toString();
75
- }
76
-
77
- get ariaExpanded() {
78
- return Boolean(this.open).toString();
79
- }
80
-
81
- render() {
82
- return html`
83
- <div class="nav-container">
84
- <nav
85
- class="${this.menuClass}"
86
- aria-hidden="${this.ariaHidden}"
87
- aria-expanded="${this.ariaExpanded}"
88
- >
89
- <ul>
90
- ${this.dropdownItems}
91
- </ul>
92
- </nav>
93
- </div>
94
- `;
95
- }
96
- }
97
-
98
- export default DropdownMenu;
1
+ import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
+ import TrackedElement from './tracked-element.js';
3
+ import dropdownMenuCSS from './styles/dropdown-menu.js';
4
+ import formatUrl from './lib/formatUrl.js';
5
+
6
+ class DropdownMenu extends TrackedElement {
7
+ static get styles() {
8
+ return dropdownMenuCSS;
9
+ }
10
+
11
+ static get properties() {
12
+ return {
13
+ baseHost: { type: String },
14
+ config: { type: Object },
15
+ hideSearch: { type: Boolean },
16
+ menuItems: { type: Array },
17
+ animate: { type: Boolean },
18
+ open: { type: Boolean },
19
+ };
20
+ }
21
+
22
+ constructor() {
23
+ super();
24
+ this.config = {};
25
+ this.menuItems = [];
26
+ this.open = false;
27
+ this.animate = false;
28
+ }
29
+
30
+ get dropdownItems() {
31
+ if (!this.menuItems) return nothing;
32
+
33
+ if (!Array.isArray(this.menuItems[0])) {
34
+ return this.dropdownSection(this.menuItems);
35
+ }
36
+ return this.menuItems.map((submenu, i) => {
37
+ const joiner = i ? DropdownMenu.dropdownDivider : html``;
38
+ return [joiner, ...this.dropdownSection(submenu)];
39
+ });
40
+ }
41
+
42
+ static get dropdownDivider() {
43
+ return html`<li role="presentation" class="divider"></li>`;
44
+ }
45
+
46
+ dropdownSection(submenu) {
47
+ return submenu.map(item => (
48
+ html`
49
+ <li>${item.url ? this.dropdownLink(item) : DropdownMenu.dropdownText(item)}</li>
50
+ `
51
+ ));
52
+ }
53
+
54
+ dropdownLink(link) {
55
+ return html`<a href="${formatUrl(link.url, this.baseHost)}" @click=${this.trackClick} data-event-click-tracking="${this.config.eventCategory}|Nav${link.analyticsEvent}">${link.title}</a>`;
56
+ }
57
+
58
+ static dropdownText(item) {
59
+ return html`<span class="info-item">${item.title}</span>`;
60
+ }
61
+
62
+ get menuClass() {
63
+ const hiddenClass = this.hideSearch ? ' search-hidden' : '';
64
+ if (this.open) {
65
+ return `open${hiddenClass}`;
66
+ }
67
+ if (this.animate) {
68
+ return `closed${hiddenClass}`;
69
+ }
70
+ return `initial${hiddenClass}`;
71
+ }
72
+
73
+ get ariaHidden() {
74
+ return Boolean(!this.open).toString();
75
+ }
76
+
77
+ get ariaExpanded() {
78
+ return Boolean(this.open).toString();
79
+ }
80
+
81
+ render() {
82
+ return html`
83
+ <div class="nav-container">
84
+ <nav
85
+ class="${this.menuClass}"
86
+ aria-hidden="${this.ariaHidden}"
87
+ aria-expanded="${this.ariaExpanded}"
88
+ >
89
+ <ul>
90
+ ${this.dropdownItems}
91
+ </ul>
92
+ </nav>
93
+ </div>
94
+ `;
95
+ }
96
+ }
97
+
98
+ export default DropdownMenu;