@internetarchive/ia-topnav 1.1.18-a1 → 1.1.18

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 (71) hide show
  1. package/README.md +10 -20
  2. package/demo.html +41 -0
  3. package/index.d.ts +7 -7
  4. package/package.json +18 -25
  5. package/src/assets/img/hamburger.js +3 -3
  6. package/src/assets/img/ia-icon.js +2 -2
  7. package/src/assets/img/icon-audio.js +1 -1
  8. package/src/assets/img/icon-close.js +1 -1
  9. package/src/assets/img/icon-donate.js +1 -1
  10. package/src/assets/img/icon-ellipses.js +1 -1
  11. package/src/assets/img/icon-ia-logo.js +1 -1
  12. package/src/assets/img/icon-images.js +1 -1
  13. package/src/assets/img/icon-search.js +1 -1
  14. package/src/assets/img/icon-software.js +1 -1
  15. package/src/assets/img/icon-texts.js +1 -1
  16. package/src/assets/img/icon-upload.js +1 -1
  17. package/src/assets/img/icon-user.js +1 -1
  18. package/src/assets/img/icon-video.js +1 -1
  19. package/src/assets/img/icon-web.js +1 -1
  20. package/src/assets/img/icon.js +1 -1
  21. package/src/assets/img/icons.js +13 -13
  22. package/src/assets/img/user.js +2 -2
  23. package/src/assets/img/wordmark-stacked.js +1 -1
  24. package/src/data/menus.js +589 -506
  25. package/src/desktop-subnav.js +5 -5
  26. package/src/dropdown-menu.js +4 -4
  27. package/src/ia-topnav.js +35 -12
  28. package/src/login-button.js +5 -5
  29. package/src/media-button.js +5 -5
  30. package/src/media-menu.js +5 -5
  31. package/src/media-slider.js +48 -8
  32. package/src/media-subnav.js +28 -23
  33. package/src/more-slider.js +5 -5
  34. package/src/nav-search.js +5 -5
  35. package/src/primary-nav.js +12 -12
  36. package/src/save-page-form.js +3 -3
  37. package/src/search-menu.js +5 -5
  38. package/src/signed-out-dropdown.js +2 -2
  39. package/src/styles/base.js +1 -1
  40. package/src/styles/desktop-subnav.js +1 -1
  41. package/src/styles/dropdown-menu.js +1 -1
  42. package/src/styles/ia-topnav.js +5 -1
  43. package/src/styles/login-button.js +1 -1
  44. package/src/styles/media-button.js +1 -1
  45. package/src/styles/media-menu.js +5 -5
  46. package/src/styles/media-slider.js +5 -1
  47. package/src/styles/media-subnav.js +2 -2
  48. package/src/styles/more-slider.js +1 -1
  49. package/src/styles/nav-search.js +1 -1
  50. package/src/styles/primary-nav.js +1 -1
  51. package/src/styles/save-page-form.js +1 -1
  52. package/src/styles/search-menu.js +4 -4
  53. package/src/styles/signed-out-dropdown.js +1 -1
  54. package/src/styles/user-menu.js +1 -1
  55. package/src/styles/wayback-search.js +1 -1
  56. package/src/styles/wayback-slider.js +2 -2
  57. package/src/tracked-element.js +1 -1
  58. package/src/user-menu.js +3 -3
  59. package/src/wayback-search.js +7 -1
  60. package/src/wayback-slider.js +8 -8
  61. package/test/data/menus.test.js +2 -1
  62. package/test/ia-topnav.test.js +17 -27
  63. package/test/media-slider.test.js +24 -8
  64. package/test/more-slider.test.js +3 -2
  65. package/test/search-menu.test.js +1 -1
  66. package/test/user-menu.test.js +11 -26
  67. package/base64_encoded_menus.html +0 -72
  68. package/index.html +0 -251
  69. package/karma.bs.config.js +0 -16
  70. package/karma.conf.js +0 -25
  71. package/src/data/petabox_signedout_menus.js +0 -514
package/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # \<ia-topnav>
2
-
3
- The top navigation menu for archive.org
1
+ # The top navigation menu component for archive.org
4
2
 
5
3
  ## Installation
6
4
 
@@ -10,6 +8,11 @@ yarn add @internetarchive/ia-topnav
10
8
 
11
9
  ## Usage
12
10
 
