@internetarchive/ia-topnav 1.3.5-alpha1 → 1.3.5-alpha11
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/package.json +1 -1
- package/src/dropdown-menu.js +1 -0
- package/src/ia-topnav.js +8 -1
- package/src/lib/keyboard-navigation.js +131 -0
- package/src/media-button.js +1 -0
- package/src/media-menu.js +21 -1
- package/src/media-slider.js +21 -7
- package/src/nav-search.js +1 -1
- package/src/primary-nav.js +38 -25
- package/src/search-menu.js +28 -22
- package/src/styles/dropdown-menu.js +2 -0
- package/src/styles/media-menu.js +1 -5
- package/src/styles/primary-nav.js +23 -13
- package/src/styles/search-menu.js +2 -0
- package/src/user-menu.js +14 -0
package/package.json
CHANGED
package/src/dropdown-menu.js
CHANGED
|
@@ -57,6 +57,7 @@ class DropdownMenu extends TrackedElement {
|
|
|
57
57
|
return html`<a
|
|
58
58
|
href="${formatUrl(link.url, this.baseHost)}"
|
|
59
59
|
class="${link.class}"
|
|
60
|
+
tabindex="${this.open ? '' : '-1'}"
|
|
60
61
|
@click=${this.trackClick}
|
|
61
62
|
data-event-click-tracking="${this.config.eventCategory}|Nav${link.analyticsEvent}"
|
|
62
63
|
aria-label=${calloutText ? `New feature: ${link.title}` : nothing}>
|
package/src/ia-topnav.js
CHANGED
|
@@ -62,6 +62,7 @@ export default class IATopNav extends LitElement {
|
|
|
62
62
|
username: { type: String },
|
|
63
63
|
userProfileImagePath: { type: String },
|
|
64
64
|
secondIdentitySlotMode: { type: String },
|
|
65
|
+
currentTab: { type: Object },
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -77,11 +78,12 @@ export default class IATopNav extends LitElement {
|
|
|
77
78
|
this.searchIn = '';
|
|
78
79
|
this.selectedMenuOption = '';
|
|
79
80
|
this.secondIdentitySlotMode = '';
|
|
81
|
+
this.currentTab = {};
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
updated(props) {
|
|
83
85
|
if (props.has('username') || props.has('localLinks') || props.has('baseHost') ||
|
|
84
|
-
|
|
86
|
+
props.has('waybackPagesArchived') || props.has('itemIdentifier')) {
|
|
85
87
|
this.menuSetup();
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -199,6 +201,7 @@ export default class IATopNav extends LitElement {
|
|
|
199
201
|
tabindex="${this.userMenuTabIndex}"
|
|
200
202
|
@menuToggled=${this.menuToggled}
|
|
201
203
|
@trackClick=${this.trackClick}
|
|
204
|
+
@focusToNext=${(e) => this.currentTab = e.detail}
|
|
202
205
|
></user-menu>
|
|
203
206
|
`;
|
|
204
207
|
}
|
|
@@ -274,6 +277,7 @@ export default class IATopNav extends LitElement {
|
|
|
274
277
|
.selectedMenuOption=${this.selectedMenuOption}
|
|
275
278
|
.username=${this.username}
|
|
276
279
|
.userProfileImagePath=${this.userProfileImagePath}
|
|
280
|
+
.currentTab=${this.currentTab}
|
|
277
281
|
?hideSearch=${this.hideSearch}
|
|
278
282
|
@mediaTypeSelected=${this.mediaTypeSelected}
|
|
279
283
|
@toggleSearchMenu=${this.toggleSearchMenu}
|
|
@@ -289,6 +293,8 @@ export default class IATopNav extends LitElement {
|
|
|
289
293
|
.selectedMenuOption=${this.selectedMenuOption}
|
|
290
294
|
.mediaSliderOpen=${this.mediaSliderOpen}
|
|
291
295
|
.menus=${this.menus}
|
|
296
|
+
tabindex="${this.mediaSliderOpen ? '1' : ''}"
|
|
297
|
+
@focusToNext=${(e) => this.currentTab = e.detail}
|
|
292
298
|
></media-slider>
|
|
293
299
|
</div>
|
|
294
300
|
${this.username ? this.userMenu : this.signedOutDropdown}
|
|
@@ -305,6 +311,7 @@ export default class IATopNav extends LitElement {
|
|
|
305
311
|
<desktop-subnav
|
|
306
312
|
.baseHost=${this.baseHost}
|
|
307
313
|
.menuItems=${this.desktopSubnavMenuItems}
|
|
314
|
+
@focus=${this.closeMenus}
|
|
308
315
|
></desktop-subnav>
|
|
309
316
|
<div id="close-layer" class="${this.closeLayerClass}" @click=${this.closeMenus}></div>
|
|
310
317
|
`;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default class KeyboardNavigation {
|
|
5
|
+
/**
|
|
6
|
+
* Constructor for the KeyboardNavigation class.
|
|
7
|
+
* @param {HTMLElement} elementsContainer - The container element that holds the focusable elements.
|
|
8
|
+
* @param {string} menuOption - The type of menu option ('web' or 'usermenu').
|
|
9
|
+
*/
|
|
10
|
+
constructor(elementsContainer, menuOption) {
|
|
11
|
+
this.elementsContainer = elementsContainer;
|
|
12
|
+
this.menuOption = menuOption;
|
|
13
|
+
this.focusableElements = this.getFocusableElements();
|
|
14
|
+
this.focusedIndex = this.getInitialFocusedIndex();
|
|
15
|
+
|
|
16
|
+
this.focusableElements[this.focusedIndex]?.focus();
|
|
17
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the initial focused index based on the menu option.
|
|
22
|
+
* @returns {number} The initial focused index (0 for 'web', 1 for 'usermenu').
|
|
23
|
+
*/
|
|
24
|
+
getInitialFocusedIndex() {
|
|
25
|
+
return this.menuOption === 'usermenu' ? 1 : 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets an array of focusable elements within the container.
|
|
30
|
+
* @returns {HTMLElement[]} An array of focusable elements.
|
|
31
|
+
*/
|
|
32
|
+
getFocusableElements() {
|
|
33
|
+
const focusableTagSelectors = 'a[href], button, input, [tabindex]:not([tabindex="-1"])';
|
|
34
|
+
const isDisabledOrHidden = el => !el.hasAttribute('disabled') && !el.getAttribute('aria-hidden');
|
|
35
|
+
|
|
36
|
+
let elements;
|
|
37
|
+
if (this.menuOption === 'web') {
|
|
38
|
+
// wayback focusable elements
|
|
39
|
+
const waybackSlider = this.elementsContainer.querySelector('wayback-slider').shadowRoot;
|
|
40
|
+
const waybackSearch = waybackSlider.querySelector('wayback-search');
|
|
41
|
+
const waybackSearchElements = Array.from(waybackSearch.shadowRoot.querySelectorAll(focusableTagSelectors));
|
|
42
|
+
|
|
43
|
+
const normalElements = Array.from(waybackSlider.querySelectorAll(focusableTagSelectors));
|
|
44
|
+
|
|
45
|
+
// wayback save-form focusable elements
|
|
46
|
+
const savePageForm = waybackSlider.querySelector('save-page-form');
|
|
47
|
+
const savePageFormElements = Array.from(savePageForm.shadowRoot.querySelectorAll(focusableTagSelectors));
|
|
48
|
+
|
|
49
|
+
elements = [...waybackSearchElements, ...normalElements, ...savePageFormElements];
|
|
50
|
+
} else {
|
|
51
|
+
elements = this.elementsContainer.querySelectorAll(focusableTagSelectors);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Array.from(elements).filter(isDisabledOrHidden);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Handles keyboard events and focuses the appropriate element.
|
|
59
|
+
* @param {KeyboardEvent} event - The keyboard event object.
|
|
60
|
+
*/
|
|
61
|
+
handleKeyDown(event) {
|
|
62
|
+
const { key } = event;
|
|
63
|
+
const isArrowKey = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(key);
|
|
64
|
+
const isTabKey = key === 'Tab';
|
|
65
|
+
|
|
66
|
+
if (isArrowKey) {
|
|
67
|
+
this.handleArrowKey(key);
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
} else if (isTabKey) {
|
|
70
|
+
this.handleTabKey(event);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handles arrow key events and focuses the next or previous element.
|
|
76
|
+
* @param {string} key - The key that was pressed ('ArrowDown', 'ArrowRight', 'ArrowUp', or 'ArrowLeft').
|
|
77
|
+
*/
|
|
78
|
+
handleArrowKey(key) {
|
|
79
|
+
const isDownOrRight = ['ArrowDown', 'ArrowRight'].includes(key);
|
|
80
|
+
isDownOrRight ? this.focusNext() : this.focusPrevious();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Focuses the previous focusable element in the container.
|
|
85
|
+
*/
|
|
86
|
+
focusPrevious() {
|
|
87
|
+
if (this.focusableElements.length === 0) return;
|
|
88
|
+
this.focusedIndex = (this.focusedIndex - 1 + this.focusableElements.length) % this.focusableElements.length;
|
|
89
|
+
this.focusableElements[this.focusedIndex]?.focus();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Focuses the next focusable element in the container.
|
|
94
|
+
*/
|
|
95
|
+
focusNext() {
|
|
96
|
+
if (this.focusableElements.length === 0) return;
|
|
97
|
+
this.focusedIndex = (this.focusedIndex + 1) % this.focusableElements.length;
|
|
98
|
+
this.focusableElements[this.focusedIndex]?.focus();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Handles the Tab key event and focuses the next or previous menu item.
|
|
103
|
+
* @param {KeyboardEvent} event - The keyboard event object.
|
|
104
|
+
*/
|
|
105
|
+
handleTabKey(event) {
|
|
106
|
+
if (this.menuOption) {
|
|
107
|
+
const isShiftPressed = event.shiftKey;
|
|
108
|
+
this.focusNextMenuItem(isShiftPressed);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.focusableElements[this.focusedIndex]?.blur();
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Focuses the next or previous menu item based on the provided flag.
|
|
117
|
+
* @param {boolean} isPrevious - A flag indicating whether to focus the previous menu item.
|
|
118
|
+
*/
|
|
119
|
+
focusNextMenuItem(isPrevious = false) {
|
|
120
|
+
this.elementsContainer.dispatchEvent(
|
|
121
|
+
new CustomEvent('focusToNext', {
|
|
122
|
+
bubbles: true,
|
|
123
|
+
composed: true,
|
|
124
|
+
detail: {
|
|
125
|
+
mediatype: this.menuOption,
|
|
126
|
+
moveTo: isPrevious ? 'prev' : 'next',
|
|
127
|
+
},
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
package/src/media-button.js
CHANGED
|
@@ -103,6 +103,7 @@ class MediaButton extends TrackedElement {
|
|
|
103
103
|
@click=${this.followable ? this.trackClick : this.onClick}
|
|
104
104
|
data-event-click-tracking="${this.analyticsEvent}"
|
|
105
105
|
title="${this.tooltipPrefix} ${this.mediatype} menu"
|
|
106
|
+
tabindex="${this.openMenu === 'media' ? '' : '0'}"
|
|
106
107
|
>
|
|
107
108
|
${this.menuItem}
|
|
108
109
|
</a>
|
package/src/media-menu.js
CHANGED
|
@@ -67,6 +67,7 @@ class MediaMenu extends LitElement {
|
|
|
67
67
|
config: { type: Object },
|
|
68
68
|
openMenu: { type: String },
|
|
69
69
|
selectedMenuOption: { type: String },
|
|
70
|
+
currentTab: { type: Object },
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -75,6 +76,25 @@ class MediaMenu extends LitElement {
|
|
|
75
76
|
this.config = {};
|
|
76
77
|
this.openMenu = '';
|
|
77
78
|
this.selectedMenuOption = '';
|
|
79
|
+
this.currentTab = {};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
updated(props) {
|
|
83
|
+
if (props.has('currentTab')) {
|
|
84
|
+
const mediaButtons = Array.from(this.shadowRoot.querySelectorAll('media-button'));
|
|
85
|
+
|
|
86
|
+
mediaButtons.map((button, index) => {
|
|
87
|
+
const linkItem = button.shadowRoot.querySelector('a.menu-item');
|
|
88
|
+
if (linkItem) {
|
|
89
|
+
if (linkItem.classList.contains(`${this.selectedMenuOption}`)) {
|
|
90
|
+
linkItem.classList.remove('selected');
|
|
91
|
+
linkItem.blur();
|
|
92
|
+
|
|
93
|
+
mediaButtons[this.currentTab.moveTo === 'next' ? index + 1 : index - 1].shadowRoot.querySelector('a.menu-item').focus();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
get mediaMenuOptionsTemplate() {
|
|
@@ -96,6 +116,7 @@ class MediaMenu extends LitElement {
|
|
|
96
116
|
.mediatype=${menu}
|
|
97
117
|
.openMenu=${this.openMenu}
|
|
98
118
|
.selected=${selected}
|
|
119
|
+
.selectedMenuOption=${this.selectedMenuOption}
|
|
99
120
|
data-mediatype="${menu}"
|
|
100
121
|
></media-button>
|
|
101
122
|
`;
|
|
@@ -117,7 +138,6 @@ class MediaMenu extends LitElement {
|
|
|
117
138
|
<div class="overflow-clip">
|
|
118
139
|
<nav
|
|
119
140
|
class="media-menu-inner"
|
|
120
|
-
aria-hidden="${!this.menuOpened}"
|
|
121
141
|
aria-expanded="${this.menuOpened}"
|
|
122
142
|
>
|
|
123
143
|
<div class="menu-group">
|
package/src/media-slider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, html } from 'https://offshoot.prod.archive.org/lit.js';
|
|
2
2
|
import './media-subnav.js';
|
|
3
3
|
import mediaSliderCSS from './styles/media-slider.js';
|
|
4
|
+
import KeyboardNavigation from './lib/keyboard-navigation.js';
|
|
4
5
|
|
|
5
6
|
class MediaSlider extends LitElement {
|
|
6
7
|
static get styles() {
|
|
@@ -26,6 +27,19 @@ class MediaSlider extends LitElement {
|
|
|
26
27
|
this.selectedMenuOption = 'texts';
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
updated(props) {
|
|
31
|
+
if (props.has('selectedMenuOption') && this.selectedMenuOption) {
|
|
32
|
+
const container = this.shadowRoot?.querySelector('.has-focused')?.shadowRoot;
|
|
33
|
+
|
|
34
|
+
if (container) {
|
|
35
|
+
const keyboardNavigation = new KeyboardNavigation(container, this.selectedMenuOption);
|
|
36
|
+
this.addEventListener('keydown', keyboardNavigation.handleKeyDown);
|
|
37
|
+
this.removeEventListener('keydown', this.previousKeydownListener);
|
|
38
|
+
this.previousKeydownListener = keyboardNavigation.handleKeyDown;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
shouldUpdate() {
|
|
30
44
|
const scrollPane = this.shadowRoot ? this.shadowRoot.querySelector('.information-menu') : null;
|
|
31
45
|
|
|
@@ -47,49 +61,49 @@ class MediaSlider extends LitElement {
|
|
|
47
61
|
<media-subnav
|
|
48
62
|
.baseHost=${this.baseHost}
|
|
49
63
|
.config=${this.config}
|
|
50
|
-
class="${this.selectedMenuOption === 'audio' ? '' : 'hidden'}"
|
|
64
|
+
class="${this.selectedMenuOption === 'audio' ? 'has-focused' : 'hidden'}"
|
|
51
65
|
menu="audio"
|
|
52
66
|
.menuItems=${this.menus.audio}
|
|
53
67
|
></media-subnav>
|
|
54
68
|
<media-subnav
|
|
55
69
|
.baseHost=${this.baseHost}
|
|
56
70
|
.config=${this.config}
|
|
57
|
-
class="${this.selectedMenuOption === 'images' ? '' : 'hidden'}"
|
|
71
|
+
class="${this.selectedMenuOption === 'images' ? 'has-focused' : 'hidden'}"
|
|
58
72
|
menu="images"
|
|
59
73
|
.menuItems=${this.menus.images}
|
|
60
74
|
></media-subnav>
|
|
61
75
|
<media-subnav
|
|
62
76
|
.baseHost=${this.baseHost}
|
|
63
77
|
.config=${this.config}
|
|
64
|
-
class="${this.selectedMenuOption === 'software' ? '' : 'hidden'}"
|
|
78
|
+
class="${this.selectedMenuOption === 'software' ? 'has-focused' : 'hidden'}"
|
|
65
79
|
menu="software"
|
|
66
80
|
.menuItems=${this.menus.software}
|
|
67
81
|
></media-subnav>
|
|
68
82
|
<media-subnav
|
|
69
83
|
.baseHost=${this.baseHost}
|
|
70
84
|
.config=${this.config}
|
|
71
|
-
class="${this.selectedMenuOption === 'texts' ? '' : 'hidden'}"
|
|
85
|
+
class="${this.selectedMenuOption === 'texts' ? 'has-focused' : 'hidden'}"
|
|
72
86
|
menu="texts"
|
|
73
87
|
.menuItems=${this.menus.texts}
|
|
74
88
|
></media-subnav>
|
|
75
89
|
<media-subnav
|
|
76
90
|
.baseHost=${this.baseHost}
|
|
77
91
|
.config=${this.config}
|
|
78
|
-
class="${this.selectedMenuOption === 'video' ? '' : 'hidden'}"
|
|
92
|
+
class="${this.selectedMenuOption === 'video' ? 'has-focused' : 'hidden'}"
|
|
79
93
|
menu="video"
|
|
80
94
|
.menuItems=${this.menus.video}
|
|
81
95
|
></media-subnav>
|
|
82
96
|
<media-subnav
|
|
83
97
|
.baseHost=${this.baseHost}
|
|
84
98
|
.config=${this.config}
|
|
85
|
-
class="${this.selectedMenuOption === 'web' ? '' : 'hidden'}"
|
|
99
|
+
class="${this.selectedMenuOption === 'web' ? 'has-focused' : 'hidden'}"
|
|
86
100
|
menu="web"
|
|
87
101
|
.menuItems=${this.menus.web}
|
|
88
102
|
></media-subnav>
|
|
89
103
|
<media-subnav
|
|
90
104
|
.baseHost=${this.baseHost}
|
|
91
105
|
.config=${this.config}
|
|
92
|
-
class="${this.selectedMenuOption === 'more' ? '' : 'hidden'}"
|
|
106
|
+
class="${this.selectedMenuOption === 'more' ? 'has-focused' : 'hidden'}"
|
|
93
107
|
menu="more"
|
|
94
108
|
.menuItems=${this.menus.more}
|
|
95
109
|
></media-subnav>
|
package/src/nav-search.js
CHANGED
|
@@ -98,8 +98,8 @@ class NavSearch extends TrackedElement {
|
|
|
98
98
|
class="search-field"
|
|
99
99
|
placeholder="Search"
|
|
100
100
|
autocomplete="off"
|
|
101
|
-
@focus=${this.toggleSearchMenu}
|
|
102
101
|
value=${this.searchQuery || ''}
|
|
102
|
+
@focus=${this.toggleSearchMenu}
|
|
103
103
|
/>
|
|
104
104
|
${this.searchInsideInput}
|
|
105
105
|
<button
|
package/src/primary-nav.js
CHANGED
|
@@ -31,6 +31,7 @@ class PrimaryNav extends TrackedElement {
|
|
|
31
31
|
userMenuOpen: { type: Boolean },
|
|
32
32
|
username: { type: String },
|
|
33
33
|
userProfileImagePath: { type: String },
|
|
34
|
+
currentTab: { type: Object },
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -44,6 +45,7 @@ class PrimaryNav extends TrackedElement {
|
|
|
44
45
|
this.userMenuOpen = false;
|
|
45
46
|
this.mediaBaseHost = 'https://archive.org';
|
|
46
47
|
this.secondIdentitySlotMode = '';
|
|
48
|
+
this.currentTab = {};
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
toggleMediaMenu(e) {
|
|
@@ -79,6 +81,24 @@ class PrimaryNav extends TrackedElement {
|
|
|
79
81
|
);
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
updated(props) {
|
|
85
|
+
const { currentTab } = this;
|
|
86
|
+
const isUserMenuTab = currentTab && currentTab.mediatype === 'usermenu';
|
|
87
|
+
if (props.has('currentTab')) {
|
|
88
|
+
if (isUserMenuTab) {
|
|
89
|
+
const focusElement = currentTab.moveTo === 'next'
|
|
90
|
+
? this.shadowRoot.querySelector('a.upload')
|
|
91
|
+
: this.shadowRoot.querySelector('.user-menu');
|
|
92
|
+
|
|
93
|
+
if (focusElement) {
|
|
94
|
+
focusElement.focus();
|
|
95
|
+
}
|
|
96
|
+
} else if (this.currentTab.moveTo === 'next') {
|
|
97
|
+
this.shadowRoot.querySelector('.user-menu').focus();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
82
102
|
get userIcon() {
|
|
83
103
|
const userMenuClass = this.openMenu === 'user' ? 'active' : '';
|
|
84
104
|
const userMenuToolTip = this.openMenu === 'user' ? 'Close user menu' : 'Expand user menu';
|
|
@@ -107,7 +127,6 @@ class PrimaryNav extends TrackedElement {
|
|
|
107
127
|
.dropdownOpen=${this.signedOutMenuOpen}
|
|
108
128
|
.openMenu=${this.openMenu}
|
|
109
129
|
@signedOutMenuToggled=${this.signedOutMenuToggled}
|
|
110
|
-
tabindex="-1"
|
|
111
130
|
></login-button>
|
|
112
131
|
`;
|
|
113
132
|
}
|
|
@@ -156,12 +175,8 @@ class PrimaryNav extends TrackedElement {
|
|
|
156
175
|
return html`
|
|
157
176
|
<a href="${formatUrl('/create', this.baseHost)}"
|
|
158
177
|
class="upload"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (e.relatedTarget !== null) {
|
|
162
|
-
this.toggleSearchMenu(e)
|
|
163
|
-
}
|
|
164
|
-
}}>
|
|
178
|
+
@focus=${this.toggleMediaMenu}
|
|
179
|
+
>
|
|
165
180
|
${icons.upload}
|
|
166
181
|
<span>Upload</span>
|
|
167
182
|
</a>`;
|
|
@@ -190,6 +205,15 @@ class PrimaryNav extends TrackedElement {
|
|
|
190
205
|
const mediaMenuTabIndex = this.openMenu === 'media' ? '' : '-1';
|
|
191
206
|
return html`
|
|
192
207
|
<nav class=${this.hideSearch ? 'hide-search' : nothing}>
|
|
208
|
+
<button
|
|
209
|
+
class="hamburger"
|
|
210
|
+
@click="${this.toggleMediaMenu}"
|
|
211
|
+
data-event-click-tracking="${this.config.eventCategory}|NavHamburger"
|
|
212
|
+
title="Open main menu"
|
|
213
|
+
>
|
|
214
|
+
<icon-hamburger ?active=${this.openMenu === 'media'}></icon-hamburger>
|
|
215
|
+
</button>
|
|
216
|
+
|
|
193
217
|
<div class=${`branding ${this.secondLogoClass}`}>
|
|
194
218
|
<a
|
|
195
219
|
href=${formatUrl('/', this.baseHost)}
|
|
@@ -197,35 +221,24 @@ class PrimaryNav extends TrackedElement {
|
|
|
197
221
|
data-event-click-tracking="${this.config.eventCategory}|NavHome"
|
|
198
222
|
title="Go home"
|
|
199
223
|
class="link-home"
|
|
200
|
-
tabindex="-1"
|
|
201
224
|
>${icons.iaLogo}${logoWordmarkStacked}</a
|
|
202
225
|
>
|
|
203
226
|
${this.secondLogoSlot}
|
|
204
227
|
</div>
|
|
205
|
-
|
|
206
|
-
<div class="right-side-section">
|
|
207
|
-
${this.mobileDonateHeart}
|
|
208
|
-
${this.searchMenu}
|
|
209
|
-
${this.uploadButtonTemplate}
|
|
210
|
-
${this.userStateTemplate}
|
|
211
|
-
</div>
|
|
212
228
|
<media-menu
|
|
213
229
|
.baseHost=${this.baseHost}
|
|
214
230
|
.config=${this.config}
|
|
215
231
|
?mediaMenuAnimate="${this.mediaMenuAnimate}"
|
|
216
|
-
tabindex="${mediaMenuTabIndex}"
|
|
217
232
|
.selectedMenuOption=${this.selectedMenuOption}
|
|
218
233
|
.openMenu=${this.openMenu}
|
|
234
|
+
.currentTab=${this.currentTab}
|
|
219
235
|
></media-menu>
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
>
|
|
227
|
-
<icon-hamburger ?active=${this.openMenu === 'media'}></icon-hamburger>
|
|
228
|
-
</button>
|
|
236
|
+
<div class="right-side-section">
|
|
237
|
+
${this.mobileDonateHeart}
|
|
238
|
+
${this.userStateTemplate}
|
|
239
|
+
${this.uploadButtonTemplate}
|
|
240
|
+
${this.searchMenu}
|
|
241
|
+
</div>
|
|
229
242
|
</nav>
|
|
230
243
|
`;
|
|
231
244
|
}
|
package/src/search-menu.js
CHANGED
|
@@ -30,26 +30,33 @@ class SearchMenu extends TrackedElement {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
firstUpdated() {
|
|
33
|
-
this.shadowRoot.addEventListener('
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
this.shadowRoot.addEventListener('keydown', e => this.handleKeyDownEvent(e));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
// Clean up event listener when the element is removed
|
|
38
|
+
this.shadowRoot.removeEventListener('keydown', e => this.handleKeyDownEvent(e));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
handleKeyDownEvent(e) {
|
|
42
|
+
const searchTypes = this.shadowRoot.querySelectorAll('.search-menu-inner label input[type=radio]');
|
|
43
|
+
|
|
44
|
+
const length = searchTypes.length - 1;
|
|
45
|
+
if (!length) return;
|
|
46
|
+
|
|
47
|
+
const searchTypeHandler = (index) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
const searchType = searchTypes[index];
|
|
50
|
+
searchType.checked = true;
|
|
51
|
+
searchType.dispatchEvent(new Event('change'));
|
|
52
|
+
searchType.focus();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (e.key === 'Home') {
|
|
56
|
+
searchTypeHandler(0);
|
|
57
|
+
} else if (e.key === 'End') {
|
|
58
|
+
searchTypeHandler(length);
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
selectSearchType(e) {
|
|
@@ -93,7 +100,7 @@ class SearchMenu extends TrackedElement {
|
|
|
93
100
|
}
|
|
94
101
|
return html`
|
|
95
102
|
<label @click="${this.selectSearchType}">
|
|
96
|
-
<input
|
|
103
|
+
<input form="nav-search" type="radio" name="sin" value="${value}" ?checked=${isDefault} @change=${this.searchInChanged} />
|
|
97
104
|
Search ${label}
|
|
98
105
|
</label>
|
|
99
106
|
`;
|
|
@@ -127,7 +134,6 @@ class SearchMenu extends TrackedElement {
|
|
|
127
134
|
href="${formatUrl('/advancedsearch.php', this.baseHost)}"
|
|
128
135
|
@click=${this.trackClick}
|
|
129
136
|
data-event-click-tracking="${this.config.eventCategory}|NavAdvancedSearch"
|
|
130
|
-
tabindex="4"
|
|
131
137
|
>Advanced Search</a
|
|
132
138
|
>
|
|
133
139
|
</div>
|
|
@@ -92,6 +92,7 @@ export default css`
|
|
|
92
92
|
|
|
93
93
|
@media (min-width: 890px) {
|
|
94
94
|
nav {
|
|
95
|
+
display: flex;
|
|
95
96
|
overflow: visible;
|
|
96
97
|
top: 0;
|
|
97
98
|
left: auto;
|
|
@@ -146,6 +147,7 @@ export default css`
|
|
|
146
147
|
a:focus {
|
|
147
148
|
color: var(--linkHoverColor);
|
|
148
149
|
background: var(--linkColor);
|
|
150
|
+
outline: none;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
.initial,
|
package/src/styles/media-menu.js
CHANGED
|
@@ -23,10 +23,6 @@ export default css`
|
|
|
23
23
|
|
|
24
24
|
/* Mobile view styles */
|
|
25
25
|
@media (max-width: 889px) {
|
|
26
|
-
.media-menu-container {
|
|
27
|
-
position: relative;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
.media-menu-inner {
|
|
31
27
|
position: absolute;
|
|
32
28
|
width: 100%;
|
|
@@ -39,7 +35,7 @@ export default css`
|
|
|
39
35
|
.overflow-clip {
|
|
40
36
|
position: absolute;
|
|
41
37
|
z-index: -1; /** needs to be under the navigation, otherwise it intercepts clicks */
|
|
42
|
-
top:
|
|
38
|
+
top: 4rem;
|
|
43
39
|
left: 0;
|
|
44
40
|
height: 0;
|
|
45
41
|
width: 100%;
|
|
@@ -2,15 +2,13 @@ import { css } from 'https://offshoot.prod.archive.org/lit.js';
|
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
4
|
button:focus,
|
|
5
|
-
a:focus,
|
|
6
5
|
input:focus {
|
|
7
6
|
outline: none;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
nav {
|
|
11
10
|
position: relative;
|
|
12
|
-
display:
|
|
13
|
-
display: grid;
|
|
11
|
+
display: flex;
|
|
14
12
|
height: 4rem;
|
|
15
13
|
grid-template-areas: 'hamburger empty heart search user';
|
|
16
14
|
-ms-grid-columns: 4rem minmax(1rem, 100%) 4rem 4rem 4rem;
|
|
@@ -29,6 +27,7 @@ export default css`
|
|
|
29
27
|
|
|
30
28
|
.right-side-section {
|
|
31
29
|
display: flex;
|
|
30
|
+
margin-left: auto;
|
|
32
31
|
user-select: none;
|
|
33
32
|
}
|
|
34
33
|
button {
|
|
@@ -86,6 +85,9 @@ export default css`
|
|
|
86
85
|
fill: var(--activeColor);
|
|
87
86
|
}
|
|
88
87
|
|
|
88
|
+
.mobile-donate-link {
|
|
89
|
+
display: inline-block;
|
|
90
|
+
}
|
|
89
91
|
.mobile-donate-link svg {
|
|
90
92
|
height: 4rem;
|
|
91
93
|
width: 4rem;
|
|
@@ -151,8 +153,10 @@ export default css`
|
|
|
151
153
|
height: 100%;
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
.user-menu:hover
|
|
156
|
+
.user-menu:hover,
|
|
157
|
+
.user-menu:focus {
|
|
155
158
|
color: var(--linkHoverColor);
|
|
159
|
+
outline: none;
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
.user-menu.active {
|
|
@@ -170,6 +174,10 @@ export default css`
|
|
|
170
174
|
text-decoration: none;
|
|
171
175
|
display: inline-flex;
|
|
172
176
|
}
|
|
177
|
+
a.link-home:focus,
|
|
178
|
+
a.link-home:focus-visible {
|
|
179
|
+
outline-offset: 1px;
|
|
180
|
+
}
|
|
173
181
|
|
|
174
182
|
@media only screen and (min-width: 890px) and (max-device-width: 905px) {
|
|
175
183
|
.branding.second-logo {
|
|
@@ -187,6 +195,13 @@ export default css`
|
|
|
187
195
|
slot[name='opt-sec-logo'] {
|
|
188
196
|
display: none;
|
|
189
197
|
}
|
|
198
|
+
|
|
199
|
+
.right-side-section {
|
|
200
|
+
display: initial;
|
|
201
|
+
}
|
|
202
|
+
.right-side-section .user-info {
|
|
203
|
+
float: right;
|
|
204
|
+
}
|
|
190
205
|
}
|
|
191
206
|
|
|
192
207
|
@media (min-width: 890px) {
|
|
@@ -195,12 +210,8 @@ export default css`
|
|
|
195
210
|
--userIconHeight: 3.2rem;
|
|
196
211
|
}
|
|
197
212
|
|
|
198
|
-
.right-side-section {
|
|
199
|
-
display: contents;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
213
|
nav {
|
|
203
|
-
display:
|
|
214
|
+
display: flex;
|
|
204
215
|
z-index: 4;
|
|
205
216
|
height: 5rem;
|
|
206
217
|
padding-right: 1.5rem;
|
|
@@ -210,10 +221,6 @@ export default css`
|
|
|
210
221
|
display: none;
|
|
211
222
|
}
|
|
212
223
|
|
|
213
|
-
.branding {
|
|
214
|
-
margin-top: 1rem;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
224
|
.ia-logo,
|
|
218
225
|
.ia-wordmark {
|
|
219
226
|
margin-right: 10px;
|
|
@@ -265,6 +272,9 @@ export default css`
|
|
|
265
272
|
.upload:hover {
|
|
266
273
|
color: var(--linkHoverColor);
|
|
267
274
|
}
|
|
275
|
+
.upload:focus-visible {
|
|
276
|
+
outline: none;
|
|
277
|
+
}
|
|
268
278
|
|
|
269
279
|
.upload svg {
|
|
270
280
|
vertical-align: middle;
|
package/src/user-menu.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { html } from 'https://offshoot.prod.archive.org/lit.js';
|
|
2
2
|
import DropdownMenu from './dropdown-menu.js';
|
|
3
3
|
import userMenuCSS from './styles/user-menu.js';
|
|
4
|
+
import KeyboardNavigation from './lib/keyboard-navigation.js';
|
|
4
5
|
|
|
5
6
|
class UserMenu extends DropdownMenu {
|
|
6
7
|
static get styles() {
|
|
@@ -21,6 +22,19 @@ class UserMenu extends DropdownMenu {
|
|
|
21
22
|
this.username = '';
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
updated(props) {
|
|
26
|
+
if (props.has('open') && this.open) {
|
|
27
|
+
const container = this.shadowRoot?.querySelector('.nav-container');
|
|
28
|
+
|
|
29
|
+
if (container) {
|
|
30
|
+
const keyboardNavigation = new KeyboardNavigation(container, 'usermenu');
|
|
31
|
+
this.addEventListener('keydown', keyboardNavigation.handleKeyDown);
|
|
32
|
+
this.removeEventListener('keydown', this.previousKeydownListener);
|
|
33
|
+
this.previousKeydownListener = keyboardNavigation.handleKeyDown;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
render() {
|
|
25
39
|
return html`
|
|
26
40
|
<div class="nav-container">
|