Skip to content

Commit

Permalink
feat(core): added catLoad event to cat-card, emits when component was…
Browse files Browse the repository at this point in the history
… fully rendered and loaded (#515)

Co-authored-by: anastasiia_glushkova <[email protected]>
  • Loading branch information
glushkova91 and anastasiia_glushkova authored May 16, 2024
1 parent dbe40d2 commit 7b079ce
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion angular/projects/catalyst/src/lib/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,16 @@ export class CatCard {
) {
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['catLoad']);
}
}

export declare interface CatCard extends Components.CatCard {}
export declare interface CatCard extends Components.CatCard {
/**
* Emitted when the card and all the children are fully loaded.
*/
catLoad: EventEmitter<CustomEvent<FocusEvent>>;
}

@ProxyCmp({
inputs: [
Expand Down
19 changes: 19 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,10 @@ export interface CatButtonCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCatButtonElement;
}
export interface CatCardCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCatCardElement;
}
export interface CatCheckboxCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLCatCheckboxElement;
Expand Down Expand Up @@ -1672,11 +1676,22 @@ declare global {
prototype: HTMLCatButtonGroupElement;
new (): HTMLCatButtonGroupElement;
};
interface HTMLCatCardElementEventMap {
"catLoad": FocusEvent;
}
/**
* Cards are surfaces that display content and actions on a single topic. They
* should be easy to scan for relevant and actionable information.
*/
interface HTMLCatCardElement extends Components.CatCard, HTMLStencilElement {
addEventListener<K extends keyof HTMLCatCardElementEventMap>(type: K, listener: (this: HTMLCatCardElement, ev: CatCardCustomEvent<HTMLCatCardElementEventMap[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 HTMLCatCardElementEventMap>(type: K, listener: (this: HTMLCatCardElement, ev: CatCardCustomEvent<HTMLCatCardElementEventMap[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 HTMLCatCardElement: {
prototype: HTMLCatCardElement;
Expand Down Expand Up @@ -2345,6 +2360,10 @@ declare namespace LocalJSX {
* should be easy to scan for relevant and actionable information.
*/
interface CatCard {
/**
* Emitted when the card and all the children are fully loaded.
*/
"onCatLoad"?: (event: CatCardCustomEvent<FocusEvent>) => void;
}
/**
* Checkboxes are used to let a user choose one or more options from a limited
Expand Down
11 changes: 10 additions & 1 deletion core/src/components/cat-card/cat-card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, h } from '@stencil/core';
import { Component, Event, EventEmitter, h } from '@stencil/core';

/**
* Cards are surfaces that display content and actions on a single topic. They
Expand All @@ -10,7 +10,16 @@ import { Component, h } from '@stencil/core';
shadow: true
})
export class CatCard {
/**
* Emitted when the card and all the children are fully loaded.
*/
@Event() catLoad!: EventEmitter<FocusEvent>;

render() {
return <slot></slot>;
}

componentDidLoad() {
this.catLoad.emit();
}
}
7 changes: 7 additions & 0 deletions core/src/components/cat-card/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
Cards are surfaces that display content and actions on a single topic. They
should be easy to scan for relevant and actionable information.

## Events

| Event | Description | Type |
| --------- | ------------------------------------------------------------ | ------------------------- |
| `catLoad` | Emitted when the card and all the children are fully loaded. | `CustomEvent<FocusEvent>` |


----------------------------------------------

Made with love in Hamburg, Germany
4 changes: 3 additions & 1 deletion vue/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export const CatButtonGroup = /*@__PURE__*/ defineContainer<JSX.CatButtonGroup>(
]);


export const CatCard = /*@__PURE__*/ defineContainer<JSX.CatCard>('cat-card', undefined);
export const CatCard = /*@__PURE__*/ defineContainer<JSX.CatCard>('cat-card', undefined, [
'catLoad'
]);


export const CatCheckbox = /*@__PURE__*/ defineContainer<JSX.CatCheckbox>('cat-checkbox', undefined, [
Expand Down

0 comments on commit 7b079ce

Please sign in to comment.