Skip to content

Commit

Permalink
Remove ha-icon usage (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Oct 9, 2021
1 parent 7b8c2c0 commit f723e71
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 216 deletions.
2 changes: 1 addition & 1 deletion homeassistant-frontend
Submodule homeassistant-frontend updated 76 files
+1 −0 .eslintrc.json
+7 −0 build-scripts/bundle.js
+0 −2 build-scripts/gulp/hassio.js
+1 −0 build-scripts/gulp/webpack.js
+7 −0 demo/src/stubs/area_registry.ts
+7 −0 demo/src/stubs/device_registry.ts
+7 −0 demo/src/stubs/entity_registry.ts
+59 −0 demo/src/stubs/hassio_supervisor.ts
+122 −0 gallery/src/components/demo-black-white-row.ts
+139 −84 gallery/src/demos/demo-ha-form.ts
+131 −0 gallery/src/demos/demo-ha-selector.ts
+1 −1 hassio/src/addon-view/config/hassio-addon-config.ts
+3 −2 hassio/src/addon-view/info/hassio-addon-info.ts
+3 −0 package.json
+1 −1 setup.py
+60 −42 src/auth/ha-auth-flow.ts
+4 −0 src/auth/ha-authorize.ts
+2 −2 src/auth/ha-password-manager-polyfill.ts
+4 −0 src/common/config/version.ts
+6 −5 src/common/const.ts
+1 −1 src/common/translations/localize.ts
+14 −13 src/components/data-table/ha-data-table.ts
+20 −7 src/components/entity/ha-state-label-badge.ts
+0 −1 src/components/ha-chip.ts
+2 −1 src/components/ha-dialog.ts
+0 −2 src/components/ha-duration-input.ts
+37 −0 src/components/ha-form/compute-initial-ha-form-data.ts
+12 −19 src/components/ha-form/ha-form-boolean.ts
+2 −17 src/components/ha-form/ha-form-constant.ts
+43 −19 src/components/ha-form/ha-form-float.ts
+115 −60 src/components/ha-form/ha-form-integer.ts
+138 −100 src/components/ha-form/ha-form-multi_select.ts
+1 −3 src/components/ha-form/ha-form-positive_time_period_dict.ts
+55 −80 src/components/ha-form/ha-form-select.ts
+61 −34 src/components/ha-form/ha-form-string.ts
+62 −156 src/components/ha-form/ha-form.ts
+86 −0 src/components/ha-form/types.ts
+4 −1 src/components/ha-icon.ts
+8 −27 src/components/ha-label-badge.ts
+0 −2 src/components/ha-tab.ts
+1 −0 src/components/map/ha-map.ts
+3 −0 src/components/paper-time-input.js
+0 −1 src/components/user/ha-user-picker.ts
+1 −1 src/data/data_entry_flow.ts
+1 −1 src/data/device_automation.ts
+1 −1 src/data/hassio/addon.ts
+2 −2 src/data/history.ts
+1 −1 src/data/zha.ts
+1 −1 src/dialogs/config-flow/show-dialog-data-entry-flow.ts
+35 −40 src/dialogs/config-flow/step-flow-form.ts
+2 −2 src/dialogs/config-flow/styles.ts
+1 −1 src/fake_data/provide_hass.ts
+1 −1 src/layouts/hass-tabs-subpage-data-table.ts
+1 −3 src/layouts/hass-tabs-subpage.ts
+1 −1 src/mixins/lit-localize-lite-mixin.ts
+3 −1 src/panels/config/automation/ha-automation-editor.ts
+4 −1 src/panels/config/automation/manual-automation-editor.ts
+1 −1 src/panels/config/automation/trigger/ha-automation-trigger-row.ts
+3 −2 src/panels/config/scene/ha-scene-editor.ts
+3 −1 src/panels/config/script/ha-script-editor.ts
+4 −4 src/panels/developer-tools/statistics/dialog-statistics-fix-unsupported-unit-meta.ts
+5 −5 src/panels/lovelace/badges/hui-error-badge.ts
+2 −0 src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts
+18 −1 src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts
+18 −1 src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts
+18 −1 src/panels/lovelace/cards/energy/hui-energy-usage-graph-card.ts
+15 −1 src/resources/ha-style.ts
+49 −0 src/resources/styles.ts
+1 −1 src/state/connection-mixin.ts
+5 −1 src/state/translations-mixin.ts
+2 −2 src/translations/en.json
+1 −0 src/types.ts
+108 −0 src/util/common-translation.ts
+3 −2 src/util/hass-attributes-util.ts
+0 −118 src/util/hass-translation.ts
+141 −5 yarn.lock
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@
"@material/mwc-menu": "0.25.1",
"@material/mwc-radio": "0.25.1",
"@material/mwc-ripple": "0.25.1",
"@material/mwc-select": "^0.25.1",
"@material/mwc-slider": "^0.25.1",
"@material/mwc-switch": "0.25.1",
"@material/mwc-tab": "0.25.1",
"@material/mwc-tab-bar": "0.25.1",
"@material/mwc-textfield": "^0.25.1",
"@material/top-app-bar": "13.0.0-canary.65125b3a6.0",
"@mdi/js": "6.2.95",
"@mdi/svg": "6.2.95",
Expand Down
13 changes: 1 addition & 12 deletions script/gulp/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const gulp = require("gulp");
const del = require("del");
const fs = require("fs-extra");
const makeDir = require("make-dir");
require("./rollup.js");
require("./translations");

Expand All @@ -11,13 +9,4 @@ gulp.task("cleanup", (task) => {
task();
});

gulp.task("create-icon-metadata", async function (task) {
await makeDir("./homeassistant-frontend/build/mdi");
await fs.outputJson("./homeassistant-frontend/build/mdi/iconMetadata.json", {
version: "0",
parts: [],
});
task();
});

gulp.task("common", gulp.series("cleanup", "create-icon-metadata", "generate-translations"));
gulp.task("common", gulp.series("cleanup", "generate-translations"));
3 changes: 2 additions & 1 deletion script/gulp/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const outputconfig = (isDev) => {
assetFileNames: !isDev ? "a.[hash].js" : "[name]-dev.js",
entryFileNames: !isDev ? "[name]-[hash].js" : "[name]-dev.js",
format: "es",
intro: "const __DEMO__ = false;",
intro: `const __DEMO__ = false;
const __SUPERVISOR__ = true`,
};
};

