artistic-elements
Version:
artistic web components
60 lines (59 loc) • 2.08 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { html, css, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
let ArtisticDoughnut = class ArtisticDoughnut extends LitElement {
constructor() {
super(...arguments);
this.diameter = 10;
this.lineWidth = 1;
this.color = '#f0f';
this.top = '0';
this.left = '0';
}
render() {
const size = this.diameter - this.lineWidth * 2;
const style = `
width: ${size}rem;
height: ${size}rem;
border: solid ${this.lineWidth}rem ${this.color};
${this.top !== '0' || this.left !== '0' ? 'position: absolute;' : ''}
${this.top !== '0' ? `top: ${this.top};` : ''}
${this.left !== '0' ? `left: ${this.left};` : ''}
`;
return html `<div style="${style}">
<slot></slot>
</div>`;
}
};
ArtisticDoughnut.styles = css `
div {
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
`;
__decorate([
property()
], ArtisticDoughnut.prototype, "diameter", void 0);
__decorate([
property()
], ArtisticDoughnut.prototype, "lineWidth", void 0);
__decorate([
property()
], ArtisticDoughnut.prototype, "color", void 0);
__decorate([
property()
], ArtisticDoughnut.prototype, "top", void 0);
__decorate([
property()
], ArtisticDoughnut.prototype, "left", void 0);
ArtisticDoughnut = __decorate([
customElement('artistic-doughnut')
], ArtisticDoughnut);
export { ArtisticDoughnut };