11
+ @see [demo.html](demo.html) for the simplest example with all the defaults
12
+
13
+ It shows a dynamic change of the logged in user name -- and how it will re-paint the menus.
14
+
15
+
13
16
  ```js
14
17
  // ia-top-nav.js
15
18
  import IATopNav from '@internetarchive/ia-topnav';
@@ -83,36 +86,23 @@ export default IATopNav;
83
86
  `mediaBaseHost` is the base host for media like the profile picture if it's not relative
84
87
 
85
88
  NOTE:
86
- When passing in the `config`, `menus`, and `searchQuery` attributes from HTML, not LitElement bindings,
89
+ When passing in the `searchQuery` attribute from HTML, not LitElement bindings,
87
90
  you must base64 the value to account for any special characters.
88
91
  -->
89
92
  <ia-topnav
90
93
  baseHost="https://archive.org"
91
94
  mediaBaseHost="https://archive.org"
92
- config=${config}
93
- menus=${menus}
94
95
  hideSearch=${true}
95
96
  username="shaneriley"
96
- screenName="really_long_screen_name_that_may_be_truncated_on_mobile"
97
+ screenName="long_screen_name_that_gets_truncated"
97
98
  searchQuery="J2Zvbyc="
98
99
  ></ia-topnav>
99
100
  ```
100
101
 
101
- **Config object:**
102
-
103
- ```js
104
- {
105
- eventCategory: "MobileTopNav", // Google Analytics event category
106
- waybackPagesArchived: "425 billion", // Copy to display for number of pages archived at the top of the Wayback search form
107
- uploadURL: 'https://archive.org/create', // Full URL to upload path. Differs on Petabox if user is admin && in category page
108
- hiddenSearchOptions: [], // Array of strings representing the values of options that should be hidden from search options
109
- }
110
- ```
111
102
 
112
- *Menus object:**
103
+ **Menus object:**
113
104
 
114
- Please see [src/data/menus.js](the example menu objects) for an example of a
115
- valid `menus` property.
105
+ Please see [src/data/menus.js](the menu objects) for our valid `menus` property.
116
106
 
117
107
  # Development
118
108
 
