import * as interfaces from './interfaces';
import {
DeesElement,
TemplateResult,
property,
customElement,
html,
} from '@designestate/dees-element';
@customElement('deap-mainselector')
export class DeapMainselector extends DeesElement {
public static demo = () => html``;
// INSTANCE
@property()
public selectionOptions: interfaces.ISelectionOption[] = [
{
key: 'option 1',
action: () => {},
},
{ key: 'option 2', action: () => {} },
{ key: 'option 3', action: () => {} },
{ key: 'option 4', action: () => {} },
];
@property()
public selectedOption: interfaces.ISelectionOption = null;
public render(): TemplateResult {
return html`
${this.selectionOptions.map((selectionOptionArg) => {
return html`
{
this.selectOption(selectionOptionArg);
}}"
>
${selectionOptionArg.key}
`;
})}
`;
}
private selectOption(optionArg: interfaces.ISelectionOption) {
this.selectedOption = optionArg;
this.selectedOption.action();
}
firstUpdated() {
this.selectOption(this.selectionOptions[0]);
}
}