Skip to content

Commit

Permalink
Improve buttons layout (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Feb 27, 2023
1 parent f3e6828 commit 97a9ac4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/cards/climate-card/climate-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,16 @@ export class ClimateCard extends MushroomBaseCard implements LovelaceCard {
}

private renderActiveControl(entity: ClimateEntity): TemplateResult | null {
const hvac_modes = this._config?.hvac_modes ?? [];
const hvac_modes = this._config!.hvac_modes ?? [];
const appearance = computeAppearance(this._config!);

switch (this._activeControl) {
case "temperature_control":
return html`
<mushroom-climate-temperature-control
.hass=${this.hass}
.entity=${entity}
.fill=${true}
.fill=${appearance.layout !== "horizontal"}
></mushroom-climate-temperature-control>
`;
case "hvac_mode_control":
Expand All @@ -268,7 +269,7 @@ export class ClimateCard extends MushroomBaseCard implements LovelaceCard {
.hass=${this.hass}
.entity=${entity}
.modes=${hvac_modes}
.fill=${true}
.fill=${appearance.layout !== "horizontal"}
></mushroom-climate-hvac-modes-control>
`;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/cards/update-card/update-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class UpdateCard extends MushroomBaseCard implements LovelaceCard {
.hass=${this.hass}
.entity=${entity}
.fill=${appearance.layout !== "horizontal"}
/>
></mushroom-update-buttons-control>
</div>
`
: null}
Expand Down
9 changes: 7 additions & 2 deletions src/shared/button-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ export class MushroomButtonGroup extends LitElement {
margin-right: initial;
margin-left: var(--spacing);
}
.container.fill > ::slotted(*) {
flex: 1;
.container > ::slotted(*) {
width: 0;
flex-grow: 0;
flex-shrink: 1;
flex-basis: calc(var(--control-height) * var(--control-button-ratio));
}
.container.fill > ::slotted(*) {
flex-grow: 1;
}
`;
}
Expand Down

0 comments on commit 97a9ac4

Please sign in to comment.