Skip to content

Commit

Permalink
Remove auto height
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Jul 3, 2024
1 parent 1ee3916 commit 0549e33
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
7 changes: 2 additions & 5 deletions src/components/ha-grid-size-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class HaGridSizeEditor extends LitElement {
const rowMax = this.rowMax ?? this.rows;
const columnMin = this.columnMin ?? 1;
const columnMax = this.columnMax ?? this.columns;
const rowValue = autoHeight ? this.rowMin ?? 1 : this._localValue?.rows;
const rowValue = autoHeight ? rowMin : this._localValue?.rows;
const columnValue = this._localValue?.columns;

return html`
Expand Down Expand Up @@ -128,7 +128,7 @@ export class HaGridSizeEditor extends LitElement {
`;
})}
</div>
<div class="selected ${autoHeight ? "auto-height" : ""}">
<div class="selected">
<div class="cell"></div>
</div>
</div>
Expand Down Expand Up @@ -235,9 +235,6 @@ export class HaGridSizeEditor extends LitElement {
grid-row: 1 / span var(--rows, 0);
opacity: 0.5;
}
.selected.auto-height .cell {
opacity: 0.2;
}
`,
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ export class HaGridLayoutSlider extends LitElement {
:host(:disabled) .handle:after {
background: var(--disabled-color);
}
:host(:disabled) .active {
background: var(--disabled-color);
}
.pressed .handle {
transition: none;
}
Expand Down
34 changes: 0 additions & 34 deletions src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,44 +136,10 @@ export class HuiCardLayoutEditor extends LitElement {
.columnMin=${options.grid_min_columns}
.columnMax=${options.grid_max_columns}
></ha-grid-size-picker>
<ha-settings-row two-line>
<span slot="heading"
>${this.hass.localize(
"ui.panel.lovelace.editor.edit_card.layout.auto_height"
)}</span
>
<span slot="description">
${this.hass.localize(
"ui.panel.lovelace.editor.edit_card.layout.auto_height_description"
)}
</span>
<ha-switch
@change=${this._autoChanged}
.checked=${sizeValue.rows === "auto"}
>
</ha-switch>
</ha-settings-row>
`}
`;
}

private _autoChanged(ev: Event) {
const checked = (ev.target as any).checked;

const defaultRows =
typeof this._defaultLayoutOptions?.grid_rows === "number"
? this._defaultLayoutOptions.grid_rows
: 1;
const newConfig: LovelaceCardConfig = {
...this.config,
layout_options: {
...this.config.layout_options,
grid_rows: checked ? "auto" : defaultRows,
},
};
fireEvent(this, "value-changed", { value: newConfig });
}

protected firstUpdated(changedProps: PropertyValues<this>): void {
super.firstUpdated(changedProps);
try {
Expand Down
4 changes: 1 addition & 3 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5551,9 +5551,7 @@
"explanation": "The card will be shown when ALL conditions below are fulfilled. If no conditions are set, the card will always be shown."
},
"layout": {
"explanation": "Configure how the card will appear on the dashboard. This settings will override the default size and position of the card.",
"auto_height": "Auto height",
"auto_height_description": "The card will ignore the grid and will adjust its height to fit its content."
"explanation": "Configure how the card will appear on the dashboard. This settings will override the default size and position of the card."
}
},
"move_card": {
Expand Down

0 comments on commit 0549e33

Please sign in to comment.