sidebar-panel-header.mjs (1416B)
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 { MozLitElement } from "chrome://global/content/lit-utils.mjs"; 6 import { html } from "chrome://global/content/vendor/lit.all.mjs"; 7 8 export class SidebarPanelHeader extends MozLitElement { 9 static properties = { 10 view: { type: String }, 11 heading: { type: String }, 12 }; 13 14 static queries = { 15 closeButton: "moz-button", 16 }; 17 18 getWindow() { 19 return window.browsingContext.embedderWindowGlobal.browsingContext.window; 20 } 21 22 closeSidebarPanel(e) { 23 e.preventDefault(); 24 this.getWindow().SidebarController.hide(); 25 } 26 27 render() { 28 return html` 29 <link rel="stylesheet" href="chrome://browser/content/sidebar/sidebar-panel-header.css"></link> 30 <div class="sidebar-panel-heading"> 31 <h4 class="text-truncated-ellipsis">${this.heading}</h4> 32 <moz-button 33 iconsrc="chrome://global/skin/icons/close.svg" 34 data-l10n-id="sidebar-panel-header-close-button" 35 @click=${this.closeSidebarPanel} 36 view=${this.view} 37 size="default" 38 type="icon ghost" 39 tabindex="1" 40 > 41 </moz-button> 42 </div> 43 <slot></slot> 44 `; 45 } 46 } 47 customElements.define("sidebar-panel-header", SidebarPanelHeader);