Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideMininni-Fincons committed Jan 29, 2024
1 parent 567ed88 commit c348e54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 12 additions & 6 deletions src/components/menu/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ let nextId = 0;
* @event {CustomEvent<void>} didClose - Emits whenever the `sbb-menu` is closed.
*/
@customElement('sbb-menu')
export class SbbMenuElement extends NamedSlotListElement<SbbMenuButtonElement | SbbMenuLinkElement> {
export class SbbMenuElement extends NamedSlotListElement<
SbbMenuButtonElement | SbbMenuLinkElement
> {
public static override styles: CSSResultGroup = style;
public static readonly events = {
willOpen: 'willOpen',
didOpen: 'didOpen',
willClose: 'willClose',
didClose: 'didClose',
} as const;
protected override readonly listChildTagNames = ['SBB-MENU-ACTION'];
protected override readonly listChildTagNames = ['SBB-MENU-BUTTON', 'SBB-MENU-LINK'];

/**
* The element that will trigger the menu overlay.
Expand Down Expand Up @@ -173,7 +175,9 @@ export class SbbMenuElement extends NamedSlotListElement<SbbMenuButtonElement |
evt.preventDefault();

const enabledActions: Element[] = Array.from(
this.querySelectorAll<SbbMenuButtonElement | SbbMenuLinkElement>('sbb-menu-button, sbb-menu-link'),
this.querySelectorAll<SbbMenuButtonElement | SbbMenuLinkElement>(
'sbb-menu-button, sbb-menu-link',
),
).filter((el: HTMLElement) => el.tabIndex === 0 && interactivityChecker.isVisible(el));

const current = enabledActions.findIndex((e: Element) => e === evt.target);
Expand Down Expand Up @@ -228,10 +232,12 @@ export class SbbMenuElement extends NamedSlotListElement<SbbMenuButtonElement |
}

protected override checkChildren(): void {
// If all children are sbb-menu-action instances, we render them as a list.
// If all children are sbb-menu-button/menu-link instances, we render them as a list.
if (
this.children?.length &&
Array.from(this.children ?? []).every((c) => c.tagName === 'SBB-MENU-BUTTON' || c.tagName === 'SBB-MENU-LINK')
Array.from(this.children ?? []).every(
(c) => c.tagName === 'SBB-MENU-BUTTON' || c.tagName === 'SBB-MENU-LINK',
)
) {
super.checkChildren();
} else if (this.listChildren.length) {
Expand Down Expand Up @@ -375,7 +381,7 @@ export class SbbMenuElement extends NamedSlotListElement<SbbMenuButtonElement |
protected override render(): TemplateResult {
setAttribute(this, 'data-state', this._state);

// TODO: Handle case with other elements than sbb-menu-action.
// TODO: Handle case with other elements than sbb-menu-button/sbb-menu-link.
return html`
<div class="sbb-menu__container">
<div
Expand Down
6 changes: 4 additions & 2 deletions src/components/navigation/navigation-list/navigation-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import style from './navigation-list.scss?lit&inline';
* @slot label - Use this to provide a label element.
*/
@customElement('sbb-navigation-list')
export class SbbNavigationListElement extends NamedSlotListElement<SbbNavigationButtonElement | SbbNavigationLinkElement> {
export class SbbNavigationListElement extends NamedSlotListElement<
SbbNavigationButtonElement | SbbNavigationLinkElement
> {
public static override styles: CSSResultGroup = style;
protected override readonly listChildTagNames = ['SBB-NAVIGATION-ACTION'];
protected override readonly listChildTagNames = ['SBB-NAVIGATION-BUTTON', 'SBB-NAVIGATION-LINK'];

/**
* The label to be shown before the action list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import style from './navigation-marker.scss?lit&inline';
* @slot - Use the unnamed slot to add `sbb-navigation-button`/`sbb-navigation-link` elements into the `sbb-navigation-marker`.
*/
@customElement('sbb-navigation-marker')
export class SbbNavigationMarkerElement extends NamedSlotListElement<SbbNavigationButtonElement | SbbNavigationLinkElement> {
export class SbbNavigationMarkerElement extends NamedSlotListElement<
SbbNavigationButtonElement | SbbNavigationLinkElement
> {
public static override styles: CSSResultGroup = style;
protected override readonly listChildTagNames = ['SBB-NAVIGATION-ACTION'];
protected override readonly listChildTagNames = ['SBB-NAVIGATION-BUTTON', 'SBB-NAVIGATION-LINK'];

/**
* Marker size variant.
Expand Down

0 comments on commit c348e54

Please sign in to comment.