Skip to content

Commit

Permalink
Merge pull request #460 from flixlix/439-spacing-between-icon-and-sec…
Browse files Browse the repository at this point in the history
…ondary_info-entity-on-the-grid-is-smaller-than-other-similar-locations

refactor: 🎨 use gap instead of random padding-top/bottom
  • Loading branch information
flixlix authored Jan 15, 2024
2 parents b3b0c2b + 3c12ced commit 8f8e440
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 45 deletions.
5 changes: 0 additions & 5 deletions src/components/battery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ export const batteryElement = (
: null}
<ha-icon
.icon=${battery.icon}
style=${entities.battery?.display_state === "two_way"
? "padding-top: 0px; padding-bottom: 2px;"
: entities.battery?.display_state === "one_way_no_zero" && battery.state.toBattery === 0 && battery.state.fromBattery === 0
? "padding-top: 2px; padding-bottom: 0px;"
: "padding-top: 2px; padding-bottom: 2px;"}
@click=${(e: { stopPropagation: () => void }) => {
main.openDetails(e, entities.battery?.state_of_charge!);
}}
Expand Down
5 changes: 0 additions & 5 deletions src/components/individualLeftBottomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ export const individualLeftBottomElement = (
<ha-icon
id="individual-left-bottom-icon"
.icon=${individualObj?.icon}
style="${individualObj?.secondary?.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${individualObj?.field?.display_zero_state !== false ||
(individualObj?.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? "padding-bottom: 2px;"
: "padding-bottom: 0px;"}"
></ha-icon>
${individualObj?.field?.display_zero_state !== false || (individualObj?.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? html` <span class="individual-bottom individual-left-top"
Expand Down
9 changes: 1 addition & 8 deletions src/components/individualLeftTopElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ export const individualLeftTopElement = (
}}
>
${individualSecondarySpan(main.hass, main, templatesObj, individualObj, 0, "left-top")}
<ha-icon
id="individual-left-top-icon"
.icon=${individualObj.icon}
style="${individualObj?.secondary?.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? "padding-bottom: 2px;"
: "padding-bottom: 0px;"}"
></ha-icon>
<ha-icon id="individual-left-top-icon" .icon=${individualObj.icon}></ha-icon>
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? html` <span class="individual-top individual-left-top">
${individualObj?.showDirection
Expand Down
9 changes: 1 addition & 8 deletions src/components/individualRightBottomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ export const individualRightBottomElement = (
}}
>
${individualSecondarySpan(main.hass, main, templatesObj, individualObj, 3, "right-bottom")}
<ha-icon
id="individual-right-bottom-icon"
.icon=${individualObj.icon}
style="${individualObj?.secondary?.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? "padding-bottom: 2px;"
: "padding-bottom: 0px;"}"
></ha-icon>
<ha-icon id="individual-right-bottom-icon" .icon=${individualObj.icon}></ha-icon>
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? html` <span class="individual-bottom individual-right-bottom">
${individualObj?.showDirection
Expand Down
5 changes: 1 addition & 4 deletions src/components/individualRightTopElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ export const individualRightTopElement = (
<ha-icon
id="individual-right-top-icon"
.icon=${individualObj.icon}
style="${individualObj?.secondary?.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? "padding-bottom: 2px;"
: "padding-bottom: 0px;"}"
></ha-icon>
${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0)
? html` <span class="individual-top individual-right-top">
Expand Down
10 changes: 1 addition & 9 deletions src/components/nonFossil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ export const nonFossilElement = (
}}
>
${generalSecondarySpan(main.hass, main, templatesObj, nonFossil, "low-carbon")}
<ha-icon
.icon=${nonFossil.icon}
class="low-carbon"
style="${nonFossil.secondary.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${entities.fossil_fuel_percentage?.display_zero_state !== false ||
(nonFossil.state.power || 0) > (entities.fossil_fuel_percentage?.display_zero_tolerance || 0)
? "padding-bottom: 2px;"
: "padding-bottom: 0px;"}"
></ha-icon>
<ha-icon .icon=${nonFossil.icon} class="low-carbon"></ha-icon>
${entities.fossil_fuel_percentage?.display_zero_state !== false ||
(nonFossil.state.power || 0) > (entities.fossil_fuel_percentage?.display_zero_tolerance || 0)
? html`
Expand Down
7 changes: 1 addition & 6 deletions src/components/solar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ export const solarElement = (
}}
>
${generalSecondarySpan(main.hass, main, templatesObj, solar, "solar")}
<ha-icon
id="solar-icon"
.icon=${solar.icon}
style="${solar.secondary.has ? "padding-top: 2px;" : "padding-top: 0px;"}
${entities.solar?.display_zero_state !== false || (solar.state.total || 0) > 0 ? "padding-bottom: 2px;" : "padding-bottom: 0px;"}"
></ha-icon>
<ha-icon id="solar-icon" .icon=${solar.icon}></ha-icon>
${entities.solar?.display_zero_state !== false || (solar.state.total || 0) > 0
? html` <span class="solar"> ${displayValue(main.hass, solar.state.total as number)}</span>`
: ""}
Expand Down
1 change: 1 addition & 0 deletions src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const styles = css`
position: relative;
text-decoration: none;
color: var(--primary-text-color);
gap: 2px;
// background-color: var(--card-background-color); /* hide overflowing lines behind background */
}
Expand Down

0 comments on commit 8f8e440

Please sign in to comment.