nav-notice.mjs (1470B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { 6 literal, 7 staticHtml, 8 ifDefined, 9 } from "chrome://global/content/vendor/lit.all.mjs"; 10 import { MozLitElement } from "chrome://global/content/lit-utils.mjs"; 11 12 export default class NavNotice extends MozLitElement { 13 static properties = { 14 href: { type: String }, 15 iconSrc: { type: String }, 16 label: { type: String, fluent: true }, 17 theme: { type: Object }, 18 }; 19 20 static queries = { 21 boxEl: "moz-box-link, moz-box-item", 22 }; 23 24 willUpdate(changedProperties) { 25 if (changedProperties.has("theme")) { 26 if (this.theme?.themeBg && this.theme?.themeFg) { 27 this.style.setProperty("--theme-bg-color", this.theme.themeBg); 28 this.style.setProperty("--theme-fg-color", this.theme.themeFg); 29 } else { 30 this.style.removeProperty("--theme-bg-color"); 31 this.style.removeProperty("--theme-fg-color"); 32 } 33 } 34 } 35 36 render() { 37 let element = this.href ? literal`moz-box-link` : literal`moz-box-item`; 38 return staticHtml`<link 39 rel="stylesheet" 40 href="chrome://browser/content/preferences/widgets/nav-notice.css" 41 /> 42 <${element} iconsrc=${this.iconSrc} label=${this.label} href=${ifDefined(this.href)}></${element}>`; 43 } 44 } 45 customElements.define("nav-notice", NavNotice);