Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/components/ha-cover-controls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">

<link rel="import" href="../util/cover-model.html">

<dom-module id="ha-cover-controls">
<template>
<style>
.state {
text-align: right;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of state-card-cover.html as it's about how the component should be rendered.

white-space: nowrap;
width: 127px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually both of those are not needed at all. Removing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure, our cards can be pretty wide if you have only 1 column. In that case the controls should be right aligned which I don't think they are now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The controls are right aligned because state-card-cover has class='horizontal justified layout'.

width:127px does nothing because the "natural" width of the 3 buttons is 126.5px. When some buttons are unsupported they are visibility: hidden so width is not changed.

If the state container were wider, for example 226.px then text-align: right; would affect to which side of the 226.5px the 3 buttons are aligned. Since the container tightly wraps the buttons - text-align: right; has no effect.

}
[invisible] {
visibility: hidden !important;
}
</style>

<div class='state'>
<paper-icon-button icon="mdi:arrow-up" on-tap='onOpenTap'
invisible$='[[!entityObj.supportsOpen]]'
disabled='[[entityObj.isFullyOpen]]'></paper-icon-button>
<paper-icon-button icon="mdi:stop" on-tap='onStopTap'
invisible$='[[!entityObj.supportsStop]]'></paper-icon-button>
<paper-icon-button icon="mdi:arrow-down" on-tap='onCloseTap'
invisible$='[[!entityObj.supportsClose]]'
disabled='[[entityObj.isFullyClosed]]'></paper-icon-button>
</div>
</template>
</dom-module>

<script>
Polymer({
is: 'ha-cover-controls',
properties: {
hass: {
type: Object,
},
stateObj: {
type: Object,
},
entityObj: {
type: Object,
computed: 'computeEntityObj(hass, stateObj)',
},
},
computeEntityObj: function (hass, stateObj) {
return new window.CoverEntity(hass, stateObj);
},
onOpenTap: function () {
this.entityObj.openCover();
},
onCloseTap: function () {
this.entityObj.closeCover();
},
onStopTap: function () {
this.entityObj.stopCover();
},
});
</script>
46 changes: 2 additions & 44 deletions src/state-summary/state-card-cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">

<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">

<link rel="import" href="../components/entity/state-info.html">

<link rel='import' href='../util/cover-model.html'>
<link rel="import" href="../components/ha-cover-controls.html">

<dom-module id="state-card-cover">
<template>
Expand All @@ -15,30 +13,11 @@
:host {
line-height: 1.5;
}

.state {
text-align: right;
white-space: nowrap;
width: 127px;
}

[invisible] {
visibility: hidden !important;
}
</style>

<div class='horizontal justified layout'>
<state-info state-obj="[[stateObj]]" in-dialog='[[inDialog]]'></state-info>
<div class='state'>
<paper-icon-button icon="mdi:arrow-up" on-tap='onOpenTap'
invisible$='[[!entityObj.supportsOpen]]'
disabled='[[entityObj.isFullyOpen]]'></paper-icon-button>
<paper-icon-button icon="mdi:stop" on-tap='onStopTap'
invisible$='[[!entityObj.supportsStop]]'></paper-icon-button>
<paper-icon-button icon="mdi:arrow-down" on-tap='onCloseTap'
invisible$='[[!entityObj.supportsClose]]'
disabled='[[entityObj.isFullyClosed]]'></paper-icon-button>
</div>
<ha-cover-controls hass="[[hass]]" state-obj="[[stateObj]]"></ha-cover-controls>
</div>
</template>
</dom-module>
Expand All @@ -60,27 +39,6 @@
stateObj: {
type: Object,
},

entityObj: {
type: Object,
computed: 'computeEntityObj(hass, stateObj)',
},
},

computeEntityObj: function (hass, stateObj) {
return new window.CoverEntity(hass, stateObj);
},

onOpenTap: function () {
this.entityObj.openCover();
},

onCloseTap: function () {
this.entityObj.closeCover();
},

onStopTap: function () {
this.entityObj.stopCover();
},
});
</script>