@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
package/README.md CHANGED
@@ -1,145 +1,145 @@
1
- # The top navigation menu component for archive.org
2
-
3
- ## Update guide
4
- https://git.archive.org/www/offshoot/-/blob/main/guides/update-top-nav.md
5
- ## Installation
6
-
7
- ```bash
8
- yarn add @internetarchive/ia-topnav
9
- ```
10
-
11
- ## Usage
12
-
13
- @see [demo.html](demo.html) for the simplest example with all the defaults
14
-
15
- It shows a dynamic change of the logged in user name -- and how it will re-paint the menus.
16
-
17
-
18
- ```js
19
- // ia-top-nav.js
20
- import IATopNav from '@internetarchive/ia-topnav';
21
- export default IATopNav;
22
- ```
23
-
24
- ```html
25
- <!-- index.html -->
26
- <script type="module">
27
- import './ia-topnav.js';
28
- </script>
29
-
30
- <style>
31
- /* Defaults */
32
- ia-topnav {
33
- --white: #fff;
34
- --grey13: #222;
35
- --grey20: #333;
36
- --grey40: #666;
37
- --grey28: #474747;
38
- --grey60: #999;
39
- --grey66: #aaa;
40
- --grey80: #ccc;
41
- --errorYellow: #ffcd27;
42
-
43
- --linkColor: #428bca;
44
- --linkHoverColor: var(--white);
45
- --subnavLinkColor: var(--grey66);
46
- --primaryTextColor: var(--white);
47
- --inverseTextColor: var(--grey20);
48
- --lightTextColor: var(--grey60);
49
- --activeColor: var(--white);
50
- --activeButtonBg: var(--grey20);
51
- --iconFill: var(--grey60);
52
-
53
- --searchActiveBg: var(--grey20);
54
- --searchActiveInputBg: var(--white);
55
- --searchMenuBg: var(--grey20);
56
- --desktopSearchIconFill: var(--grey20);
57
-
58
- --mediaMenuBg: var(--grey13);
59
- --mediaLabelDesktopColor: var(--grey60);
60
- --activeDesktopMenuIcon: var(--grey28);
61
-
62
- --mediaSliderBg: var(--grey20);
63
- --mediaSliderDesktopBg: var(--grey28);
64
-
65
- --primaryNavBg: var(--grey13);
66
- --primaryNavBottomBorder: var(--grey20);
67
-
68
- --desktopSubnavBg: var(--grey20);
69
-
70
- --dropdownMenuBg: var(--grey20);
71
- --dropdownMenuInfoItem: var(--grey60);
72
- --dropdownMenuDivider: var(--grey40);
73
-
74
- --loginTextColor: var(--grey60);
75
-
76
- --themeFontFamily: 'Helvetica Neue', Helvetica, Arial, sans-serif;
77
- --logoWidthTablet: 263px;
78
-
79
- --savePageSubmitBg: var(--grey13);
80
- --savePageSubmitText: var(--white);
81
- --savePageInputBorder: var(--grey60);
82
- --savePageErrorText: var(--errorYellow);
83
- }
84
- </style>
85
-
86
- <!--
87
- `baseHost` is the navigation base so leave emtpy for relative links
88
- `mediaBaseHost` is the base host for media like the profile picture if it's not relative
89
-
90
- NOTE:
91
- When passing in the `searchQuery` attribute from HTML, not LitElement bindings,
92
- you must base64 the value to account for any special characters.
93
- -->
94
- <ia-topnav
95
- baseHost="https://archive.org"
96
- mediaBaseHost="https://archive.org"
97
- hideSearch=${true}
98
- username="shaneriley"
99
- screenName="long_screen_name_that_gets_truncated"
100
- searchQuery="J2Zvbyc="
101
- ></ia-topnav>
102
- ```
103
-
104
-
105
- **Menus object:**
106
-
107
- Please see [src/data/menus.js](the menu objects) for our valid `menus` property.
108
-
109
- # Development
110
-
111
- ## Prerequisite
112
-
113
- ```bash
114
- yarn install
115
- ```
116
-
117
- ## Start Development Server
118
-
119
- ```bash
120
- yarn start // start development server and typescript compiler
121
- ```
122
-
123
- ## Testing
124
-
125
- ```bash
126
- yarn test
127
- ```
128
-
129
- ## Testing via browserstack
130
-
131
- ```bash
132
- yarn test:bs
133
- ```
134
-
135
- ## Demoing using storybook
136
-
137
- ```bash
138
- yarn storybook
139
- ```
140
-
141
- ## Linting
142
-
143
- ```bash
144
- yarn lint
145
- ```
1
+ # The top navigation menu component for archive.org
2
+
3
+ ## Update guide
4
+ https://git.archive.org/www/offshoot/-/blob/main/guides/update-top-nav.md
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @internetarchive/ia-topnav
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ @see [demo.html](demo.html) for the simplest example with all the defaults
14
+
15
+ It shows a dynamic change of the logged in user name -- and how it will re-paint the menus.
16
+
17
+
18
+ ```js
19
+ // ia-top-nav.js
20
+ import IATopNav from '@internetarchive/ia-topnav';
21
+ export default IATopNav;
22
+ ```
23
+
24
+ ```html
25
+ <!-- index.html -->
26
+ <script type="module">
27
+ import './ia-topnav.js';
28
+ </script>
29
+
30
+ <style>
31
+ /* Defaults */
32
+ ia-topnav {
33
+ --white: #fff;
34
+ --grey13: #222;
35
+ --grey20: #333;
36
+ --grey40: #666;
37
+ --grey28: #474747;
38
+ --grey60: #999;
39
+ --grey66: #aaa;
40
+ --grey80: #ccc;
41
+ --errorYellow: #ffcd27;
42
+
43
+ --linkColor: #428bca;
44
+ --linkHoverColor: var(--white);
45
+ --subnavLinkColor: var(--grey66);
46
+ --primaryTextColor: var(--white);
47
+ --inverseTextColor: var(--grey20);
48
+ --lightTextColor: var(--grey60);
49
+ --activeColor: var(--white);
50
+ --activeButtonBg: var(--grey20);
51
+ --iconFill: var(--grey60);
52
+
53
+ --searchActiveBg: var(--grey20);
54
+ --searchActiveInputBg: var(--white);
55
+ --searchMenuBg: var(--grey20);
56
+ --desktopSearchIconFill: var(--grey20);
57
+
58
+ --mediaMenuBg: var(--grey13);
59
+ --mediaLabelDesktopColor: var(--grey60);
60
+ --activeDesktopMenuIcon: var(--grey28);
61
+
62
+ --mediaSliderBg: var(--grey20);
63
+ --mediaSliderDesktopBg: var(--grey28);
64
+
65
+ --primaryNavBg: var(--grey13);
66
+ --primaryNavBottomBorder: var(--grey20);
67
+
68
+ --desktopSubnavBg: var(--grey20);
69
+
70
+ --dropdownMenuBg: var(--grey20);
71
+ --dropdownMenuInfoItem: var(--grey60);
72
+ --dropdownMenuDivider: var(--grey40);
73
+
74
+ --loginTextColor: var(--grey60);
75
+
76
+ --themeFontFamily: 'Helvetica Neue', Helvetica, Arial, sans-serif;
77
+ --logoWidthTablet: 263px;
78
+
79
+ --savePageSubmitBg: var(--grey13);
80
+ --savePageSubmitText: var(--white);
81
+ --savePageInputBorder: var(--grey60);
82
+ --savePageErrorText: var(--errorYellow);
83
+ }
84
+ </style>
85
+
86
+ <!--
87
+ `baseHost` is the navigation base so leave emtpy for relative links
88
+ `mediaBaseHost` is the base host for media like the profile picture if it's not relative
89
+
90
+ NOTE:
91
+ When passing in the `searchQuery` attribute from HTML, not LitElement bindings,
92
+ you must base64 the value to account for any special characters.
93
+ -->
94
+ <ia-topnav
95
+ baseHost="https://archive.org"
96
+ mediaBaseHost="https://archive.org"
97
+ hideSearch=${true}
98
+ username="shaneriley"
99
+ screenName="long_screen_name_that_gets_truncated"
100
+ searchQuery="J2Zvbyc="
101
+ ></ia-topnav>
102
+ ```
103
+
104
+
105
+ **Menus object:**
106
+
107
+ Please see [src/data/menus.js](the menu objects) for our valid `menus` property.
108
+
109
+ # Development
110
+
111
+ ## Prerequisite
112
+
113
+ ```bash
114
+ yarn install
115
+ ```
116
+
117
+ ## Start Development Server
118
+
119
+ ```bash
120
+ yarn start // start development server and typescript compiler
121
+ ```
122
+
123
+ ## Testing
124
+
125
+ ```bash
126
+ yarn test
127
+ ```
128
+
129
+ ## Testing via browserstack
130
+
131
+ ```bash
132
+ yarn test:bs
133
+ ```
134
+
135
+ ## Demoing using storybook
136
+
137
+ ```bash
138
+ yarn storybook
139
+ ```
140
+
141
+ ## Linting
142
+
143
+ ```bash
144
+ yarn lint
145
+ ```
package/demo.html CHANGED
@@ -1,41 +1,41 @@
1
- <link rel="stylesheet" href="https://archive.org/includes/build/css/archive.min.css">
2
-
3
- <ia-topnav></ia-topnav>
4
-
5
-
6
- <center>
7
-
8
- <h1>demo</h1>
9
-
10
-
11
- <button onclick="document.querySelector('ia-topnav').setAttribute('username', 'brewster')">
12
- switch username to brewster
13
- </button>
14
- <br>
15
- <button onclick="document.querySelector('ia-topnav').removeAttribute('username')">
16
- switch to un-logged-in
17
- </button>
18
-
19
-
20
- <hr>
21
-
22
-
23
- <button onclick="document.querySelector('ia-topnav').setAttribute('localLinks', false)">
24
- switch localLinks false (change to https://archive.org)
25
- </button>
26
- <br>
27
- <button onclick="document.querySelector('ia-topnav').removeAttribute('localLinks')">
28
- switch to localLinks (default, change links to start with /)
29
- </button>
30
-
31
-
32
- <hr>
33
- <button onclick="document.querySelector('ia-topnav').setAttribute('waybackPagesArchived', 'many, MAAAANNNY')">
34
- change WB pages count
35
- </button>
36
-
37
-
38
-
39
- <script type="module" src="./src/ia-topnav.js"></script>
40
-
41
- </center>
1
+ <link rel="stylesheet" href="https://archive.org/includes/build/css/archive.min.css">
2
+
3
+ <ia-topnav></ia-topnav>
4
+
5
+
6
+ <center>
7
+
8
+ <h1>demo</h1>
9
+
10
+
11
+ <button onclick="document.querySelector('ia-topnav').setAttribute('username', 'brewster')">
12
+ switch username to brewster
13
+ </button>
14
+ <br>
15
+ <button onclick="document.querySelector('ia-topnav').removeAttribute('username')">
16
+ switch to un-logged-in
17
+ </button>
18
+
19
+
20
+ <hr>
21
+
22
+
23
+ <button onclick="document.querySelector('ia-topnav').setAttribute('localLinks', false)">
24
+ switch localLinks false (change to https://archive.org)
25
+ </button>
26
+ <br>
27
+ <button onclick="document.querySelector('ia-topnav').removeAttribute('localLinks')">
28
+ switch to localLinks (default, change links to start with /)
29
+ </button>
30
+
31
+
32
+ <hr>
33
+ <button onclick="document.querySelector('ia-topnav').setAttribute('waybackPagesArchived', 'many, MAAAANNNY')">
34
+ change WB pages count
35
+ </button>
36
+
37
+
38
+
39
+ <script type="module" src="./src/ia-topnav.js"></script>
40
+
41
+ </center>
package/index.d.ts CHANGED
@@ -1,105 +1,105 @@
1
- import { LitElement } from 'lit';
2
-
3
- export interface IATopNavConfig {
4
- /**
5
- * Google Analytics event category
6
- */
7
- eventCategory: string;
8
-
9
- /**
10
- * Copy to display for number of pages archived at the top of the Wayback search form
11
- *
12
- * ie. "425 billion"
13
- */
14
- waybackPagesArchived: string;
15
-
16
- /**
17
- * Array of strings representing the values of options that should be hidden from search options
18
- */
19
- hiddenSearchOptions: [];
20
- }
21
-
22
- export interface IATopNavLink {
23
- /**
24
- * Link title
25
- */
26
- title: string;
27
-
28
- /**
29
- * Link url
30
- */
31
- url?: string;
32
- }
33
-
34
- export interface IATopNavIconLink extends IATopNavLink {
35
- /**
36
- * Icon URL
37
- */
38
- icon: string;
39
- }
40
-
41
- export interface IATopNavAnalyticsLink extends IATopNavLink {
42
- /**
43
- * Google analytics event name
44
- */
45
- analyticsEvent: string;
46
- }
47
-
48
- export interface IATopNavExternalLink extends IATopNavLink {
49
- /**
50
- * Is the link external or not
51
- */
52
- external: boolean;
53
- }
54
-
55
- export interface IATopNavMediaMenu {
56
- heading: string;
57
- iconLinks: IATopNavIconLink[];
58
- featuredLinks: IATopNavLink[];
59
- links: IATopNavLink[];
60
- }
61
-
62
- export interface IATopNavWaybackMenuConfig {
63
- mobileAppsLinks: IATopNavExternalLink[];
64
- browserExtensionsLinks: IATopNavExternalLink[];
65
- archiveItLinks: IATopNavExternalLink[];
66
- }
67
-
68
- export interface IATopNavMenuConfig {
69
- audio: IATopNavMediaMenu;
70
- images: IATopNavMediaMenu;
71
- more: IATopNavLink[];
72
- signedOut: IATopNavAnalyticsLink[];
73
- software: IATopNavMediaMenu;
74
- texts: IATopNavMediaMenu;
75
- user: IATopNavAnalyticsLink[];
76
- video: IATopNavMediaMenu;
77
- web: IATopNavWaybackMenuConfig;
78
- }
79
-
80
- export type IATopNavSecondIdentitySlotMode = 'allow' | '';
81
-
82
- export declare class IATopNav extends LitElement {
83
- localLinks?: boolean;
84
- baseHost?: string;
85
- config?: IATopNavConfig;
86
- hideSearch?: boolean;
87
- mediaBaseHost?: string;
88
- menuSliderOpen?: boolean;
89
- openMenu?: string;
90
- screenName?: string;
91
- searchIn?: string;
92
- searchQuery?: string;
93
- secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
94
- selectedMenuOption?: string;
95
- username?: string;
96
- userProfileImagePath?: string;
97
- userProfileLastModified?: string;
98
- menus: IATopNavMenuConfig;
99
- /**
100
- * Copy to display for number of pages archived at the top of the Wayback search form
101
- *
102
- * ie. "425 billion"
103
- */
104
- waybackPagesArchived?: string;
105
- }
1
+ import { LitElement } from 'lit';
2
+
3
+ export interface IATopNavConfig {
4
+ /**
5
+ * Google Analytics event category
6
+ */
7
+ eventCategory: string;
8
+
9
+ /**
10
+ * Copy to display for number of pages archived at the top of the Wayback search form
11
+ *
12
+ * ie. "425 billion"
13
+ */
14
+ waybackPagesArchived: string;
15
+
16
+ /**
17
+ * Array of strings representing the values of options that should be hidden from search options
18
+ */
19
+ hiddenSearchOptions: [];
20
+ }
21
+
22
+ export interface IATopNavLink {
23
+ /**
24
+ * Link title
25
+ */
26
+ title: string;
27
+
28
+ /**
29
+ * Link url
30
+ */
31
+ url?: string;
32
+ }
33
+
34
+ export interface IATopNavIconLink extends IATopNavLink {
35
+ /**
36
+ * Icon URL
37
+ */
38
+ icon: string;
39
+ }
40
+
41
+ export interface IATopNavAnalyticsLink extends IATopNavLink {
42
+ /**
43
+ * Google analytics event name
44
+ */
45
+ analyticsEvent: string;
46
+ }
47
+
48
+ export interface IATopNavExternalLink extends IATopNavLink {
49
+ /**
50
+ * Is the link external or not
51
+ */
52
+ external: boolean;
53
+ }
54
+
55
+ export interface IATopNavMediaMenu {
56
+ heading: string;
57
+ iconLinks: IATopNavIconLink[];
58
+ featuredLinks: IATopNavLink[];
59
+ links: IATopNavLink[];
60
+ }
61
+
62
+ export interface IATopNavWaybackMenuConfig {
63
+ mobileAppsLinks: IATopNavExternalLink[];
64
+ browserExtensionsLinks: IATopNavExternalLink[];
65
+ archiveItLinks: IATopNavExternalLink[];
66
+ }
67
+
68
+ export interface IATopNavMenuConfig {
69
+ audio: IATopNavMediaMenu;
70
+ images: IATopNavMediaMenu;
71
+ more: IATopNavLink[];
72
+ signedOut: IATopNavAnalyticsLink[];
73
+ software: IATopNavMediaMenu;
74
+ texts: IATopNavMediaMenu;
75
+ user: IATopNavAnalyticsLink[];
76
+ video: IATopNavMediaMenu;
77
+ web: IATopNavWaybackMenuConfig;
78
+ }
79
+
80
+ export type IATopNavSecondIdentitySlotMode = 'allow' | '';
81
+
82
+ export declare class IATopNav extends LitElement {
83
+ localLinks?: boolean;
84
+ baseHost?: string;
85
+ config?: IATopNavConfig;
86
+ hideSearch?: boolean;
87
+ mediaBaseHost?: string;
88
+ menuSliderOpen?: boolean;
89
+ openMenu?: string;
90
+ screenName?: string;
91
+ searchIn?: string;
92
+ searchQuery?: string;
93
+ secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
94
+ selectedMenuOption?: string;
95
+ username?: string;
96
+ userProfileImagePath?: string;
97
+ userProfileLastModified?: string;
98
+ menus: IATopNavMenuConfig;
99
+ /**
100
+ * Copy to display for number of pages archived at the top of the Wayback search form
101
+ *
102
+ * ie. "425 billion"
103
+ */
104
+ waybackPagesArchived?: string;
105
+ }
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import IATopNav from './src/ia-topnav';
2
-
3
- export default IATopNav;
1
+ import IATopNav from './src/ia-topnav';
2
+
3
+ export default IATopNav;