Skip to content

Commit

Permalink
perf(cta): lazy-load icon dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Jun 17, 2024
1 parent 6474df5 commit 879dfb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changeset/few-buckets-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-cta>`: lazy-load the icon component dependency
9 changes: 7 additions & 2 deletions elements/rh-cta/rh-cta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { colorContextConsumer, type ColorTheme } from '../../lib/context/color/c

import style from './rh-cta.css';

import '@patternfly/elements/pf-icon/pf-icon.js';

export interface CtaData {
href?: string;
text?: string;
Expand Down Expand Up @@ -147,6 +145,13 @@ export class RhCta extends LitElement {

#logger = new Logger(this);

protected override async getUpdateComplete(): Promise<boolean> {
if (this.icon) {
await import('@patternfly/elements/pf-icon/pf-icon.js');
}
return super.getUpdateComplete();
}

get #isDefault(): boolean {
return !this.hasAttribute('variant');
}
Expand Down

0 comments on commit 879dfb7

Please sign in to comment.