-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment: add LitElement based version of app-layout
- Loading branch information
1 parent
885d7e9
commit 16c3aa1
Showing
25 changed files
with
195 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './vaadin-app-layout.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2018 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import './detect-ios-navbar.js'; | ||
import './safe-area-inset.js'; | ||
import { html, LitElement } from 'lit'; | ||
import { defineCustomElement } from '@vaadin/component-base/src/define.js'; | ||
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; | ||
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { AppLayoutMixin } from './vaadin-app-layout-mixin.js'; | ||
import { appLayoutStyles } from './vaadin-app-layout-styles.js'; | ||
|
||
/** | ||
* LitElement based version of `<vaadin-app-layout>` web component. | ||
* | ||
* ## Disclaimer | ||
* | ||
* This component is an experiment and not yet a part of Vaadin platform. | ||
* There is no ETA regarding specific Vaadin version where it'll land. | ||
* Feel free to try this code in your apps as per Apache 2.0 license. | ||
*/ | ||
class AppLayout extends AppLayoutMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) { | ||
static get is() { | ||
return 'vaadin-app-layout'; | ||
} | ||
|
||
static get styles() { | ||
return appLayoutStyles; | ||
} | ||
|
||
/** @protected */ | ||
render() { | ||
return html` | ||
<div part="navbar" id="navbarTop"> | ||
<slot name="navbar" @slotchange="${this._updateTouchOptimizedMode}"></slot> | ||
</div> | ||
<div part="backdrop" @click="${this._onBackdropClick}" @touchend="${this._onBackdropTouchend}"></div> | ||
<div part="drawer" id="drawer"> | ||
<slot name="drawer" id="drawerSlot" @slotchange="${this._updateDrawerSize}"></slot> | ||
</div> | ||
<div content> | ||
<slot></slot> | ||
</div> | ||
<div part="navbar" id="navbarBottom" bottom hidden> | ||
<slot name="navbar-bottom"></slot> | ||
</div> | ||
<div hidden> | ||
<slot id="touchSlot" name="navbar touch-optimized" @slotchange="${this._updateTouchOptimizedMode}"></slot> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
defineCustomElement(AppLayout); | ||
|
||
export { AppLayout }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './vaadin-drawer-toggle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2018 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { html, LitElement } from 'lit'; | ||
import { buttonStyles } from '@vaadin/button/src/vaadin-button-base.js'; | ||
import { ButtonMixin } from '@vaadin/button/src/vaadin-button-mixin.js'; | ||
import { defineCustomElement } from '@vaadin/component-base/src/define.js'; | ||
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js'; | ||
import { isEmptyTextNode } from '@vaadin/component-base/src/dom-utils.js'; | ||
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { drawerToggle } from './vaadin-drawer-toggle-styles.js'; | ||
|
||
/** | ||
* LitElement based version of `<vaadin-drawer-toggle>` web component. | ||
* | ||
* ## Disclaimer | ||
* | ||
* This component is an experiment and not yet a part of Vaadin platform. | ||
* There is no ETA regarding specific Vaadin version where it'll land. | ||
* Feel free to try this code in your apps as per Apache 2.0 license. | ||
*/ | ||
class DrawerToggle extends ButtonMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))) { | ||
static get is() { | ||
return 'vaadin-drawer-toggle'; | ||
} | ||
|
||
static get styles() { | ||
return [buttonStyles, drawerToggle]; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
ariaLabel: { | ||
type: String, | ||
value: 'Toggle navigation panel', | ||
reflectToAttribute: true, | ||
sync: true, | ||
}, | ||
|
||
/** @private */ | ||
_showFallbackIcon: { | ||
type: Boolean, | ||
value: false, | ||
}, | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.addEventListener('click', () => { | ||
this.dispatchEvent(new CustomEvent('drawer-toggle-click', { bubbles: true, composed: true })); | ||
}); | ||
} | ||
|
||
/** @protected */ | ||
render() { | ||
return html` | ||
<slot id="slot" @slotchange="${this._toggleFallbackIcon}"> | ||
<div part="icon"></div> | ||
</slot> | ||
<div part="icon" ?hidden="${!this._showFallbackIcon}"></div> | ||
`; | ||
} | ||
|
||
/** @protected */ | ||
ready() { | ||
super.ready(); | ||
|
||
this._toggleFallbackIcon(); | ||
} | ||
|
||
/** @private */ | ||
_toggleFallbackIcon() { | ||
const nodes = this.$.slot.assignedNodes(); | ||
|
||
// Show fallback icon if there are 1-2 empty text nodes assigned to the default slot. | ||
this._showFallbackIcon = nodes.length > 0 && nodes.every((node) => isEmptyTextNode(node)); | ||
} | ||
} | ||
|
||
defineCustomElement(DrawerToggle); | ||
|
||
export { DrawerToggle }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../src/vaadin-lit-app-layout.js'; | ||
import '../src/vaadin-lit-drawer-toggle.js'; | ||
import './app-layout.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../vaadin-app-layout.js'; | ||
import '../vaadin-drawer-toggle.js'; | ||
import './app-layout.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../src/vaadin-lit-drawer-toggle.js'; | ||
import './drawer-toggle.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../vaadin-drawer-toggle.js'; | ||
import './drawer-toggle.common.js'; |
6 changes: 3 additions & 3 deletions
6
...ges/app-layout/test/drawer-toggle.test.js → ...s/app-layout/test/drawer-toggle.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../src/vaadin-lit-app-layout.js'; | ||
import '../src/vaadin-lit-drawer-toggle.js'; | ||
import './keyboard-desktop.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../vaadin-app-layout.js'; | ||
import '../vaadin-drawer-toggle.js'; | ||
import './keyboard-desktop.common.js'; |
2 changes: 0 additions & 2 deletions
2
.../app-layout/test/keyboard-desktop.test.js → ...pp-layout/test/keyboard-desktop.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../src/vaadin-lit-app-layout.js'; | ||
import '../src/vaadin-lit-drawer-toggle.js'; | ||
import './keyboard-mobile.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../vaadin-app-layout.js'; | ||
import '../vaadin-drawer-toggle.js'; | ||
import './keyboard-mobile.common.js'; |
2 changes: 0 additions & 2 deletions
2
...s/app-layout/test/keyboard-mobile.test.js → ...app-layout/test/keyboard-mobile.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-app-layout-styles.js'; | ||
import '../../src/vaadin-lit-app-layout.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-drawer-toggle-styles.js'; | ||
import '../../src/vaadin-lit-drawer-toggle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-app-layout-styles.js'; | ||
import '../../src/vaadin-lit-app-layout.js'; |
2 changes: 2 additions & 0 deletions
2
packages/app-layout/theme/material/vaadin-lit-drawer-toggle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-drawer-toggle-styles.js'; | ||
import '../../src/vaadin-lit-drawer-toggle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/vaadin-app-layout.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './theme/lumo/vaadin-lit-app-layout.js'; | ||
export * from './src/vaadin-lit-app-layout.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/vaadin-drawer-toggle.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './theme/lumo/vaadin-lit-drawer-toggle.js'; | ||
export * from './src/vaadin-lit-drawer-toggle.js'; |