-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
310 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
mdiHome, | ||
mdiHomeFloor0, | ||
mdiHomeFloor1, | ||
mdiHomeFloor2, | ||
mdiHomeFloor3, | ||
mdiHomeFloorNegative1, | ||
} from "@mdi/js"; | ||
import { LitElement, html } from "lit"; | ||
import { customElement, property } from "lit/decorators"; | ||
import { FloorRegistryEntry } from "../data/floor_registry"; | ||
import "./ha-icon"; | ||
import "./ha-svg-icon"; | ||
|
||
export const floorDefaultIconPath = ( | ||
floor: Pick<FloorRegistryEntry, "level"> | ||
) => { | ||
switch (floor.level) { | ||
case 0: | ||
return mdiHomeFloor0; | ||
case 1: | ||
return mdiHomeFloor1; | ||
case 2: | ||
return mdiHomeFloor2; | ||
case 3: | ||
return mdiHomeFloor3; | ||
case -1: | ||
return mdiHomeFloorNegative1; | ||
} | ||
return mdiHome; | ||
}; | ||
|
||
@customElement("ha-floor-icon") | ||
export class HaFloorIcon extends LitElement { | ||
@property({ attribute: false }) public floor!: Pick< | ||
FloorRegistryEntry, | ||
"icon" | "level" | ||
>; | ||
|
||
@property() public icon?: string; | ||
|
||
protected render() { | ||
if (this.floor.icon) { | ||
return html`<ha-icon .icon=${this.floor.icon}></ha-icon>`; | ||
} | ||
const defaultPath = floorDefaultIconPath(this.floor); | ||
|
||
return html`<ha-svg-icon .path=${defaultPath}></ha-svg-icon>`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
"ha-floor-icon": HaFloorIcon; | ||
} | ||
} |
Oops, something went wrong.