Skip to content

Commit

Permalink
WIP: demo theme
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonailea committed Jul 9, 2024
1 parent 2c85573 commit 49e36d3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/calcite-components/src/demos/_assets/demo-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class DemoTheme extends HTMLElement {
const slot = document.createElement("slot");
shadow.append(slot);
this._slot = slot;
this._el = this._slot.assignedNodes()[0] as HTMLElement;
if (this._slot.assignedNodes().length === 1 && this._slot.assignedNodes()[0].nodeName.includes("calcite")) {
this._el = this._slot.assignedNodes()[0] as HTMLElement;
}
}

attributeChangedCallback(name: string, oldValue: string, newValue: string): void {
Expand Down Expand Up @@ -79,7 +81,11 @@ export class DemoTheme extends HTMLElement {
})
.join(" ");

this._el.style.cssText = stringifiedTheme;
if (this._el) {
this._el.style.cssText = stringifiedTheme;
} else {
this.setAttribute("style", stringifiedTheme);
}
}
}
}
Expand Down

0 comments on commit 49e36d3

Please sign in to comment.