@internetarchive/ia-topnav 1.4.1 → 2.0.1-alpha-webdev8396.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 (92) hide show
  1. package/.prettierignore +1 -1
  2. package/LICENSE +661 -661
  3. package/README.md +147 -147
  4. package/demo/index.html +28 -28
  5. package/dist/src/data/menus.js +0 -2
  6. package/dist/src/data/menus.js.map +1 -1
  7. package/dist/src/dropdown-menu.d.ts +3 -4
  8. package/dist/src/dropdown-menu.js +6 -13
  9. package/dist/src/dropdown-menu.js.map +1 -1
  10. package/dist/src/ia-topnav.d.ts +10 -10
  11. package/dist/src/ia-topnav.js +39 -67
  12. package/dist/src/ia-topnav.js.map +1 -1
  13. package/dist/src/login-button.d.ts +3 -0
  14. package/dist/src/login-button.js +11 -1
  15. package/dist/src/login-button.js.map +1 -1
  16. package/dist/src/models.d.ts +0 -4
  17. package/dist/src/models.js.map +1 -1
  18. package/dist/src/primary-nav.d.ts +9 -4
  19. package/dist/src/primary-nav.js +34 -36
  20. package/dist/src/primary-nav.js.map +1 -1
  21. package/dist/src/signed-out-dropdown.d.ts +1 -1
  22. package/dist/src/signed-out-dropdown.js +1 -2
  23. package/dist/src/signed-out-dropdown.js.map +1 -1
  24. package/dist/src/styles/dropdown-menu.js +1 -0
  25. package/dist/src/styles/dropdown-menu.js.map +1 -1
  26. package/dist/src/styles/ia-topnav.js +0 -5
  27. package/dist/src/styles/ia-topnav.js.map +1 -1
  28. package/dist/src/styles/primary-nav.js +50 -5
  29. package/dist/src/styles/primary-nav.js.map +1 -1
  30. package/dist/src/user-menu.d.ts +1 -2
  31. package/dist/src/user-menu.js +1 -2
  32. package/dist/src/user-menu.js.map +1 -1
  33. package/dist/test/ia-topnav.test.js +18 -60
  34. package/dist/test/ia-topnav.test.js.map +1 -1
  35. package/dist/test/primary-nav.test.js +31 -2
  36. package/dist/test/primary-nav.test.js.map +1 -1
  37. package/eslint.config.mjs +53 -53
  38. package/package.json +72 -72
  39. package/prettier.config.js +9 -9
  40. package/src/data/menus.ts +0 -2
  41. package/src/dropdown-menu.ts +6 -12
  42. package/src/ia-topnav.ts +44 -78
  43. package/src/login-button.ts +12 -1
  44. package/src/models.ts +0 -5
  45. package/src/primary-nav.ts +38 -34
  46. package/src/signed-out-dropdown.ts +1 -2
  47. package/src/styles/dropdown-menu.ts +1 -0
  48. package/src/styles/ia-topnav.ts +0 -5
  49. package/src/styles/primary-nav.ts +50 -5
  50. package/src/user-menu.ts +3 -4
  51. package/ssl/server.key +28 -28
  52. package/test/ia-topnav.test.ts +20 -81
  53. package/test/primary-nav.test.ts +43 -2
  54. package/tsconfig.json +31 -31
  55. package/web-dev-server.config.mjs +32 -32
  56. package/web-test-runner.config.mjs +41 -41
  57. package/dist/src/lib/location-handler.d.ts +0 -1
  58. package/dist/src/lib/location-handler.js +0 -5
  59. package/dist/src/lib/location-handler.js.map +0 -1
  60. package/dist/src/nav-search.d.ts +0 -19
  61. package/dist/src/nav-search.js +0 -127
  62. package/dist/src/nav-search.js.map +0 -1
  63. package/dist/src/search-menu.d.ts +0 -20
  64. package/dist/src/search-menu.js +0 -162
  65. package/dist/src/search-menu.js.map +0 -1
  66. package/dist/src/styles/nav-search.d.ts +0 -2
  67. package/dist/src/styles/nav-search.js +0 -136
  68. package/dist/src/styles/nav-search.js.map +0 -1
  69. package/dist/src/styles/search-menu.d.ts +0 -2
  70. package/dist/src/styles/search-menu.js +0 -118
  71. package/dist/src/styles/search-menu.js.map +0 -1
  72. package/dist/src/styles/signed-out-dropdown.d.ts +0 -2
  73. package/dist/src/styles/signed-out-dropdown.js +0 -31
  74. package/dist/src/styles/signed-out-dropdown.js.map +0 -1
  75. package/dist/src/styles/user-menu.d.ts +0 -2
  76. package/dist/src/styles/user-menu.js +0 -31
  77. package/dist/src/styles/user-menu.js.map +0 -1
  78. package/dist/test/nav-search.test.d.ts +0 -1
  79. package/dist/test/nav-search.test.js +0 -47
  80. package/dist/test/nav-search.test.js.map +0 -1
  81. package/dist/test/search-menu.test.d.ts +0 -1
  82. package/dist/test/search-menu.test.js +0 -42
  83. package/dist/test/search-menu.test.js.map +0 -1
  84. package/src/lib/location-handler.ts +0 -5
  85. package/src/nav-search.ts +0 -117
  86. package/src/search-menu.ts +0 -156
  87. package/src/styles/nav-search.ts +0 -136
  88. package/src/styles/search-menu.ts +0 -118
  89. package/src/styles/signed-out-dropdown.ts +0 -31
  90. package/src/styles/user-menu.ts +0 -31
  91. package/test/nav-search.test.ts +0 -70
  92. package/test/search-menu.test.ts +0 -58
