/** * Copyright Aquera Inc 2023 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import { LitElement, html, CSSResultArray, TemplateResult, } from 'lit'; import { styles } from './nile-badge.css'; import '../nile-icon-button/nile-icon-button'; import { classMap } from 'lit/directives/class-map.js'; import { customElement, property } from 'lit/decorators.js'; import NileElement, { setupA11yMetadata } from '../internal/nile-element'; import type { CSSResultGroup } from 'lit'; import { A11yProperty } from '../internal/accessibility/a11y.property.enum'; import { A11yRole } from '../internal/accessibility/a11y.role.enum'; import { Role } from '../internal/accessibility/role.enum'; import { A11yCustomValue } from '../internal/accessibility/a11y.custom-value.enum'; /** * Nile icon component. * * @tag nile-badge * */ /** * @summary badges are used as labels to organize things or to indicate a selection. * @status stable * * @dependency nile-icon-button * * @slot - The badge's content. * * @event nile-remove - Emitted when the remove button is activated. * * @csspart base - The component's base wrapper. * @csspart content - The badge's content. * @csspart remove-button - The badge's remove button, an ``. * @csspart remove-button__base - The remove button's exported `base` part. */ @customElement('nile-badge') export class NileBadge extends NileElement { static styles: CSSResultGroup = styles; connectedCallback(): void { super.connectedCallback(); setupA11yMetadata(this, { [Role.Role]: A11yRole.Text, [A11yProperty.AriaLabel]: this.textContent?.trim() || A11yCustomValue.Badge, }); } /** The badge's theme variant. */ @property({ reflect: true }) variant: | 'primary' | 'success' | 'normal' | 'warning' | 'error' | 'info' | 'gray' | 'brand' | 'blue-light' | 'blue' | 'indigo' | 'purple' | 'pink' | 'orange' | 'blue-gray' | 'gray-blue' = 'normal'; /** Draws a pill-style badge with rounded edges. */ @property({ type: Boolean, reflect: true }) rounded = false; // For setting pill type @property({ reflect: true }) pilltype: | 'pill-color' | 'pill-outline' | 'badge-color'='badge-color'; render() { return html` `; } } export default NileBadge; declare global { interface HTMLElementTagNameMap { 'nile-badge': NileBadge; } }