shoelace/scripts/plop/templates/component/component.hbs

45 wiersze
988 B
Handlebars

import { LitElement, html } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { emit } from '~/internal/event';
import { watch } from '~/internal/watch';
import styles from './{{ tagWithoutPrefix tag }}.styles';
/**
* @since 2.0
* @status experimental
*
* @dependency sl-example
*
* @event sl-event-name - Emitted as an example.
*
* @slot - The default slot.
* @slot example - An example slot.
*
* @csspart base - The component's internal wrapper.
*
* @cssproperty --example - An example CSS custom property.
*/
@customElement('{{ tag }}')
export default class {{ properCase tag }} extends LitElement {
static styles = styles;
/** An example property. */
@property() prop = 'example';
@watch('someProp')
doSomething() {
// Example event
emit(this, 'sl-event-name');
}
render() {
return html` <slot></slot> `;
}
}
declare global {
interface HTMLElementTagNameMap {
'{{ tag }}': {{ properCase tag }};
}
}