@internetarchive/ia-topnav 1.1.30 → 1.1.31-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 (83) hide show
  1. package/.eslintrc +16 -16
  2. package/LICENSE +661 -661
  3. package/README.md +147 -147
  4. package/index.d.ts +104 -104
  5. package/index.js +3 -3
  6. package/package.json +61 -61
  7. package/src/assets/img/hamburger.js +36 -36
  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.js +15 -15
  12. package/src/assets/img/icon-ellipses.js +15 -15
  13. package/src/assets/img/icon-ia-logo.js +24 -24
  14. package/src/assets/img/icon-images.js +15 -15
  15. package/src/assets/img/icon-search.js +15 -15
  16. package/src/assets/img/icon-software.js +15 -15
  17. package/src/assets/img/icon-texts.js +15 -15
  18. package/src/assets/img/icon-upload.js +15 -15
  19. package/src/assets/img/icon-user.js +15 -15
  20. package/src/assets/img/icon-video.js +15 -15
  21. package/src/assets/img/icon-web.js +15 -15
  22. package/src/assets/img/icon.js +18 -18
  23. package/src/assets/img/icons.js +29 -29
  24. package/src/assets/img/user.js +38 -38
  25. package/src/assets/img/wordmark-stacked.js +13 -13
  26. package/src/data/menus.js +669 -659
  27. package/src/desktop-subnav.js +45 -45
  28. package/src/dropdown-menu.js +102 -98
  29. package/src/ia-topnav.js +307 -307
  30. package/src/lib/formatUrl.js +1 -1
  31. package/src/lib/location-handler.js +5 -5
  32. package/src/lib/query-handler.js +7 -7
  33. package/src/lib/toSentenceCase.js +8 -8
  34. package/src/login-button.js +79 -79
  35. package/src/media-button.js +113 -113
  36. package/src/media-menu.js +133 -133
  37. package/src/media-slider.js +104 -104
  38. package/src/media-subnav.js +112 -112
  39. package/src/more-slider.js +33 -33
  40. package/src/nav-search.js +125 -125
  41. package/src/primary-nav.js +215 -203
  42. package/src/save-page-form.js +59 -59
  43. package/src/search-menu.js +115 -115
  44. package/src/signed-out-dropdown.js +10 -10
  45. package/src/styles/base.js +48 -48
  46. package/src/styles/desktop-subnav.js +37 -37
  47. package/src/styles/dropdown-menu.js +149 -139
  48. package/src/styles/ia-topnav.js +88 -88
  49. package/src/styles/login-button.js +70 -70
  50. package/src/styles/media-button.js +153 -153
  51. package/src/styles/media-menu.js +70 -70
  52. package/src/styles/media-slider.js +81 -81
  53. package/src/styles/media-subnav.js +156 -156
  54. package/src/styles/more-slider.js +15 -15
  55. package/src/styles/nav-search.js +134 -134
  56. package/src/styles/primary-nav.js +298 -258
  57. package/src/styles/save-page-form.js +53 -53
  58. package/src/styles/search-menu.js +99 -99
  59. package/src/styles/signed-out-dropdown.js +31 -31
  60. package/src/styles/user-menu.js +31 -31
  61. package/src/styles/wayback-search.js +48 -48
  62. package/src/styles/wayback-slider.js +30 -30
  63. package/src/tracked-element.js +27 -27
  64. package/src/user-menu.js +42 -42
  65. package/src/wayback-search.js +18 -18
  66. package/src/wayback-slider.js +88 -88
  67. package/test/assets/img/hamburger.test.js +15 -15
  68. package/test/assets/img/user.test.js +15 -15
  69. package/test/data/menus.test.js +19 -19
  70. package/test/dropdown-menu.test.js +25 -25
  71. package/test/ia-icon.test.js +13 -13
  72. package/test/ia-topnav.test.js +273 -273
  73. package/test/login-button.test.js +15 -15
  74. package/test/media-button.test.js +19 -19
  75. package/test/media-menu.test.js +40 -40
  76. package/test/media-slider.test.js +57 -57
  77. package/test/more-slider.test.js +13 -13
  78. package/test/nav-search.test.js +61 -61
  79. package/test/primary-nav.test.js +82 -82
  80. package/test/save-page-form.test.js +35 -35
  81. package/test/search-menu.test.js +49 -49
  82. package/test/user-menu.test.js +33 -33
  83. package/test/wayback-slider.test.js +80 -80
