@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
@@ -1,136 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- export default css`
4
- input[type='text'] {
5
- color: var(--grey13);
6
- }
7
-
8
- input:focus {
9
- outline: none;
10
- }
11
- button {
12
- background: none;
13
- color: inherit;
14
- border: none;
15
- font: inherit;
16
- cursor: pointer;
17
- }
18
- button:focus {
19
- outline: none;
20
- }
21
- .search {
22
- padding-top: 0;
23
- margin-right: 0.5rem;
24
- }
25
- .search svg {
26
- position: relative;
27
- fill: var(--activeSearchColor);
28
- }
29
- .search-activated {
30
- display: -webkit-box;
31
- display: -ms-flexbox;
32
- display: flex;
33
- position: absolute;
34
- top: 0;
35
- right: 4rem;
36
- bottom: 0;
37
- left: 4rem;
38
- z-index: 3;
39
- padding: 0.5rem 0.2rem;
40
- border-radius: 1rem 1rem 0 0;
41
- background: var(--searchActiveBg);
42
- }
43
- .search-inactive {
44
- display: none;
45
- }
46
- .search-activated .highlight,
47
- .search-activated .search {
48
- background: var(--searchActiveInputBg);
49
- border-radius: 0.5rem;
50
- }
51
- .search-activated .highlight {
52
- display: -webkit-box;
53
- display: -ms-flexbox;
54
- display: flex;
55
- width: 100%;
56
- margin: 0 0.5rem;
57
- }
58
- .search-activated .search {
59
- height: 100%;
60
- padding: 0;
61
- margin-right: 0;
62
- -ms-flex-item-align: center;
63
- -ms-grid-row-align: center;
64
- align-self: center;
65
- }
66
- .search-activated .search svg {
67
- height: 3rem;
68
- width: 3rem;
69
- }
70
- .search-activated .search-field {
71
- width: 100%;
72
- height: 100%;
73
- box-sizing: border-box;
74
- padding-left: 1rem;
75
- border-radius: 0.5rem;
76
- border: none;
77
- font-size: 1.6rem;
78
- text-align: center;
79
- }
80
- .search-activated .search-field:focus {
81
- outline: none;
82
- }
83
- @keyframes fade-in {
84
- 0% {
85
- opacity: 0;
86
- }
87
- 100% {
88
- opacity: 1;
89
- }
90
- }
91
- .fade-in {
92
- animation: fade-in 0.2s forwards;
93
- }
94
-
95
- @media (min-width: 890px) {
96
- .search svg {
97
- display: inline;
98
- width: 2.8rem;
99
- height: 2.8rem;
100
- vertical-align: -14px;
101
- }
102
- .search path {
103
- fill: var(--desktopSearchIconFill);
104
- }
105
-
106
- .search-inactive,
107
- .search-activated {
108
- display: block;
109
- position: static;
110
- padding: 1.1rem 0.2rem;
111
- background: transparent;
112
- }
113
-
114
- .search-activated .highlight {
115
- width: 13rem;
116
- height: 2.8rem;
117
- -webkit-box-orient: horizontal;
118
- -webkit-box-direction: reverse;
119
- -ms-flex-direction: row-reverse;
120
- flex-direction: row-reverse;
121
- }
122
-
123
- .search-activated .search-field {
124
- width: calc(100% - 28px);
125
- height: 100%;
126
- padding-left: 0;
127
- font-size: 1.4rem;
128
- text-align: left;
129
- }
130
-
131
- .search-activated .search svg {
132
- width: 2.8rem;
133
- height: 2.8rem;
134
- }
135
- }
136
- `;
@@ -1,118 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- export default css`
4
- .menu-wrapper {
5
- position: relative;
6
- }
7
-
8
- button:focus,
9
- input:focus {
10
- outline-color: var(--linkColor);
11
- outline-width: 0.16rem;
12
- outline-style: auto;
13
- outline-offset: 2px !important;
14
- }
15
- .search-menu-inner {
16
- position: absolute;
17
- right: 0;
18
- left: 0;
19
- z-index: 4;
20
- padding: 0 4.5rem;
21
- font-size: 1.6rem;
22
- background-color: var(--searchMenuBg);
23
- }
24
- .tx-slide {
25
- overflow: hidden;
26
- transition-property: top;
27
- transition-duration: 0.2s;
28
- transition-timing-function: ease;
29
- }
30
- .initial,
31
- .closed {
32
- top: var(--topOffset, -1500px);
33
- }
34
- .closed {
35
- transition-duration: 0.2s;
36
- }
37
-
38
- label,
39
- a {
40
- padding: 1rem;
41
- display: block;
42
- }
43
-
44
- .advanced-search {
45
- text-decoration: underline;
46
- color: inherit;
47
- line-height: normal;
48
- padding: 0.5rem;
49
- margin-top: 5px;
50
- }
51
-
52
- .advanced-search:hover {
53
- text-decoration: none;
54
- }
55
-
56
- @media (min-width: 890px) {
57
- .search-menu-inner {
58
- overflow: visible;
59
- right: 2rem;
60
- left: auto;
61
- z-index: 5;
62
- padding: 1rem 2rem;
63
- transition: opacity 0.2s ease-in-out;
64
- font-size: 1.4rem;
65
- color: var(--inverseTextColor);
66
- border-radius: 2px;
67
- background: var(--primaryTextColor);
68
- box-shadow: 0 1px 2px 1px rgba(0, 0, 0, 0.15);
69
- }
70
-
71
- .search-menu-inner:after {
72
- position: absolute;
73
- right: 7px;
74
- top: -7px;
75
- width: 12px;
76
- height: 7px;
77
- box-sizing: border-box;
78
- color: #fff;
79
- content: '';
80
- border-bottom: 7px solid currentColor;
81
- border-left: 6px solid transparent;
82
- border-right: 6px solid transparent;
83
- }
84
-
85
- .advanced-search {
86
- text-decoration: none;
87
- color: var(--linkColor);
88
- }
89
-
90
- .advanced-search:hover {
91
- text-decoration: underline;
92
- }
93
-
94
- .initial,
95
- .closed {
96
- opacity: 0;
97
- transition-duration: 0.2s;
98
- }
99
-
100
- .open {
101
- opacity: 1;
102
- }
103
-
104
- label {
105
- padding: 0;
106
- font-weight: normal;
107
- margin: 0;
108
- }
109
-
110
- label + label {
111
- padding-top: 7px;
112
- }
113
-
114
- a {
115
- padding: 1rem 0 0 0;
116
- }
117
- }
118
- `;
@@ -1,31 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- export default css`
4
- @media (min-width: 890px) {
5
- .initial,
6
- .closed,
7
- .open {
8
- right: 33.5rem;
9
- }
10
-
11
- .search-hidden.initial,
12
- .search-hidden.closed,
13
- .search-hidden.open {
14
- right: 18.5rem;
15
- }
16
- }
17
-
18
- @media (min-width: 990px) {
19
- .initial,
20
- .closed,
21
- .open {
22
- right: 40rem;
23
- }
24
-
25
- .search-hidden.initial,
26
- .search-hidden.closed,
27
- .search-hidden.open {
28
- right: 26rem;
29
- }
30
- }
31
- `;
@@ -1,31 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- export default css`
4
- @media (min-width: 890px) {
5
- .initial,
6
- .closed,
7
- .open {
8
- right: 22.4rem;
9
- }
10
-
11
- .search-hidden.initial,
12
- .search-hidden.closed,
13
- .search-hidden.open {
14
- right: 5.8rem;
15
- }
16
- }
17
-
18
- @media (min-width: 990px) {
19
- .initial,
20
- .closed,
21
- .open {
22
- right: 27.2rem;
23
- }
24
-
25
- .search-hidden.initial,
26
- .search-hidden.closed,
27
- .search-hidden.open {
28
- right: 12rem;
29
- }
30
- }
31
- `;
@@ -1,70 +0,0 @@
1
- import { html, fixture, expect } from '@open-wc/testing';
2
- import sinon from 'sinon';
3
-
4
- import '../src/nav-search';
5
- import { NavSearch } from '../src/nav-search';
6
-
7
- const component = html`<nav-search></nav-search>`;
8
-
9
- describe('<nav-search>', () => {
10
- it('defaults to closed', async () => {
11
- const el = await fixture<NavSearch>(component);
12
-
13
- expect(el.open).to.be.false;
14
- });
15
-
16
- it('does not allow search form to submit if query empty', async () => {
17
- const el = await fixture<NavSearch>(component);
18
-
19
- // const result = el.search({
20
- // preventDefault: () => {},
21
- // });
22
-
23
- // expect(result).to.be.false;
24
- });
25
-
26
- it('redirects to the TV details page when search inside is TV', async () => {
27
- const query = 'bananas';
28
- const submitEvent = {
29
- type: 'submit',
30
- preventDefault: () => {},
31
- };
32
- const locationHandler = sinon.fake();
33
- const el = await fixture<NavSearch>(
34
- html`<nav-search .locationHandler=${locationHandler}></nav-search>`,
35
- );
36
-
37
- el.searchIn = 'TV';
38
-
39
- await el.updateComplete;
40
-
41
- // el.shadowRoot.querySelector('[name=query]').value = query;
42
- // el.search(submitEvent);
43
-
44
- // expect(locationHandler.callCount).to.equal(1);
45
- // expect(locationHandler.firstArg).to.contain(`/details/tv?q=${query}`);
46
- });
47
-
48
- it('prefills the search query when present in config', async () => {
49
- const el = await fixture<NavSearch>(
50
- html`<nav-search searchQuery="bananas"></nav-search>`,
51
- );
52
-
53
- const queryInput = el.shadowRoot?.querySelector(
54
- '[name="query"]',
55
- ) as HTMLInputElement;
56
-
57
- expect(queryInput.value).to.equal('bananas');
58
- });
59
-
60
- it('conditionally renders `sin` input based on `searchIn` truthiness', async () => {
61
- const el = await fixture<NavSearch>(component);
62
-
63
- expect(el.shadowRoot?.querySelector('[name="sin"]')).to.be.null;
64
-
65
- el.searchIn = 'TV';
66
- await el.updateComplete;
67
-
68
- expect(el.shadowRoot?.querySelector('[name="sin"]')).not.to.be.null;
69
- });
70
- });
@@ -1,58 +0,0 @@
1
- import { html, fixture, expect } from '@open-wc/testing';
2
-
3
- import '../src/search-menu';
4
- import { SearchMenu } from '../src/search-menu';
5
-
6
- const component = html`<search-menu></search-menu>`;
7
-
8
- describe('<search-menu>', () => {
9
- it('sets default properties', async () => {
10
- const el = await fixture<SearchMenu>(component);
11
-
12
- expect(el.searchMenuOpen).to.be.false;
13
- expect(el.searchMenuAnimate).to.be.false;
14
- expect(el.selectedSearchType).to.equal('');
15
- });
16
-
17
- it('sets selected search type', async () => {
18
- const el = await fixture<SearchMenu>(component);
19
- const value = 'text';
20
-
21
- const inputEvent = new InputEvent('input');
22
- Object.defineProperty(inputEvent, 'target', {
23
- value: {
24
- value,
25
- },
26
- writable: false,
27
- });
28
-
29
- el.selectSearchType(inputEvent);
30
-
31
- expect(el.selectedSearchType).to.equal(value);
32
- });
33
-
34
- it('renders with closed class if done animating', async () => {
35
- const el = await fixture<SearchMenu>(component);
36
-
37
- el.searchMenuAnimate = true;
38
- await el.updateComplete;
39
-
40
- expect(
41
- el.shadowRoot
42
- ?.querySelector('.search-menu-inner')
43
- ?.classList.contains('closed'),
44
- ).to.be.true;
45
- });
46
-
47
- it('omits rendering of an option when hiddenSearchOptions has a value', async () => {
48
- const el = await fixture<SearchMenu>(component);
49
- const hiddenSearchOptions = ['WEB', 'RADIO'];
50
-
51
- el.config = { hiddenSearchOptions };
52
- await el.updateComplete;
53
-
54
- hiddenSearchOptions.forEach((value) => {
55
- expect(el.shadowRoot?.querySelector(`[value=${value}]`)).to.equal(null);
56
- });
57
- });
58
- });