100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI update: Added or-mwc-drawer component
Rich Turnerafd4037b0d98
diff --git a/ui/component/or-mwc-components/package.json b/ui/component/or-mwc-components/package.jsonindex 29e51e194..d653d992f 100644--- a/ui/component/or-mwc-components/package.json+++ b/ui/component/or-mwc-components/package.json@@ -11,6 +11,7 @@"license": "AGPL-3.0-or-later","dependencies": {"@material/menu": "^4.0.0",+ "@material/drawer": "^4.0.0","lit-element": "^2.2.1"},"devDependencies": {diff --git a/ui/component/or-mwc-components/src/or-mwc-drawer.ts b/ui/component/or-mwc-components/src/or-mwc-drawer.tsnew file mode 100644index 000000000..3a1131733--- /dev/null+++ b/ui/component/or-mwc-components/src/or-mwc-drawer.ts@@ -0,0 +1,98 @@+import { css, customElement, html, LitElement, property, TemplateResult, unsafeCSS, query } from "lit-element";+import { MDCDrawer } from "@material/drawer";+import { classMap } from "lit-html/directives/class-map";++const drawerStyle = require("!!raw-loader!@material/drawer/dist/mdc.drawer.css");++export class OrMwcDrawerChangedEvent extends CustomEvent<boolean> {++ public static readonly NAME = "or-mwc-drawer-changed";++ constructor(value: boolean) {+ super(OrMwcDrawerChangedEvent.NAME, {+ detail: value,+ bubbles: true,+ composed: true+ });+ }+}++@customElement("or-mwc-drawer")+export class OrMwcDrawer extends LitElement {++ public static get styles() {+ return [+ css`${unsafeCSS(drawerStyle)}`,+ css`+ .transparent{+ background: none;+ }`+ ];+ }++ @property({ attribute: false }) public header!: TemplateResult;++ @property({ type: Boolean }) public dismissible: boolean = false;+ @property({ type: Boolean }) public rightSided: boolean = false;+ @property({ type: Boolean }) public transparent: boolean = false;+ @property({ type: Boolean }) public open: boolean = false;++ @property({ attribute: false }) public appContent!: HTMLElement;+ @property({ attribute: false }) public topBar!: HTMLElement;++ @query(".mdc-drawer")+ protected drawerElement!: HTMLElement;+ protected drawer?: MDCDrawer;++ public toggle() {+ this.open = !this.open;+ }++ public disconnectedCallback(): void {+ super.disconnectedCallback();+ if (this.drawer) {+ this.drawer.destroy();+ this.drawer = undefined;+ }+ }++ protected render() {++ const classes = {+ "mdc-drawer--dismissible": this.dismissible,+ "transparent": this.transparent+ };++ return html`+ <aside class="mdc-drawer ${classMap(classes)}" dir="${(this.rightSided ? "rtl" : "ltr")}">+ ${this.header}+ <div class="mdc-drawer__content" dir="ltr">+ <slot></slot>+ </div>+ </aside>`;+ }++ protected updated() {+ if (this.drawer!.open !== this.open) {+ this.drawer!.open = this.open;+ }+ }++ protected dispatchChangedEvent(value: boolean) {+ this.dispatchEvent(new OrMwcDrawerChangedEvent(value));+ }++ protected firstUpdated() {+ this.drawer = MDCDrawer.attachTo(this.drawerElement);+ const openHandler = () => { this.dispatchChangedEvent(true); };+ const closeHandler = () => { this.dispatchChangedEvent(false); };+ this.drawer!.listen("MDCDrawer:opened", openHandler);+ this.drawer!.listen("MDCDrawer:closed", closeHandler);+ if (this.appContent) {+ this.appContent.classList.add("mdc-drawer-app-content");+ }+ if (this.topBar) {+ this.topBar.classList.add("mdc-top-app-bar");+ }+ }+}