package/eslint.config.mjs CHANGED
@@ -1,53 +1,53 @@
1
- import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
- import html from 'eslint-plugin-html';
3
- import tsParser from '@typescript-eslint/parser';
4
- import path from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
- import js from '@eslint/js';
7
- import { FlatCompat } from '@eslint/eslintrc';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const compat = new FlatCompat({
12
- baseDirectory: __dirname,
13
- recommendedConfig: js.configs.recommended,
14
- allConfig: js.configs.all,
15
- });
16
-
17
- export default [
18
- ...compat.extends('plugin:@typescript-eslint/recommended'),
19
- {
20
- plugins: {
21
- '@typescript-eslint': typescriptEslint,
22
- html,
23
- },
24
-
25
- languageOptions: {
26
- parser: tsParser,
27
- },
28
-
29
- settings: {
30
- 'import/resolver': {
31
- node: {
32
- extensions: ['.ts', '.tsx'],
33
- moduleDirectory: ['node_modules', 'src', 'demo'],
34
- },
35
- },
36
- },
37
-
38
- rules: {
39
- '@typescript-eslint/no-unsafe-function-type': 'warn',
40
- '@typescript-eslint/no-unused-vars': 'warn',
41
- '@typescript-eslint/no-explicit-any': 'warn',
42
- },
43
- },
44
- {
45
- ignores: ['**/*.js', '**/*.mjs'],
46
- },
47
- {
48
- files: ['**/*.test.ts'],
49
- rules: {
50
- '@typescript-eslint/no-unused-expressions': 'off',
51
- },
52
- },
53
- ];
1
+ import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
+ import html from 'eslint-plugin-html';
3
+ import tsParser from '@typescript-eslint/parser';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import js from '@eslint/js';
7
+ import { FlatCompat } from '@eslint/eslintrc';
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const compat = new FlatCompat({
12
+ baseDirectory: __dirname,
13
+ recommendedConfig: js.configs.recommended,
14
+ allConfig: js.configs.all,
15
+ });
16
+
17
+ export default [
18
+ ...compat.extends('plugin:@typescript-eslint/recommended'),
19
+ {
20
+ plugins: {
21
+ '@typescript-eslint': typescriptEslint,
22
+ html,
23
+ },
24
+
25
+ languageOptions: {
26
+ parser: tsParser,
27
+ },
28
+
29
+ settings: {
30
+ 'import/resolver': {
31
+ node: {
32
+ extensions: ['.ts', '.tsx'],
33
+ moduleDirectory: ['node_modules', 'src', 'demo'],
34
+ },
35
+ },
36
+ },
37
+
38
+ rules: {
39
+ '@typescript-eslint/no-unsafe-function-type': 'warn',
40
+ '@typescript-eslint/no-unused-vars': 'warn',
41
+ '@typescript-eslint/no-explicit-any': 'warn',
42
+ },
43
+ },
44
+ {
45
+ ignores: ['**/*.js', '**/*.mjs'],
46
+ },
47
+ {
48
+ files: ['**/*.test.ts'],
49
+ rules: {
50
+ '@typescript-eslint/no-unused-expressions': 'off',
51
+ },
52
+ },
53
+ ];
package/package.json CHANGED
@@ -1,72 +1,72 @@
1
- {
2
- "name": "@internetarchive/ia-topnav",
3
- "version": "1.4.1",
4
- "description": "Top nav for Internet Archive",
5
- "license": "AGPL-3.0-only",
6
- "main": "dist/index.js",
7
- "module": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "type": "module",
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "scripts": {
14
- "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
15
- "prepare": "rimraf dist && tsc && husky install",
16
- "build": "tsc",
17
- "lint": "eslint . && prettier \"**/*.ts\" --check",
18
- "format": "eslint . --fix && prettier \"**/*.ts\" --write",
19
- "circular": "madge --circular --extensions ts .",
20
- "test": "tsc && npm run lint && npm run circular && wtr --coverage",
21
- "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
22
- "ghpages:build": "rimraf ghpages && npm run prepare && vite build",
23
- "ghpages:publish": "npm run ghpages:prepare -e $(git branch --show-current)",
24
- "ghpages:prepare": "npm run ghpages:build && touch ghpages/.nojekyll && npm run ghpages:generate",
25
- "ghpages:generate": "gh-pages -t -d ghpages -m \"Build for $(git log --pretty=format:\"%h %an %ai %s\" -n1) [skip ci]\""
26
- },
27
- "dependencies": {
28
- "@internetarchive/ia-styles": "^1.0.0",
29
- "@internetarchive/ia-wayback-search": "^1.0.4",
30
- "lit": "^2.8.0"
31
- },
32
- "devDependencies": {
33
- "@open-wc/eslint-config": "^12.0.3",
34
- "@open-wc/testing": "^4.0.0",
35
- "@types/mocha": "^10.0.10",
36
- "@typescript-eslint/eslint-plugin": "^8.19.1",
37
- "@typescript-eslint/parser": "^8.19.1",
38
- "@web/dev-server": "^0.4.6",
39
- "@web/test-runner": "^0.20.0",
40
- "concurrently": "^9.1.2",
41
- "eslint": "^9.24.0",
42
- "eslint-config-prettier": "^10.1.1",
43
- "eslint-plugin-html": "^8.1.2",
44
- "eslint-plugin-import": "^2.31.0",
45
- "eslint-plugin-lit": "^2.0.0",
46
- "eslint-plugin-lit-a11y": "^4.1.4",
47
- "eslint-plugin-no-only-tests": "^3.3.0",
48
- "eslint-plugin-wc": "^3.0.0",
49
- "gh-pages": "^6.3.0",
50
- "husky": "^9.1.7",
51
- "madge": "^8.0.0",
52
- "prettier": "^3.4.2",
53
- "rimraf": "^6.0.1",
54
- "sinon": "^20.0.0",
55
- "ts-lit-plugin": "^2.0.2",
56
- "tslib": "^2.8.1",
57
- "typescript": "^5.7.2",
58
- "vite": "^6.0.7"
59
- },
60
- "husky": {
61
- "hooks": {
62
- "pre-commit": "lint-staged"
63
- }
64
- },
65
- "lint-staged": {
66
- "*.ts": [
67
- "eslint --fix",
68
- "prettier --write",
69
- "git add"
70
- ]
71
- }
72
- }
1
+ {
2
+ "name": "@internetarchive/ia-topnav",
3
+ "version": "2.0.1-alpha-webdev8396.0",
4
+ "description": "Top nav for Internet Archive",
5
+ "license": "AGPL-3.0-only",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "type": "module",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
15
+ "prepare": "rimraf dist && tsc && husky install",
16
+ "build": "tsc",
17
+ "lint": "eslint . && prettier \"**/*.ts\" --check",
18
+ "format": "eslint . --fix && prettier \"**/*.ts\" --write",
19
+ "circular": "madge --circular --extensions ts .",
20
+ "test": "tsc && npm run lint && npm run circular && wtr --coverage",
21
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
22
+ "ghpages:build": "rimraf ghpages && npm run prepare && vite build",
23
+ "ghpages:publish": "npm run ghpages:prepare -e $(git branch --show-current)",
24
+ "ghpages:prepare": "npm run ghpages:build && touch ghpages/.nojekyll && npm run ghpages:generate",
25
+ "ghpages:generate": "gh-pages -t -d ghpages -m \"Build for $(git log --pretty=format:\"%h %an %ai %s\" -n1) [skip ci]\""
26
+ },
27
+ "dependencies": {
28
+ "@internetarchive/ia-styles": "^1.0.0",
29
+ "@internetarchive/ia-wayback-search": "^1.0.4",
30
+ "lit": "^2.8.0"
31
+ },
32
+ "devDependencies": {
33
+ "@open-wc/eslint-config": "^12.0.3",
34
+ "@open-wc/testing": "^4.0.0",
35
+ "@types/mocha": "^10.0.10",
36
+ "@typescript-eslint/eslint-plugin": "^8.19.1",
37
+ "@typescript-eslint/parser": "^8.19.1",
38
+ "@web/dev-server": "^0.4.6",
39
+ "@web/test-runner": "^0.20.0",
40
+ "concurrently": "^9.1.2",
41
+ "eslint": "^9.24.0",
42
+ "eslint-config-prettier": "^10.1.1",
43
+ "eslint-plugin-html": "^8.1.2",
44
+ "eslint-plugin-import": "^2.31.0",
45
+ "eslint-plugin-lit": "^2.0.0",
46
+ "eslint-plugin-lit-a11y": "^4.1.4",
47
+ "eslint-plugin-no-only-tests": "^3.3.0",
48
+ "eslint-plugin-wc": "^3.0.0",
49
+ "gh-pages": "^6.3.0",
50
+ "husky": "^9.1.7",
51
+ "madge": "^8.0.0",
52
+ "prettier": "^3.4.2",
53
+ "rimraf": "^6.0.1",
54
+ "sinon": "^20.0.0",
55
+ "ts-lit-plugin": "^2.0.2",
56
+ "tslib": "^2.8.1",
57
+ "typescript": "^5.7.2",
58
+ "vite": "^6.0.7"
59
+ },
60
+ "husky": {
61
+ "hooks": {
62
+ "pre-commit": "lint-staged"
63
+ }
64
+ },
65
+ "lint-staged": {
66
+ "*.ts": [
67
+ "eslint --fix",
68
+ "prettier --write",
69
+ "git add"
70
+ ]
71
+ }
72
+ }
@@ -1,9 +1,9 @@
1
- /**
2
- * @see https://prettier.io/docs/configuration
3
- * @type {import("prettier").Config}
4
- */
5
- const config = {
6
- singleQuote: true,
7
- };
8
-
9
- export default config;
1
+ /**
2
+ * @see https://prettier.io/docs/configuration
3
+ * @type {import("prettier").Config}
4
+ */
5
+ const config = {
6
+ singleQuote: true,
7
+ };
8
+
9
+ export default config;
package/src/data/menus.ts CHANGED
@@ -5,8 +5,6 @@ import { IATopNavConfig, IATopNavMenuConfig } from '../models';
5
5
  export const defaultTopNavConfig: IATopNavConfig = {
6
6
  // Google Analytics event category
7
7
  eventCategory: 'TopNav',
8
- // Array of strings representing the values of options that should be hidden from search options
9
- hiddenSearchOptions: [],
10
8
  // Default value, if more accurate value is not passed in to `buildTopNavMenus()`
11
9
  waybackPagesArchived: '1 trillion',
12
10
  };
