Add support for brand images (#13930)

This commit is contained in:
Bram Kragten 2022-09-30 14:50:01 +02:00 committed by GitHub
parent cd8c1f42ca
commit b9395e1c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -385,7 +385,11 @@ class AddIntegrationDialog extends LitElement {
return html``;
}
return html`
<ha-integration-list-item .hass=${this.hass} .integration=${integration}>
<ha-integration-list-item
brand
.hass=${this.hass}
.integration=${integration}
>
</ha-integration-list-item>
`;
};

View File

@ -22,6 +22,8 @@ export class HaIntegrationListItem extends ListItemBase {
@property({ type: Boolean }) hasMeta = true;
@property({ type: Boolean }) brand = false;
renderSingleLine() {
if (!this.integration) {
return html``;
@ -51,6 +53,7 @@ export class HaIntegrationListItem extends ListItemBase {
type: "icon",
useFallback: true,
darkOptimized: this.hass.themes?.darkMode,
brand: this.brand,
})}
referrerpolicy="no-referrer"
/>

View File

@ -3,6 +3,7 @@ export interface BrandsOptions {
type: "icon" | "logo" | "icon@2x" | "logo@2x";
useFallback?: boolean;
darkOptimized?: boolean;
brand?: boolean;
}
export interface HardwareBrandsOptions {
@ -13,9 +14,11 @@ export interface HardwareBrandsOptions {
}
export const brandsUrl = (options: BrandsOptions): string =>
`https://brands.home-assistant.io/${options.useFallback ? "_/" : ""}${
options.domain
}/${options.darkOptimized ? "dark_" : ""}${options.type}.png`;
`https://brands.home-assistant.io/${options.brand ? "brands/" : ""}${
options.useFallback ? "_/" : ""
}${options.domain}/${options.darkOptimized ? "dark_" : ""}${
options.type
}.png`;
export const hardwareBrandsUrl = (options: HardwareBrandsOptions): string =>
`https://brands.home-assistant.io/hardware/${options.category}/${