UNPKG

@zeix/ui-element

Version:

UIElement - a HTML-first library for reactive Web Components

33 lines (28 loc) 554 B
import { type Component, asEnum, component, setText, toggleClass, } from '../../..' export type BasicStatusProps = { status: string } const STATUS_OPTIONS: [string, ...string[]] = ['success', 'warning', 'error'] export default component( 'basic-status', { status: asEnum(STATUS_OPTIONS), }, el => [ setText('status'), ...STATUS_OPTIONS.map(status => toggleClass<BasicStatusProps>(status, () => el.status === status), ), ], ) declare global { interface HTMLElementTagNameMap { 'basic-status': Component<BasicStatusProps> } }