feat: Start implementing Zen Library, b=no-bug, c=common, folders

This commit is contained in:
mr. m
2026-03-06 10:16:05 +01:00
parent 7c8ccdedd4
commit 237f0c0ea5
12 changed files with 123 additions and 2 deletions

View File

@@ -19,3 +19,4 @@
#include ../../../zen/vendor/jar.inc.mn
#include ../../../zen/fonts/jar.inc.mn
#include ../../../zen/live-folders/jar.inc.mn
#include ../../../zen/library/jar.inc.mn

View File

@@ -65,4 +65,6 @@
<command id="cmd_zenNewNavigatorUnsynced" />
<command id="cmd_zenNewLiveFolder" />
<command id="cmd_zenToggleLibrary" />
</commandset>

View File

@@ -13,6 +13,7 @@
skipintoolbarset="true"
context="toolbar-context-menu"
mode="icons">
<toolbarbutton removable="true" class="chromeclass-toolbar-additional toolbarbutton-1 zen-sidebar-action-button" id="zen-library-button" command="cmd_zenToggleLibrary"></toolbarbutton>
<toolbarbutton removable="true" class="chromeclass-toolbar-additional toolbarbutton-1 zen-sidebar-action-button" id="zen-expand-sidebar-button" command="cmd_zenToggleSidebar" data-l10n-id="sidebar-zen-expand"></toolbarbutton>
<zen-workspace-icons id="zen-workspaces-button" overflows="false" removable="false"></zen-workspace-icons>
<toolbarbutton removable="true" class="chromeclass-toolbar-additional toolbarbutton-1 zen-sidebar-action-button" id="zen-create-new-button" context="zenCreateNewPopup" data-l10n-id="sidebar-zen-create-new"></toolbarbutton>

View File

@@ -289,7 +289,8 @@
display: none;
}
#library-button {
#library-button,
#zen-library-button {
list-style-image: url("library.svg") !important;
}

View File

@@ -8,7 +8,7 @@ export const ZenCustomizableUI = new (class {
constructor() {}
TYPE_TOOLBAR = "toolbar";
defaultSidebarIcons = ["downloads-button", "zen-workspaces-button", "zen-create-new-button"];
defaultSidebarIcons = ["zen-library-button", "zen-workspaces-button", "zen-create-new-button"];
startup(CustomizableUIInternal) {
CustomizableUIInternal.registerArea(

View File

@@ -137,6 +137,14 @@ document.addEventListener(
ZenLiveFoldersManager.handleEvent(event);
break;
}
case "cmd_zenToggleLibrary": {
const { ZenLibrary } = ChromeUtils.importESModule(
"moz-src:///zen/library/ZenLibrary.mjs",
{ global: "current" }
);
ZenLibrary.toggle();
break;
}
default:
gZenGlanceManager.handleMainCommandSet(event);
if (event.target.id.startsWith("cmd_zenWorkspaceSwitch")) {

View File

@@ -0,0 +1,86 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import { html } from "chrome://global/content/vendor/lit.all.mjs";
import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
let gZenLibraryInstance = null;
/**
* The ZenLibrary class is responsible for managing the UI for the library feature.
* This feature allows users to view and manage their browsing history, downloads,
* spaces, and other related data in a unified interface.
*/
export class ZenLibrary extends MozLitElement {
#initialized = false;
static properties = {
activeTab: { type: String },
};
static queries = {
content: "#zen-library-content",
tabs: { all: "#zen-library-sidebar-tabs > .library-tab" },
};
constructor() {
super();
this.activeTab = "history";
}
connectedCallback() {
super.connectedCallback();
if (this.#initialized) {
return;
}
window.addEventListener("keydown", this);
this.#initialized = true;
}
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener("keydown", this);
this.#initialized = false;
}
render() {
return html`
<link rel="stylesheet" href="chrome://browser/content/zen-styles/zen-library.css" />
<hbox>
<vbox id="zen-library-sidebar">
<vbox id="zen-library-sidebar-header"></vbox>
<vbox id="zen-library-sidebar-tabs"></vbox>
<vbox id="zen-library-sidebar-footer"></vbox>
</vbox>
<vbox id="zen-library-content"> test </vbox>
</hbox>
`;
}
handleEvent() {
// Handle events related to the library UI here
}
static getInstance() {
if (!gZenLibraryInstance) {
gZenLibraryInstance = new ZenLibrary();
gNavToolbox.before(gZenLibraryInstance);
}
return gZenLibraryInstance;
}
static clearInstance() {
if (gZenLibraryInstance) {
gZenLibraryInstance.remove();
gZenLibraryInstance = null;
}
}
static toggle() {
let instance = this.getInstance();
instance.toggleAttribute("open");
}
}
customElements.define("zen-library", ZenLibrary);

View File

@@ -0,0 +1,5 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
content/browser/zen-components/zen-library.css (../../zen/library/zen-library.css)

View File

@@ -0,0 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOZ_SRC_FILES += [
"ZenLibrary.mjs",
]

View File

@@ -0,0 +1,8 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
:host {
}

View File

@@ -1,6 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",

View File

@@ -17,4 +17,5 @@ DIRS += [
"toolkit",
"sessionstore",
"share",
"library",
]