@internetarchive/ia-topnav 1.1.19 → 1.1.21-alpha

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 (89) hide show
  1. package/.eslintrc +16 -16
  2. package/.storybook/.babelrc +15 -15
  3. package/.storybook/addons.js +7 -7
  4. package/.storybook/config.js +11 -11
  5. package/.storybook/webpack.config.js +5 -5
  6. package/LICENSE +661 -661
  7. package/README.md +145 -145
  8. package/demo.html +41 -41
  9. package/index.d.ts +105 -105
  10. package/index.js +3 -3
  11. package/package.json +65 -65
  12. package/src/assets/img/hamburger.js +36 -36
  13. package/src/assets/img/ia-icon.js +33 -33
  14. package/src/assets/img/icon-audio.js +23 -23
  15. package/src/assets/img/icon-close.js +16 -16
  16. package/src/assets/img/icon-donate.js +15 -15
  17. package/src/assets/img/icon-ellipses.js +15 -15
  18. package/src/assets/img/icon-ia-logo.js +24 -24
  19. package/src/assets/img/icon-images.js +15 -15
  20. package/src/assets/img/icon-search.js +15 -15
  21. package/src/assets/img/icon-software.js +15 -15
  22. package/src/assets/img/icon-texts.js +15 -15
  23. package/src/assets/img/icon-upload.js +15 -15
  24. package/src/assets/img/icon-user.js +15 -15
  25. package/src/assets/img/icon-video.js +15 -15
  26. package/src/assets/img/icon-web.js +15 -15
  27. package/src/assets/img/icon.js +18 -18
  28. package/src/assets/img/icons.js +29 -29
  29. package/src/assets/img/user.js +38 -38
  30. package/src/assets/img/wordmark-stacked.js +13 -13
  31. package/src/data/menus.js +603 -603
  32. package/src/desktop-subnav.js +45 -45
  33. package/src/dropdown-menu.js +98 -98
  34. package/src/ia-topnav.js +285 -285
  35. package/src/lib/formatUrl.js +1 -1
  36. package/src/lib/location-handler.js +5 -5
  37. package/src/lib/query-handler.js +7 -7
  38. package/src/lib/toSentenceCase.js +8 -8
  39. package/src/login-button.js +79 -79
  40. package/src/media-button.js +113 -113
  41. package/src/media-menu.js +133 -133
  42. package/src/media-slider.js +104 -104
  43. package/src/media-subnav.js +112 -112
  44. package/src/more-slider.js +33 -33
  45. package/src/nav-search.js +124 -124
  46. package/src/primary-nav.js +211 -211
  47. package/src/save-page-form.js +59 -59
  48. package/src/search-menu.js +115 -115
  49. package/src/signed-out-dropdown.js +10 -10
  50. package/src/styles/base.js +48 -48
  51. package/src/styles/desktop-subnav.js +37 -37
  52. package/src/styles/dropdown-menu.js +143 -143
  53. package/src/styles/ia-topnav.js +88 -88
  54. package/src/styles/login-button.js +70 -70
  55. package/src/styles/media-button.js +153 -153
  56. package/src/styles/media-menu.js +70 -70
  57. package/src/styles/media-slider.js +81 -81
  58. package/src/styles/media-subnav.js +156 -156
  59. package/src/styles/more-slider.js +15 -15
  60. package/src/styles/nav-search.js +134 -130
  61. package/src/styles/primary-nav.js +254 -254
  62. package/src/styles/save-page-form.js +53 -52
  63. package/src/styles/search-menu.js +104 -103
  64. package/src/styles/signed-out-dropdown.js +31 -31
  65. package/src/styles/user-menu.js +31 -31
  66. package/src/styles/wayback-search.js +48 -48
  67. package/src/styles/wayback-slider.js +30 -30
  68. package/src/tracked-element.js +27 -27
  69. package/src/user-menu.js +42 -42
  70. package/src/wayback-search.js +18 -18
  71. package/src/wayback-slider.js +88 -88
  72. package/stories/topnav-element.stories.js +7 -7
  73. package/test/assets/img/hamburger.test.js +15 -15
  74. package/test/assets/img/user.test.js +15 -15
  75. package/test/data/menus.test.js +19 -19
  76. package/test/dropdown-menu.test.js +25 -25
  77. package/test/ia-icon.test.js +13 -13
  78. package/test/ia-topnav.test.js +273 -273
  79. package/test/login-button.test.js +15 -15
  80. package/test/media-button.test.js +19 -19
  81. package/test/media-menu.test.js +40 -40
  82. package/test/media-slider.test.js +57 -57
  83. package/test/more-slider.test.js +13 -13
  84. package/test/nav-search.test.js +61 -61
  85. package/test/primary-nav.test.js +82 -82
  86. package/test/save-page-form.test.js +35 -35
  87. package/test/search-menu.test.js +49 -49
  88. package/test/user-menu.test.js +33 -33
  89. package/test/wayback-slider.test.js +80 -80
@@ -1,79 +1,79 @@
1
- import { html } from 'https://offshoot.ux.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.ux.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.ux.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.ux.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.ux.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.ux.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);