mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
* feat: components v2 * fix: build * chore: apply formatting * refactor(components): some types * refactor(types): replace TopLevelComponents with APITopLevelComponent in REST * fix: unify components * refactor(TextDisplay): rename content method to setContent for clarity * refactor(builders): add missing builder from component * fix: touche * feat(webhook): webhook params for components v2 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
24 lines
879 B
TypeScript
24 lines
879 B
TypeScript
import { componentFactory } from '.';
|
|
import type { APISectionComponent, ComponentType } from '../types';
|
|
import { BaseComponent } from './BaseComponent';
|
|
import type { ButtonComponent } from './ButtonComponent';
|
|
import type { TextDisplayComponent } from './TextDisplay';
|
|
import type { ThumbnailComponent } from './Thumbnail';
|
|
|
|
export class SectionComponent extends BaseComponent<ComponentType.Section> {
|
|
protected _components: TextDisplayComponent[];
|
|
protected _accessory: ThumbnailComponent | ButtonComponent;
|
|
constructor(data: APISectionComponent) {
|
|
super(data);
|
|
this._components = data.components?.map(componentFactory) as TextDisplayComponent[];
|
|
this._accessory = componentFactory(data.accessory) as ThumbnailComponent | ButtonComponent;
|
|
}
|
|
get components() {
|
|
return this._components;
|
|
}
|
|
|
|
get accessory() {
|
|
return this._accessory;
|
|
}
|
|
}
|