mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Ensure consistent "blank before percent" handling (#14638)
This commit is contained in:
parent
6e4a6cb0db
commit
1dbe8c9b64
@ -3,6 +3,7 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { canShowPage } from "../../../common/config/can_show_page";
|
import { canShowPage } from "../../../common/config/can_show_page";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { relativeTime } from "../../../common/datetime/relative_time";
|
import { relativeTime } from "../../../common/datetime/relative_time";
|
||||||
|
import { blankBeforePercent } from "../../../common/translations/blank_before_percent";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-navigation-list";
|
import "../../../components/ha-navigation-list";
|
||||||
import "../../../components/ha-tip";
|
import "../../../components/ha-tip";
|
||||||
@ -84,7 +85,7 @@ class HaConfigSystemNavigation extends LitElement {
|
|||||||
"percent_used",
|
"percent_used",
|
||||||
`${Math.round(
|
`${Math.round(
|
||||||
(this._storageInfo.used / this._storageInfo.total) * 100
|
(this._storageInfo.used / this._storageInfo.total) * 100
|
||||||
)}%`,
|
)}${blankBeforePercent(this.hass.locale)}%`,
|
||||||
"free_space",
|
"free_space",
|
||||||
`${this._storageInfo.free} GB`
|
`${this._storageInfo.free} GB`
|
||||||
)
|
)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import {
|
import {
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@ -7,18 +8,19 @@ import {
|
|||||||
mdiPencil,
|
mdiPencil,
|
||||||
mdiPlusCircle,
|
mdiPlusCircle,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
|
||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
import { SENSOR_ENTITIES } from "../../../common/const";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { stringCompare } from "../../../common/string/compare";
|
import { stringCompare } from "../../../common/string/compare";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
import { slugify } from "../../../common/string/slugify";
|
||||||
|
import { blankBeforePercent } from "../../../common/translations/blank_before_percent";
|
||||||
import { groupBy } from "../../../common/util/group-by";
|
import { groupBy } from "../../../common/util/group-by";
|
||||||
import "../../../components/entity/ha-battery-icon";
|
import "../../../components/entity/ha-battery-icon";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
@ -59,6 +61,7 @@ import {
|
|||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
} from "../../../dialogs/generic/show-dialog-box";
|
} from "../../../dialogs/generic/show-dialog-box";
|
||||||
import "../../../layouts/hass-error-screen";
|
import "../../../layouts/hass-error-screen";
|
||||||
|
import "../../../layouts/hass-subpage";
|
||||||
import "../../../layouts/hass-tabs-subpage";
|
import "../../../layouts/hass-tabs-subpage";
|
||||||
import { haStyle } from "../../../resources/styles";
|
import { haStyle } from "../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
@ -74,8 +77,6 @@ import {
|
|||||||
loadDeviceRegistryDetailDialog,
|
loadDeviceRegistryDetailDialog,
|
||||||
showDeviceRegistryDetailDialog,
|
showDeviceRegistryDetailDialog,
|
||||||
} from "./device-registry-detail/show-dialog-device-registry-detail";
|
} from "./device-registry-detail/show-dialog-device-registry-detail";
|
||||||
import "../../../layouts/hass-subpage";
|
|
||||||
import { SENSOR_ENTITIES } from "../../../common/const";
|
|
||||||
|
|
||||||
export interface EntityRegistryStateEntry extends EntityRegistryEntry {
|
export interface EntityRegistryStateEntry extends EntityRegistryEntry {
|
||||||
stateName?: string | null;
|
stateName?: string | null;
|
||||||
@ -639,7 +640,11 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
batteryState
|
batteryState
|
||||||
? html`
|
? html`
|
||||||
<div class="battery">
|
<div class="battery">
|
||||||
${batteryIsBinary ? "" : batteryState.state + " %"}
|
${batteryIsBinary
|
||||||
|
? ""
|
||||||
|
: batteryState.state +
|
||||||
|
blankBeforePercent(this.hass.locale) +
|
||||||
|
"%"}
|
||||||
<ha-battery-icon
|
<ha-battery-icon
|
||||||
.hass=${this.hass!}
|
.hass=${this.hass!}
|
||||||
.batteryStateObj=${batteryState}
|
.batteryStateObj=${batteryState}
|
||||||
|
@ -7,6 +7,7 @@ import memoizeOne from "memoize-one";
|
|||||||
import { HASSDomEvent } from "../../../common/dom/fire_event";
|
import { HASSDomEvent } from "../../../common/dom/fire_event";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
|
import { blankBeforePercent } from "../../../common/translations/blank_before_percent";
|
||||||
import { LocalizeFunc } from "../../../common/translations/localize";
|
import { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||||
import {
|
import {
|
||||||
@ -339,7 +340,9 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
battery && computeStateDomain(battery) === "binary_sensor";
|
battery && computeStateDomain(battery) === "binary_sensor";
|
||||||
return battery && (batteryIsBinary || !isNaN(battery.state as any))
|
return battery && (batteryIsBinary || !isNaN(battery.state as any))
|
||||||
? html`
|
? html`
|
||||||
${batteryIsBinary ? "" : battery.state + " %"}
|
${batteryIsBinary
|
||||||
|
? ""
|
||||||
|
: battery.state + blankBeforePercent(this.hass.locale) + "%"}
|
||||||
<ha-battery-icon
|
<ha-battery-icon
|
||||||
.hass=${this.hass!}
|
.hass=${this.hass!}
|
||||||
.batteryStateObj=${battery}
|
.batteryStateObj=${battery}
|
||||||
|
@ -9,6 +9,7 @@ import { ifDefined } from "lit/directives/if-defined";
|
|||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { numberFormatToLocale } from "../../../common/number/format_number";
|
import { numberFormatToLocale } from "../../../common/number/format_number";
|
||||||
import { round } from "../../../common/number/round";
|
import { round } from "../../../common/number/round";
|
||||||
|
import { blankBeforePercent } from "../../../common/translations/blank_before_percent";
|
||||||
import "../../../components/buttons/ha-progress-button";
|
import "../../../components/buttons/ha-progress-button";
|
||||||
import "../../../components/chart/ha-chart-base";
|
import "../../../components/chart/ha-chart-base";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
@ -169,7 +170,8 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
|
|||||||
max: 100,
|
max: 100,
|
||||||
min: 0,
|
min: 0,
|
||||||
stepSize: 1,
|
stepSize: 1,
|
||||||
callback: (value) => value + "%",
|
callback: (value) =>
|
||||||
|
value + blankBeforePercent(this.hass.locale) + "%",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
x: {
|
x: {
|
||||||
@ -386,7 +388,8 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
${this._systemStatusData.cpu_percent || "-"}%
|
${this._systemStatusData.cpu_percent ||
|
||||||
|
"-"}${blankBeforePercent(this.hass.locale)}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
@ -129,7 +129,7 @@ class HuiEnergyCarbonGaugeCard
|
|||||||
min="0"
|
min="0"
|
||||||
max="100"
|
max="100"
|
||||||
.value=${value}
|
.value=${value}
|
||||||
.locale=${this.hass!.locale}
|
.locale=${this.hass.locale}
|
||||||
label="%"
|
label="%"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
"--gauge-color": this._computeSeverity(value),
|
"--gauge-color": this._computeSeverity(value),
|
||||||
|
@ -108,7 +108,7 @@ class HuiEnergySolarGaugeCard
|
|||||||
min="0"
|
min="0"
|
||||||
max="100"
|
max="100"
|
||||||
.value=${value}
|
.value=${value}
|
||||||
.locale=${this.hass!.locale}
|
.locale=${this.hass.locale}
|
||||||
label="%"
|
label="%"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
"--gauge-color": this._computeSeverity(value),
|
"--gauge-color": this._computeSeverity(value),
|
||||||
|
@ -86,15 +86,17 @@ class HuiCoverOpenCloseTileFeature
|
|||||||
`
|
`
|
||||||
: null}
|
: null}
|
||||||
${supportsFeature(this.stateObj, CoverEntityFeature.STOP)
|
${supportsFeature(this.stateObj, CoverEntityFeature.STOP)
|
||||||
? html`<ha-tile-button
|
? html`
|
||||||
.label=${this.hass.localize(
|
<ha-tile-button
|
||||||
"ui.dialogs.more_info_control.cover.stop_cover"
|
.label=${this.hass.localize(
|
||||||
)}
|
"ui.dialogs.more_info_control.cover.stop_cover"
|
||||||
@click=${this._onStopTap}
|
)}
|
||||||
.disabled=${!canStop(this.stateObj)}
|
@click=${this._onStopTap}
|
||||||
>
|
.disabled=${!canStop(this.stateObj)}
|
||||||
<ha-svg-icon .path=${mdiStop}></ha-svg-icon>
|
>
|
||||||
</ha-tile-button> `
|
<ha-svg-icon .path=${mdiStop}></ha-svg-icon>
|
||||||
|
</ha-tile-button>
|
||||||
|
`
|
||||||
: null}
|
: null}
|
||||||
${supportsFeature(this.stateObj, CoverEntityFeature.CLOSE)
|
${supportsFeature(this.stateObj, CoverEntityFeature.CLOSE)
|
||||||
? html`
|
? html`
|
||||||
|
@ -80,15 +80,17 @@ class HuiCoverTiltTileFeature
|
|||||||
`
|
`
|
||||||
: null}
|
: null}
|
||||||
${supportsFeature(this.stateObj, CoverEntityFeature.STOP_TILT)
|
${supportsFeature(this.stateObj, CoverEntityFeature.STOP_TILT)
|
||||||
? html`<ha-tile-button
|
? html`
|
||||||
.label=${this.hass.localize(
|
<ha-tile-button
|
||||||
"ui.dialogs.more_info_control.cover.stop_cover"
|
.label=${this.hass.localize(
|
||||||
)}
|
"ui.dialogs.more_info_control.cover.stop_cover"
|
||||||
@click=${this._onStopTap}
|
)}
|
||||||
.disabled=${!canStopTilt(this.stateObj)}
|
@click=${this._onStopTap}
|
||||||
>
|
.disabled=${!canStopTilt(this.stateObj)}
|
||||||
<ha-svg-icon .path=${mdiStop}></ha-svg-icon>
|
>
|
||||||
</ha-tile-button> `
|
<ha-svg-icon .path=${mdiStop}></ha-svg-icon>
|
||||||
|
</ha-tile-button>
|
||||||
|
`
|
||||||
: null}
|
: null}
|
||||||
${supportsFeature(this.stateObj, CoverEntityFeature.CLOSE_TILT)
|
${supportsFeature(this.stateObj, CoverEntityFeature.CLOSE_TILT)
|
||||||
? html`
|
? html`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user