-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Lovelace Entity Card Editor to Ha Form - Adds Theme Selector and HaFormColumn #11731
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f8caf86
Add Theme Selector
zsarnett de7a09e
Add Schema
zsarnett 138ac8d
Add Column Form
zsarnett e94bcd0
Import and make flex
zsarnett b598635
css fix
zsarnett 07e00ab
Update Value Changed
zsarnett 8301034
Fix Value Changed
zsarnett bd7e3b8
Add Place Holder and Fallback path to icon picker
zsarnett 43a233f
Change entity Card editor to use Ha-form
zsarnett 3e67d9c
Re-order
zsarnett 66180df
Fix Tab index
zsarnett 40464dc
Update to give column all the data
zsarnett e44c85b
add label to theme selector
zsarnett 30f0222
fixes + change to grid
bramkragten 87d51b0
delete empty, fix value
bramkragten 6a420c7
Update ha-selector-boolean.ts
bramkragten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,73 @@ | ||
| import "./ha-form"; | ||
| import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; | ||
| import { customElement, property } from "lit/decorators"; | ||
| import type { | ||
| HaFormGridSchema, | ||
| HaFormDataContainer, | ||
| HaFormElement, | ||
| HaFormSchema, | ||
| } from "./types"; | ||
| import type { HomeAssistant } from "../../types"; | ||
|
|
||
| @customElement("ha-form-grid") | ||
| export class HaFormGrid extends LitElement implements HaFormElement { | ||
| @property({ attribute: false }) public hass!: HomeAssistant; | ||
|
|
||
| @property({ attribute: false }) public data!: HaFormDataContainer; | ||
|
|
||
| @property({ attribute: false }) public schema!: HaFormGridSchema; | ||
|
|
||
| @property({ type: Boolean }) public disabled = false; | ||
|
|
||
| @property() public computeLabel?: ( | ||
| schema: HaFormSchema, | ||
| data?: HaFormDataContainer | ||
| ) => string; | ||
|
|
||
| @property() public computeHelper?: (schema: HaFormSchema) => string; | ||
|
|
||
| protected firstUpdated() { | ||
| this.setAttribute("own-margin", ""); | ||
| } | ||
|
|
||
| protected render(): TemplateResult { | ||
| return html` | ||
| ${this.schema.schema.map( | ||
| (item) => | ||
| html` | ||
| <ha-form | ||
| .hass=${this.hass} | ||
| .data=${this.data} | ||
| .schema=${[item]} | ||
| .disabled=${this.disabled} | ||
| .computeLabel=${this.computeLabel} | ||
| .computeHelper=${this.computeHelper} | ||
| ></ha-form> | ||
| ` | ||
| )} | ||
| `; | ||
| } | ||
|
|
||
| static get styles(): CSSResultGroup { | ||
| return css` | ||
| :host { | ||
| display: grid !important; | ||
| grid-template-columns: repeat( | ||
| var(--form-grid-column-count, auto-fit), | ||
| minmax(var(--form-grid-min-width, 200px), 1fr) | ||
| ); | ||
| grid-gap: 8px; | ||
| } | ||
| :host > ha-form { | ||
| display: block; | ||
| margin-bottom: 24px; | ||
| } | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "ha-form-grid": HaFormGrid; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,34 @@ | ||
| import "../../panels/lovelace/components/hui-theme-select-editor"; | ||
| import { html, LitElement } from "lit"; | ||
| import { customElement, property } from "lit/decorators"; | ||
| import type { HomeAssistant } from "../../types"; | ||
| import type { ThemeSelector } from "../../data/selector"; | ||
|
|
||
| @customElement("ha-selector-theme") | ||
| export class HaThemeSelector extends LitElement { | ||
| @property({ attribute: false }) public hass!: HomeAssistant; | ||
|
|
||
| @property({ attribute: false }) public selector!: ThemeSelector; | ||
|
|
||
| @property() public value?: string; | ||
|
|
||
| @property() public label?: string; | ||
|
|
||
| @property({ type: Boolean, reflect: true }) public disabled = false; | ||
|
|
||
| protected render() { | ||
| return html` | ||
| <hui-theme-select-editor | ||
| .hass=${this.hass} | ||
| .value=${this.value} | ||
| .label=${this.label} | ||
| ></hui-theme-select-editor> | ||
| `; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "ha-selector-theme": HaThemeSelector; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use a
huielement here, but let's do that in a later PR