Optimize cards for horizontal stack (#5254)

This commit is contained in:
Bram Kragten 2020-03-21 15:59:30 +01:00 committed by GitHub
parent 02e01626f5
commit eed3263c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 42 deletions

View File

@ -228,6 +228,9 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
text-align: center; text-align: center;
padding: 4% 0; padding: 4% 0;
font-size: 1.2rem; font-size: 1.2rem;
height: 100%;
box-sizing: border-box;
justify-content: center;
} }
ha-card:focus { ha-card:focus {

View File

@ -185,6 +185,9 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
static get styles(): CSSResult { static get styles(): CSSResult {
return css` return css`
ha-card {
height: 100%;
}
.card-header { .card-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -249,6 +249,12 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
ha-card { ha-card {
cursor: pointer; cursor: pointer;
padding: 16px 16px 0 16px; padding: 16px 16px 0 16px;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
justify-content: center;
align-items: center;
} }
ha-card:focus { ha-card:focus {
outline: none; outline: none;
@ -259,8 +265,6 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
height: calc(var(--base-unit) * 2); height: calc(var(--base-unit) * 2);
overflow: hidden; overflow: hidden;
position: relative; position: relative;
text-align: center;
margin: auto;
} }
.gauge-a { .gauge-a {
position: absolute; position: absolute;

View File

@ -116,21 +116,25 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
tabindex="0" tabindex="0"
></paper-icon-button> ></paper-icon-button>
<div class="content">
<div id="controls"> <div id="controls">
<div id="slider"> <div id="slider">
${supportsFeature(stateObj, SUPPORT_BRIGHTNESS)
? html`
<round-slider <round-slider
min="0" min="0"
.value=${brightness} .value=${brightness}
@value-changing=${this._dragEvent} @value-changing=${this._dragEvent}
@value-changed=${this._setBrightness} @value-changed=${this._setBrightness}
style=${styleMap({
visibility: supportsFeature(stateObj, SUPPORT_BRIGHTNESS)
? "visible"
: "hidden",
})}
></round-slider> ></round-slider>
`
: ""}
<paper-icon-button <paper-icon-button
class="light-button ${classMap({ class="light-button ${classMap({
"slider-center": supportsFeature(
stateObj,
SUPPORT_BRIGHTNESS
),
"state-on": stateObj.state === "on", "state-on": stateObj.state === "on",
"state-unavailable": stateObj.state === "unavailable", "state-unavailable": stateObj.state === "unavailable",
})}" })}"
@ -151,6 +155,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
</div> </div>
${this._config.name || computeStateName(stateObj)} ${this._config.name || computeStateName(stateObj)}
</div> </div>
</div>
</ha-card> </ha-card>
`; `;
} }
@ -256,6 +261,8 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
} }
ha-card { ha-card {
height: 100%;
box-sizing: border-box;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
text-align: center; text-align: center;
@ -273,6 +280,13 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
z-index: 25; z-index: 25;
} }
.content {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
#controls { #controls {
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -298,13 +312,6 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
color: var(--paper-item-icon-color, #44739e); color: var(--paper-item-icon-color, #44739e);
width: 60%; width: 60%;
height: auto; height: auto;
position: absolute;
max-width: calc(100% - 40px);
box-sizing: border-box;
border-radius: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} }
.light-button.state-on { .light-button.state-on {
@ -315,9 +322,17 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
color: var(--state-icon-unavailable-color); color: var(--state-icon-unavailable-color);
} }
.slider-center {
position: absolute;
max-width: calc(100% - 40px);
box-sizing: border-box;
border-radius: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#info { #info {
display: flex-vertical;
justify-content: center;
text-align: center; text-align: center;
margin-top: -56px; margin-top: -56px;
padding: 16px; padding: 16px;