@illinois-toolkit/ilw-header-megamenu 1.0.2 → 1.1.7
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/README.md +11 -6
- package/builder/ilw-header-megamenu.json +10 -0
- package/builder/versions/ilw-header-megamenu.1.0.json +1 -1
- package/builder/versions/ilw-header-megamenu.1.1.json +66 -0
- package/dist/cdn/ilw-header-megamenu.css +1 -1
- package/dist/cdn/ilw-header-megamenu.js +333 -307
- package/dist/ilw-header-megamenu.css +1 -1
- package/dist/ilw-header-megamenu.js +129 -103
- package/package.json +6 -5
- package/src/MegaMenu.styles.css +1 -1
- package/src/MegaMenu.ts +52 -50
- package/src/MegaMenuSection.css +49 -1
- package/src/MegaMenuSection.styles.css +2 -2
- package/src/MegaMenuSection.ts +84 -28
- package/dist/MegaMenu.d.ts +0 -27
- package/dist/MegaMenu.d.ts.map +0 -1
- package/dist/MegaMenuSection.d.ts +0 -27
- package/dist/MegaMenuSection.d.ts.map +0 -1
- package/dist/ilw-header-megamenu.d.ts +0 -1
- package/dist/ilw-header-megamenu.d.ts.map +0 -1
package/src/MegaMenuSection.css
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
ilw-header-megamenu-section[linked] a[slot="link"] {
|
|
2
|
+
all: initial;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
height: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
text-indent: var(--ilw-header-megamenu-section--anchor--text-indent);
|
|
8
|
+
position: relative;
|
|
9
|
+
font: var(--ilw-header-megamenu--font);
|
|
10
|
+
background: var(--ilw-header-megamenu--link-background);
|
|
11
|
+
color: var(--ilw-header-megamenu--link-color);
|
|
12
|
+
outline: 0;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
padding: 9px 2px 6px 20px;
|
|
15
|
+
border-width: 0 0 3px 0;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
border-color: transparent;
|
|
18
|
+
border-bottom: var(--ilw-header-megamenu--link-border-bottom-highlight);
|
|
19
|
+
border-left: var(--ilw-header-megamenu--link-border-left-highlight);
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
background: var(--ilw-header-megamenu--link-background--hover);
|
|
23
|
+
border-bottom: var(--ilw-header-megamenu--link-border-bottom-highlight--hover);
|
|
24
|
+
color: var(--ilw-header-megamenu--link-color--hover);
|
|
25
|
+
text-decoration: underline;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:focus {
|
|
29
|
+
background: var(--ilw-header-megamenu--link-background--focus);
|
|
30
|
+
border-bottom: var(--ilw-header-megamenu--link-border-bottom-highlight--focus);
|
|
31
|
+
color: var(--ilw-header-megamenu--link-color--focus);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ilw-header-megamenu-section[linked][aria-current="page"] a[slot="link"] {
|
|
36
|
+
border-color: var(--il-blue);
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
border-bottom: var(--ilw-header-megamenu--link-border-bottom-highlight--hover);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:focus {
|
|
43
|
+
border-bottom: var(--ilw-header-megamenu--link-border-bottom-highlight--focus);
|
|
44
|
+
color: var(--ilw-header-megamenu--link-color--focus)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
1
49
|
ilw-header-megamenu-section {
|
|
2
50
|
|
|
3
51
|
img {
|
|
@@ -69,7 +117,7 @@ ilw-header-megamenu-section {
|
|
|
69
117
|
|
|
70
118
|
li {
|
|
71
119
|
list-style: none;
|
|
72
|
-
padding
|
|
120
|
+
padding: 0 30px;
|
|
73
121
|
|
|
74
122
|
span {
|
|
75
123
|
display: inline-block;
|
|
@@ -197,9 +197,9 @@ button[aria-expanded="true"] {
|
|
|
197
197
|
/* make distinct lists */
|
|
198
198
|
div.list-wrapper {
|
|
199
199
|
display: grid;
|
|
200
|
-
grid-template-columns: repeat(4,
|
|
201
|
-
max-width: 100vw;
|
|
200
|
+
grid-template-columns: repeat(4, 1fr);
|
|
202
201
|
overflow: hidden;
|
|
202
|
+
max-width: 100vw;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
@media (max-width: 989px) {
|
package/src/MegaMenuSection.ts
CHANGED
|
@@ -27,10 +27,24 @@ export default class MegaMenuSection extends LitElement {
|
|
|
27
27
|
})
|
|
28
28
|
mouseover = false;
|
|
29
29
|
|
|
30
|
+
@property({
|
|
31
|
+
reflect: true,
|
|
32
|
+
type: Boolean
|
|
33
|
+
})
|
|
34
|
+
linked = false;
|
|
35
|
+
|
|
30
36
|
static get styles() {
|
|
31
37
|
return unsafeCSS(styles);
|
|
32
38
|
}
|
|
33
39
|
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
this.addEventListener('keydown', this.handleWindowKeydown.bind(this));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
super.connectedCallback();
|
|
47
|
+
}
|
|
34
48
|
|
|
35
49
|
handleToggleClick(evt: Event) {
|
|
36
50
|
this.expanded = !this.expanded;
|
|
@@ -44,6 +58,26 @@ export default class MegaMenuSection extends LitElement {
|
|
|
44
58
|
this.moveToNextItem();
|
|
45
59
|
this.closeAllExceptOneSections(evt.target);
|
|
46
60
|
}
|
|
61
|
+
else if (evt.key === 'ArrowRight' || evt.key === 'ArrowLeft') {
|
|
62
|
+
if (this.isOnAnchorInLinked() && evt.key === 'ArrowRight') {
|
|
63
|
+
evt.stopPropagation();
|
|
64
|
+
evt.preventDefault();
|
|
65
|
+
this.expanded = false;
|
|
66
|
+
this.setFocus(true);
|
|
67
|
+
} else if (this.isOnButtonInLinked() && evt.key === 'ArrowLeft') {
|
|
68
|
+
evt.stopPropagation();
|
|
69
|
+
evt.preventDefault();
|
|
70
|
+
this.expanded = false;
|
|
71
|
+
this.setFocus();
|
|
72
|
+
} else if (this.isOnButtonInLinked() && evt.key === 'ArrowRight') {
|
|
73
|
+
this.expanded = false;
|
|
74
|
+
} else if (this.isOnAnchorInLinked() && evt.key === 'ArrowLeft') {
|
|
75
|
+
this.expanded = false;
|
|
76
|
+
} else {
|
|
77
|
+
this.expanded = false;
|
|
78
|
+
this.setFocus();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
47
81
|
else if (evt.key === 'ArrowUp') {
|
|
48
82
|
evt.stopPropagation();
|
|
49
83
|
evt.preventDefault();
|
|
@@ -59,18 +93,37 @@ export default class MegaMenuSection extends LitElement {
|
|
|
59
93
|
}
|
|
60
94
|
}
|
|
61
95
|
|
|
96
|
+
isEmbedded() {
|
|
97
|
+
return this.parentElement && this.parentElement.closest('ilw-header-megamenu-section') != null;
|
|
98
|
+
}
|
|
62
99
|
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
isOnAnchorInLinked() {
|
|
101
|
+
return this.linked && document.activeElement && document.activeElement.tagName === 'A';
|
|
102
|
+
}
|
|
65
103
|
|
|
66
|
-
|
|
67
|
-
|
|
104
|
+
isOnButtonInLinked() {
|
|
105
|
+
return this.linked && document.activeElement && document.activeElement.tagName === 'ILW-HEADER-MEGAMENU-SECTION';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setFocus(useButton: Boolean = false) {
|
|
109
|
+
let newNode: Element | null = null;
|
|
110
|
+
if (this.linked && !useButton) {
|
|
111
|
+
newNode = this.querySelector('a');
|
|
112
|
+
}
|
|
113
|
+
else if (this.shadowRoot) {
|
|
114
|
+
newNode = this.shadowRoot.querySelector('a');
|
|
115
|
+
if (newNode == null) {
|
|
116
|
+
newNode = this.shadowRoot.querySelector('button');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (newNode != null) {
|
|
120
|
+
(newNode as HTMLElement).focus();
|
|
121
|
+
}
|
|
68
122
|
}
|
|
69
|
-
}
|
|
70
123
|
|
|
71
124
|
|
|
72
125
|
moveToNextItem() {
|
|
73
|
-
if (!this.expanded) {
|
|
126
|
+
if (!this.expanded && !this.isEmbedded()) {
|
|
74
127
|
this.expanded = true;
|
|
75
128
|
}
|
|
76
129
|
|
|
@@ -144,18 +197,6 @@ export default class MegaMenuSection extends LitElement {
|
|
|
144
197
|
return slot.assignedNodes({ flatten: true }).length > 0;
|
|
145
198
|
}
|
|
146
199
|
|
|
147
|
-
private limitSoloListItems = (event: Event) => {
|
|
148
|
-
const slot = event.currentTarget as HTMLSlotElement;
|
|
149
|
-
const items = slot.assignedElements({ flatten: true })
|
|
150
|
-
.filter((element): element is HTMLUListElement => element instanceof HTMLUListElement)
|
|
151
|
-
.flatMap(ul => Array.from(ul.children)
|
|
152
|
-
.filter((child): child is HTMLLIElement => child instanceof HTMLLIElement));
|
|
153
|
-
|
|
154
|
-
items.slice(20).forEach(item => {
|
|
155
|
-
item.hidden = true;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
200
|
render() {
|
|
160
201
|
const actionSpan = this.querySelector('span[slot="action-left"], span[slot="action-right"]');
|
|
161
202
|
let actionId: string | null = null;
|
|
@@ -185,7 +226,7 @@ export default class MegaMenuSection extends LitElement {
|
|
|
185
226
|
let columnend = Math.floor(listitems / 5) * 5;
|
|
186
227
|
columnend = Math.min(columnend, 15);
|
|
187
228
|
lists.forEach((list, index) => {
|
|
188
|
-
const position = index
|
|
229
|
+
const position = index;
|
|
189
230
|
if (position <= columnend) {
|
|
190
231
|
list.style.borderRight = 'solid 2px var(--il-storm-85, #d5d3d3)';
|
|
191
232
|
} else {
|
|
@@ -195,21 +236,36 @@ export default class MegaMenuSection extends LitElement {
|
|
|
195
236
|
});
|
|
196
237
|
|
|
197
238
|
let isSubMenu = this.parentElement != null && this.parentElement.closest("ilw-header-megamenu-section") != null;
|
|
239
|
+
let isSolo = this.parentElement != null && this.parentElement.closest("ilw-header-megamenu-section") != null;
|
|
198
240
|
|
|
199
241
|
this.current = this.current || (this.getAttribute('aria-current') != null && (this.getAttribute('aria-current') === 'page' || this.getAttribute('aria-current') === 'true'));
|
|
242
|
+
|
|
243
|
+
var withLink = html`
|
|
244
|
+
<div class="header-link ${this.mouseover ? "highlighted" : ""} ${this.compact ? "compact" : ""} ${this.current ? "current" : ""}" @mouseover="${this.toggleMouseOver.bind(this)}" @mouseout="${this.toggleMouseOver.bind(this)}">
|
|
245
|
+
<slot name="link"></slot>
|
|
246
|
+
<button class="arrow-only" @click=${this.handleToggleClick.bind(this)} aria-expanded=${this.expanded ? 'true' : 'false'} aria-label=${this.querySelector('a[slot="link"]')?.textContent + ' submenu'} aria-controls="items">
|
|
247
|
+
${this.renderArrow()}
|
|
248
|
+
</button>
|
|
249
|
+
</div>
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
var withoutLink = html`
|
|
253
|
+
<button class="${this.current ? "current" : ""}" @click=${this.handleToggleClick.bind(this)} aria-expanded=${this.expanded ? 'true' : 'false'} aria-controls="items">
|
|
254
|
+
<div class="header">
|
|
255
|
+
<div class="label"><slot name="label"></slot> </div>
|
|
256
|
+
<div class="icon">${this.renderArrow()}</div>
|
|
257
|
+
</div>
|
|
258
|
+
</button>
|
|
259
|
+
`;
|
|
260
|
+
|
|
200
261
|
|
|
201
262
|
const isSoloList = this.classList.contains('solo-list');
|
|
202
263
|
|
|
203
264
|
const needsWrapper = !isSoloList;
|
|
204
|
-
|
|
265
|
+
|
|
205
266
|
return html`
|
|
206
|
-
<div class="${isSubMenu ? 'submenu' : 'menu'} parent" @ilw-header-megamenu-section-expanded=${this.handleNavigationSectionToggleClick}
|
|
207
|
-
|
|
208
|
-
<div class="header">
|
|
209
|
-
<div class="label"><slot name="label"></slot> </div>
|
|
210
|
-
<div class="icon">${this.renderArrow()}</div>
|
|
211
|
-
</div>
|
|
212
|
-
</button>
|
|
267
|
+
<div class="${isSubMenu ? 'submenu' : 'menu'} parent" @ilw-header-megamenu-section-expanded=${this.handleNavigationSectionToggleClick}>
|
|
268
|
+
${this.linked ? withLink : withoutLink}
|
|
213
269
|
<div id="items" class="${this.expanded ? 'expanded' : ''}">
|
|
214
270
|
${needsWrapper
|
|
215
271
|
? html`
|
|
@@ -219,7 +275,7 @@ export default class MegaMenuSection extends LitElement {
|
|
|
219
275
|
<slot name="action-right"></slot>
|
|
220
276
|
</div>
|
|
221
277
|
`
|
|
222
|
-
: html`<slot id="list-slot"
|
|
278
|
+
: html`<slot id="list-slot"></slot>`}
|
|
223
279
|
</div>
|
|
224
280
|
</div>
|
|
225
281
|
`;
|
package/dist/MegaMenu.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { LitElement, CSSResultGroup } from 'lit';
|
|
2
|
-
import { default as MegaMenuSection } from './MegaMenuSection';
|
|
3
|
-
export default class MegaMenu extends LitElement {
|
|
4
|
-
compact: boolean;
|
|
5
|
-
width: number;
|
|
6
|
-
static get styles(): CSSResultGroup;
|
|
7
|
-
constructor();
|
|
8
|
-
connectedCallback(): void;
|
|
9
|
-
disconnectedCallback(): void;
|
|
10
|
-
handleWindowClick(evt: MouseEvent): void;
|
|
11
|
-
handleWindowKeydown(evt: KeyboardEvent): void;
|
|
12
|
-
handleNavigationSectionToggleClick(evt: CustomEvent): void;
|
|
13
|
-
gotoPreviousSection(): void;
|
|
14
|
-
gotoNextSection(): void;
|
|
15
|
-
handleWindowResize(): void;
|
|
16
|
-
setCompactTrue(): void;
|
|
17
|
-
setCompactFalse(): void;
|
|
18
|
-
getSections(): NodeListOf<MegaMenuSection>;
|
|
19
|
-
closeAllExceptOneSections(target: EventTarget | null): void;
|
|
20
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
21
|
-
}
|
|
22
|
-
declare global {
|
|
23
|
-
interface HTMLElementTagNameMap {
|
|
24
|
-
"ilw-header-megamenu": MegaMenu;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=MegaMenu.d.ts.map
|
package/dist/MegaMenu.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MegaMenu.d.ts","sourceRoot":"","sources":["../src/MegaMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,cAAc,EAAE,MAAM,KAAK,CAAC;AAGlE,OAAO,gBAAgB,CAAC;AAExB,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAM5C,OAAO,UAAS;IAKhB,KAAK,SAAO;IAGZ,MAAM,KAAK,MAAM,IAAK,cAAc,CAEnC;;IASD,iBAAiB;IAOjB,oBAAoB;IAMpB,iBAAiB,CAAC,GAAG,EAAE,UAAU;IAIjC,mBAAmB,CAAC,GAAG,EAAE,aAAa;IActC,kCAAkC,CAAC,GAAG,EAAE,WAAW;IAIrD,mBAAmB;IA4BrB,eAAe;IA4BX,kBAAkB;IAUlB,cAAc;IAKd,eAAe;IAKf,WAAW;IAIX,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAMpD,MAAM;CAST;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,qBAAqB,EAAE,QAAQ,CAAC;KACnC;CACJ"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
export default class MegaMenuSection extends LitElement {
|
|
3
|
-
current: boolean;
|
|
4
|
-
compact: boolean;
|
|
5
|
-
expanded: boolean;
|
|
6
|
-
mouseover: boolean;
|
|
7
|
-
static get styles(): import('lit').CSSResult;
|
|
8
|
-
handleToggleClick(evt: Event): void;
|
|
9
|
-
handleWindowKeydown(evt: KeyboardEvent): void;
|
|
10
|
-
setFocus(): void;
|
|
11
|
-
moveToNextItem(): void;
|
|
12
|
-
moveToPreviousItem(): void;
|
|
13
|
-
renderArrow(): import('lit-html').TemplateResult<1>;
|
|
14
|
-
toggleMouseOver(): void;
|
|
15
|
-
handleNavigationSectionToggleClick(evt: CustomEvent): void;
|
|
16
|
-
getSections(): NodeListOf<MegaMenuSection>;
|
|
17
|
-
closeAllExceptOneSections(target: EventTarget | null): void;
|
|
18
|
-
private hasSlotContent;
|
|
19
|
-
private limitSoloListItems;
|
|
20
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
21
|
-
}
|
|
22
|
-
declare global {
|
|
23
|
-
interface HTMLElementTagNameMap {
|
|
24
|
-
"ilw-header-megamenu-section": MegaMenuSection;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=MegaMenuSection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MegaMenuSection.d.ts","sourceRoot":"","sources":["../src/MegaMenuSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAGlD,OAAO,uBAAuB,CAAC;AAI/B,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IAKnD,OAAO,UAAS;IAKhB,OAAO,UAAS;IAKhB,QAAQ,UAAS;IAKjB,SAAS,UAAS;IAElB,MAAM,KAAK,MAAM,4BAEhB;IAGD,iBAAiB,CAAC,GAAG,EAAE,KAAK;IAK5B,mBAAmB,CAAC,GAAG,EAAE,aAAa;IAuBvC,QAAQ;IASP,cAAc;IAyBd,kBAAkB;IAqBlB,WAAW;IAMT,eAAe;IAIf,kCAAkC,CAAC,GAAG,EAAE,WAAW;IAKrD,WAAW;IAIX,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIpD,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,kBAAkB,CAUzB;IAED,MAAM;CAoET;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,6BAA6B,EAAE,eAAe,CAAC;KAClD;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=ilw-header-megamenu.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ilw-header-megamenu.d.ts","sourceRoot":"","sources":["../src/ilw-header-megamenu.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,mBAAmB,CAAC"}
|