Bug 1577257 - Share logic behind panel headers across the UI r=willdurand,Gijs,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D160972
This commit is contained in:
Itiel
2022-11-17 21:34:34 +00:00
parent d652d9fa29
commit c5c7610894
13 changed files with 154 additions and 173 deletions

View File

@@ -1374,20 +1374,27 @@ var PanelView = class extends AssociatedToNode {
};
// If the header already exists, update or remove it as requested.
let header = this.node.firstElementChild;
if (header && header.classList.contains("panel-header")) {
if (value) {
// The back button has a label in it - we want to select
// the label that's a direct child of the header.
header.querySelector(".panel-header > h1 > span").textContent = value;
ensureHeaderSeparator(header);
} else {
let header = this.node.querySelector(".panel-header");
if (header) {
if (!this.node.getAttribute("mainview")) {
if (value) {
// The back button has a label in it - we want to select
// the span that's a child of the header.
header.querySelector(".panel-header > h1 > span").textContent = value;
ensureHeaderSeparator(header);
} else {
if (header.nextSibling.tagName == "toolbarseparator") {
header.nextSibling.remove();
}
header.remove();
}
return;
} else if (!this.node.getAttribute("showheader")) {
if (header.nextSibling.tagName == "toolbarseparator") {
header.nextSibling.remove();
}
header.remove();
}
return;
}
// The header doesn't exist, only create it if needed.

View File

@@ -74,9 +74,12 @@
hidden="true">
<panelmultiview mainViewId="unified-extensions-view">
<panelview id="unified-extensions-view"
class="cui-widget-panelview">
<vbox class="unified-extensions-panel-header">
<html:h1 data-l10n-id="unified-extensions-header-title"/>
class="cui-widget-panelview"
showheader="true">
<vbox class="panel-header">
<html:h1>
<html:span data-l10n-id="unified-extensions-header-title"/>
</html:h1>
</vbox>
<toolbarseparator />