@internetarchive/ia-topnav 1.3.6 → 1.3.7-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.
- package/.eslintrc +16 -16
- package/LICENSE +661 -661
- package/README.md +147 -147
- package/index.d.ts +109 -109
- package/index.js +3 -3
- package/package.json +61 -61
- package/src/assets/img/hamburger.js +38 -38
- package/src/assets/img/ia-icon.js +33 -33
- package/src/assets/img/icon-audio.js +23 -23
- package/src/assets/img/icon-close.js +16 -16
- package/src/assets/img/icon-donate-unpadded.js +16 -16
- package/src/assets/img/icon-donate.js +15 -15
- package/src/assets/img/icon-ellipses.js +15 -15
- package/src/assets/img/icon-ia-logo.js +22 -22
- package/src/assets/img/icon-images.js +15 -15
- package/src/assets/img/icon-search.js +15 -15
- package/src/assets/img/icon-software.js +15 -15
- package/src/assets/img/icon-texts.js +15 -15
- package/src/assets/img/icon-upload-unpadded.js +14 -14
- package/src/assets/img/icon-upload.js +15 -15
- package/src/assets/img/icon-user.js +15 -15
- package/src/assets/img/icon-video.js +15 -15
- package/src/assets/img/icon-web.js +15 -15
- package/src/assets/img/icon.js +18 -18
- package/src/assets/img/icons.js +33 -33
- package/src/assets/img/wordmark-stacked.js +13 -13
- package/src/data/menus.js +646 -646
- package/src/desktop-subnav.js +45 -45
- package/src/dropdown-menu.js +110 -109
- package/src/ia-topnav.js +324 -314
- package/src/lib/formatUrl.js +1 -1
- package/src/lib/keyboard-navigation.js +128 -0
- package/src/lib/location-handler.js +5 -5
- package/src/lib/query-handler.js +7 -7
- package/src/lib/toSentenceCase.js +8 -8
- package/src/login-button.js +79 -79
- package/src/media-button.js +113 -113
- package/src/media-menu.js +154 -133
- package/src/media-slider.js +118 -104
- package/src/media-subnav.js +112 -112
- package/src/more-slider.js +33 -33
- package/src/nav-search.js +111 -117
- package/src/primary-nav.js +258 -224
- package/src/save-page-form.js +59 -59
- package/src/search-menu.js +145 -115
- package/src/signed-out-dropdown.js +10 -10
- package/src/styles/base.js +48 -48
- package/src/styles/desktop-subnav.js +37 -37
- package/src/styles/dropdown-menu.js +168 -166
- package/src/styles/ia-topnav.js +87 -87
- package/src/styles/login-button.js +82 -79
- package/src/styles/media-button.js +156 -156
- package/src/styles/media-menu.js +66 -70
- package/src/styles/media-slider.js +81 -81
- package/src/styles/media-subnav.js +156 -156
- package/src/styles/more-slider.js +15 -15
- package/src/styles/nav-search.js +136 -136
- package/src/styles/primary-nav.js +311 -300
- package/src/styles/save-page-form.js +54 -54
- package/src/styles/search-menu.js +105 -99
- package/src/styles/signed-out-dropdown.js +31 -31
- package/src/styles/user-menu.js +31 -31
- package/src/styles/wayback-search.js +48 -48
- package/src/styles/wayback-slider.js +30 -30
- package/src/tracked-element.js +29 -27
- package/src/user-menu.js +56 -42
- package/src/wayback-search.js +18 -18
- package/src/wayback-slider.js +87 -87
- package/test/assets/img/hamburger.test.js +15 -15
- package/test/assets/img/user.test.js +15 -15
- package/test/data/menus.test.js +19 -19
- package/test/dropdown-menu.test.js +25 -25
- package/test/ia-icon.test.js +13 -13
- package/test/ia-topnav.test.js +273 -273
- package/test/login-button.test.js +15 -15
- package/test/media-button.test.js +19 -19
- package/test/media-menu.test.js +40 -40
- package/test/media-slider.test.js +57 -57
- package/test/more-slider.test.js +13 -13
- package/test/nav-search.test.js +61 -61
- package/test/primary-nav.test.js +82 -82
- package/test/save-page-form.test.js +35 -35
- package/test/search-menu.test.js +49 -49
- package/test/user-menu.test.js +33 -33
- package/test/wayback-slider.test.js +80 -80
package/src/desktop-subnav.js
CHANGED
|
@@ -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);
|
package/src/dropdown-menu.js
CHANGED
|
@@ -1,109 +1,110 @@
|
|
|
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
|
-
import icons from './assets/img/icons.js';
|
|
6
|
-
|
|
7
|
-
class DropdownMenu extends TrackedElement {
|
|
8
|
-
static get styles() {
|
|
9
|
-
return dropdownMenuCSS;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static get properties() {
|
|
13
|
-
return {
|
|
14
|
-
baseHost: { type: String },
|
|
15
|
-
config: { type: Object },
|
|
16
|
-
hideSearch: { type: Boolean },
|
|
17
|
-
menuItems: { type: Array },
|
|
18
|
-
animate: { type: Boolean },
|
|
19
|
-
open: { type: Boolean },
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
constructor() {
|
|
24
|
-
super();
|
|
25
|
-
this.config = {};
|
|
26
|
-
this.menuItems = [];
|
|
27
|
-
this.open = false;
|
|
28
|
-
this.animate = false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get dropdownItems() {
|
|
32
|
-
if (!this.menuItems) return nothing;
|
|
33
|
-
|
|
34
|
-
if (!Array.isArray(this.menuItems[0])) {
|
|
35
|
-
return this.dropdownSection(this.menuItems);
|
|
36
|
-
}
|
|
37
|
-
return this.menuItems.map((submenu, i) => {
|
|
38
|
-
const joiner = i ? DropdownMenu.dropdownDivider : html``;
|
|
39
|
-
return [joiner, ...this.dropdownSection(submenu)];
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static get dropdownDivider() {
|
|
44
|
-
return html`<li role="presentation" class="divider"></li>`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
dropdownSection(submenu) {
|
|
48
|
-
return submenu.map(item => (
|
|
49
|
-
html`
|
|
50
|
-
<li>${item.url ? this.dropdownLink(item) : DropdownMenu.dropdownText(item)}</li>
|
|
51
|
-
`
|
|
52
|
-
));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
dropdownLink(link) {
|
|
56
|
-
const calloutText = this.config.callouts?.[link.title];
|
|
57
|
-
return html`<a
|
|
58
|
-
href="${formatUrl(link.url, this.baseHost)}"
|
|
59
|
-
class="${link.class}"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
${link.
|
|
65
|
-
${
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
aria-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
import icons from './assets/img/icons.js';
|
|
6
|
+
|
|
7
|
+
class DropdownMenu extends TrackedElement {
|
|
8
|
+
static get styles() {
|
|
9
|
+
return dropdownMenuCSS;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
baseHost: { type: String },
|
|
15
|
+
config: { type: Object },
|
|
16
|
+
hideSearch: { type: Boolean },
|
|
17
|
+
menuItems: { type: Array },
|
|
18
|
+
animate: { type: Boolean },
|
|
19
|
+
open: { type: Boolean },
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.config = {};
|
|
26
|
+
this.menuItems = [];
|
|
27
|
+
this.open = false;
|
|
28
|
+
this.animate = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get dropdownItems() {
|
|
32
|
+
if (!this.menuItems) return nothing;
|
|
33
|
+
|
|
34
|
+
if (!Array.isArray(this.menuItems[0])) {
|
|
35
|
+
return this.dropdownSection(this.menuItems);
|
|
36
|
+
}
|
|
37
|
+
return this.menuItems.map((submenu, i) => {
|
|
38
|
+
const joiner = i ? DropdownMenu.dropdownDivider : html``;
|
|
39
|
+
return [joiner, ...this.dropdownSection(submenu)];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static get dropdownDivider() {
|
|
44
|
+
return html`<li role="presentation" class="divider"></li>`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
dropdownSection(submenu) {
|
|
48
|
+
return submenu.map(item => (
|
|
49
|
+
html`
|
|
50
|
+
<li>${item.url ? this.dropdownLink(item) : DropdownMenu.dropdownText(item)}</li>
|
|
51
|
+
`
|
|
52
|
+
));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dropdownLink(link) {
|
|
56
|
+
const calloutText = this.config.callouts?.[link.title];
|
|
57
|
+
return html`<a
|
|
58
|
+
href="${formatUrl(link.url, this.baseHost)}"
|
|
59
|
+
class="${link.class}"
|
|
60
|
+
tabindex="${this.open ? '' : '-1'}"
|
|
61
|
+
@click=${this.trackClick}
|
|
62
|
+
data-event-click-tracking="${this.config.eventCategory}|Nav${link.analyticsEvent}"
|
|
63
|
+
aria-label=${calloutText ? `New feature: ${link.title}` : nothing}>
|
|
64
|
+
${link.class === 'mobile-upload' ? icons.uploadUnpadded : nothing}
|
|
65
|
+
${link.title}
|
|
66
|
+
${calloutText ? html`<span class="callout" aria-hidden="true">${calloutText}</span>` : nothing}
|
|
67
|
+
</a>`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static dropdownText(item) {
|
|
71
|
+
return html`<span class="info-item">${item.title}</span>`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get menuClass() {
|
|
75
|
+
const hiddenClass = this.hideSearch ? ' search-hidden' : '';
|
|
76
|
+
if (this.open) {
|
|
77
|
+
return `open${hiddenClass}`;
|
|
78
|
+
}
|
|
79
|
+
if (this.animate) {
|
|
80
|
+
return `closed${hiddenClass}`;
|
|
81
|
+
}
|
|
82
|
+
return `initial${hiddenClass}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get ariaHidden() {
|
|
86
|
+
return Boolean(!this.open).toString();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get ariaExpanded() {
|
|
90
|
+
return Boolean(this.open).toString();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
render() {
|
|
94
|
+
return html`
|
|
95
|
+
<div class="nav-container">
|
|
96
|
+
<nav
|
|
97
|
+
class="${this.menuClass}"
|
|
98
|
+
aria-hidden="${this.ariaHidden}"
|
|
99
|
+
aria-expanded="${this.ariaExpanded}"
|
|
100
|
+
>
|
|
101
|
+
<ul>
|
|
102
|
+
${this.dropdownItems}
|
|
103
|
+
</ul>
|
|
104
|
+
</nav>
|
|
105
|
+
</div>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default DropdownMenu;
|