@@ -1,4 +1,4 @@
1
- import { CSSResult, html, nothing, PropertyValues, TemplateResult } from 'lit';
1
+ import { html, nothing, PropertyValues, TemplateResult } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
3
 
4
4
  import icons from './assets/img/icons';
@@ -14,7 +14,6 @@ import KeyboardNavigation from './lib/keyboard-navigation';
14
14
  export default class DropdownMenu extends TrackedElement {
15
15
  @property({ type: String }) baseHost = '';
16
16
  @property({ type: Object }) config: IATopNavConfig = defaultTopNavConfig;
17
- @property({ type: Boolean }) hideSearch = false;
18
17
  @property({ type: Array }) menuItems: IATopNavLink[] | IATopNavLink[][] = [];
19
18
  @property({ type: Boolean }) animated = false;
20
19
  @property({ type: Boolean }) open = false;
@@ -22,8 +21,8 @@ export default class DropdownMenu extends TrackedElement {
22
21
  private previousKeydownListener?: // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
22
  (this: HTMLElement, ev: KeyboardEvent) => any;
24
23
 
25
- static get styles(): CSSResult[] {
26
- return [dropdownMenuCSS];
24
+ static get styles() {
25
+ return dropdownMenuCSS;
27
26
  }
28
27
 
29
28
  updated(props: PropertyValues) {
@@ -104,14 +103,9 @@ export default class DropdownMenu extends TrackedElement {
104
103
  }
105
104
 
106
105
  get menuClass() {
107
- const hiddenClass = this.hideSearch ? ' search-hidden' : '';
108
- if (this.open) {
109
- return `open${hiddenClass}`;
110
- }
111
- if (this.animated) {
112
- return `closed${hiddenClass}`;
113
- }
114
- return `initial${hiddenClass}`;
106
+ if (this.open) return 'open';
107
+ if (this.animated) return 'closed';
108
+ return 'initial';
115
109
  }
116
110
 
117
111
  render() {
package/src/ia-topnav.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LitElement, PropertyValues, html, nothing } from 'lit';
2
- import { customElement, property, state } from 'lit/decorators.js';
2
+ import { customElement, property, query, state } from 'lit/decorators.js';
3
3
 
4
4
  import { buildTopNavMenus, defaultTopNavConfig } from './data/menus';
5
5
  import './desktop-subnav';
@@ -11,11 +11,10 @@ import {
11
11
  IATopNavSecondIdentitySlotMode,
12
12
  } from './models';
13
13
  import './primary-nav';
14
- import './search-menu';
14
+ import type { PrimaryNav } from './primary-nav';
15
15
  import './signed-out-dropdown';
16
16
  import iaTopNavCSS from './styles/ia-topnav';
17
17
  import './user-menu';
18
- import KeyboardNavigation from './lib/keyboard-navigation';
19
18
 
20
19
  @customElement('ia-topnav')
21
20
  export class IATopNav extends LitElement {
@@ -43,10 +42,6 @@ export class IATopNav extends LitElement {
43
42
 
44
43
  @property({ type: String }) screenName: string = '';
45
44
 
46
- @property({ type: String }) searchIn = '';
47
-
48
- @property({ type: String }) searchQuery = '';
49
-
50
45
  @property({ type: String }) selectedMenuOption = '';
51
46
 
52
47
  @property({ type: String }) username: string = '';
@@ -62,11 +57,16 @@ export class IATopNav extends LitElement {
62
57
  moveTo: string;
63
58
  };
64
59
 
60
+ @query('primary-nav') private primaryNav?: PrimaryNav;
61
+ /** Only one of user-menu or signed-out-dropdown is rendered at a time. */
62
+ @query('user-menu, signed-out-dropdown')
63
+ private accountDropdown?: HTMLElement;
64
+
65
65
  @state() private menus: IATopNavMenuConfig = buildTopNavMenus();
66
- private previousKeydownListener: // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- ((this: HTMLElement, ev: KeyboardEvent) => any) | undefined;
68
66
 
69
- private keyboardNavigation?: KeyboardNavigation;
67
+ private boundHandleKeydown = this.handleDocumentKeydown.bind(this);
68
+
69
+ private boundHandleClick = this.handleDocumentClick.bind(this);
70
70
 
71
71
  private get normalizedBaseHost() {
72
72
  return !this.localLinks ? this.baseHost : '';
@@ -86,37 +86,33 @@ export class IATopNav extends LitElement {
86
86
  ) {
87
87
  this.menuSetup();
88
88
  }
89
+ }
89
90
 
90
- if (this.openMenu === 'search') {
91
- const targetElement =
92
- this.renderRoot.querySelector('search-menu')?.shadowRoot;
93
- if (targetElement) {
94
- this.keyboardNavigation = new KeyboardNavigation(
95
- targetElement as unknown as HTMLElement,
96
- this.openMenu,
97
- );
91
+ connectedCallback() {
92
+ super.connectedCallback();
93
+ document.addEventListener('keydown', this.boundHandleKeydown);
94
+ document.addEventListener('click', this.boundHandleClick);
95
+ }
98
96
 
99
- if (this.previousKeydownListener) {
100
- this.removeEventListener('keydown', this.previousKeydownListener);
101
- }
102
- this.addEventListener('keydown', this.keyboardNavigation.handleKeyDown);
103
- this.previousKeydownListener = this.keyboardNavigation.handleKeyDown;
104
- }
97
+ disconnectedCallback() {
98
+ super.disconnectedCallback();
99
+ document.removeEventListener('keydown', this.boundHandleKeydown);
100
+ document.removeEventListener('click', this.boundHandleClick);
101
+ }
102
+
103
+ private handleDocumentKeydown(e: KeyboardEvent) {
104
+ if (e.key === 'Escape') {
105
+ this.openMenu = '';
106
+ this.mediaSliderOpen = false;
105
107
  }
106
108
  }
107
109
 
108
- firstUpdated() {
109
- // close open menu on `esc` click
110
- document.addEventListener(
111
- 'keydown',
112
- (e) => {
113
- if (e.key === 'Escape') {
114
- this.openMenu = '';
115
- this.mediaSliderOpen = false;
116
- }
117
- },
118
- false,
119
- );
110
+ private handleDocumentClick(e: MouseEvent) {
111
+ if (!this.openMenu) return;
112
+ const path = e.composedPath();
113
+ if (!path.includes(this)) {
114
+ this.closeMenus();
115
+ }
120
116
  }
121
117
 
122
118
  menuSetup() {
@@ -137,21 +133,14 @@ export class IATopNav extends LitElement {
137
133
  return;
138
134
  }
139
135
  this.closeMediaSlider();
140
- }
141
136
 
142
- navSearchBlurEvent(e: CustomEvent) {
143
- if (this.previousKeydownListener) {
144
- this.removeEventListener('keydown', this.previousKeydownListener);
145
- }
146
-
147
- const isUploadButton = e.detail?.isUploadButton;
148
- if (!isUploadButton) {
149
- const searchMenu = this.renderRoot.querySelector(
150
- 'search-menu',
151
- ) as HTMLElement;
152
- const elements = this.keyboardNavigation?.getFocusableElements();
153
- if (searchMenu && elements?.length) {
154
- elements[0].focus();
137
+ if (this.openMenu === 'user' || this.openMenu === 'login') {
138
+ if (this.primaryNav && this.accountDropdown) {
139
+ const right = this.primaryNav.getAccountDropdownOffset();
140
+ this.accountDropdown.style.setProperty(
141
+ '--dropdownMenuRight',
142
+ `${right}px`,
143
+ );
155
144
  }
156
145
  }
157
146
  }
@@ -170,10 +159,6 @@ export class IATopNav extends LitElement {
170
159
  this.closeMediaSlider();
171
160
  }
172
161
 
173
- searchInChanged(e: CustomEvent) {
174
- this.searchIn = e.detail.searchIn;
175
- }
176
-
177
162
  trackClick(e: CustomEvent) {
178
163
  this.dispatchEvent(
179
164
  new CustomEvent('analyticsClick', {
@@ -203,10 +188,6 @@ export class IATopNav extends LitElement {
203
188
  this.openMediaSlider();
204
189
  }
205
190
 
206
- get searchMenuOpened() {
207
- return this.openMenu === 'search';
208
- }
209
-
210
191
  get signedOutOpened() {
211
192
  return this.openMenu === 'login';
212
193
  }
@@ -215,10 +196,6 @@ export class IATopNav extends LitElement {
215
196
  return this.openMenu === 'user';
216
197
  }
217
198
 
218
- get searchMenuTabIndex() {
219
- return this.searchMenuOpened ? '' : '-1';
220
- }
221
-
222
199
  get userMenuTabIndex() {
223
200
  return this.userMenuOpened ? '' : '-1';
224
201
  }
@@ -239,7 +216,6 @@ export class IATopNav extends LitElement {
239
216
  .menuItems=${this.userMenuItems}
240
217
  ?open=${this.openMenu === 'user'}
241
218
  .username=${this.username}
242
- ?hideSearch=${this.hideSearch}
243
219
  tabindex="${this.userMenuTabIndex}"
244
220
  @menuToggled=${this.menuToggled}
245
221
  @trackClick=${this.trackClick}
@@ -255,7 +231,6 @@ export class IATopNav extends LitElement {
255
231
  .baseHost=${this.normalizedBaseHost}
256
232
  .config=${this.config}
257
233
  .open=${this.signedOutOpened}
258
- ?hideSearch=${this.hideSearch}
259
234
  tabindex="${this.signedOutTabIndex}"
260
235
  .menuItems=${this.signedOutMenuItems}
261
236
  @focusToOtherMenuItem=${(e: CustomEvent) => {
@@ -291,6 +266,10 @@ export class IATopNav extends LitElement {
291
266
  return this.secondIdentitySlotMode === 'allow';
292
267
  }
293
268
 
269
+ get searchSlot() {
270
+ return html`<slot name="search" slot="search"></slot>`;
271
+ }
272
+
294
273
  get secondLogoSlot() {
295
274
  return this.allowSecondaryIcon
296
275
  ? html`
@@ -313,8 +292,6 @@ export class IATopNav extends LitElement {
313
292
  .config=${this.config}
314
293
  .openMenu=${this.openMenu}
315
294
  .screenName=${this.screenName}
316
- .searchIn=${this.searchIn}
317
- .searchQuery=${this.searchQuery}
318
295
  .secondIdentitySlotMode=${this.secondIdentitySlotMode}
319
296
  .selectedMenuOption=${this.selectedMenuOption}
320
297
  .username=${this.username}
@@ -325,9 +302,8 @@ export class IATopNav extends LitElement {
325
302
  @trackClick=${this.trackClick}
326
303
  @trackSubmit=${this.trackSubmit}
327
304
  @menuToggled=${this.menuToggled}
328
- @navSearchBlur=${this.navSearchBlurEvent}
329
305
  >
330
- ${this.secondLogoSlot}
306
+ ${this.secondLogoSlot} ${this.searchSlot}
331
307
  </primary-nav>
332
308
  <media-slider
333
309
  .baseHost=${this.normalizedBaseHost}
@@ -341,16 +317,6 @@ export class IATopNav extends LitElement {
341
317
  ></media-slider>
342
318
  </div>
343
319
  ${this.username ? this.userMenu : this.signedOutDropdown}
344
- <search-menu
345
- .baseHost=${this.normalizedBaseHost}
346
- .config=${this.config}
347
- .openMenu=${this.openMenu}
348
- tabindex="${this.searchMenuTabIndex}"
349
- ?hideSearch=${this.hideSearch}
350
- @searchInChanged=${this.searchInChanged}
351
- @trackClick=${this.trackClick}
352
- @trackSubmit=${this.trackSubmit}
353
- ></search-menu>
354
320
  <desktop-subnav
355
321
  .baseHost=${this.normalizedBaseHost}
356
322
  .menuItems=${this.menus.more.links}
@@ -4,7 +4,7 @@ import icons from './assets/img/icons';
4
4
  import loginButtonCSS from './styles/login-button';
5
5
  import formatUrl from './lib/format-url';
6
6
  import { makeBooleanString } from './lib/make-boolean-string';
7
- import { customElement, property, state } from 'lit/decorators.js';
7
+ import { customElement, property, query, state } from 'lit/decorators.js';
8
8
  import { IATopNavConfig } from './models';
9
9
  import { defaultTopNavConfig } from './data/menus';
10
10
 
@@ -14,12 +14,23 @@ export class LoginButton extends TrackedElement {
14
14
  @property({ type: Object }) config: IATopNavConfig = defaultTopNavConfig;
15
15
  @property({ type: String }) openMenu = '';
16
16
 
17
+ @query('button.logged-out-menu') private toggleButton?: HTMLButtonElement;
18
+
17
19
  @state() private dropdownTabIndex = '';
18
20
 
19
21
  static get styles() {
20
22
  return loginButtonCSS;
21
23
  }
22
24
 
25
+ /** Distance (px) from this element's right edge to the right edge of the dropdown toggle icon. */
26
+ getDropdownToggleOffset(): number {
27
+ if (!this.toggleButton) return 0;
28
+ return (
29
+ this.getBoundingClientRect().right -
30
+ this.toggleButton.getBoundingClientRect().right
31
+ );
32
+ }
33
+
23
34
  get signupPath() {
24
35
  return formatUrl('/signup', this.baseHost);
25
36
  }
package/src/models.ts CHANGED
@@ -11,11 +11,6 @@ export interface IATopNavConfig {
11
11
  */
12
12
  waybackPagesArchived?: string;
13
13
 
14
- /**
15
- * Array of strings representing the values of options that should be hidden from search options
16
- */
17
- hiddenSearchOptions?: string[];
18
-
19
14
  /**
20
15
  * Map from dropdown item ids to any callout text that should be applied beside them
21
16
  */