shoelace/src/components/divider/divider.ts

36 wiersze
904 B
TypeScript
Czysty Zwykły widok Historia

2021-12-13 22:16:50 +00:00
import { LitElement } from 'lit';
2021-09-29 12:03:03 +00:00
import { customElement, property } from 'lit/decorators.js';
2022-03-24 11:48:03 +00:00
import { watch } from '~/internal/watch';
2021-09-29 12:03:03 +00:00
import styles from './divider.styles';
/**
* @since 2.0
* @status stable
*
* @cssproperty --color - The color of the divider.
* @cssproperty --width - The width of the divider.
* @cssproperty --spacing - The spacing of the divider.
2021-09-29 12:03:03 +00:00
*/
@customElement('sl-divider')
export default class SlDivider extends LitElement {
static styles = styles;
/** Draws the divider in a vertical orientation. */
@property({ type: Boolean, reflect: true }) vertical = false;
firstUpdated() {
this.setAttribute('role', 'separator');
}
@watch('vertical')
handleVerticalChange() {
this.setAttribute('aria-orientation', this.vertical ? 'vertical' : 'horizontal');
}
}
declare global {
interface HTMLElementTagNameMap {
'sl-divider': SlDivider;
}
}