From 836bbd47e2351a81b3ee5d2aa620c62eb1560ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Sat, 10 Jul 2021 16:47:52 +0200 Subject: [PATCH] retract menu on click (mobile devices) --- src/components/app-link/AppLinkElement.ts | 3 ++- src/components/menu-item/MenuItemElement.ts | 12 +++++++++++- src/core/constants/deviceWidths.ts | 3 +++ src/core/constants/index.ts | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/core/constants/deviceWidths.ts diff --git a/src/components/app-link/AppLinkElement.ts b/src/components/app-link/AppLinkElement.ts index 47e305d..ef529df 100644 --- a/src/components/app-link/AppLinkElement.ts +++ b/src/components/app-link/AppLinkElement.ts @@ -10,6 +10,7 @@ class AppLinkElement extends BaseComponentElement { @attr to: string; @attr goBack: string; @attr title: string; + @attr customAction: string; @target main: Element; constructor() { super(); @@ -61,7 +62,7 @@ class AppLinkElement extends BaseComponentElement { : html`${this.title} { + if (window.innerWidth < deviceWidths.mobile) { + (this.appMain?.mainRoot?.rootElement as MenuLayoutElement)?.retractMenu?.(); + } + }; + render = (): TemplateResult => { return html`
- ${this.title} + ${this.title} ${this.customaction ? html`
+
` : html``} diff --git a/src/core/constants/deviceWidths.ts b/src/core/constants/deviceWidths.ts new file mode 100644 index 0000000..90e04c1 --- /dev/null +++ b/src/core/constants/deviceWidths.ts @@ -0,0 +1,3 @@ +export default { + mobile: 600, +}; diff --git a/src/core/constants/index.ts b/src/core/constants/index.ts index 51297e7..7d9008a 100644 --- a/src/core/constants/index.ts +++ b/src/core/constants/index.ts @@ -1 +1,2 @@ export * from './validatorErrors'; +export { default as deviceWidths } from './deviceWidths';