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;
padding: 4% 0;
font-size: 1.2rem;
height: 100%;
box-sizing: border-box;
justify-content: center;
}
ha-card:focus {

View File

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

View File

@ -249,6 +249,12 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
ha-card {
cursor: pointer;
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 {
outline: none;
@ -259,8 +265,6 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
height: calc(var(--base-unit) * 2);
overflow: hidden;
position: relative;
text-align: center;
margin: auto;
}
.gauge-a {
position: absolute;

View File

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