feat(dees-mobilenavigation): update to use zindex registry and shadcn-like design
- Replace old zIndexLayers with new zIndexRegistry system - Update design to match shadcn aesthetic with clean borders and shadows - Add support for icons in menu items using Lucide icons - Improve animations with staggered item appearance - Better typography using Geist font family - Add divider support for menu item grouping - Improve hover and active states - Add custom scrollbar styling - Create comprehensive demo showcasing all features - Ensure proper cleanup in disconnectedCallback
This commit is contained in:
215
ts_web/elements/dees-mobilenavigation.demo.ts
Normal file
215
ts_web/elements/dees-mobilenavigation.demo.ts
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
import { html, css } from '@design.estate/dees-element';
|
||||||
|
import './dees-button.js';
|
||||||
|
import './dees-panel.js';
|
||||||
|
import '@design.estate/dees-wcctools/demotools';
|
||||||
|
|
||||||
|
export const demoFunc = () => html`
|
||||||
|
<dees-demowrapper>
|
||||||
|
<style>
|
||||||
|
${css`
|
||||||
|
.demo-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
padding: 24px;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.demo-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
`}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="demo-container">
|
||||||
|
<dees-panel .title=${'Mobile Navigation'} .subtitle=${'Shadcn-style slide-in navigation menu with icons'}>
|
||||||
|
<div class="demo-buttons">
|
||||||
|
<dees-button
|
||||||
|
@click=${async () => {
|
||||||
|
const { DeesMobilenavigation } = await import('./dees-mobilenavigation.js');
|
||||||
|
DeesMobilenavigation.createAndShow([
|
||||||
|
{
|
||||||
|
name: 'Dashboard',
|
||||||
|
iconName: 'lucide:layout-dashboard',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to dashboard');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Profile',
|
||||||
|
iconName: 'lucide:user',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to profile');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Messages',
|
||||||
|
iconName: 'lucide:mail',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to messages');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Settings',
|
||||||
|
iconName: 'lucide:settings',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to settings');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ divider: true } as any,
|
||||||
|
{
|
||||||
|
name: 'Help & Support',
|
||||||
|
iconName: 'lucide:help-circle',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Show help');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Sign Out',
|
||||||
|
iconName: 'lucide:log-out',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Sign out');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Open Navigation Menu
|
||||||
|
</dees-button>
|
||||||
|
|
||||||
|
<dees-button
|
||||||
|
type="secondary"
|
||||||
|
@click=${async () => {
|
||||||
|
const { DeesMobilenavigation } = await import('./dees-mobilenavigation.js');
|
||||||
|
const nav = await DeesMobilenavigation.createAndShow([
|
||||||
|
{
|
||||||
|
name: 'New Document',
|
||||||
|
iconName: 'lucide:file-plus',
|
||||||
|
action: async () => console.log('New document'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Upload File',
|
||||||
|
iconName: 'lucide:upload',
|
||||||
|
action: async () => console.log('Upload file'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Download',
|
||||||
|
iconName: 'lucide:download',
|
||||||
|
action: async () => console.log('Download'),
|
||||||
|
},
|
||||||
|
{ divider: true } as any,
|
||||||
|
{
|
||||||
|
name: 'Share',
|
||||||
|
iconName: 'lucide:share-2',
|
||||||
|
action: async () => console.log('Share'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Export',
|
||||||
|
iconName: 'lucide:export',
|
||||||
|
action: async () => console.log('Export'),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
nav.heading = 'File Actions';
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
File Actions Menu
|
||||||
|
</dees-button>
|
||||||
|
|
||||||
|
<dees-button
|
||||||
|
type="outline"
|
||||||
|
@click=${async () => {
|
||||||
|
const { DeesMobilenavigation } = await import('./dees-mobilenavigation.js');
|
||||||
|
const nav = await DeesMobilenavigation.createAndShow([
|
||||||
|
{
|
||||||
|
name: 'Cut',
|
||||||
|
iconName: 'lucide:scissors',
|
||||||
|
action: async () => console.log('Cut'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Copy',
|
||||||
|
iconName: 'lucide:copy',
|
||||||
|
action: async () => console.log('Copy'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Paste',
|
||||||
|
iconName: 'lucide:clipboard',
|
||||||
|
action: async () => console.log('Paste'),
|
||||||
|
},
|
||||||
|
{ divider: true } as any,
|
||||||
|
{
|
||||||
|
name: 'Select All',
|
||||||
|
iconName: 'lucide:square-check',
|
||||||
|
action: async () => console.log('Select all'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Find',
|
||||||
|
iconName: 'lucide:search',
|
||||||
|
action: async () => console.log('Find'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Replace',
|
||||||
|
iconName: 'lucide:replace',
|
||||||
|
action: async () => console.log('Replace'),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
nav.heading = 'Edit';
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Edit Menu
|
||||||
|
</dees-button>
|
||||||
|
</div>
|
||||||
|
</dees-panel>
|
||||||
|
|
||||||
|
<dees-panel .title=${'Features'} .subtitle=${'Modern shadcn-inspired mobile navigation'}>
|
||||||
|
<div style="padding: 16px;">
|
||||||
|
<ul style="margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px;">
|
||||||
|
<li>Smooth slide-in animation from the right</li>
|
||||||
|
<li>Z-index registry integration for proper stacking</li>
|
||||||
|
<li>Backdrop blur with window layer</li>
|
||||||
|
<li>Support for icons using Lucide icons</li>
|
||||||
|
<li>Menu item dividers for grouping</li>
|
||||||
|
<li>Staggered animation for menu items</li>
|
||||||
|
<li>Responsive design that adapts to mobile screens</li>
|
||||||
|
<li>Clean, modern shadcn-style aesthetics</li>
|
||||||
|
<li>Dark/light theme support</li>
|
||||||
|
<li>Singleton pattern ensures only one instance</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</dees-panel>
|
||||||
|
|
||||||
|
<dees-panel .title=${'Code Example'} .subtitle=${'How to use the mobile navigation'}>
|
||||||
|
<div style="padding: 16px; background: var(--background-secondary); border-radius: 8px;">
|
||||||
|
<pre style="margin: 0; font-family: monospace; font-size: 13px; line-height: 1.6;"><code>import { DeesMobilenavigation } from '@design.estate/dees-catalog';
|
||||||
|
|
||||||
|
DeesMobilenavigation.createAndShow([
|
||||||
|
{
|
||||||
|
name: 'Dashboard',
|
||||||
|
iconName: 'lucide:layout-dashboard',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to dashboard');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Settings',
|
||||||
|
iconName: 'lucide:settings',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Navigate to settings');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ divider: true },
|
||||||
|
{
|
||||||
|
name: 'Sign Out',
|
||||||
|
iconName: 'lucide:log-out',
|
||||||
|
action: async (nav) => {
|
||||||
|
console.log('Sign out');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);</code></pre>
|
||||||
|
</div>
|
||||||
|
</dees-panel>
|
||||||
|
</div>
|
||||||
|
</dees-demowrapper>
|
||||||
|
`;
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './00plugins.js';
|
import * as plugins from './00plugins.js';
|
||||||
import { zIndexLayers } from './00zindex.js';
|
import { zIndexRegistry } from './00zindex.js';
|
||||||
|
import { cssGeistFontFamily } from './00fonts.js';
|
||||||
import {
|
import {
|
||||||
cssManager,
|
cssManager,
|
||||||
css,
|
css,
|
||||||
@ -9,8 +10,10 @@ import {
|
|||||||
domtools,
|
domtools,
|
||||||
html,
|
html,
|
||||||
property,
|
property,
|
||||||
|
state,
|
||||||
} from '@design.estate/dees-element';
|
} from '@design.estate/dees-element';
|
||||||
import { DeesWindowLayer } from './dees-windowlayer.js';
|
import { DeesWindowLayer } from './dees-windowlayer.js';
|
||||||
|
import './dees-icon.js';
|
||||||
|
|
||||||
@customElement('dees-mobilenavigation')
|
@customElement('dees-mobilenavigation')
|
||||||
export class DeesMobilenavigation extends DeesElement {
|
export class DeesMobilenavigation extends DeesElement {
|
||||||
@ -19,14 +22,48 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
<dees-button @click=${() => {
|
<dees-button @click=${() => {
|
||||||
DeesMobilenavigation.createAndShow([
|
DeesMobilenavigation.createAndShow([
|
||||||
{
|
{
|
||||||
name: 'Test',
|
name: 'Dashboard',
|
||||||
|
iconName: 'lucide:layout-dashboard',
|
||||||
action: async (deesMobileNav) => {
|
action: async (deesMobileNav) => {
|
||||||
alert('test');
|
console.log('Navigate to dashboard');
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Profile',
|
||||||
|
iconName: 'lucide:user',
|
||||||
|
action: async (deesMobileNav) => {
|
||||||
|
console.log('Navigate to profile');
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Settings',
|
||||||
|
iconName: 'lucide:settings',
|
||||||
|
action: async (deesMobileNav) => {
|
||||||
|
console.log('Navigate to settings');
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ divider: true } as any,
|
||||||
|
{
|
||||||
|
name: 'Help',
|
||||||
|
iconName: 'lucide:help-circle',
|
||||||
|
action: async (deesMobileNav) => {
|
||||||
|
console.log('Show help');
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Sign Out',
|
||||||
|
iconName: 'lucide:log-out',
|
||||||
|
action: async (deesMobileNav) => {
|
||||||
|
console.log('Sign out');
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}}></dees-button>
|
}}>Open Mobile Navigation</dees-button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
private static singletonRef: DeesMobilenavigation;
|
private static singletonRef: DeesMobilenavigation;
|
||||||
@ -44,15 +81,18 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
@property({
|
@property({
|
||||||
type: Array,
|
type: String,
|
||||||
})
|
})
|
||||||
public heading: string = `MENU`;
|
public heading: string = `Menu`;
|
||||||
|
|
||||||
@property({
|
@property({
|
||||||
type: Array,
|
type: Array,
|
||||||
})
|
})
|
||||||
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
public menuItems: plugins.tsclass.website.IMenuItem[] = [];
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private mobileNavZIndex: number = 1000;
|
||||||
|
|
||||||
readyDeferred: plugins.smartpromise.Deferred<any> = domtools.plugins.smartpromise.defer();
|
readyDeferred: plugins.smartpromise.Deferred<any> = domtools.plugins.smartpromise.defer();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -74,25 +114,32 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
css`
|
css`
|
||||||
:host {
|
:host {
|
||||||
|
font-family: ${cssGeistFontFamily};
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
min-width: 280px;
|
width: 100%;
|
||||||
transform: translateX(200px);
|
max-width: 320px;
|
||||||
color: ${cssManager.bdTheme('#333', '#fff')};
|
transform: translateX(100%);
|
||||||
z-index: ${zIndexLayers.fixed.mobileNav};
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
|
z-index: var(--z-index);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
padding: 16px 32px;
|
|
||||||
right: 0px;
|
right: 0px;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
background: ${cssManager.bdTheme('#eeeeeb', '#000')};
|
background: ${cssManager.bdTheme('#ffffff', '#09090b')};
|
||||||
border-left: 1px solid ${cssManager.bdTheme('#eeeeeb', '#222')};
|
border-left: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
box-shadow: ${cssManager.bdTheme(
|
||||||
|
'-20px 0 25px -5px rgba(0, 0, 0, 0.1), -10px 0 10px -5px rgba(0, 0, 0, 0.04)',
|
||||||
|
'-20px 0 25px -5px rgba(0, 0, 0, 0.3), -10px 0 10px -5px rgba(0, 0, 0, 0.2)'
|
||||||
|
)};
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main.show {
|
.main.show {
|
||||||
@ -101,48 +148,152 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuItem {
|
.header {
|
||||||
text-align: left;
|
padding: 24px;
|
||||||
padding: 8px;
|
border-bottom: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
||||||
margin-left: -8px;
|
|
||||||
margin-right: -8px;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
.menuItem:hover {
|
|
||||||
background: ${cssManager.bdTheme('#CCC', '#333')};;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
text-align: left;
|
font-size: 18px;
|
||||||
font-size: 24px;
|
font-weight: 600;
|
||||||
padding: 8px 0px;
|
letter-spacing: -0.02em;
|
||||||
font-family: 'Geist Sans', sans-serif;
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
font-weight: 300;
|
margin: 0;
|
||||||
border-bottom: 1px dashed #444;
|
}
|
||||||
margin-top: 16px;
|
|
||||||
margin-bottom: 16px;
|
.menu-container {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem:hover {
|
||||||
|
background: ${cssManager.bdTheme('#f4f4f5', '#27272a')};
|
||||||
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem:active {
|
||||||
|
background: ${cssManager.bdTheme('#e5e7eb', '#3f3f46')};
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem dees-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: ${cssManager.bdTheme('#71717a', '#71717a')};
|
||||||
|
transition: color 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem:hover dees-icon {
|
||||||
|
color: ${cssManager.bdTheme('#09090b', '#fafafa')};
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem-text {
|
||||||
|
flex: 1;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
||||||
|
margin: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile responsiveness */
|
||||||
|
@media (max-width: 400px) {
|
||||||
|
.main {
|
||||||
|
max-width: 100vw;
|
||||||
|
width: 85vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animation for menu items */
|
||||||
|
@keyframes slideInRight {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main.show .menuItem {
|
||||||
|
animation: slideInRight 0.3s ease-out forwards;
|
||||||
|
animation-delay: calc(var(--item-index, 0) * 0.05s);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollbar styling */
|
||||||
|
.menu-container::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-container::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-container::-webkit-scrollbar-thumb {
|
||||||
|
background: ${cssManager.bdTheme('#e5e7eb', '#3f3f46')};
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-container::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: ${cssManager.bdTheme('#d1d5db', '#52525b')};
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return html`
|
return html`
|
||||||
|
<style>
|
||||||
|
.main {
|
||||||
|
--z-index: ${this.mobileNavZIndex};
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="heading">${this.heading}</div>
|
<div class="header">
|
||||||
${this.menuItems.map((menuItem) => {
|
<h2 class="heading">${this.heading}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="menu-container">
|
||||||
|
${this.menuItems.map((menuItem, index) => {
|
||||||
|
if ('divider' in menuItem && menuItem.divider) {
|
||||||
|
return html`<div class="menuItem-divider"></div>`;
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="menuItem"
|
class="menuItem"
|
||||||
|
style="--item-index: ${index}"
|
||||||
@click="${() => {
|
@click="${() => {
|
||||||
this.hide();
|
this.hide();
|
||||||
menuItem.action(this);
|
menuItem.action(this);
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
${menuItem.name}
|
${menuItem.iconName ? html`
|
||||||
|
<dees-icon .icon=${menuItem.iconName} size="20"></dees-icon>
|
||||||
|
` : ''}
|
||||||
|
<span class="menuItem-text">${menuItem.name}</span>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,18 +305,25 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
public async show() {
|
public async show() {
|
||||||
const domtools = await this.domtoolsPromise;
|
const domtools = await this.domtoolsPromise;
|
||||||
const main = this.shadowRoot.querySelector('.main');
|
const main = this.shadowRoot.querySelector('.main');
|
||||||
|
|
||||||
|
// Create window layer first (it will get its own z-index)
|
||||||
if (!this.windowLayer) {
|
if (!this.windowLayer) {
|
||||||
this.windowLayer = new DeesWindowLayer();
|
this.windowLayer = await DeesWindowLayer.createAndShow({
|
||||||
this.windowLayer.options.blur = true;
|
blur: true,
|
||||||
|
});
|
||||||
this.windowLayer.addEventListener('click', () => {
|
this.windowLayer.addEventListener('click', () => {
|
||||||
this.hide();
|
this.hide();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
document.body.append(this.windowLayer);
|
document.body.append(this.windowLayer);
|
||||||
await domtools.convenience.smartdelay.delayFor(0);
|
await this.windowLayer.show();
|
||||||
this.windowLayer.show();
|
}
|
||||||
|
|
||||||
await domtools.convenience.smartdelay.delayFor(0);
|
// Get z-index for mobile nav (will be above window layer)
|
||||||
|
this.mobileNavZIndex = zIndexRegistry.getNextZIndex();
|
||||||
|
zIndexRegistry.register(this, this.mobileNavZIndex);
|
||||||
|
|
||||||
|
await domtools.convenience.smartdelay.delayFor(10);
|
||||||
main.classList.add('show');
|
main.classList.add('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +334,23 @@ export class DeesMobilenavigation extends DeesElement {
|
|||||||
const domtools = await this.domtoolsPromise;
|
const domtools = await this.domtoolsPromise;
|
||||||
const main = this.shadowRoot.querySelector('.main');
|
const main = this.shadowRoot.querySelector('.main');
|
||||||
main.classList.remove('show');
|
main.classList.remove('show');
|
||||||
this.windowLayer.hide();
|
|
||||||
|
// Unregister from z-index registry
|
||||||
|
zIndexRegistry.unregister(this);
|
||||||
|
|
||||||
|
if (this.windowLayer) {
|
||||||
|
await this.windowLayer.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnectedCallback() {
|
async disconnectedCallback() {
|
||||||
document.body.removeChild(this.windowLayer);
|
super.disconnectedCallback();
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
zIndexRegistry.unregister(this);
|
||||||
|
|
||||||
|
if (this.windowLayer) {
|
||||||
|
await this.windowLayer.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user