artistic-elements
Version:
artistic web components
87 lines (86 loc) • 2.91 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 ArtisticRectangleGradient = class ArtisticRectangleGradient extends LitElement {
constructor() {
super(...arguments);
this.width = '10rem';
this.height = '10rem';
this.angle = '0deg';
this.color = '#f0f';
this.color2 = '#0f0';
this.top = '0';
this.left = '0';
this.align = 'initial';
this['border-radius'] = '0';
}
render() {
const style = `
width: ${this.width};
height: ${this.height};
background: linear-gradient(
${this.angle},
${this.color} 0%,
${this.color} 50%,
${this.color2} 50%,
${this.color2} 100%
);
align-self: ${this.align};
${this.top !== '0' || this.left !== '0' ? 'position: absolute;' : ''}
${this.top !== '0' ? `top: ${this.top};` : ''}
${this.left !== '0' ? `left: ${this.left};` : ''}
${this['border-radius'] !== '0'
? `border-radius: ${this['border-radius']};`
: ''}
`;
return html `<div style="${style}">
<slot></slot>
</div>`;
}
};
ArtisticRectangleGradient.styles = css `
:host {
display: contents;
}
div {
display: flex;
align-items: center;
justify-content: center;
}
`;
__decorate([
property()
], ArtisticRectangleGradient.prototype, "width", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "height", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "angle", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "color", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "color2", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "top", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "left", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "align", void 0);
__decorate([
property()
], ArtisticRectangleGradient.prototype, "border-radius", void 0);
ArtisticRectangleGradient = __decorate([
customElement('artistic-rectangle-gradient')
], ArtisticRectangleGradient);
export { ArtisticRectangleGradient };