This repository was archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhydrofoil-paper-shell.ts
129 lines (109 loc) · 3.72 KB
/
hydrofoil-paper-shell.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { HydrofoilShell } from '@hydrofoil/hydrofoil-shell/hydrofoil-shell'
import { AppDrawerElement } from '@polymer/app-layout/app-drawer/app-drawer'
import { css, customElement, html, property, query } from 'lit-element'
import '@polymer/app-layout/app-layout'
import '@polymer/iron-icon/iron-icon'
import '@polymer/iron-icons/iron-icons'
import '@polymer/paper-icon-button/paper-icon-button'
import '@polymer/paper-item/paper-item'
import './loading-overlay'
/**
* An extension of `<hydrofoil-shell>` with Material Design UI
*
* The UI elements include:
*
* * Center pane wrapped in a `app-header-layout`
* * Left `<app-drawer>` with a `app-header-layout`
* * Right `<app-drawer>`, plain
* * A full-screen loading overlay which is displayed when a resource is being loaded
*
* The static UI parts can be extended through a number of slots, whose names should be self-explanatory:
*
* * `drawer-left`
* * `drawer-right`
* * `toolbar-main`
* * `header`
* * `shell-ready`
* * `loader`
*
* @customElement
*/
@customElement('hydrofoil-paper-shell')
export class HydrofoilPaperShell extends HydrofoilShell {
@property({ type: String })
public title = 'Hydrofoil Paper Shell'
@property({ type: String, attribute: 'left-drawer-title' })
public leftDrawerTitle = ''
@query('#rightDrawer')
private rightDrawer: AppDrawerElement
@query('#leftDrawer')
private leftDrawer: AppDrawerElement
public static get styles () {
return css`${super.styles}
:host {
--app-drawer-width: 350px;
}
app-drawer-layout[narrow] {
--open-menu-icon-display: block;
}
paper-icon-button[icon="menu"] {
display: var(--open-menu-icon-display, none)
}
app-toolbar, ::slotted(app-toolbar) {
background: var(--paper-blue-400);
color: white;
@apply(--paper-font-common-base);
}
side-menu {
height: calc(100% - 128px);
overflow: auto;
}`
}
/**
* Opens the right drawer
*/
public openRightDrawer () {
this.rightDrawer.open()
}
/**
* Opens the left drawer
*/
public openLeftDrawer () {
this.leftDrawer.open()
}
public render () {
return html`<app-drawer-layout>
<app-drawer slot="drawer" swipe-open id="leftDrawer">
<app-toolbar class="medium-tall">
<div class="title">
<slot name="left-drawer-title">
${this.leftDrawerTitle}
</slot>
</div>
</app-toolbar>
<slot name="drawer-left"></slot>
</app-drawer>
<app-drawer align="end" slot="drawer" swipe-open id="rightDrawer">
<slot name="drawer-right"></slot>
</app-drawer>
<app-header-layout>
<app-header slot="header" fixed>
<app-toolbar>
<paper-icon-button icon="menu" @click="${this.openLeftDrawer}"></paper-icon-button>
<div main-title>
<slot name="toolbar-title">
${this.title}
</slot>
</div>
<slot name="toolbar-main"></slot>
</app-toolbar>
<slot name="header"></slot>
</app-header>
${super.render()}
<loading-overlay ?opened="${this.isLoading}">
<slot name="loader"></slot>
</loading-overlay>
</app-header-layout>
</app-drawer-layout>`
}
}