Truly independent web browser
LibWebView: Offer all three tab layouts on the welcome page
Andreas Kling0f2a8f73dca5
diff --git a/Base/res/ladybird/about-pages/welcome.html b/Base/res/ladybird/about-pages/welcome.htmlindex acfc84935d5..34cfe90c22e 100644--- a/Base/res/ladybird/about-pages/welcome.html+++ b/Base/res/ladybird/about-pages/welcome.html@@ -58,19 +58,19 @@ SPDX-License-Identifier: BSD-2-Clause/></div></section>- <section id="tab-mode-section" aria-labelledby="tab-mode-title">- <h2 id="tab-mode-title">Layout</h2>- <div class="tab-options" role="radiogroup" aria-labelledby="tab-mode-title">+ <section id="tab-layout-section" aria-labelledby="tab-layout-title">+ <h2 id="tab-layout-title">Layout</h2>+ <div class="tab-options" role="radiogroup" aria-labelledby="tab-layout-title"><label class="tab-option">- <input type="radio" name="tab-mode" value="horizontal" checked />+ <input type="radio" name="tab-layout" value="horizontal" checked /><span class="tab-preview horizontal-preview" aria-hidden="true"><span class="preview-strip"><i class="active"></i><i></i><i></i></span><span class="preview-toolbar"><i></i></span></span><span class="tab-option-label">Tabs on top</span></label>- <label id="vertical-tab-option" class="tab-option">- <input type="radio" name="tab-mode" value="vertical" />+ <label class="tab-option">+ <input type="radio" name="tab-layout" value="vertical" /><span class="tab-preview vertical-preview" aria-hidden="true"><span class="preview-sidebar"><i></i><i class="active"></i><i></i></span><span class="preview-main"@@ -79,6 +79,14 @@ SPDX-License-Identifier: BSD-2-Clause</span><span class="tab-option-label">Tabs on the side</span></label>+ <label class="tab-option">+ <input type="radio" name="tab-layout" value="sidebar" />+ <span class="tab-preview vertical-preview" aria-hidden="true">+ <span class="preview-sidebar"><b></b><i></i><i class="active"></i><i></i></span>+ <span class="preview-main"></span>+ </span>+ <span class="tab-option-label">Everything in the sidebar</span>+ </label></div></section><section class="switch-card" aria-labelledby="ad-blocking-title">diff --git a/Base/res/ladybird/about-pages/welcome.js b/Base/res/ladybird/about-pages/welcome.jsindex c0c7063a5ab..4c319e506ab 100644--- a/Base/res/ladybird/about-pages/welcome.js+++ b/Base/res/ladybird/about-pages/welcome.js@@ -11,6 +11,7 @@ const searchEngines = document.querySelector("#search-engines");const searchSuggestions = document.querySelector("#search-suggestions");const searchSuggestionsEnabled = document.querySelector("#search-suggestions-enabled");const searchSuggestionsDescription = document.querySelector("#search-suggestions-description");+const tabLayoutInputs = document.querySelectorAll('input[name="tab-layout"]');const enableContentBlocking = document.querySelector("#enable-content-blocking");const saveStatus = document.querySelector("#save-status");@@ -93,13 +94,22 @@ function renderSearchEngines() {}}+function tabLayout() {+ if (!settings.tabs.verticalTabsEnabled) return "horizontal";+ return settings.tabs.everythingInSidebar ? "sidebar" : "vertical";+}++function updateTabLayout() {+ const layout = tabLayout();+ for (const input of tabLayoutInputs) input.checked = input.value === layout;+}+function initialize() {if (initialized || !settings || !engines || !features) return;initialized = true;- document.querySelector("#tab-mode-section").classList.toggle("hidden", !features.verticalTabs);- const tabMode = settings.tabs.verticalTabsEnabled ? "vertical" : "horizontal";- document.querySelector(`input[name="tab-mode"][value="${tabMode}"]`).checked = true;+ document.querySelector("#tab-layout-section").classList.toggle("hidden", !features.verticalTabs);+ updateTabLayout();renderSearchEngines();updateSearchSuggestions();@@ -109,13 +119,16 @@ function initialize() {startBrowsing.disabled = false;}-for (const input of document.querySelectorAll('input[name="tab-mode"]')) {+for (const input of tabLayoutInputs) {input.addEventListener("change", () => {if (!initialized || !input.checked || !features.verticalTabs) return;- ladybird.sendMessage("setTabSettings", {+ // NB: Keep our copy current, as the settings update for this change can arrive after the next one is made.+ settings.tabs = {...settings.tabs,- verticalTabsEnabled: input.value === "vertical",- });+ verticalTabsEnabled: input.value !== "horizontal",+ everythingInSidebar: input.value === "sidebar",+ };+ ladybird.sendMessage("setTabSettings", settings.tabs);});}@@ -160,10 +173,7 @@ document.addEventListener("WebUIMessage", event => {settings = { ...settings, ...data };if (initialized) {- if (Object.hasOwn(data, "tabs")) {- const mode = settings.tabs.verticalTabsEnabled ? "vertical" : "horizontal";- document.querySelector(`input[name="tab-mode"][value="${mode}"]`).checked = true;- }+ if (Object.hasOwn(data, "tabs")) updateTabLayout();if (Object.hasOwn(data, "searchEngine")) {for (const radio of searchEngines.querySelectorAll("input"))radio.checked = radio.value === settings.searchEngine.engine;diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.mdindex a50c4260a98..087d3efa34d 100644--- a/Documentation/UI/QuietDesign.md+++ b/Documentation/UI/QuietDesign.md@@ -617,7 +617,7 @@ never shows "about:blank".with version, build and platform plus a Copy button. Nothing else.- Welcome (`about:welcome`): the logomark at 56 px (0.85 line, so it doesn't get heavy), the title, then one centered column, in this order: search engine (optional,nothing preselected, engines in a new random order each time, so none is favored by its- place), tab layout, content blocking switch, "Start browsing" (enabled as soon as the+ place), Layout (all three layouts), content blocking switch, "Start browsing" (enabled as soon as thecurrent settings are loaded; it never waits for a choice).- Error pages: icon, title, one line of detail, buttons, centered like every othersingle-message page ("Report sent"). Security errors may use two lines, because the@@ -638,7 +638,8 @@ never shows "about:blank".it really is (in the toolbar row, or at the top of the sidebar). With Tabs on the side, a"Sidebar on: Left / Right" control appears below the cards. Everything in the sidebaris always on the left, where the traffic lights are. The welcome page- uses the same heading and labels.+ offers the same three cards, with the same heading, labels and pictures; in its+ three-column grid they line up with the search engine buttons above.- Settings that change how websites look (Website appearance, Force dark mode, zoom) livein Appearance, next to the browser's own look, not in a separate section.- Permissions: one row per permission (camera, microphone, location, notifications, …),diff --git a/Libraries/LibWebView/WebUI/SettingsUI.cpp b/Libraries/LibWebView/WebUI/SettingsUI.cppindex efb9406826c..5b8d1e515ed 100644--- a/Libraries/LibWebView/WebUI/SettingsUI.cpp+++ b/Libraries/LibWebView/WebUI/SettingsUI.cpp@@ -428,6 +428,10 @@ void SettingsUI::set_tab_settings(JsonValue const& tab_settings)parsed_tab_settings.vertical_tabs_expanded = current_tab_settings.vertical_tabs_expanded;parsed_tab_settings.vertical_tabs_expanded_width = current_tab_settings.vertical_tabs_expanded_width;+ // NB: A sidebar layout picked on the welcome page opens expanded, so the choice shows in the window at once.+ if (host() == "welcome"sv && parsed_tab_settings.vertical_tabs_enabled)+ parsed_tab_settings.vertical_tabs_expanded = true;+settings.set_tab_settings(parsed_tab_settings);}