UNPKG

@rxdi/ui-kit

Version:

UI Components for building graphql-server website

105 lines 3.4 kB
"use strict"; 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DotnavComponent = void 0; const lit_html_1 = require("@rxdi/lit-html"); /** * @customElement rx-dotnav */ let DotnavComponent = class DotnavComponent extends lit_html_1.LitElement { constructor() { super(...arguments); this.orientation = 'row'; } OnUpdateFirst() { this.dots = this.selectAllHrefs(); this.attachListeners(); } selectAllHrefs() { return [...Array.from(this.querySelectorAll('a'))]; } attachListeners() { this.dots.forEach(el => this.attachListener(el)); } attachListener(el) { el.addEventListener('click', () => this.focusElement(el)); } focusElement(el) { this.dots.forEach(d => d.classList.remove('focus')); el.classList.add('focus'); } }; __decorate([ (0, lit_html_1.property)({ type: String }), __metadata("design:type", String) ], DotnavComponent.prototype, "orientation", void 0); __decorate([ (0, lit_html_1.property)({ type: Array }), __metadata("design:type", Array) ], DotnavComponent.prototype, "dots", void 0); DotnavComponent = __decorate([ (0, lit_html_1.Component)({ selector: 'rx-dotnav', style: (0, lit_html_1.css) ` a { display: block; cursor: pointer; box-sizing: border-box; width: 10px; height: 10px; border-radius: 50%; background: transparent; text-indent: 100%; overflow: hidden; white-space: nowrap; border: 1px solid rgba(102, 102, 102, 0.4); transition: 0.2s ease-in-out; transition-property: background-color, border-color; } .focus { background-color: rgba(102, 102, 102, 0.6); outline: none; border-color: transparent; } `, template() { return (0, lit_html_1.html) ` ${this.orientation === 'row' ? (0, lit_html_1.html) ` <style> a { margin-top: 0px; margin-right: 12px; } </style> ` : (0, lit_html_1.html) ` <style> a { margin-top: 12px; margin-right: 0px; } </style> `} <div style=${(0, lit_html_1.styleMap)({ display: 'flex', 'flex-direction': this.orientation })} > ${this.dots} </div> `; } }) ], DotnavComponent); exports.DotnavComponent = DotnavComponent; //# sourceMappingURL=dotnav.component.js.map