@internetarchive/ia-topnav 1.4.1-alpha-webdev8259.0 → 1.4.1-alpha-webdev8259.1
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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js.map +1 -1
- package/dist/src/data/menus.js.map +1 -1
- package/dist/src/dropdown-menu.js +26 -26
- package/dist/src/dropdown-menu.js.map +1 -1
- package/dist/src/ia-topnav.d.ts +2 -13
- package/dist/src/ia-topnav.js +70 -140
- package/dist/src/ia-topnav.js.map +1 -1
- package/dist/src/lib/keyboard-navigation.js.map +1 -1
- package/dist/src/login-button.js +17 -17
- package/dist/src/login-button.js.map +1 -1
- package/dist/src/media-menu.js +21 -21
- package/dist/src/media-menu.js.map +1 -1
- package/dist/src/models.d.ts +0 -1
- package/dist/src/models.js.map +1 -1
- package/dist/src/primary-nav.d.ts +6 -7
- package/dist/src/primary-nav.js +98 -142
- package/dist/src/primary-nav.js.map +1 -1
- package/dist/src/styles/login-button.js +87 -87
- package/dist/src/styles/login-button.js.map +1 -1
- package/dist/src/styles/primary-nav.js +343 -343
- package/dist/src/styles/primary-nav.js.map +1 -1
- package/dist/src/user-menu.js +13 -13
- package/dist/src/user-menu.js.map +1 -1
- package/dist/test/ia-topnav.test.js +15 -87
- package/dist/test/ia-topnav.test.js.map +1 -1
- package/dist/test/primary-nav.test.js +16 -34
- package/dist/test/primary-nav.test.js.map +1 -1
- package/index.ts +3 -4
- package/package.json +1 -1
- package/src/data/menus.ts +652 -652
- package/src/dropdown-menu.ts +132 -132
- package/src/ia-topnav.ts +301 -383
- package/src/lib/keyboard-navigation.ts +166 -166
- package/src/login-button.ts +78 -78
- package/src/media-menu.ts +143 -143
- package/src/models.ts +63 -65
- package/src/primary-nav.ts +277 -324
- package/src/styles/login-button.ts +90 -90
- package/src/styles/primary-nav.ts +346 -346
- package/src/user-menu.ts +32 -32
- package/test/ia-topnav.test.ts +282 -381
- package/test/primary-nav.test.ts +136 -163
package/test/primary-nav.test.ts
CHANGED
|
@@ -1,163 +1,136 @@
|
|
|
1
|
-
import {
|
|
2
|
-
html,
|
|
3
|
-
fixture,
|
|
4
|
-
expect,
|
|
5
|
-
fixtureCleanup,
|
|
6
|
-
elementUpdated,
|
|
7
|
-
} from '@open-wc/testing';
|
|
8
|
-
|
|
9
|
-
import '../src/primary-nav';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
expect(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const el = await fixture<PrimaryNav>(
|
|
138
|
-
component({
|
|
139
|
-
baseHost: 'archive.org',
|
|
140
|
-
username: 'boop',
|
|
141
|
-
screenName: 'somesuperlongscreenname',
|
|
142
|
-
secondIdentitySlotMode: 'allow',
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const brandingBlock = el.shadowRoot?.querySelector('div.branding');
|
|
147
|
-
expect(brandingBlock?.getAttribute('class')).to.contain(
|
|
148
|
-
'branding second-logo',
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const slot = brandingBlock?.querySelector('slot');
|
|
152
|
-
expect(slot).to.exist;
|
|
153
|
-
expect(slot?.getAttribute('name')).to.equal('opt-sec-logo');
|
|
154
|
-
|
|
155
|
-
el.secondIdentitySlotMode = '';
|
|
156
|
-
await elementUpdated(el);
|
|
157
|
-
const noSlotBrandingBlock = el.shadowRoot?.querySelector('div.branding');
|
|
158
|
-
expect(noSlotBrandingBlock?.getAttribute('class')).to.contain('branding');
|
|
159
|
-
|
|
160
|
-
const noSlot = noSlotBrandingBlock?.querySelector('slot');
|
|
161
|
-
expect(noSlot).to.not.exist;
|
|
162
|
-
});
|
|
163
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
html,
|
|
3
|
+
fixture,
|
|
4
|
+
expect,
|
|
5
|
+
fixtureCleanup,
|
|
6
|
+
elementUpdated,
|
|
7
|
+
} from '@open-wc/testing';
|
|
8
|
+
|
|
9
|
+
import '../src/primary-nav';
|
|
10
|
+
import { IATopNavConfig, IATopNavSecondIdentitySlotMode } from '../src/models';
|
|
11
|
+
import { PrimaryNav } from '../src/primary-nav';
|
|
12
|
+
|
|
13
|
+
const component = ({
|
|
14
|
+
baseHost = 'archive.org',
|
|
15
|
+
username = '',
|
|
16
|
+
screenName = '',
|
|
17
|
+
hideSearch = false,
|
|
18
|
+
config = {},
|
|
19
|
+
secondIdentitySlotMode = 'allow',
|
|
20
|
+
}: {
|
|
21
|
+
baseHost?: string;
|
|
22
|
+
username?: string;
|
|
23
|
+
screenName?: string;
|
|
24
|
+
hideSearch?: boolean;
|
|
25
|
+
config?: IATopNavConfig;
|
|
26
|
+
secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
|
|
27
|
+
}) =>
|
|
28
|
+
html` <primary-nav
|
|
29
|
+
.baseHost=${baseHost}
|
|
30
|
+
.username=${username}
|
|
31
|
+
.screenName=${screenName}
|
|
32
|
+
?hideSearch=${hideSearch}
|
|
33
|
+
.config=${config}
|
|
34
|
+
.secondIdentitySlotMode=${secondIdentitySlotMode}
|
|
35
|
+
></primary-nav>`;
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
fixtureCleanup();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('<primary-nav>', () => {
|
|
42
|
+
it('renders the login link when no username present', async () => {
|
|
43
|
+
const el = await fixture<PrimaryNav>(
|
|
44
|
+
component({
|
|
45
|
+
baseHost: 'archive.org',
|
|
46
|
+
username: '',
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(el.shadowRoot?.querySelector('login-button')).to.not.be.undefined;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('does not render search trigger or search slot if hideSearch true', async () => {
|
|
54
|
+
const el = await fixture<PrimaryNav>(
|
|
55
|
+
component({
|
|
56
|
+
baseHost: 'archive.org',
|
|
57
|
+
username: 'shaneriley',
|
|
58
|
+
screenName: 'shaneriley',
|
|
59
|
+
hideSearch: true,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(el.shadowRoot?.querySelector('.search-trigger')).to.equal(null);
|
|
64
|
+
expect(el.shadowRoot?.querySelector('.custom-search-container')).to.not
|
|
65
|
+
.exist;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders custom-search slot container', async () => {
|
|
69
|
+
const el = await fixture<PrimaryNav>(
|
|
70
|
+
component({
|
|
71
|
+
baseHost: 'archive.org',
|
|
72
|
+
username: 'testuser',
|
|
73
|
+
screenName: 'testuser',
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(el.shadowRoot?.querySelector('.custom-search-container')).to.exist;
|
|
78
|
+
|
|
79
|
+
const slot = el.shadowRoot?.querySelector<HTMLSlotElement>(
|
|
80
|
+
'slot[name="custom-search"]',
|
|
81
|
+
);
|
|
82
|
+
expect(slot).to.exist;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renders search trigger button for mobile toggle', async () => {
|
|
86
|
+
const el = await fixture<PrimaryNav>(
|
|
87
|
+
component({
|
|
88
|
+
baseHost: 'archive.org',
|
|
89
|
+
username: 'testuser',
|
|
90
|
+
screenName: 'testuser',
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(el.shadowRoot?.querySelector('.search-trigger')).to.exist;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('does not render nav-search', async () => {
|
|
98
|
+
const el = await fixture<PrimaryNav>(
|
|
99
|
+
component({
|
|
100
|
+
baseHost: 'archive.org',
|
|
101
|
+
username: 'testuser',
|
|
102
|
+
screenName: 'testuser',
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(el.shadowRoot?.querySelector('nav-search')).to.not.exist;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('opens a slot with `secondIdentitySlotMode`', async () => {
|
|
110
|
+
const el = await fixture<PrimaryNav>(
|
|
111
|
+
component({
|
|
112
|
+
baseHost: 'archive.org',
|
|
113
|
+
username: 'boop',
|
|
114
|
+
screenName: 'somesuperlongscreenname',
|
|
115
|
+
secondIdentitySlotMode: 'allow',
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const brandingBlock = el.shadowRoot?.querySelector('div.branding');
|
|
120
|
+
expect(brandingBlock?.getAttribute('class')).to.contain(
|
|
121
|
+
'branding second-logo',
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const slot = brandingBlock?.querySelector('slot');
|
|
125
|
+
expect(slot).to.exist;
|
|
126
|
+
expect(slot?.getAttribute('name')).to.equal('opt-sec-logo');
|
|
127
|
+
|
|
128
|
+
el.secondIdentitySlotMode = '';
|
|
129
|
+
await elementUpdated(el);
|
|
130
|
+
const noSlotBrandingBlock = el.shadowRoot?.querySelector('div.branding');
|
|
131
|
+
expect(noSlotBrandingBlock?.getAttribute('class')).to.contain('branding');
|
|
132
|
+
|
|
133
|
+
const noSlot = noSlotBrandingBlock?.querySelector('slot');
|
|
134
|
+
expect(noSlot).to.not.exist;
|
|
135
|
+
});
|
|
136
|
+
});
|