Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 🎨 use gap instead of random padding-top/bottom #460

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading