mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 21:36:36 +00:00
Apply paper-dialog-behavior instead of nesting paper-dialogs (#987)
* disable ha-url-sync * apply a paper-dialog-behavior mixin to dialogs * Revert "disable ha-url-sync" This reverts commit 4758a81af61d9f6979a93c0a899d3788fb48090e. * fix css :host attribute selector * move hass back to the components
This commit is contained in:
parent
2c79094fb4
commit
7066b40e4c
@ -1,6 +1,6 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
|
<link rel="import" href="../../bower_components/paper-dialog-behavior/paper-dialog-shared-styles.html">
|
||||||
<link rel="import" href="../../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
|
<link rel="import" href="../../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
|
||||||
<link rel="import" href="../components/state-history-charts.html">
|
<link rel="import" href="../components/state-history-charts.html">
|
||||||
<link rel="import" href="../data/ha-state-history-data.html">
|
<link rel="import" href="../data/ha-state-history-data.html">
|
||||||
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
<dom-module id="ha-more-info-dialog">
|
<dom-module id="ha-more-info-dialog">
|
||||||
<template>
|
<template>
|
||||||
<style include="ha-style-dialog">
|
<style include="ha-style-dialog paper-dialog-shared-styles">
|
||||||
paper-dialog {
|
:host {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
width: 365px;
|
width: 365px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
@ -33,28 +33,21 @@
|
|||||||
--more-info-header-background: var(--primary-color);
|
--more-info-header-background: var(--primary-color);
|
||||||
--more-info-header-color: var(--text-primary-color);
|
--more-info-header-color: var(--text-primary-color);
|
||||||
}
|
}
|
||||||
paper-dialog {
|
:host {
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-dialog[data-domain=camera] {
|
:host([data-domain=camera]) {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-dialog[data-domain=history_graph] {
|
:host([data-domain=history_graph]) {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- entry-animation='slide-up-animation' exit-animation='slide-down-animation' -->
|
|
||||||
<paper-dialog
|
|
||||||
id="dialog"
|
|
||||||
with-backdrop
|
|
||||||
opened='{{_dialogOpen}}'
|
|
||||||
data-domain$='[[_computeDomain(stateObj)]]'
|
|
||||||
>
|
|
||||||
<template is='dom-if' if='[[!_page]]'>
|
<template is='dom-if' if='[[!_page]]'>
|
||||||
<more-info-controls
|
<more-info-controls
|
||||||
class='no-padding'
|
class='no-padding'
|
||||||
@ -72,29 +65,21 @@
|
|||||||
registry-info='{{_registryInfo}}'
|
registry-info='{{_registryInfo}}'
|
||||||
></more-info-settings>
|
></more-info-settings>
|
||||||
</template>
|
</template>
|
||||||
</paper-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class HaMoreInfoDialog extends window.hassMixins.EventsMixin(Polymer.Element) {
|
class HaMoreInfoDialog extends window.hassMixins.DialogMixin(Polymer.Element) {
|
||||||
static get is() { return 'ha-more-info-dialog'; }
|
static get is() { return 'ha-more-info-dialog'; }
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
|
|
||||||
stateObj: {
|
stateObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
computed: '_computeStateObj(hass)',
|
computed: '_computeStateObj(hass)',
|
||||||
observer: '_stateObjChanged',
|
observer: '_stateObjChanged',
|
||||||
},
|
},
|
||||||
|
|
||||||
_dialogOpen: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
observer: '_dialogOpenChanged',
|
|
||||||
},
|
|
||||||
|
|
||||||
_dialogElement: Object,
|
_dialogElement: Object,
|
||||||
_registryInfo: Object,
|
_registryInfo: Object,
|
||||||
|
|
||||||
@ -102,12 +87,19 @@ class HaMoreInfoDialog extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
type: String,
|
type: String,
|
||||||
value: null,
|
value: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dataDomain: {
|
||||||
|
computed: '_computeDomain(stateObj)',
|
||||||
|
reflectToAttribute: true
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get observers() { return ['_dialogOpenChanged(opened)']; }
|
||||||
|
|
||||||
ready() {
|
ready() {
|
||||||
super.ready();
|
super.ready();
|
||||||
this._dialogElement = this.$.dialog;
|
this._dialogElement = this;
|
||||||
this.addEventListener('more-info-page', (ev) => { this._page = ev.detail.page; });
|
this.addEventListener('more-info-page', (ev) => { this._page = ev.detail.page; });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +114,7 @@ class HaMoreInfoDialog extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
_stateObjChanged(newVal, oldVal) {
|
_stateObjChanged(newVal, oldVal) {
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
_dialogOpen: false,
|
opened: false,
|
||||||
_page: null,
|
_page: null,
|
||||||
_registryInfo: null,
|
_registryInfo: null,
|
||||||
});
|
});
|
||||||
@ -141,7 +133,7 @@ class HaMoreInfoDialog extends window.hassMixins.EventsMixin(Polymer.Element) {
|
|||||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||||
// allow dialog to render content before showing it so it will be
|
// allow dialog to render content before showing it so it will be
|
||||||
// positioned correctly.
|
// positioned correctly.
|
||||||
this._dialogOpen = true;
|
this.opened = true;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
|
<link rel="import" href="../../bower_components/paper-dialog-behavior/paper-dialog-shared-styles.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
|
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
|
||||||
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
|
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
|
||||||
|
|
||||||
<dom-module id="ha-voice-command-dialog">
|
<dom-module id="ha-voice-command-dialog">
|
||||||
<template>
|
<template>
|
||||||
<style>
|
<style include="paper-dialog-shared-styles">
|
||||||
iron-icon {
|
iron-icon {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
@ -16,6 +16,7 @@
|
|||||||
width: 450px;
|
width: 450px;
|
||||||
min-height: 80px;
|
min-height: 80px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.messages {
|
.messages {
|
||||||
@ -75,12 +76,12 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-dialog {
|
:host {
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 450px) {
|
@media all and (max-width: 450px) {
|
||||||
paper-dialog {
|
:host {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: calc(100% - 64px);
|
max-height: calc(100% - 64px);
|
||||||
@ -104,7 +105,6 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<paper-dialog id="dialog" with-backdrop opened='{{dialogOpen}}'>
|
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<div class='messages' id='messages'>
|
<div class='messages' id='messages'>
|
||||||
<template is='dom-repeat' items='[[_conversation]]' as='message'>
|
<template is='dom-repeat' items='[[_conversation]]' as='message'>
|
||||||
@ -127,27 +127,17 @@
|
|||||||
></paper-icon-button>
|
></paper-icon-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</paper-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
class HaVoiceCommandDialog extends Polymer.Element {
|
class HaVoiceCommandDialog extends window.hassMixins.DialogMixin(Polymer.Element) {
|
||||||
static get is() { return 'ha-voice-command-dialog'; }
|
static get is() { return 'ha-voice-command-dialog'; }
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
hass: {
|
hass: Object,
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
dialogOpen: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
observer: 'dialogOpenChanged',
|
|
||||||
},
|
|
||||||
|
|
||||||
results: {
|
results: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: null,
|
value: null,
|
||||||
@ -164,6 +154,8 @@ class HaVoiceCommandDialog extends Polymer.Element {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get observers() { return ['dialogOpenChanged(opened)']; }
|
||||||
|
|
||||||
initRecognition() {
|
initRecognition() {
|
||||||
/* eslint-disable new-cap */
|
/* eslint-disable new-cap */
|
||||||
this.recognition = new webkitSpeechRecognition();
|
this.recognition = new webkitSpeechRecognition();
|
||||||
|
@ -130,7 +130,7 @@
|
|||||||
|
|
||||||
handleStartVoice(ev) {
|
handleStartVoice(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.$.voiceDialog.dialogOpen = true;
|
this.$.voiceDialog.opened = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOpenMenu() {
|
handleOpenMenu() {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<link rel='import' href='../../bower_components/app-localize-behavior/app-localize-behavior.html'>
|
<link rel='import' href='../../bower_components/app-localize-behavior/app-localize-behavior.html'>
|
||||||
|
<link rel="import" href='../../bower_components/paper-dialog/paper-dialog-behavior.html'>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
@ -108,4 +109,21 @@ window.hassMixins.LocalizeMixin = Polymer.dedupingMixin(superClass =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @polymerMixin
|
||||||
|
* @appliesMixin window.hassMixins.EventsMixin
|
||||||
|
* @appliesMixin Polymer.PaperDialogBehavior
|
||||||
|
*/
|
||||||
|
window.hassMixins.DialogMixin = Polymer.dedupingMixin(superClass =>
|
||||||
|
class extends Polymer.mixinBehaviors([window.hassMixins.EventsMixin,
|
||||||
|
Polymer.PaperDialogBehavior], superClass) {
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
withBackdrop: {
|
||||||
|
type: Boolean,
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user