UNPKG

blaze-2d

Version:

A fast and simple WebGL 2 2D game engine written in TypeScript

75 lines (74 loc) 2.03 kB
import BlazeElement from "./element"; import "./styles/dropdown.css"; export default class BlazeDropdown extends BlazeElement<HTMLDivElement> { private size; private selected; private options; private select; private label; /** * Callback that is called whenever the dropdown's selected option changes. */ onSelect: (selected: string) => void; /** * Create a {@link BlazeDropdown}. * * @param selected The initially selected option * @param options The options in the dropdown * @param size The dropdown's font size in `rem` units */ constructor(selected: string, options: string[], size: number); /** * Sets the dropdown's selected option. * * @param selected The dropdown's new selected option */ setSelected(selected: string): void; /** * Gets the dropdown's currently selected option. * * @returns The dropdown's currently selected option */ getSelected(): string; /** * Sets the options in the dropdown. * * @param options The dropdown's new options */ setOptions(options: string[]): void; /** * Gets the dropdown's options. * * @returns The dropdown's options */ getOptions(): string[]; /** * Adds an option to the dropdown. * * @param option The option to add */ addOption(option: string): void; /** * Sets the dropdown's font size. * * @param size The dropdown's font size in `rem` units */ setSize(size: number): void; /** * Gets the dropdown's font size. * * @returns The dropdown's font size in `rem` units */ getSize(): number; /** * Add a label above or to the side of the input. * * @param label The label's text * @param aside Wether the label is above or to the side of the input */ addLabel(label: string, aside?: boolean): void; /** * Remove the input's label. */ removeLabel(): void; }