@internetarchive/ia-topnav 1.2.2-alpha2 → 1.2.2-alpha4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-topnav",
3
- "version": "1.2.2-alpha2",
3
+ "version": "1.2.2-alpha4",
4
4
  "description": "Top nav for Internet Archive",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "index.js",
@@ -7,6 +7,8 @@ class HamBurger extends Icon {
7
7
  return css`
8
8
  svg {
9
9
  display: block;
10
+ height: 4rem;
11
+ width: 4rem;
10
12
  }
11
13
  .fill-color {
12
14
  fill: var(--activeColor);
@@ -0,0 +1,17 @@
1
+ import { html } from 'https://offshoot.prod.archive.org/lit.js';
2
+
3
+ export default html`
4
+ <svg
5
+ viewBox="0 0 40 40"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ aria-labelledby="hamburgerTitleID hamburgerDescID"
8
+ >
9
+ <title id="hamburgerTitleID">Hamburger icon</title>
10
+ <desc id="hamburgerDescID">
11
+ An icon used to represent a menu that can be toggled by interacting with this icon.
12
+ </desc>
13
+ <path d="m30.5 26.5c.8284271 0 1.5.6715729 1.5 1.5s-.6715729 1.5-1.5 1.5h-21c-.82842712 0-1.5-.6715729-1.5-1.5s.67157288-1.5 1.5-1.5zm0-8c.8284271 0 1.5.6715729 1.5 1.5s-.6715729 1.5-1.5 1.5h-21c-.82842712 0-1.5-.6715729-1.5-1.5s.67157288-1.5 1.5-1.5zm0-8c.8284271 0 1.5.6715729 1.5 1.5s-.6715729 1.5-1.5 1.5h-21c-.82842712 0-1.5-.6715729-1.5-1.5s.67157288-1.5 1.5-1.5z" fill="#999" fill-rule="evenodd"/>
14
+ </svg>
15
+ `;
16
+
17
+
@@ -1,5 +1,6 @@
1
1
  import audio from './icon-audio.js';
2
2
  import close from './icon-close.js';
3
+ import hamburger from './icon-hamburger.js';
3
4
  import donate from './icon-donate.js';
4
5
  import ellipses from './icon-ellipses.js';
5
6
  import iaLogo from './icon-ia-logo.js';
@@ -8,7 +9,6 @@ import search from './icon-search.js';
8
9
  import software from './icon-software.js';
9
10
  import texts from './icon-texts.js';
10
11
  import upload from './icon-upload.js';
11
- import uploadUnpadded from './icon-upload-unpadded.js';
12
12
  import user from './icon-user.js';
13
13
  import video from './icon-video.js';
14
14
  import web from './icon-web.js';
@@ -16,6 +16,7 @@ import web from './icon-web.js';
16
16
  export default {
17
17
  audio,
18
18
  close,
19
+ hamburger,
19
20
  donate,
20
21
  ellipses,
21
22
  iaLogo,
@@ -24,7 +25,6 @@ export default {
24
25
  software,
25
26
  texts,
26
27
  upload,
27
- uploadUnpadded,
28
28
  user,
29
29
  video,
30
30
  web,
package/src/data/menus.js CHANGED
@@ -524,7 +524,6 @@ export function buildTopNavMenus(userid = '___USERID___', localLinks = true, way
524
524
  url: `${prefix}/create`,
525
525
  title: 'Upload files',
526
526
  analyticsEvent: 'UserUpload',
527
- class: 'mobile-upload',
528
527
  },
529
528
  {
530
529
  url: `${prefix}/details/@${userid}`,
@@ -1,9 +1,7 @@
1
1
  import { html, nothing } from 'https://offshoot.prod.archive.org/lit.js';
2
- import { ifDefined } from 'https://offshoot.prod.archive.org/lit/directives/if-defined.js';
3
2
  import TrackedElement from './tracked-element.js';
4
3
  import dropdownMenuCSS from './styles/dropdown-menu.js';
5
4
  import formatUrl from './lib/formatUrl.js';
6
- import icons from './assets/img/icons.js';
7
5
 
8
6
  class DropdownMenu extends TrackedElement {
9
7
  static get styles() {
@@ -57,11 +55,9 @@ class DropdownMenu extends TrackedElement {
57
55
  const calloutText = this.config.callouts?.[link.title];
58
56
  return html`<a
59
57
  href="${formatUrl(link.url, this.baseHost)}"
60
- class="${ifDefined(link.class)}"
61
58
  @click=${this.trackClick}
62
59
  data-event-click-tracking="${this.config.eventCategory}|Nav${link.analyticsEvent}"
63
60
  aria-label=${calloutText ? `New feature: ${link.title}` : nothing}>
64
- ${link.class === 'mobile-upload' ? icons.uploadUnpadded : nothing}
65
61
  ${link.title}
66
62
  ${calloutText ? html`<span class="callout" aria-hidden="true">${calloutText}</span>` : nothing}
67
63
  </a>`;
@@ -124,7 +124,7 @@ class PrimaryNav extends TrackedElement {
124
124
 
125
125
  return html`
126
126
  <button
127
- class="search-trigger"
127
+ class="mobile-search-trigger right-side-item"
128
128
  @click="${this.toggleSearchMenu}"
129
129
  data-event-click-tracking="${this.config.eventCategory}|NavSearchOpen"
130
130
  >
@@ -144,15 +144,26 @@ class PrimaryNav extends TrackedElement {
144
144
 
145
145
  get mobileDonateHeart() {
146
146
  return html`
147
- <a class="mobile-donate-link" href=${formatUrl('/donate/?origin=iawww-mbhrt', this.baseHost)}>
148
- <span class="icon">
147
+ <a class="mobile-donate-link right-side-item" href=${formatUrl('/donate/?origin=iawww-mbhrt', this.baseHost)}>
149
148
  ${icons.donate}
150
- </span>
151
- <span class="label">"Donate to the archive"</span>
149
+ <span class="sr-only">"Donate to the archive"</span>
152
150
  </a>
153
151
  `;
154
152
  }
155
153
 
154
+ get uploadButtonTemplate() {
155
+ return html`<a href="${formatUrl('/create', this.baseHost)}" class="upload right-side-item">
156
+ ${icons.upload}
157
+ <span>Upload</span>
158
+ </a>`;
159
+ }
160
+
161
+ get userStateTemplate() {
162
+ return html`<div class="user-info right-side-item">
163
+ ${this.username ? this.userIcon : this.loginIcon}
164
+ </div>`;
165
+ }
166
+
156
167
  get secondLogoSlot() {
157
168
  return this.allowSecondaryIcon
158
169
  ? html`
@@ -181,14 +192,12 @@ class PrimaryNav extends TrackedElement {
181
192
  >
182
193
  ${this.secondLogoSlot}
183
194
  </div>
184
- ${this.mobileDonateHeart}
185
- ${this.searchMenu}
186
- <a href="${formatUrl('/create', this.baseHost)}" class="upload">
187
- ${icons.upload}
188
- <span>Upload</span>
189
- </a>
190
- <div class="user-info">
191
- ${this.username ? this.userIcon : this.loginIcon}
195
+
196
+ <div class="right-side-section">
197
+ ${this.mobileDonateHeart}
198
+ ${this.searchMenu}
199
+ ${this.uploadButtonTemplate}
200
+ ${this.userStateTemplate}
192
201
  </div>
193
202
  <media-menu
194
203
  .baseHost=${this.baseHost}
@@ -205,7 +214,7 @@ class PrimaryNav extends TrackedElement {
205
214
  data-event-click-tracking="${this.config.eventCategory}|NavHamburger"
206
215
  title="Open main menu"
207
216
  >
208
- <icon-hamburger ?active=${this.openMenu === 'media'}></icon-hamburger>
217
+ ${this.openMenu === 'media' ? icons.close : icons.hamburger}
209
218
  </button>
210
219
  </nav>
211
220
  `;
@@ -20,7 +20,7 @@ export const subnavListCSS = css`
20
20
  padding-top: 1.5rem;
21
21
  }
22
22
 
23
- @media (min-width: 890px) {
23
+ @media (min-width: 89rem) {
24
24
  h4 {
25
25
  margin: 0 0 1rem 0;
26
26
  font-weight: 100;
@@ -29,9 +29,9 @@ export default css`
29
29
  }
30
30
 
31
31
  .donate svg {
32
- width: 16px;
33
- height: 16px;
34
- vertical-align: -4px;
32
+ width: 1.6rem;
33
+ height: 1.6rem;
34
+ vertical-align: top;
35
35
  fill: #f00;
36
36
  }
37
37
  `;
@@ -78,16 +78,6 @@ export default css`
78
78
  font-weight: bold;
79
79
  }
80
80
 
81
- a.mobile-upload {
82
- display: flex;
83
- justify-content: left;
84
- align-items: center;
85
- }
86
- a.mobile-upload svg {
87
- fill: #fff;
88
- margin-right: 10px;
89
- }
90
-
91
81
  @media (min-width: 890px) {
92
82
  nav {
93
83
  overflow: visible;
@@ -156,9 +146,5 @@ export default css`
156
146
  opacity: 1;
157
147
  overflow: visible;
158
148
  }
159
-
160
- a.mobile-upload {
161
- display: none;
162
- }
163
149
  }
164
150
  `;
@@ -3,14 +3,16 @@ import { css } from 'https://offshoot.prod.archive.org/lit.js';
3
3
  export default css`
4
4
  .dropdown-toggle {
5
5
  display: block;
6
- height: 4rem;
7
- font-size: 1.6rem;
8
6
  text-transform: uppercase;
9
- text-decoration: none;
10
7
  color: var(--grey80);
11
8
  cursor: pointer;
12
9
  }
13
10
 
11
+ .dropdown-toggle svg {
12
+ height: 4rem;
13
+ width: 4rem;
14
+ }
15
+
14
16
  .dropdown-toggle .fill-color {
15
17
  fill: var(--iconFill);
16
18
  }
@@ -49,10 +51,6 @@ export default css`
49
51
  }
50
52
 
51
53
  @media (min-width: 890px) {
52
- .logged-out-toolbar {
53
- transform: translateY(-.5rem);
54
- }
55
-
56
54
  .active {
57
55
  background: transparent;
58
56
  }
@@ -33,8 +33,6 @@ export default css`
33
33
 
34
34
  .menu-item > .icon {
35
35
  display: inline-flex;
36
- width: 42px;
37
- height: 42px;
38
36
  vertical-align: middle;
39
37
  -webkit-box-align: center;
40
38
  -ms-flex-align: center;
@@ -44,6 +42,11 @@ export default css`
44
42
  justify-content: center;
45
43
  }
46
44
 
45
+ .menu-item > .icon > svg {
46
+ height: 4rem;
47
+ width: 4rem;
48
+ }
49
+
47
50
  .menu-item.selected .icon {
48
51
  background-color: var(--activeButtonBg);
49
52
  border-radius: 1rem 0 0 1rem;
@@ -61,7 +64,7 @@ export default css`
61
64
  fill: #f00;
62
65
  }
63
66
 
64
- @media (min-width: 890px) {
67
+ @media (min-width: 55.62rem) {
65
68
  .menu-item {
66
69
  width: auto;
67
70
  height: 5rem;
@@ -91,7 +94,6 @@ export default css`
91
94
  color: inherit;
92
95
  }
93
96
 
94
-
95
97
  .web:after {
96
98
  display: none;
97
99
  content: "web";
@@ -140,7 +142,7 @@ export default css`
140
142
  }
141
143
  }
142
144
 
143
- @media (min-width: 1300px) {
145
+ @media (min-width: 81.25rem) {
144
146
  .label,
145
147
  .web:after {
146
148
  display: inline;
@@ -54,9 +54,9 @@ export default css`
54
54
  }
55
55
 
56
56
  /* Desktop view styles */
57
- @media (min-width: 890px) {
57
+ @media (min-width: 55.625rem) {
58
58
  .media-menu-inner {
59
- display: inline-block;
59
+ display: block;
60
60
  position: static;
61
61
  width: auto;
62
62
  height: 5rem;
@@ -24,8 +24,6 @@ export default css`
24
24
  }
25
25
  .search svg {
26
26
  position: relative;
27
- top: -5px;
28
- right: -3px;
29
27
  fill: var(--activeSearchColor);
30
28
  }
31
29
  .search-activated {
@@ -65,6 +63,10 @@ export default css`
65
63
  -ms-grid-row-align: center;
66
64
  align-self: center;
67
65
  }
66
+ .search-activated .search svg {
67
+ height: 3rem;
68
+ width: 3rem;
69
+ }
68
70
  .search-activated .search-field {
69
71
  width: 100%;
70
72
  height: 100%;
@@ -93,8 +95,8 @@ export default css`
93
95
  @media (min-width: 890px) {
94
96
  .search svg {
95
97
  display: inline;
96
- width: 28px;
97
- height: 28px;
98
+ width: 2.8rem;
99
+ height: 2.8rem;
98
100
  vertical-align: -14px;
99
101
  }
100
102
  .search path {
@@ -105,7 +107,7 @@ export default css`
105
107
  .search-activated {
106
108
  display: block;
107
109
  position: static;
108
- padding: 1.2rem 0.2rem;
110
+ padding: 1.1rem 0.2rem;
109
111
  background: transparent;
110
112
  }
111
113
 
@@ -127,8 +129,8 @@ export default css`
127
129
  }
128
130
 
129
131
  .search-activated .search svg {
130
- width: 28px;
131
- height: 28px;
132
+ width: 2.8rem;
133
+ height: 2.8rem;
132
134
  }
133
135
  }
134
136
  `;
@@ -11,10 +11,9 @@ export default css`
11
11
  position: relative;
12
12
  display: -ms-grid;
13
13
  display: grid;
14
- height: 40px;
15
14
  grid-template-areas: 'hamburger empty heart search user';
16
- -ms-grid-columns: 40px minmax(1rem, 100%) 40px 40px 40px;
17
- grid-template-columns: 40px auto 40px 40px 40px;
15
+ -ms-grid-columns: 4rem minmax(1rem, 100%) 4rem 4rem 4rem;
16
+ grid-template-columns: 4rem auto 4rem 4rem 4rem;
18
17
  -ms-grid-rows: 100%;
19
18
  grid-template-rows: 100%;
20
19
  background: var(--primaryNavBg);
@@ -23,10 +22,24 @@ export default css`
23
22
 
24
23
  nav.hide-search {
25
24
  grid-template-areas: 'hamburger empty heart user';
26
- -ms-grid-columns: 40px minmax(1rem, 100%) 40px 40px;
27
- grid-template-columns: 40px auto 40px 40px;
25
+ -ms-grid-columns: 4rem minmax(1rem, 100%) 4rem 4rem;
26
+ grid-template-columns: 4rem auto 4rem 4rem;
28
27
  }
29
28
 
29
+ .right-side-section {
30
+ display: flex;
31
+ user-select: none;
32
+ align-items: center;
33
+ }
34
+ .right-side-item {
35
+ position: static;
36
+ padding: 0;
37
+ background: transparent;
38
+ }
39
+ .right-side-item svg {
40
+ height: 4rem;
41
+ width: 4rem;
42
+ }
30
43
  button {
31
44
  background: none;
32
45
  color: inherit;
@@ -56,6 +69,14 @@ export default css`
56
69
  grid-column-end: user-end;
57
70
  }
58
71
 
72
+ .ia-logo {
73
+ height: 3rem;
74
+ width: 3rem;
75
+ }
76
+ .ia-wordmark {
77
+ height: 3rem;
78
+ width: 9.5rem;
79
+ }
59
80
  .ia-logo,
60
81
  .ia-wordmark {
61
82
  margin-right: 5px;
@@ -67,55 +88,32 @@ export default css`
67
88
  grid-area: hamburger;
68
89
  padding: 0;
69
90
  }
70
-
71
- .mobile-donate-link {
72
- -ms-grid-row: 1;
73
- -ms-grid-column: 3;
74
- grid-area: heart;
75
- position: relative;
76
- padding: 0;
77
- z-index: 1;
78
- width: 100%;
79
- text-align: right;
80
- -webkit-box-align: center;
81
- -ms-flex-align: center;
82
- align-items: center;
83
- }
84
- .mobile-donate-link svg {
85
- height: 50px;
86
- width: 50px;
87
- margin-top: -5px;
88
- margin-left: -5px;
91
+ .hamburger svg {
92
+ height: 4rem;
93
+ width: 4rem;
94
+ fill: var(--activeColor);
89
95
  }
96
+
90
97
  .mobile-donate-link .fill-color {
91
98
  fill: rgb(255, 0, 0);
92
99
  }
93
- .mobile-donate-link .label {
100
+
101
+ .sr-only {
94
102
  position: absolute;
95
103
  width: 1px;
96
104
  height: 1px;
97
- padding: 0;
98
105
  margin: -1px;
99
- overflow: hidden;
100
- clip: rect(0,0,0,0);
101
- border: 0;
102
- }
103
-
104
- .search-trigger {
105
- -ms-grid-row: 1;
106
- -ms-grid-column: 4;
107
- grid-area: search;
108
- position: relative;
109
106
  padding: 0;
110
- z-index: 1;
111
- width: 100%;
112
- text-align: right;
113
- -webkit-box-align: center;
114
- -ms-flex-align: center;
115
- align-items: center;
107
+ border: 0;
108
+ overflow: hidden;
109
+ white-space: nowrap;
110
+ clip: rect(1px, 1px, 1px, 1px);
111
+ -webkit-clip-path: inset(50%);
112
+ clip-path: inset(50%);
113
+ user-select: none;
116
114
  }
117
115
 
118
- .search-trigger .fill-color {
116
+ .mobile-search-trigger .fill-color {
119
117
  fill: var(--iconFill);
120
118
  }
121
119
 
@@ -132,14 +130,9 @@ export default css`
132
130
  display: none;
133
131
  }
134
132
 
135
- .user-info {
136
- -ms-grid-row: 1;
137
- -ms-grid-column: 5;
138
- grid-area: user;
139
- -ms-grid-row-align: stretch;
140
- align-self: stretch;
141
- -ms-grid-column-align: end;
142
- justify-self: end;
133
+ .upload svg {
134
+ height: 3rem;
135
+ width: 3rem;
143
136
  }
144
137
 
145
138
  .screen-name {
@@ -150,9 +143,8 @@ export default css`
150
143
  }
151
144
 
152
145
  .user-menu {
153
- height: 100%;
154
- padding: 0.5rem 1rem;
155
146
  color: var(--lightTextColor);
147
+ padding: 0;
156
148
  }
157
149
 
158
150
  .user-menu:hover {
@@ -166,8 +158,8 @@ export default css`
166
158
 
167
159
  .user-menu img {
168
160
  display: block;
169
- width: 30px;
170
- height: 30px;
161
+ width: 4rem;
162
+ height: 4rem;
171
163
  }
172
164
 
173
165
  .link-home {
@@ -195,15 +187,20 @@ export default css`
195
187
 
196
188
  @media (min-width: 890px) {
197
189
  :host {
198
- --userIconWidth: 32px;
199
- --userIconHeight: 32px;
190
+ --userIconWidth: 3.2rem;
191
+ --userIconHeight: 3.2rem;
200
192
  }
201
193
 
194
+ .right-side-section {
195
+ display: contents;
196
+ }
197
+ .right-side-item {
198
+ padding: 0.5rem 0.5rem;
199
+ }
202
200
  nav {
203
201
  display: block;
204
202
  z-index: 3;
205
203
  height: 5rem;
206
- padding-right: 1.5rem;
207
204
  }
208
205
 
209
206
  slot[name='opt-sec-logo-mobile'] {
@@ -220,14 +217,13 @@ export default css`
220
217
  }
221
218
 
222
219
  .hamburger,
223
- .search-trigger,
220
+ .mobile-search-trigger,
224
221
  .mobile-donate-link {
225
222
  display: none;
226
223
  }
227
224
 
228
225
  .user-info {
229
226
  float: right;
230
- padding-top: 1rem;
231
227
  }
232
228
 
233
229
  .user-menu {
@@ -245,8 +241,8 @@ export default css`
245
241
 
246
242
  .upload {
247
243
  display: block;
244
+ padding: 1rem 0.5rem;
248
245
  float: right;
249
- margin-top: 1rem;
250
246
  font-size: 1.4rem;
251
247
  text-transform: uppercase;
252
248
  text-decoration: none;
@@ -259,8 +255,6 @@ export default css`
259
255
  }
260
256
 
261
257
  .upload svg {
262
- width: 32px;
263
- height: 32px;
264
258
  vertical-align: middle;
265
259
  fill: var(--iconFill);
266
260
  }
@@ -5,7 +5,7 @@ export default css`
5
5
  .initial,
6
6
  .closed,
7
7
  .open {
8
- right: 21.3rem;
8
+ right: 20.5rem;
9
9
  }
10
10
 
11
11
  .search-hidden.initial,
@@ -19,7 +19,7 @@ export default css`
19
19
  .initial,
20
20
  .closed,
21
21
  .open {
22
- right: 27.5rem;
22
+ right: 25.5rem;
23
23
  }
24
24
 
25
25
  .search-hidden.initial,
@@ -198,7 +198,7 @@ describe('<ia-topnav>', () => {
198
198
 
199
199
  it('toggles search menu when search toggle button clicked', async () => {
200
200
  const el = await fixture(container());
201
- el.shadowRoot.querySelector('primary-nav').shadowRoot.querySelector('.search-trigger').click();
201
+ el.shadowRoot.querySelector('primary-nav').shadowRoot.querySelector('.mobile-search-trigger').click();
202
202
  await el.updateComplete;
203
203
 
204
204
  expect(el.openMenu).to.equal('search');
@@ -40,7 +40,7 @@ describe('<primary-nav>', () => {
40
40
  hideSearch: true,
41
41
  }));
42
42
 
43
- expect(el.shadowRoot.querySelector('.search-trigger')).to.equal(null);
43
+ expect(el.shadowRoot.querySelector('.mobile-search-trigger')).to.equal(null);
44
44
  expect(el.shadowRoot.querySelector('nav-search')).to.equal(null);
45
45
  });
46
46
 
@@ -1,15 +0,0 @@
1
- import { html } from 'https://offshoot.prod.archive.org/lit.js';
2
-
3
- export default html`
4
- <svg
5
- height="14"
6
- width="14"
7
- viewBox="8 8 24 24"
8
- xmlns="http://www.w3.org/2000/svg"
9
- aria-labelledby="uploadTitleID uploadDescID"
10
- >
11
- <title id="uploadTitleID">Upload icon</title>
12
- <desc id="uploadDescID">An illustration of a horizontal line over an up pointing arrow.</desc>
13
- <path class="fill-color" d="m20 12.8 8 10.4h-4.8v8.8h-6.4v-8.8h-4.8zm12-4.8v3.2h-24v-3.2z" fill-rule="evenodd"/>
14
- </svg>
15
- `;