package/demo.html ADDED
@@ -0,0 +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>
package/index.d.ts CHANGED
@@ -13,13 +13,6 @@ export interface IATopNavConfig {
13
13
  */
14
14
  waybackPagesArchived: string;
15
15
 
16
- /**
17
- * Full URL to upload path. Differs on Petabox if user is admin && in category page
18
- *
19
- * ie. 'https://archive.org/create'
20
- */
21
- uploadURL: string;
22
-
23
16
  /**
24
17
  * Array of strings representing the values of options that should be hidden from search options
25
18
  */
@@ -87,6 +80,7 @@ export interface IATopNavMenuConfig {
87
80
  export type IATopNavSecondIdentitySlotMode = 'allow' | '';
88
81
 
89
82
  export declare class IATopNav extends LitElement {
83
+ localLinks?: boolean;
90
84
  baseHost?: string;
91
85
  config?: IATopNavConfig;
92
86
  hideSearch?: boolean;
@@ -102,4 +96,10 @@ export declare class IATopNav extends LitElement {
102
96
  userProfileImagePath?: string;
103
97
  userProfileLastModified?: string;
104
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
105
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-topnav",
3
- "version": "1.1.18-a1",
3
+ "version": "1.1.18",
4
4
  "description": "Top nav for Internet Archive",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
8
8
  "types": "index.d.ts",
9
+ "type": "module",
9
10
  "publishConfig": {
10
11
  "access": "public"
11
12
  },
@@ -17,38 +18,30 @@
17
18
  "format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore",
18
19
  "lint": "npm run lint:eslint",
19
20
  "format": "npm run format:eslint && npm run format:prettier",
20
- "test": "karma start --coverage",
21
- "test:watch": "karma start --auto-watch=true --single-run=false",
22
- "test:update-snapshots": "karma start --update-snapshots",
23
- "test:prune-snapshots": "karma start --prune-snapshots",
24
- "test:compatibility": "karma start --compatibility all --coverage",
25
- "test:compatibility:watch": "karma start --compatibility all --auto-watch=true --single-run=false",
26
- "test:bs": "karma start karma.bs.config.js --compatibility all --coverage",
21
+ "test": "ulimit -v unlimited; web-test-runner 'test/**/*.test.js' --node-resolve --coverage --puppeteer",
27
22
  "site:build": "npm run storybook:build",
28
23
  "storybook": "start-storybook -p 9001",
29
24
  "storybook:build": "build-storybook -o _site -s storybook-static"
30
25
  },
31
26
  "dependencies": {
32
- "@internetarchive/ia-wayback-search": "^0.2.2",
33
- "lit": "^2.2.7"
27
+ "@internetarchive/ia-wayback-search": "^0.2.3"
34
28
  },
35
29
  "devDependencies": {
36
- "@open-wc/demoing-storybook": "^0.3.0",
37
- "@open-wc/eslint-config": "^1.0.0",
38
- "@open-wc/polyfills-loader": "^0.2.1",
39
- "@open-wc/prettier-config": "^0.1.10",
40
- "@open-wc/testing": "^2.0.0",
41
- "@open-wc/testing-karma": "^3.0.0",
42
- "@open-wc/testing-karma-bs": "^1.0.0",
43
- "@storybook/react": "^5.1.11",
44
- "es-dev-server": "^1.42.0",
45
- "eslint": "^6.1.0",
46
- "eslint-plugin-lit": "^0.5.0",
30
+ "@open-wc/demoing-storybook": "^2.4.7",
31
+ "@open-wc/eslint-config": "^8.0.2",
32
+ "@open-wc/polyfills-loader": "^0.3.3",
33
+ "@open-wc/prettier-config": "^1.1.0",
34
+ "@open-wc/testing": "^3.1.6",
35
+ "@storybook/react": "^6.5.12",
36
+ "@web/test-runner": "^0.14.0",
37
+ "@web/test-runner-puppeteer": "^0.10.5",
38
+ "es-dev-server": "^2.1.0",
39
+ "eslint": "^8.24.0",
40
+ "eslint-plugin-lit": "^1.6.1",
47
41
  "gulp": "^4.0.2",
48
- "husky": "^4.2.3",
49
- "lint-staged": "^8.0.0",
50
- "sinon": "^9.0.0",
51
- "webpack-merge": "^4.1.5"
42
+ "husky": "^8.0.1",
43
+ "lint-staged": "^13.0.3",
44
+ "sinon": "^14.0.1"
52
45
  },
53
46
  "husky": {
54
47
  "hooks": {
@@ -1,6 +1,6 @@
1
- import { html, css } from 'lit';
2
- import Icon from './icon';
3
- import icons from './icons';
1
+ import { html, css } from 'https://offshoot.ux.archive.org/lit.js';
2
+ import Icon from './icon.js';
3
+ import icons from './icons.js';
4
4
 
5
5
  class HamBurger extends Icon {
6
6
  static get styles() {
@@ -1,5 +1,5 @@
1
- import { LitElement, html } from 'lit';
2
- import './icons';
1
+ import { LitElement, html } from 'https://offshoot.ux.archive.org/lit.js';
2
+ import './icons.js';
3
3
 
4
4
  class IAIcon extends LitElement {
5
5
  constructor() {
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default html`
4
4
  <svg
@@ -1,4 +1,4 @@
1
- import { LitElement } from 'lit';
1
+ import { LitElement } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  class Icon extends LitElement {
4
4
  constructor() {
@@ -1,16 +1,16 @@
1
- import audio from './icon-audio';
2
- import close from './icon-close';
3
- import donate from './icon-donate';
4
- import ellipses from './icon-ellipses';
5
- import iaLogo from './icon-ia-logo';
6
- import images from './icon-images';
7
- import search from './icon-search';
8
- import software from './icon-software';
9
- import texts from './icon-texts';
10
- import upload from './icon-upload';
11
- import user from './icon-user';
12
- import video from './icon-video';
13
- import web from './icon-web';
1
+ import audio from './icon-audio.js';
2
+ import close from './icon-close.js';
3
+ import donate from './icon-donate.js';
4
+ import ellipses from './icon-ellipses.js';
5
+ import iaLogo from './icon-ia-logo.js';
6
+ import images from './icon-images.js';
7
+ import search from './icon-search.js';
8
+ import software from './icon-software.js';
9
+ import texts from './icon-texts.js';
10
+ import upload from './icon-upload.js';
11
+ import user from './icon-user.js';
12
+ import video from './icon-video.js';
13
+ import web from './icon-web.js';
14
14
 
15
15
  export default {
16
16
  audio,
@@ -1,5 +1,5 @@
1
- import { html, css } from 'lit';
2
- import Icon from './icon';
1
+ import { html, css } from 'https://offshoot.ux.archive.org/lit.js';
2
+ import Icon from './icon.js';
3
3
 
4
4
  class User extends Icon {
5
5
  static get styles() {
@@ -1,4 +1,4 @@
1
- import { svg } from 'lit';
1
+ import { svg } from 'https://offshoot.ux.archive.org/lit.js';
2
2
 
3
3
  export default svg`
4
4
  <svg class="ia-wordmark stacked" height="30" viewBox="0 0 95 30" width="95" xmlns="http://www.w3.org/2000/svg">