From 5a172a64c51ae688ad557af218b53da3b09c1556 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 11 Jan 2020 01:40:19 +0100 Subject: [PATCH] Make entry flow dialog modal (#4440) * Make entry flow dialog modal * Add close button * Update dialog-data-entry-flow.ts * Fix aria-label --- .../config-flow/dialog-data-entry-flow.ts | 109 ++++++++++-------- .../config-flow/step-flow-pick-handler.ts | 44 +++---- src/translations/en.json | 1 + 3 files changed, 86 insertions(+), 68 deletions(-) diff --git a/src/dialogs/config-flow/dialog-data-entry-flow.ts b/src/dialogs/config-flow/dialog-data-entry-flow.ts index d51838a682..c4c2972574 100644 --- a/src/dialogs/config-flow/dialog-data-entry-flow.ts +++ b/src/dialogs/config-flow/dialog-data-entry-flow.ts @@ -11,6 +11,7 @@ import { import "@material/mwc-button"; import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; import "@polymer/paper-tooltip/paper-tooltip"; +import "@polymer/paper-icon-button/paper-icon-button"; import "@polymer/paper-spinner/paper-spinner"; import { UnsubscribeFunc } from "home-assistant-js-websocket"; @@ -124,6 +125,7 @@ class DataEntryFlowDialog extends LitElement { ${this._loading || (this._step === null && this._handlers === undefined) @@ -134,53 +136,62 @@ class DataEntryFlowDialog extends LitElement { ? // When we are going to next step, we render 1 round of empty // to reset the element. "" - : this._step === null - ? // Show handler picker - html` - - ` - : this._step.type === "form" - ? html` - - ` - : this._step.type === "external" - ? html` - - ` - : this._step.type === "abort" - ? html` - - ` - : this._devices === undefined || this._areas === undefined - ? // When it's a create entry result, we will fetch device & area registry - html` - - ` : html` - + + ${this._step === null + ? // Show handler picker + html` + + ` + : this._step.type === "form" + ? html` + + ` + : this._step.type === "external" + ? html` + + ` + : this._step.type === "abort" + ? html` + + ` + : this._devices === undefined || this._areas === undefined + ? // When it's a create entry result, we will fetch device & area registry + html` + + ` + : html` + + `} `} `; @@ -318,6 +329,12 @@ class DataEntryFlowDialog extends LitElement { display: block; padding: 0; } + paper-icon-button { + display: inline-block; + padding: 8px; + margin: 16px 16px 0 0; + float: right; + } `, ]; } diff --git a/src/dialogs/config-flow/step-flow-pick-handler.ts b/src/dialogs/config-flow/step-flow-pick-handler.ts index 19963854af..c25a338121 100644 --- a/src/dialogs/config-flow/step-flow-pick-handler.ts +++ b/src/dialogs/config-flow/step-flow-pick-handler.ts @@ -19,6 +19,7 @@ import "../../components/ha-icon-next"; import "../../common/search/search-input"; import { styleMap } from "lit-html/directives/style-map"; import { FlowConfig } from "./show-dialog-data-entry-flow"; +import { configFlowContentStyles } from "./styles"; interface HandlerObj { name: string; @@ -133,28 +134,27 @@ class StepFlowPickHandler extends LitElement { }); } - static get styles(): CSSResult { - return css` - h2 { - margin-bottom: 2px; - padding-left: 16px; - } - div { - overflow: auto; - max-height: 600px; - } - paper-item { - cursor: pointer; - } - p { - text-align: center; - padding: 16px; - margin: 0; - } - p > a { - color: var(--primary-color); - } - `; + static get styles(): CSSResult[] { + return [ + configFlowContentStyles, + css` + div { + overflow: auto; + max-height: 600px; + } + paper-item { + cursor: pointer; + } + p { + text-align: center; + padding: 16px; + margin: 0; + } + p > a { + color: var(--primary-color); + } + `, + ]; } } diff --git a/src/translations/en.json b/src/translations/en.json index a5067120f6..208f8c9645 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1373,6 +1373,7 @@ "config_flow": { "aborted": "Aborted", "close": "Close", + "dismiss": "Dismiss dialog", "finish": "Finish", "submit": "Submit", "not_all_required_fields": "Not all required fields are filled in.",