UNPKG

artistic-elements

Version:
63 lines (62 loc) 2.36 kB
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 ArtisticRadialCircularGradient = class ArtisticRadialCircularGradient extends LitElement { constructor() { super(...arguments); this.width = '10rem'; this.height = '10rem'; this.colors = ['#f0f', '#ff0']; this.stops = [0, 1]; } render() { const { colors, stops } = this; // set the background if we have the correct number of stops / colors // if not, use default values const style = ` width: ${this.width}; height: ${this.height}; background: radial-gradient(circle at center, ${colors.length !== stops.length ? `${colors[0]} 0, ${colors[1]} 100%` : colors .map((c, i) => `${c} ${stops[i] * 100}%`) .join(', ')}) `; return html `<div style="${style}"> <slot></slot> </div>`; } }; ArtisticRadialCircularGradient.styles = css ` :host { display: contents; } div { border-radius: 50%; display: flex; align-items: center; justify-content: center; overflow: hidden; } `; __decorate([ property() ], ArtisticRadialCircularGradient.prototype, "width", void 0); __decorate([ property() ], ArtisticRadialCircularGradient.prototype, "height", void 0); __decorate([ property({ type: Array }) ], ArtisticRadialCircularGradient.prototype, "colors", void 0); __decorate([ property({ type: Array }) ], ArtisticRadialCircularGradient.prototype, "stops", void 0); ArtisticRadialCircularGradient = __decorate([ customElement('artistic-radial-circular-gradient') ], ArtisticRadialCircularGradient); export { ArtisticRadialCircularGradient };