Skip to content
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

Fix vertical card editor #167

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix vertical card editor (#165)
Signed-off-by: Konrad Vité <kvite@paktolos.net>
kgraefe authored Dec 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7d27cc2de865fcd9757f9ef369791abfe208b466
14 changes: 12 additions & 2 deletions vertical-stack-in-card.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
console.log(`%cvertical-stack-in-card\n%cVersion: ${'0.4.4'}`, 'color: #1976d2; font-weight: bold;', '');

const HELPERS = window.loadCardHelpers ? window.loadCardHelpers() : undefined;

class VerticalStackInCard extends HTMLElement {
constructor() {
super();
@@ -181,8 +183,16 @@ class VerticalStackInCard extends HTMLElement {
return sizes.reduce((a, b) => a + b, 0);
}

static getConfigElement() {
return customElements.get('hui-vertical-stack-card').getConfigElement();
static async getConfigElement() {
// Ensure hui-card-element-editor and hui-card-picker are loaded.
// They happen to be used by the vertical-stack card editor but there must be a better way?
let cls = customElements.get('hui-vertical-stack-card');
if (!cls) {
(await HELPERS).createCardElement({ type: 'vertical-stack', cards: [] });
await customElements.whenDefined('hui-vertical-stack-card');
cls = customElements.get('hui-vertical-stack-card');
}
return cls.getConfigElement();
}

static getStubConfig() {