blob: 113177ca5b2dde02332e34f4557331bbf347f9c3 [file] [log] [blame]
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +02001import '@material/web/fab/fab.js';
2import './components/List.js';
3import './components/AddDialog.js';
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +02004import './components/WorkflowDialog.js';
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +02005
6import {css, html, LitElement} from 'lit';
7import {createRef, ref} from 'lit/directives/ref.js';
8
9import {SHARED_MD3_STYLES} from '../../common/styles/md3.js';
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020010import {default as WorkflowsStorage, kWorkflowsDataKey} from '../workflowsStorage.js';
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020011
12export default class WFApp extends LitElement {
13 static styles = [
14 SHARED_MD3_STYLES,
15 css`
16 :host {
17 font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI',
18 Helvetica, Arial, sans-serif, 'Apple Color Emoji',
19 'Segoe UI Emoji', 'Segoe UI Symbol'!important;
20
21 display: block;
22 max-width: 1024px;
23 margin: auto;
24 position: relative;
25 }
26
27 md-fab {
28 position: fixed;
29 bottom: 2em;
30 right: 2em;
31 }
32 `,
33 ];
34
35 addFabRef = createRef();
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020036 addDialog = createRef();
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020037
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020038 constructor() {
39 super();
40 this._workflows = undefined;
Adrià Vilanova Martínez0caffdd2022-10-17 19:40:35 +020041 WorkflowsStorage.watch(workflows => {
42 this._workflows = workflows;
43 this.requestUpdate();
44 }, /* asProtobuf = */ true);
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020045 }
46
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020047 render() {
48 return html`
49 <h1>Workflows</h1>
Adrià Vilanova Martínez7f1e8ea2022-10-14 15:50:11 +020050 <p>Workflows allow you to run a customized list of actions on a thread easily.</p>
51 <wf-list .workflows=${this._workflows}></wf-list>
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020052 <md-fab ${ref(this.addFabRef)}
53 icon="add"
54 @click=${this._showAddDialog}>
55 </md-fab>
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020056 <wf-add-dialog ${ref(this.addDialog)}>
57 </wf-add-dialog>
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020058 `;
59 }
60
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020061 _showAddDialog() {
Adrià Vilanova Martínez8803b6c2022-10-17 00:36:38 +020062 this.addDialog.value.open = true;
Adrià Vilanova Martínezf276ac72022-10-13 22:16:22 +020063 }
64}
65window.customElements.define('wf-app', WFApp);