@@ -1,79 +1,79 @@
1
- import { html } 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 loginButtonCSS from './styles/login-button.js';
5
- import formatUrl from './lib/formatUrl.js';
6
-
7
- class LoginButton extends TrackedElement {
8
- static get styles() {
9
- return loginButtonCSS;
10
- }
11
-
12
- static get properties() {
13
- return {
14
- baseHost: { type: String },
15
- config: { type: Object },
16
- openMenu: { type: String },
17
- };
18
- }
19
-
20
- constructor() {
21
- super();
22
- this.config = {};
23
- this.openMenu = '';
24
- }
25
-
26
- get signupPath() {
27
- return formatUrl('/account/signup', this.baseHost);
28
- }
29
-
30
- get loginPath() {
31
- return formatUrl('/account/login', this.baseHost);
32
- }
33
-
34
- get analyticsEvent() {
35
- return `${this.config.eventCategory}|NavLoginIcon`;
36
- }
37
-
38
- get menuOpened() {
39
- return this.openMenu === 'login';
40
- }
41
-
42
- get avatarClass() {
43
- return `dropdown-toggle${this.menuOpened ? ' active' : ''}`;
44
- }
45
-
46
- toggleDropdown(e) {
47
- e.preventDefault();
48
- this.trackClick(e);
49
- this.dropdownTabIndex = this.menuOpened ? '' : '-1';
50
- this.dispatchEvent(new CustomEvent('menuToggled', {
51
- bubbles: true,
52
- composed: true,
53
- detail: {
54
- menuName: 'login'
55
- }
56
- }));
57
- }
58
-
59
- render() {
60
- return html`
61
- <div class="logged-out-toolbar">
62
- <a
63
- class="${this.avatarClass}"
64
- @click=${this.toggleDropdown}
65
- data-event-click-tracking="${this.analyticsEvent}"
66
- >
67
- ${icons.user}
68
- </a>
69
- <span>
70
- <a href="${this.signupPath}">Sign up</a>
71
- |
72
- <a href="${this.loginPath}">Log in</a>
73
- </span>
74
- </div>
75
- `;
76
- }
77
- }
78
-
79
- customElements.define('login-button', LoginButton);
1
+ import { html } 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 loginButtonCSS from './styles/login-button.js';
5
+ import formatUrl from './lib/formatUrl.js';
6
+
7
+ class LoginButton extends TrackedElement {
8
+ static get styles() {
9
+ return loginButtonCSS;
10
+ }
11
+
12
+ static get properties() {
13
+ return {
14
+ baseHost: { type: String },
15
+ config: { type: Object },
16
+ openMenu: { type: String },
17
+ };
18
+ }
19
+
20
+ constructor() {
21
+ super();
22
+ this.config = {};
23
+ this.openMenu = '';
24
+ }
25
+
26
+ get signupPath() {
27
+ return formatUrl('/account/signup', this.baseHost);
28
+ }
29
+
30
+ get loginPath() {
31
+ return formatUrl('/account/login', this.baseHost);
32
+ }
33
+
34
+ get analyticsEvent() {
35
+ return `${this.config.eventCategory}|NavLoginIcon`;
36
+ }
37
+
38
+ get menuOpened() {
39
+ return this.openMenu === 'login';
40
+ }
41
+
42
+ get avatarClass() {
43
+ return `dropdown-toggle${this.menuOpened ? ' active' : ''}`;
44
+ }
45
+
46
+ toggleDropdown(e) {
47
+ e.preventDefault();
48
+ this.trackClick(e);
49
+ this.dropdownTabIndex = this.menuOpened ? '' : '-1';
50
+ this.dispatchEvent(new CustomEvent('menuToggled', {
51
+ bubbles: true,
52
+ composed: true,
53
+ detail: {
54
+ menuName: 'login'
55
+ }
56
+ }));
57
+ }
58
+
59
+ render() {
60
+ return html`
61
+ <div class="logged-out-toolbar">
62
+ <a
63
+ class="${this.avatarClass}"
64
+ @click=${this.toggleDropdown}
65
+ data-event-click-tracking="${this.analyticsEvent}"
66
+ >
67
+ ${icons.user}
68
+ </a>
69
+ <span>
70
+ <a href="${this.signupPath}">Sign up</a>
71
+ |
72
+ <a href="${this.loginPath}">Log in</a>
73
+ </span>
74
+ </div>
75
+ `;
76
+ }
77
+ }
78
+
79
+ customElements.define('login-button', LoginButton);
@@ -1,113 +1,113 @@
1
- import { html } 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 toSentenceCase from './lib/toSentenceCase.js';
5
- import mediaButtonCSS from './styles/media-button.js';
6
-
7
- class MediaButton extends TrackedElement {
8
- static get styles() {
9
- return mediaButtonCSS;
10
- }
11
-
12
- static get properties() {
13
- return {
14
- config: { type: Object },
15
- icon: { type: String },
16
- href: { type: String },
17
- label: { type: String },
18
- mediatype: { type: String },
19
- openMenu: { type: String },
20
- selected: { type: Boolean },
21
- followable: { type: Boolean },
22
- };
23
- }
24
-
25
- static get icons() {
26
- return icons;
27
- }
28
-
29
- constructor() {
30
- super();
31
- this.config = {};
32
- this.icon = '';
33
- this.href = '';
34
- this.label = '';
35
- this.mediatype = '';
36
- this.openMenu = '';
37
- this.selected = false;
38
- this.followable = false;
39
- }
40
-
41
- onClick(e) {
42
- this.trackClick(e);
43
- e.preventDefault();
44
- // On desktop viewport widths, the media subnav is always visible. To
45
- // ensure the media subnav is open on mobile if the viewport is
46
- // resized, the openMenu needs to be set to 'media'.
47
- if (this.openMenu !== 'media') {
48
- this.dispatchMenuToggledEvent();
49
- }
50
- this.dispatchMediaTypeSelectedEvent();
51
- }
52
-
53
- dispatchMenuToggledEvent() {
54
- this.dispatchEvent(new CustomEvent('menuToggled', {
55
- bubbles: true,
56
- composed: true,
57
- detail: {
58
- menuName: 'media'
59
- }
60
- }));
61
- }
62
-
63
- dispatchMediaTypeSelectedEvent() {
64
- this.dispatchEvent(new CustomEvent('mediaTypeSelected', {
65
- bubbles: true,
66
- composed: true,
67
- detail: {
68
- mediatype: this.mediatype
69
- }
70
- }));
71
- }
72
-
73
- get buttonClass() {
74
- return this.selected ? 'selected' : '';
75
- }
76
-
77
- get tooltipPrefix() {
78
- return this.selected ? 'Collapse' : 'Expand';
79
- }
80
-
81
- get iconClass() {
82
- return this.selected ? 'active' : '';
83
- }
84
-
85
- get analyticsEvent() {
86
- return `${this.config.eventCategory}|NavMenu${toSentenceCase(this.mediatype)}`;
87
- }
88
-
89
- get menuItem() {
90
- return html`
91
- <span class="icon ${this.iconClass}">
92
- ${MediaButton.icons[this.icon]}
93
- </span>
94
- <span class="label">${this.label}</span>
95
- `;
96
- }
97
-
98
- render() {
99
- return html`
100
- <a
101
- href="${this.href}"
102
- class="menu-item ${this.mediatype} ${this.buttonClass}"
103
- @click=${this.followable ? this.trackClick : this.onClick}
104
- data-event-click-tracking="${this.analyticsEvent}"
105
- title="${this.tooltipPrefix} ${this.mediatype} menu"
106
- >
107
- ${this.menuItem}
108
- </a>
109
- `;
110
- }
111
- }
112
-
113
- customElements.define('media-button', MediaButton);
1
+ import { html } 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 toSentenceCase from './lib/toSentenceCase.js';
5
+ import mediaButtonCSS from './styles/media-button.js';
6
+
7
+ class MediaButton extends TrackedElement {
8
+ static get styles() {
9
+ return mediaButtonCSS;
10
+ }
11
+
12
+ static get properties() {
13
+ return {
14
+ config: { type: Object },
15
+ icon: { type: String },
16
+ href: { type: String },
17
+ label: { type: String },
18
+ mediatype: { type: String },
19
+ openMenu: { type: String },
20
+ selected: { type: Boolean },
21
+ followable: { type: Boolean },
22
+ };
23
+ }
24
+
25
+ static get icons() {
26
+ return icons;
27
+ }
28
+
29
+ constructor() {
30
+ super();
31
+ this.config = {};
32
+ this.icon = '';
33
+ this.href = '';
34
+ this.label = '';
35
+ this.mediatype = '';
36
+ this.openMenu = '';
37
+ this.selected = false;
38
+ this.followable = false;
39
+ }
40
+
41
+ onClick(e) {
42
+ this.trackClick(e);
43
+ e.preventDefault();
44
+ // On desktop viewport widths, the media subnav is always visible. To
45
+ // ensure the media subnav is open on mobile if the viewport is
46
+ // resized, the openMenu needs to be set to 'media'.
47
+ if (this.openMenu !== 'media') {
48
+ this.dispatchMenuToggledEvent();
49
+ }
50
+ this.dispatchMediaTypeSelectedEvent();
51
+ }
52
+
53
+ dispatchMenuToggledEvent() {
54
+ this.dispatchEvent(new CustomEvent('menuToggled', {
55
+ bubbles: true,
56
+ composed: true,
57
+ detail: {
58
+ menuName: 'media'
59
+ }
60
+ }));
61
+ }
62
+
63
+ dispatchMediaTypeSelectedEvent() {
64
+ this.dispatchEvent(new CustomEvent('mediaTypeSelected', {
65
+ bubbles: true,
66
+ composed: true,
67
+ detail: {
68
+ mediatype: this.mediatype
69
+ }
70
+ }));
71
+ }
72
+
73
+ get buttonClass() {
74
+ return this.selected ? 'selected' : '';
75
+ }
76
+
77
+ get tooltipPrefix() {
78
+ return this.selected ? 'Collapse' : 'Expand';
79
+ }
80
+
81
+ get iconClass() {
82
+ return this.selected ? 'active' : '';
83
+ }
84
+
85
+ get analyticsEvent() {
86
+ return `${this.config.eventCategory}|NavMenu${toSentenceCase(this.mediatype)}`;
87
+ }
88
+
89
+ get menuItem() {
90
+ return html`
91
+ <span class="icon ${this.iconClass}">
92
+ ${MediaButton.icons[this.icon]}
93
+ </span>
94
+ <span class="label">${this.label}</span>
95
+ `;
96
+ }
97
+
98
+ render() {
99
+ return html`
100
+ <a
101
+ href="${this.href}"
102
+ class="menu-item ${this.mediatype} ${this.buttonClass}"
103
+ @click=${this.followable ? this.trackClick : this.onClick}
104
+ data-event-click-tracking="${this.analyticsEvent}"
105
+ title="${this.tooltipPrefix} ${this.mediatype} menu"
106
+ >
107
+ ${this.menuItem}
108
+ </a>
109
+ `;
110
+ }
111
+ }
112
+
113
+ customElements.define('media-button', MediaButton);
package/src/media-menu.js CHANGED
@@ -1,133 +1,133 @@
1
- import { LitElement, html } from 'https://offshoot.prod.archive.org/lit.js';
2
-
3
- import './media-button.js';
4
- import mediaMenuCSS from './styles/media-menu.js';
5
- import formatUrl from './lib/formatUrl.js';
6
-
7
- const menuSelection = [
8
- {
9
- icon: 'web',
10
- menu: 'web',
11
- href: '/web/',
12
- label: 'Wayback Machine',
13
- },
14
- {
15
- icon: 'texts',
16
- menu: 'texts',
17
- href: '/details/texts',
18
- label: 'Books',
19
- },
20
- {
21
- icon: 'video',
22
- menu: 'video',
23
- href: '/details/movies',
24
- label: 'Video',
25
- },
26
- {
27
- icon: 'audio',
28
- menu: 'audio',
29
- href: '/details/audio',
30
- label: 'Audio',
31
- },
32
- {
33
- icon: 'software',
34
- menu: 'software',
35
- href: '/details/software',
36
- label: 'Software',
37
- },
38
- {
39
- icon: 'images',
40
- menu: 'images',
41
- href: '/details/image',
42
- label: 'Images',
43
- },
44
- {
45
- icon: 'donate',
46
- menu: 'donate',
47
- href: '/donate/',
48
- label: 'Donate',
49
- followable: true,
50
- },
51
- {
52
- icon: 'ellipses',
53
- menu: 'more',
54
- href: '/about/',
55
- label: 'More',
56
- },
57
- ];
58
-
59
- class MediaMenu extends LitElement {
60
- static get styles() {
61
- return mediaMenuCSS;
62
- }
63
-
64
- static get properties() {
65
- return {
66
- baseHost: { type: String },
67
- config: { type: Object },
68
- openMenu: { type: String },
69
- selectedMenuOption: { type: String },
70
- };
71
- }
72
-
73
- constructor() {
74
- super();
75
- this.config = {};
76
- this.openMenu = '';
77
- this.selectedMenuOption = '';
78
- }
79
-
80
- get mediaMenuOptionsTemplate() {
81
- const buttons = menuSelection.map(({
82
- icon,
83
- menu,
84
- label,
85
- href,
86
- followable,
87
- }) => {
88
- const selected = this.selectedMenuOption === menu;
89
- return html`
90
- <media-button
91
- .config=${this.config}
92
- .icon=${icon}
93
- .href=${formatUrl(href, this.baseHost)}
94
- .followable=${followable}
95
- .label=${label}
96
- .mediatype=${menu}
97
- .openMenu=${this.openMenu}
98
- .selected=${selected}
99
- data-mediatype="${menu}"
100
- ></media-button>
101
- `;
102
- });
103
- return buttons;
104
- }
105
-
106
- get menuOpened() {
107
- return this.openMenu === 'media';
108
- }
109
-
110
- get menuClass() {
111
- return this.menuOpened ? 'open' : 'closed';
112
- }
113
-
114
- render() {
115
- return html`
116
- <div class="media-menu-container ${this.menuClass}">
117
- <div class="overflow-clip">
118
- <nav
119
- class="media-menu-inner"
120
- aria-hidden="${!this.menuOpened}"
121
- aria-expanded="${this.menuOpened}"
122
- >
123
- <div class="menu-group">
124
- ${this.mediaMenuOptionsTemplate}
125
- </div>
126
- </nav>
127
- </div>
128
- </div>
129
- `;
130
- }
131
- }
132
-
133
- customElements.define('media-menu', MediaMenu);
1
+ import { LitElement, html } from 'https://offshoot.prod.archive.org/lit.js';
2
+
3
+ import './media-button.js';
4
+ import mediaMenuCSS from './styles/media-menu.js';
5
+ import formatUrl from './lib/formatUrl.js';
6
+
7
+ const menuSelection = [
8
+ {
9
+ icon: 'web',
10
+ menu: 'web',
11
+ href: '/web/',
12
+ label: 'Wayback Machine',
13
+ },
14
+ {
15
+ icon: 'texts',
16
+ menu: 'texts',
17
+ href: '/details/texts',
18
+ label: 'Books',
19
+ },
20
+ {
21
+ icon: 'video',
22
+ menu: 'video',
23
+ href: '/details/movies',
24
+ label: 'Video',
25
+ },
26
+ {
27
+ icon: 'audio',
28
+ menu: 'audio',
29
+ href: '/details/audio',
30
+ label: 'Audio',
31
+ },
32
+ {
33
+ icon: 'software',
34
+ menu: 'software',
35
+ href: '/details/software',
36
+ label: 'Software',
37
+ },
38
+ {
39
+ icon: 'images',
40
+ menu: 'images',
41
+ href: '/details/image',
42
+ label: 'Images',
43
+ },
44
+ {
45
+ icon: 'donate',
46
+ menu: 'donate',
47
+ href: '/donate/',
48
+ label: 'Donate',
49
+ followable: true,
50
+ },
51
+ {
52
+ icon: 'ellipses',
53
+ menu: 'more',
54
+ href: '/about/',
55
+ label: 'More',
56
+ },
57
+ ];
58
+
59
+ class MediaMenu extends LitElement {
60
+ static get styles() {
61
+ return mediaMenuCSS;
62
+ }
63
+
64
+ static get properties() {
65
+ return {
66
+ baseHost: { type: String },
67
+ config: { type: Object },
68
+ openMenu: { type: String },
69
+ selectedMenuOption: { type: String },
70
+ };
71
+ }
72
+
73
+ constructor() {
74
+ super();
75
+ this.config = {};
76
+ this.openMenu = '';
77
+ this.selectedMenuOption = '';
78
+ }
79
+
80
+ get mediaMenuOptionsTemplate() {
81
+ const buttons = menuSelection.map(({
82
+ icon,
83
+ menu,
84
+ label,
85
+ href,
86
+ followable,
87
+ }) => {
88
+ const selected = this.selectedMenuOption === menu;
89
+ return html`
90
+ <media-button
91
+ .config=${this.config}
92
+ .icon=${icon}
93
+ .href=${formatUrl(href, this.baseHost)}
94
+ .followable=${followable}
95
+ .label=${label}
96
+ .mediatype=${menu}
97
+ .openMenu=${this.openMenu}
98
+ .selected=${selected}
99
+ data-mediatype="${menu}"
100
+ ></media-button>
101
+ `;
102
+ });
103
+ return buttons;
104
+ }
105
+
106
+ get menuOpened() {
107
+ return this.openMenu === 'media';
108
+ }
109
+
110
+ get menuClass() {
111
+ return this.menuOpened ? 'open' : 'closed';
112
+ }
113
+
114
+ render() {
115
+ return html`
116
+ <div class="media-menu-container ${this.menuClass}">
117
+ <div class="overflow-clip">
118
+ <nav
119
+ class="media-menu-inner"
120
+ aria-hidden="${!this.menuOpened}"
121
+ aria-expanded="${this.menuOpened}"
122
+ >
123
+ <div class="menu-group">
124
+ ${this.mediaMenuOptionsTemplate}
125
+ </div>
126
+ </nav>
127
+ </div>
128
+ </div>
129
+ `;
130
+ }
131
+ }
132
+
133
+ customElements.define('media-menu', MediaMenu);