UNPKG

@anjuna/docs

Version:

Anjuna Documentation Web Components

47 lines (46 loc) 1.58 kB
import { h } from "@stencil/core"; export class FrameworkSwitcher { constructor() { this.frameworks = ['js', 'angular', 'vue']; } switch(framework) { const current = this.getCurrent(); if (framework !== current) { document.location.assign(document.location.toString().replace(current, framework)); } } getCurrent() { return this.frameworks.find(f => document.location.pathname.includes(f)); } render() { const current = this.getCurrent(); return (h("anj-dropdown", null, h("anj-button", { context: "text", slot: "dropdown-toggle" }, "Framework"), this.frameworks.map(f => h("anj-dropdown-item", { active: f === current, onClick: () => this.switch(f) }, f)))); } static get is() { return "ad-framework-switcher"; } static get originalStyleUrls() { return { "$": ["framework-switcher.scss"] }; } static get styleUrls() { return { "$": ["framework-switcher.css"] }; } static get properties() { return { "frameworks": { "type": "unknown", "mutable": false, "complexType": { "original": "string[]", "resolved": "string[]", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "defaultValue": "['js', 'angular', 'vue']" } }; } }