@internetarchive/ia-topnav 1.3.5-alpha7 → 1.3.6-alpha.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.
Files changed (84) hide show
  1. package/.eslintrc +16 -16
  2. package/LICENSE +661 -661
  3. package/README.md +147 -147
  4. package/index.d.ts +109 -109
  5. package/index.js +3 -3
  6. package/package.json +61 -61
  7. package/src/assets/img/hamburger.js +38 -38
  8. package/src/assets/img/ia-icon.js +33 -33
  9. package/src/assets/img/icon-audio.js +23 -23
  10. package/src/assets/img/icon-close.js +16 -16
  11. package/src/assets/img/icon-donate-unpadded.js +16 -16
  12. package/src/assets/img/icon-donate.js +15 -15
  13. package/src/assets/img/icon-ellipses.js +15 -15
  14. package/src/assets/img/icon-ia-logo.js +22 -22
  15. package/src/assets/img/icon-images.js +15 -15
  16. package/src/assets/img/icon-search.js +15 -15
  17. package/src/assets/img/icon-software.js +15 -15
  18. package/src/assets/img/icon-texts.js +15 -15
  19. package/src/assets/img/icon-upload-unpadded.js +14 -14
  20. package/src/assets/img/icon-upload.js +15 -15
  21. package/src/assets/img/icon-user.js +15 -15
  22. package/src/assets/img/icon-video.js +15 -15
  23. package/src/assets/img/icon-web.js +15 -15
  24. package/src/assets/img/icon.js +18 -18
  25. package/src/assets/img/icons.js +33 -33
  26. package/src/assets/img/wordmark-stacked.js +13 -13
  27. package/src/data/menus.js +670 -670
  28. package/src/desktop-subnav.js +45 -45
  29. package/src/dropdown-menu.js +109 -110
  30. package/src/ia-topnav.js +314 -315
  31. package/src/lib/formatUrl.js +1 -1
  32. package/src/lib/location-handler.js +5 -5
  33. package/src/lib/query-handler.js +7 -7
  34. package/src/lib/toSentenceCase.js +8 -8
  35. package/src/login-button.js +79 -79
  36. package/src/media-button.js +113 -114
  37. package/src/media-menu.js +133 -133
  38. package/src/media-slider.js +104 -104
  39. package/src/media-subnav.js +112 -112
  40. package/src/more-slider.js +33 -33
  41. package/src/nav-search.js +117 -120
  42. package/src/primary-nav.js +224 -232
  43. package/src/save-page-form.js +59 -59
  44. package/src/search-menu.js +115 -146
  45. package/src/signed-out-dropdown.js +10 -10
  46. package/src/styles/base.js +48 -48
  47. package/src/styles/desktop-subnav.js +37 -37
  48. package/src/styles/dropdown-menu.js +166 -166
  49. package/src/styles/ia-topnav.js +87 -87
  50. package/src/styles/login-button.js +79 -79
  51. package/src/styles/media-button.js +156 -156
  52. package/src/styles/media-menu.js +70 -70
  53. package/src/styles/media-slider.js +81 -81
  54. package/src/styles/media-subnav.js +156 -156
  55. package/src/styles/more-slider.js +15 -15
  56. package/src/styles/nav-search.js +136 -136
  57. package/src/styles/primary-nav.js +300 -300
  58. package/src/styles/save-page-form.js +54 -54
  59. package/src/styles/search-menu.js +99 -104
  60. package/src/styles/signed-out-dropdown.js +31 -31
  61. package/src/styles/user-menu.js +31 -31
  62. package/src/styles/wayback-search.js +48 -48
  63. package/src/styles/wayback-slider.js +30 -30
  64. package/src/tracked-element.js +27 -27
  65. package/src/user-menu.js +42 -42
  66. package/src/wayback-search.js +18 -18
  67. package/src/wayback-slider.js +87 -87
  68. package/test/assets/img/hamburger.test.js +15 -15
  69. package/test/assets/img/user.test.js +15 -15
  70. package/test/data/menus.test.js +19 -19
  71. package/test/dropdown-menu.test.js +25 -25
  72. package/test/ia-icon.test.js +13 -13
  73. package/test/ia-topnav.test.js +273 -273
  74. package/test/login-button.test.js +15 -15
  75. package/test/media-button.test.js +19 -19
  76. package/test/media-menu.test.js +40 -40
  77. package/test/media-slider.test.js +57 -57
  78. package/test/more-slider.test.js +13 -13
  79. package/test/nav-search.test.js +61 -61
  80. package/test/primary-nav.test.js +82 -82
  81. package/test/save-page-form.test.js +35 -35
  82. package/test/search-menu.test.js +49 -49
  83. package/test/user-menu.test.js +33 -33
  84. package/test/wayback-slider.test.js +80 -80
