Skip to content

Commit

Permalink
Emit a componentLoad event from swirl-card (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
matvlaovi-flip authored Dec 18, 2024
1 parent da19b5b commit 7d3fd46
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/stale-tigers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@getflip/swirl-components": minor
"@getflip/swirl-components-angular": minor
"@getflip/swirl-components-react": minor
---

Emit a componentLoad event from swirl-card
16 changes: 16 additions & 0 deletions packages/swirl-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,10 @@ export interface SwirlBannerCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLSwirlBannerElement;
}
export interface SwirlCardCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLSwirlCardElement;
}
export interface SwirlCarouselCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLSwirlCarouselElement;
Expand Down Expand Up @@ -2795,7 +2799,18 @@ declare global {
prototype: HTMLSwirlButtonGroupElement;
new (): HTMLSwirlButtonGroupElement;
};
interface HTMLSwirlCardElementEventMap {
"componentLoad": void;
}
interface HTMLSwirlCardElement extends Components.SwirlCard, HTMLStencilElement {
addEventListener<K extends keyof HTMLSwirlCardElementEventMap>(type: K, listener: (this: HTMLSwirlCardElement, ev: SwirlCardCustomEvent<HTMLSwirlCardElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLSwirlCardElementEventMap>(type: K, listener: (this: HTMLSwirlCardElement, ev: SwirlCardCustomEvent<HTMLSwirlCardElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
var HTMLSwirlCardElement: {
prototype: HTMLSwirlCardElement;
Expand Down Expand Up @@ -6034,6 +6049,7 @@ declare namespace LocalJSX {
"isBorderless"?: boolean;
"justifyContent"?: SwirlCardJustifyContent;
"linkTarget"?: string;
"onComponentLoad"?: (event: SwirlCardCustomEvent<void>) => void;
"overflow"?: SwirlCardOverflow;
"padding"?: SwirlCardPadding;
"paddingBlockEnd"?: SwirlCardPadding;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
Component,
Element,
Event,
EventEmitter,
h,
Host,
Method,
Expand Down Expand Up @@ -75,6 +77,8 @@ export class SwirlCard {
@Prop() swirlAriaLabel?: string;
@Prop() swirlAriaLabelledby?: string;

@Event() componentLoad: EventEmitter<void>;

@State() flashing = false;

private flashingTimeout?: NodeJS.Timeout;
Expand All @@ -96,6 +100,10 @@ export class SwirlCard {
}, duration);
}

componentDidLoad() {
this.componentLoad.emit();
}

render() {
const Tag = Boolean(this.href) ? "a" : this.as;

Expand Down

0 comments on commit 7d3fd46

Please sign in to comment.