@scania/tegel
Version:
Tegel Design System
31 lines (30 loc) • 1.49 kB
JavaScript
import { h, Host } from "@stencil/core";
import inheritAriaAttributes from "../../../utils/inheritAriaAttributes";
export class TdsSideMenuCloseButton {
static handleClick() {
const hamburgerButton = document.querySelector('tds-header-hamburger');
if (hamburgerButton) {
hamburgerButton.setAttribute('aria-expanded', 'false');
}
}
render() {
// Find the closest side menu to this close button
const sideMenuEl = this.host.closest('tds-side-menu');
const sideMenuId = sideMenuEl ? sideMenuEl.id : '';
const buttonProps = Object.assign(Object.assign(Object.assign({ 'aria-label': 'Close' }, (sideMenuId && { 'aria-controls': sideMenuId })), inheritAriaAttributes(this.host)), { 'onClick': TdsSideMenuCloseButton.handleClick });
return (h(Host, { key: 'b0e953d2148179c2a4fd1ed352b9024f6939c77c' }, h("button", Object.assign({ key: 'cd5f48b31d9eb62f4327a2918351920d961c446f' }, buttonProps), h("tds-icon", { key: 'f007bf92a2ba7186006aa4dd5126820108badecf', name: "cross", size: "20px", svgTitle: "Cross" }))));
}
static get is() { return "tds-side-menu-close-button"; }
static get encapsulation() { return "shadow"; }
static get originalStyleUrls() {
return {
"$": ["side-menu-close-button.scss"]
};
}
static get styleUrls() {
return {
"$": ["side-menu-close-button.css"]
};
}
static get elementRef() { return "host"; }
}