@@ -1,232 +1,224 @@
1
- import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
- import TrackedElement from './tracked-element.js';
3
- import icons from './assets/img/icons.js';
4
- import './assets/img/hamburger.js';
5
- import './login-button.js';
6
- import './nav-search.js';
7
- import './media-menu.js';
8
- import logoWordmarkStacked from './assets/img/wordmark-stacked.js';
9
- import primaryNavCSS from './styles/primary-nav.js';
10
- import locationHandler from './lib/location-handler.js';
11
- import formatUrl from './lib/formatUrl.js';
12
-
13
- class PrimaryNav extends TrackedElement {
14
- static get styles() {
15
- return primaryNavCSS;
16
- }
17
-
18
- static get properties() {
19
- return {
20
- mediaBaseHost: { type: String },
21
- baseHost: { type: String },
22
- hideSearch: { type: Boolean },
23
- config: { type: Object },
24
- openMenu: { type: String },
25
- screenName: { type: String },
26
- searchIn: { type: String },
27
- searchQuery: { type: String },
28
- secondIdentitySlotMode: { type: String },
29
- selectedMenuOption: { type: String },
30
- signedOutMenuOpen: { type: Boolean },
31
- userMenuOpen: { type: Boolean },
32
- username: { type: String },
33
- userProfileImagePath: { type: String },
34
- };
35
- }
36
-
37
- constructor() {
38
- super();
39
- this.config = {};
40
- this.openMenu = '';
41
- this.searchIn = '';
42
- this.selectedMenuOption = '';
43
- this.signedOutMenuOpen = false;
44
- this.userMenuOpen = false;
45
- this.mediaBaseHost = 'https://archive.org';
46
- this.secondIdentitySlotMode = '';
47
- }
48
-
49
- toggleMediaMenu(e) {
50
- this.trackClick(e);
51
- this.dispatchEvent(
52
- new CustomEvent('menuToggled', {
53
- detail: {
54
- menuName: 'media',
55
- },
56
- }),
57
- );
58
- }
59
-
60
- toggleSearchMenu(e) {
61
- this.trackClick(e);
62
- this.dispatchEvent(
63
- new CustomEvent('menuToggled', {
64
- detail: {
65
- menuName: 'search',
66
- },
67
- }),
68
- );
69
- }
70
-
71
- toggleUserMenu(e) {
72
- this.trackClick(e);
73
- this.dispatchEvent(
74
- new CustomEvent('menuToggled', {
75
- detail: {
76
- menuName: 'user',
77
- },
78
- }),
79
- );
80
- }
81
-
82
- get userIcon() {
83
- const userMenuClass = this.openMenu === 'user' ? 'active' : '';
84
- const userMenuToolTip = this.openMenu === 'user' ? 'Close user menu' : 'Expand user menu';
85
-
86
- return html`
87
- <button
88
- class="user-menu ${userMenuClass}"
89
- title="${userMenuToolTip}"
90
- tabindex="-1"
91
- @click="${this.toggleUserMenu}"
92
- data-event-click-tracking="${this.config.eventCategory}|NavUserMenu"
93
- >
94
- <img
95
- src="${this.mediaBaseHost}${this.userProfileImagePath}"
96
- alt="${this.screenName}"
97
- />
98
- <span class="screen-name" dir="auto">${this.screenName}</span>
99
- </button>
100
- `;
101
- }
102
-
103
- get loginIcon() {
104
- return html`
105
- <login-button
106
- .baseHost=${this.baseHost}
107
- .config=${this.config}
108
- .dropdownOpen=${this.signedOutMenuOpen}
109
- .openMenu=${this.openMenu}
110
- tabindex="-1"
111
- @signedOutMenuToggled=${this.signedOutMenuToggled}
112
- ></login-button>
113
- `;
114
- }
115
-
116
- get searchMenuOpen() {
117
- return this.openMenu === 'search';
118
- }
119
-
120
- get allowSecondaryIcon() {
121
- return this.secondIdentitySlotMode === 'allow';
122
- }
123
-
124
- get searchMenu() {
125
- if (this.hideSearch) return nothing;
126
-
127
- return html`
128
- <button
129
- class="search-trigger"
130
- @click="${this.toggleSearchMenu}"
131
- data-event-click-tracking="${this.config.eventCategory}|NavSearchOpen"
132
- >
133
- ${icons.search}
134
- </button>
135
- <nav-search
136
- .baseHost=${this.baseHost}
137
- .config=${this.config}
138
- .locationHandler=${locationHandler}
139
- .open=${this.searchMenuOpen}
140
- .openMenu=${this.openMenu}
141
- .searchIn=${this.searchIn}
142
- .searchQuery=${this.searchQuery}
143
- ></nav-search>
144
- `;
145
- }
146
-
147
- get mobileDonateHeart() {
148
- return html`
149
- <a class="mobile-donate-link" href=${formatUrl('/donate/?origin=iawww-mbhrt', this.baseHost)}>
150
- ${icons.donateUnpadded}
151
- <span class="sr-only">"Donate to the archive"</span>
152
- </a>
153
- `;
154
- }
155
-
156
- get uploadButtonTemplate() {
157
- return html`
158
- <a href="${formatUrl('/create', this.baseHost)}"
159
- class="upload"
160
- tabindex="1"
161
- @focus=${this.toggleMediaMenu}
162
- >
163
- ${icons.upload}
164
- <span>Upload</span>
165
- </a>`;
166
- }
167
-
168
- get userStateTemplate() {
169
- return html`<div class="user-info">
170
- ${this.username ? this.userIcon : this.loginIcon}
171
- </div>`;
172
- }
173
-
174
- get secondLogoSlot() {
175
- return this.allowSecondaryIcon
176
- ? html`
177
- <slot name="opt-sec-logo"></slot>
178
- <slot name="opt-sec-logo-mobile"></slot>
179
- `
180
- : nothing;
181
- }
182
-
183
- get secondLogoClass() {
184
- return this.allowSecondaryIcon ? 'second-logo' : '';
185
- }
186
-
187
- render() {
188
- const mediaMenuTabIndex = this.openMenu === 'media' ? '' : '-1';
189
- return html`
190
- <nav class=${this.hideSearch ? 'hide-search' : nothing}>
191
- <div class=${`branding ${this.secondLogoClass}`}>
192
- <a
193
- href=${formatUrl('/', this.baseHost)}
194
- @click=${this.trackClick}
195
- data-event-click-tracking="${this.config.eventCategory}|NavHome"
196
- title="Go home"
197
- class="link-home"
198
- tabindex="-1"
199
- >${icons.iaLogo}${logoWordmarkStacked}</a
200
- >
201
- ${this.secondLogoSlot}
202
- </div>
203
-
204
- <div class="right-side-section">
205
- ${this.mobileDonateHeart}
206
- ${this.searchMenu}
207
- ${this.uploadButtonTemplate}
208
- ${this.userStateTemplate}
209
- </div>
210
- <media-menu
211
- .baseHost=${this.baseHost}
212
- .config=${this.config}
213
- ?mediaMenuAnimate="${this.mediaMenuAnimate}"
214
- tabindex="${mediaMenuTabIndex}"
215
- .selectedMenuOption=${this.selectedMenuOption}
216
- .openMenu=${this.openMenu}
217
- ></media-menu>
218
- <button
219
- class="hamburger"
220
- @click="${this.toggleMediaMenu}"
221
- tabindex="1"
222
- data-event-click-tracking="${this.config.eventCategory}|NavHamburger"
223
- title="Open main menu"
224
- >
225
- <icon-hamburger ?active=${this.openMenu === 'media'}></icon-hamburger>
226
- </button>
227
- </nav>
228
- `;
229
- }
230
- }
231
-
232
- customElements.define('primary-nav', PrimaryNav);
1
+ import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
+ import TrackedElement from './tracked-element.js';
3
+ import icons from './assets/img/icons.js';
4
+ import './assets/img/hamburger.js';
5
+ import './login-button.js';
6
+ import './nav-search.js';
7
+ import './media-menu.js';
8
+ import logoWordmarkStacked from './assets/img/wordmark-stacked.js';
9
+ import primaryNavCSS from './styles/primary-nav.js';
10
+ import locationHandler from './lib/location-handler.js';
11
+ import formatUrl from './lib/formatUrl.js';
12
+
13
+ class PrimaryNav extends TrackedElement {
14
+ static get styles() {
15
+ return primaryNavCSS;
16
+ }
17
+
18
+ static get properties() {
19
+ return {
20
+ mediaBaseHost: { type: String },
21
+ baseHost: { type: String },
22
+ hideSearch: { type: Boolean },
23
+ config: { type: Object },
24
+ openMenu: { type: String },
25
+ screenName: { type: String },
26
+ searchIn: { type: String },
27
+ searchQuery: { type: String },
28
+ secondIdentitySlotMode: { type: String },
29
+ selectedMenuOption: { type: String },
30
+ signedOutMenuOpen: { type: Boolean },
31
+ userMenuOpen: { type: Boolean },
32
+ username: { type: String },
33
+ userProfileImagePath: { type: String },
34
+ };
35
+ }
36
+
37
+ constructor() {
38
+ super();
39
+ this.config = {};
40
+ this.openMenu = '';
41
+ this.searchIn = '';
42
+ this.selectedMenuOption = '';
43
+ this.signedOutMenuOpen = false;
44
+ this.userMenuOpen = false;
45
+ this.mediaBaseHost = 'https://archive.org';
46
+ this.secondIdentitySlotMode = '';
47
+ }
48
+
49
+ toggleMediaMenu(e) {
50
+ this.trackClick(e);
51
+ this.dispatchEvent(
52
+ new CustomEvent('menuToggled', {
53
+ detail: {
54
+ menuName: 'media',
55
+ },
56
+ }),
57
+ );
58
+ }
59
+
60
+ toggleSearchMenu(e) {
61
+ this.trackClick(e);
62
+ this.dispatchEvent(
63
+ new CustomEvent('menuToggled', {
64
+ detail: {
65
+ menuName: 'search',
66
+ },
67
+ }),
68
+ );
69
+ }
70
+
71
+ toggleUserMenu(e) {
72
+ this.trackClick(e);
73
+ this.dispatchEvent(
74
+ new CustomEvent('menuToggled', {
75
+ detail: {
76
+ menuName: 'user',
77
+ },
78
+ }),
79
+ );
80
+ }
81
+
82
+ get userIcon() {
83
+ const userMenuClass = this.openMenu === 'user' ? 'active' : '';
84
+ const userMenuToolTip = this.openMenu === 'user' ? 'Close user menu' : 'Expand user menu';
85
+
86
+ return html`
87
+ <button
88
+ class="user-menu ${userMenuClass}"
89
+ title="${userMenuToolTip}"
90
+ @click="${this.toggleUserMenu}"
91
+ data-event-click-tracking="${this.config.eventCategory}|NavUserMenu"
92
+ >
93
+ <img
94
+ src="${this.mediaBaseHost}${this.userProfileImagePath}"
95
+ alt="${this.screenName}"
96
+ />
97
+ <span class="screen-name" dir="auto">${this.screenName}</span>
98
+ </button>
99
+ `;
100
+ }
101
+
102
+ get loginIcon() {
103
+ return html`
104
+ <login-button
105
+ .baseHost=${this.baseHost}
106
+ .config=${this.config}
107
+ .dropdownOpen=${this.signedOutMenuOpen}
108
+ .openMenu=${this.openMenu}
109
+ @signedOutMenuToggled=${this.signedOutMenuToggled}
110
+ ></login-button>
111
+ `;
112
+ }
113
+
114
+ get searchMenuOpen() {
115
+ return this.openMenu === 'search';
116
+ }
117
+
118
+ get allowSecondaryIcon() {
119
+ return this.secondIdentitySlotMode === 'allow';
120
+ }
121
+
122
+ get searchMenu() {
123
+ if (this.hideSearch) return nothing;
124
+
125
+ return html`
126
+ <button
127
+ class="search-trigger"
128
+ @click="${this.toggleSearchMenu}"
129
+ data-event-click-tracking="${this.config.eventCategory}|NavSearchOpen"
130
+ >
131
+ ${icons.search}
132
+ </button>
133
+ <nav-search
134
+ .baseHost=${this.baseHost}
135
+ .config=${this.config}
136
+ .locationHandler=${locationHandler}
137
+ .open=${this.searchMenuOpen}
138
+ .openMenu=${this.openMenu}
139
+ .searchIn=${this.searchIn}
140
+ .searchQuery=${this.searchQuery}
141
+ ></nav-search>
142
+ `;
143
+ }
144
+
145
+ get mobileDonateHeart() {
146
+ return html`
147
+ <a class="mobile-donate-link" href=${formatUrl('/donate/?origin=iawww-mbhrt', this.baseHost)}>
148
+ ${icons.donateUnpadded}
149
+ <span class="sr-only">"Donate to the archive"</span>
150
+ </a>
151
+ `;
152
+ }
153
+
154
+ get uploadButtonTemplate() {
155
+ return html`<a href="${formatUrl('/create', this.baseHost)}" class="upload">
156
+ ${icons.upload}
157
+ <span>Upload</span>
158
+ </a>`;
159
+ }
160
+
161
+ get userStateTemplate() {
162
+ return html`<div class="user-info">
163
+ ${this.username ? this.userIcon : this.loginIcon}
164
+ </div>`;
165
+ }
166
+
167
+ get secondLogoSlot() {
168
+ return this.allowSecondaryIcon
169
+ ? html`
170
+ <slot name="opt-sec-logo"></slot>
171
+ <slot name="opt-sec-logo-mobile"></slot>
172
+ `
173
+ : nothing;
174
+ }
175
+
176
+ get secondLogoClass() {
177
+ return this.allowSecondaryIcon ? 'second-logo' : '';
178
+ }
179
+
180
+ render() {
181
+ const mediaMenuTabIndex = this.openMenu === 'media' ? '' : '-1';
182
+ return html`
183
+ <nav class=${this.hideSearch ? 'hide-search' : nothing}>
184
+ <div class=${`branding ${this.secondLogoClass}`}>
185
+ <a
186
+ href=${formatUrl('/', this.baseHost)}
187
+ @click=${this.trackClick}
188
+ data-event-click-tracking="${this.config.eventCategory}|NavHome"
189
+ title="Go home"
190
+ class="link-home"
191
+ >${icons.iaLogo}${logoWordmarkStacked}</a
192
+ >
193
+ ${this.secondLogoSlot}
194
+ </div>
195
+
196
+ <div class="right-side-section">
197
+ ${this.mobileDonateHeart}
198
+ ${this.searchMenu}
199
+ ${this.uploadButtonTemplate}
200
+ ${this.userStateTemplate}
201
+ </div>
202
+ <media-menu
203
+ .baseHost=${this.baseHost}
204
+ .config=${this.config}
205
+ ?mediaMenuAnimate="${this.mediaMenuAnimate}"
206
+ tabindex="${mediaMenuTabIndex}"
207
+ .selectedMenuOption=${this.selectedMenuOption}
208
+ .openMenu=${this.openMenu}
209
+ ></media-menu>
210
+ <button
211
+ class="hamburger"
212
+ @click="${this.toggleMediaMenu}"
213
+ tabindex="1"
214
+ data-event-click-tracking="${this.config.eventCategory}|NavHamburger"
215
+ title="Open main menu"
216
+ >
217
+ <icon-hamburger ?active=${this.openMenu === 'media'}></icon-hamburger>
218
+ </button>
219
+ </nav>
220
+ `;
221
+ }
222
+ }
223
+
224
+ customElements.define('primary-nav', PrimaryNav);
@@ -1,59 +1,59 @@
1
- import { html } from 'https://offshoot.prod.archive.org/lit.js';
2
- import TrackedElement from './tracked-element.js';
3
- import savePageFormCSS from './styles/save-page-form.js';
4
-
5
- class SavePageForm extends TrackedElement {
6
- static get styles() {
7
- return savePageFormCSS;
8
- }
9
-
10
- static get properties() {
11
- return {
12
- config: { type: Object },
13
- inputValid: { type: Boolean }
14
- };
15
- }
16
-
17
- constructor() {
18
- super();
19
- this.config = {
20
- eventCategory: ''
21
- };
22
- this.inputValid = true;
23
- }
24
-
25
- validateURL(e) {
26
- const urlInput = e.target.querySelector('[name="url_preload"]');
27
- const valid = /\..{2,}$/.test(urlInput.value);
28
-
29
- if (!valid) {
30
- e.preventDefault();
31
- this.inputValid = false;
32
- return;
33
- }
34
- this.inputValid = true;
35
- this.trackSubmit(e);
36
- }
37
-
38
- get errorClass() {
39
- return `error${this.inputValid ? '' : ' visible'}`;
40
- }
41
-
42
- render() {
43
- return html`
44
- <form action="//web.archive.org/save" method="post" data-event-submit-tracking="${this.config.eventCategory}|SavePageSubmit" @submit=${this.validateURL}>
45
- <h3>Save Page Now</h3>
46
- <p>Capture a web page as it appears now for use as a trusted citation in the future.</p>
47
- <div>
48
- <input type="text" name="url_preload" placeholder="https://" />
49
- <input type="submit" value="Save" />
50
- </div>
51
- <p class=${this.errorClass}>Please enter a valid web address</p>
52
- </form>
53
- `;
54
- }
55
- }
56
-
57
- customElements.define('save-page-form', SavePageForm);
58
-
59
- export default SavePageForm;
1
+ import { html } from 'https://offshoot.prod.archive.org/lit.js';
2
+ import TrackedElement from './tracked-element.js';
3
+ import savePageFormCSS from './styles/save-page-form.js';
4
+
5
+ class SavePageForm extends TrackedElement {
6
+ static get styles() {
7
+ return savePageFormCSS;
8
+ }
9
+
10
+ static get properties() {
11
+ return {
12
+ config: { type: Object },
13
+ inputValid: { type: Boolean }
14
+ };
15
+ }
16
+
17
+ constructor() {
18
+ super();
19
+ this.config = {
20
+ eventCategory: ''
21
+ };
22
+ this.inputValid = true;
23
+ }
24
+
25
+ validateURL(e) {
26
+ const urlInput = e.target.querySelector('[name="url_preload"]');
27
+ const valid = /\..{2,}$/.test(urlInput.value);
28
+
29
+ if (!valid) {
30
+ e.preventDefault();
31
+ this.inputValid = false;
32
+ return;
33
+ }
34
+ this.inputValid = true;
35
+ this.trackSubmit(e);
36
+ }
37
+
38
+ get errorClass() {
39
+ return `error${this.inputValid ? '' : ' visible'}`;
40
+ }
41
+
42
+ render() {
43
+ return html`
44
+ <form action="//web.archive.org/save" method="post" data-event-submit-tracking="${this.config.eventCategory}|SavePageSubmit" @submit=${this.validateURL}>
45
+ <h3>Save Page Now</h3>
46
+ <p>Capture a web page as it appears now for use as a trusted citation in the future.</p>
47
+ <div>
48
+ <input type="text" name="url_preload" placeholder="https://" />
49
+ <input type="submit" value="Save" />
50
+ </div>
51
+ <p class=${this.errorClass}>Please enter a valid web address</p>
52
+ </form>
53
+ `;
54
+ }
55
+ }
56
+
57
+ customElements.define('save-page-form', SavePageForm);
58
+
59
+ export default SavePageForm;