entlib
Version:
Entry API Wrapper
46 lines (41 loc) • 1.12 kB
text/typescript
import { Parser } from "./Parser"
import { Block } from "./Block"
import { executeAction, Action } from "./Action"
export interface ButtonParam {
template: string
textColor: string
action: Action
align: 'center' | 'left' | 'right'
}
export class Button extends Block {
public align: 'center' | 'left' | 'right'
constructor({
template,
textColor = 'default',
action,
align = 'center'
}: ButtonParam) {
super({
template,
color: textColor,
action
})
this.align = align
}
public export(parser: Parser, name: string) {
const ret = parser.parseButton({
textColor: this.color,
text: this.template,
align: this.align,
action: async (event: any) => {
return await executeAction(this.action, null, null, { event })
},
name,
className: this.className,
})
return {
...ret,
dynamics: {}
}
}
}