Expand Down
47 changes: 30 additions & 17 deletions src/components/dialogs/hacs-add-repository-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "@polymer/paper-item/paper-item";
import { mdiGithub } from "@mdi/js";
import "@polymer/paper-item/paper-icon-item";
import "@polymer/paper-item/paper-item-body";
Expand All @@ -11,21 +12,27 @@ import "../../../homeassistant-frontend/src/components/ha-svg-icon";
import "../../../homeassistant-frontend/src/components/ha-paper-dropdown-menu";
import { Repository } from "../../data/common";
import { activePanel } from "../../panels/hacs-sections";
import { scrollBarStyle, searchStyles } from "../../styles/element-styles";
import { hacsIconStyle, scrollBarStyle, searchStyles } from "../../styles/element-styles";
import { filterRepositoriesByInput } from "../../tools/filter-repositories-by-input";
import "../hacs-chip";
import "../hacs-filter";
import { hacsIcon } from "../hacs-icon";
import "./hacs-dialog";
import { HacsDialogBase } from "./hacs-dialog-base";
import { brandsUrl } from "../../../homeassistant-frontend/src/util/brands-url";

@customElement("hacs-add-repository-dialog")
export class HacsAddRepositoryDialog extends HacsDialogBase {
@property({ attribute: false }) public filters: any = [];
@property({ type: Number }) private _load: number = 30;
@property({ type: Number }) private _top: number = 0;
@property() private _searchInput: string = "";
@property() private _sortBy: string = "stars";

@property({ type: Number }) private _load = 30;

@property({ type: Number }) private _top = 0;

@property() private _searchInput = "";

@property() private _sortBy = "stars";

@property() public section!: string;

shouldUpdate(changedProperties: PropertyValues) {
Expand Down Expand Up @@ -116,15 +123,15 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {
?narrow=${this.narrow}
>
<paper-listbox slot="dropdown-content" selected="0">
<paper-item @tap=${() => (this._sortBy = "stars")}
>${this.hacs.localize("store.stars")}</paper-item
>
<paper-item @tap=${() => (this._sortBy = "name")}
>${this.hacs.localize("store.name")}</paper-item
>
<paper-item @tap=${() => (this._sortBy = "last_updated")}
>${this.hacs.localize("store.last_updated")}</paper-item
>
<paper-item @tap=${() => (this._sortBy = "stars")}>
${this.hacs.localize("store.stars")}
</paper-item>
<paper-item @tap=${() => (this._sortBy = "name")}>
${this.hacs.localize("store.name")}
</paper-item>
<paper-item @tap=${() => (this._sortBy = "last_updated")}>
${this.hacs.localize("store.last_updated")}
</paper-item>
</paper-listbox>
</ha-paper-dropdown-menu>
</div>
Expand Down Expand Up @@ -153,7 +160,11 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {
? html`
<img
loading="lazy"
src="https://brands.home-assistant.io/_/${repo.domain}/icon.png"
.src=${brandsUrl({
domain: repo.domain,
darkOptimized: this.hass.themes.darkMode,
type: "icon",
})}
referrerpolicy="no-referrer"
@error=${this._onImageError}
@load=${this._onImageLoad}
Expand Down Expand Up @@ -215,13 +226,15 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {

private _onImageError(ev) {
if (ev.target) {
ev.target.outerHTML = `<ha-svg-icon .path=${mdiGithub} slot="item-icon"></ha-svg-icon>`;
ev.target.outerHTML = `<ha-svg-icon path="${mdiGithub}" slot="item-icon"></ha-svg-icon>`;
}
}

static get styles() {
return [
searchStyles,
scrollBarStyle,
hacsIconStyle,
css`
.content {
width: 100%;
Expand All @@ -246,7 +259,7 @@ export class HacsAddRepositoryDialog extends HacsDialogBase {
top: 8px;
right: 8px;
}
ha-icon {
ha-svg-icon {
--mdc-icon-size: 36px;
}
search-input {
Expand Down
29 changes: 18 additions & 11 deletions src/components/dialogs/hacs-custom-repositories-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "@material/mwc-button/mwc-button";
import "@polymer/paper-item/paper-item";
import { mdiDelete, mdiGithub } from "@mdi/js";
import "@polymer/paper-item/paper-icon-item";
import "@polymer/paper-item/paper-item-body";
Expand All @@ -7,15 +9,19 @@ import { customElement, property, query } from "lit/decorators";
import "../../../homeassistant-frontend/src/components/ha-svg-icon";
import "../../../homeassistant-frontend/src/components/ha-paper-dropdown-menu";
import { getRepositories, repositoryAdd, repositoryDelete } from "../../data/websocket";
import { scrollBarStyle } from "../../styles/element-styles";
import { hacsIconStyle, scrollBarStyle } from "../../styles/element-styles";
import "./hacs-dialog";
import { HacsDialogBase } from "./hacs-dialog-base";
import { brandsUrl } from "../../../homeassistant-frontend/src/util/brands-url";

@customElement("hacs-custom-repositories-dialog")
export class HacsCustomRepositoriesDialog extends HacsDialogBase {
@property() private _inputRepository: string;
@property() private _inputRepository?: string;

@property() private _error: any;

@query("#add-input") private _addInput?: any;

@query("#category") private _addCategory?: any;

shouldUpdate(changedProperties: PropertyValues) {
Expand Down Expand Up @@ -48,7 +54,11 @@ export class HacsCustomRepositoriesDialog extends HacsDialogBase {
? html`
<img
loading="lazy"
src="https://brands.home-assistant.io/_/${repo.domain}/icon.png"
.src=${brandsUrl({
domain: repo.domain,
darkOptimized: this.hass.themes.darkMode,
type: "icon",
})}
referrerpolicy="no-referrer"
@error=${this._onImageError}
@load=${this._onImageLoad}
Expand Down Expand Up @@ -147,10 +157,9 @@ export class HacsCustomRepositoriesDialog extends HacsDialogBase {
}

private _onImageError(ev) {
ev.target.outerHTML = `<ha-icon
icon="mdi:github-circle"
slot="item-icon"
></ha-icon>`;
if (ev.target) {
ev.target.outerHTML = `<ha-svg-icon path="${mdiGithub}" slot="item-icon"></ha-svg-icon>`;
}
}

private async _showReopsitoryInfo(repository: string) {
Expand All @@ -169,6 +178,7 @@ export class HacsCustomRepositoriesDialog extends HacsDialogBase {
static get styles() {
return [
scrollBarStyle,
hacsIconStyle,
css`
.content {
width: 1024px;
Expand All @@ -180,10 +190,7 @@ export class HacsCustomRepositoriesDialog extends HacsDialogBase {
max-height: 870px;
overflow: auto;
}
ha-icon {
color: var(--secondary-text-color);
}
ha-icon {
ha-svg-icon {
--mdc-icon-size: 36px;
}
img {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/element-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const hacsButtonStyle = css`

export const hacsIconStyle = css`
paper-menu-button,
ha-icon {
ha-svg-icon {
color: var(--hcv-color-icon);
}
`;
Expand Down
Loading

0 comments on commit f723e71

Please sign in to comment.