Skip to content

Control modification for cover#298

Merged
balloob merged 9 commits into
home-assistant:masterfrom
cribbstechnologies:master
Jun 18, 2017
Merged

Control modification for cover#298
balloob merged 9 commits into
home-assistant:masterfrom
cribbstechnologies:master

Conversation

@cribbstechnologies
Copy link
Copy Markdown
Contributor

Modifying cover card to have up/down and/or tilt controls on the face of the card.

Relies on home-assistant/core#7841

@emlove
Copy link
Copy Markdown
Contributor

emlove commented May 31, 2017

Can you attach some screenshots of different configurations? I.e. An entity that only supports open/close, an entity that only tilts, one that does both. Also be sure to check a small width card. (Mobile)

@cribbstechnologies
Copy link
Copy Markdown
Contributor Author

cribbstechnologies commented May 31, 2017 via email

@cribbstechnologies
Copy link
Copy Markdown
Contributor Author

@armills here are the screenshots
screenshot_20170531-105748
Android on a Nexus 6

image
Chrome

@emlove
Copy link
Copy Markdown
Contributor

emlove commented May 31, 2017

OK, thanks.

So I think we should only show one set of controls on the state card. It's too crowded otherwise. I think what we should do is if there are tilt controls but no cover controls, we show the tilt controls. Otherwise we only show the cover controls. I believe this was the original use case, right?

.has-close_tilt .tilt,
.has-stop_tilt .tilt,
{
max-height: 40px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The max-height classes here are redundant with the invisible attribute. We use max-height on the more info dialog so that hidden controls collapse vertically, but here the buttons should just occupy their space anyway, so visibility is enough.

@cribbstechnologies
Copy link
Copy Markdown
Contributor Author

No. Original case was that only cover controls were shown and configuration was required. Tilt controls were only shown on the more-info card.

I'd definitely need some more guidance/help if the either/or situation was put in place. The controls are separate components now and I have no idea how I'd keep them logically separated if they had to "know" if the other were shown or not. The same goes for the more info card; there would have to be logic here to put the tilt controls into the body of the card if they weren't in the header.

@emlove
Copy link
Copy Markdown
Contributor

emlove commented May 31, 2017

I think it shouldn't be too bad. What I'm thinking is in state-card-cover, you can make use of the polymer hidden attribute. (Example). You could have the cover controls be hidden$='[[!computeOnlyTilt(stateObj)]]' and the tilt controls be hidden$='[[computeOnlyTilt(stateObj)]]', where computeOnlyTilt checks if any of the tilt supported_features are set, and none of the normal cover supported_features are set. I don't think we need to change the more-info.

Comment thread src/util/cover-model.html Outdated
var openClasses = [
window.hassUtil.featureClassNames(stateObj, this.openFeatureClassNames),
];
var openClassString = openClasses.join(' ').trim();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is pretty clever, but I think we should only be doing integer or logical checking here rather than generating these strings, joining them, and looking for an empty string. I'm thinking something along these lines.

var supportsCover = this.supportsOpen || this.supportsClose || this.supportsStop;
var supportsTilt = this.supportsOpenTilt || this.supportsCloseTilt || this.supportsStopTilt;
return supportsTilt && !supportsCover;

or

var supportsCover = this.stateObj.attributes.supported_features & 11; //where 11 is in a constant somewhere

Copy link
Copy Markdown
Contributor

@emlove emlove left a comment

Choose a reason for hiding this comment

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

Code LGTM. Do you mind updating the screenshots to reflect the latest code?

@cribbstechnologies
Copy link
Copy Markdown
Contributor Author

cribbstechnologies commented May 31, 2017 via email

@emlove
Copy link
Copy Markdown
Contributor

emlove commented May 31, 2017

Either way is fine.

@cribbstechnologies
Copy link
Copy Markdown
Contributor Author

From top to bottom:
open/close only
Tilt only
open/close and tilt
image

More info for tilt only
image

More info for open/close and tilt
image

@balloob
Copy link
Copy Markdown
Member

balloob commented Jun 2, 2017

So just coming in here to say that 3 buttons is the max that fits in a state info but it seems like you already fixed that 👍

@balloob balloob merged commit 37098f8 into home-assistant:master Jun 18, 2017
tkdrob pushed a commit to tkdrob/frontend that referenced this pull request Apr 20, 2021
Grammatical changes for the English language.

Co-authored-by: Daniel Shokouhi <dshokouhi@gmail.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants