Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Reduce status bar height in compact mode https://github.com/siyuan-note/siyuan/issues/20503

Daniel760ce92ec910
diff --git a/app/src/assets/scss/main/_main.scss b/app/src/assets/scss/main/_main.scss
index ff9f1ae7cf..8cafd6bf87 100644
--- a/app/src/assets/scss/main/_main.scss
+++ b/app/src/assets/scss/main/_main.scss
@@ -102,7 +102,7 @@ body.body--harmony {
}
:root[data-ios-window-controls] #status {
- height: calc(32px + var(--ios-window-safe-bottom, 0px));
+ height: calc(var(--b3-ui-status-height, 32px) + var(--ios-window-safe-bottom, 0px));
padding-bottom: var(--ios-window-safe-bottom, 0px);
}
@@ -281,8 +281,8 @@ body.body--harmony {
box-sizing: border-box;
z-index: 2;
- height: 32px;
- line-height: 32px;
+ height: var(--b3-ui-status-height, 32px);
+ line-height: var(--b3-ui-status-height, 32px);
padding: 0 7px;
&__msg {
diff --git a/app/src/assets/scss/util/_density.scss b/app/src/assets/scss/util/_density.scss
index f7a94a3bb5..0a8ed5e919 100644
--- a/app/src/assets/scss/util/_density.scss
+++ b/app/src/assets/scss/util/_density.scss
@@ -15,6 +15,7 @@ $compact-sizes: (
"dock-margin": 4px,
"dock-split-height": 13px,
"toolbar-height": 28px,
+ "status-height": 28px,
"browser-titlebar-height": 27px,
"toolbar-control-height": 27.5px,
"toolbar-control-padding": 7px,
@@ -38,7 +39,8 @@ $compact-sizes: (
}
// 编辑器及预览正文内复用的控件保持内容布局,浮层菜单仍使用界面密度。
-:where(.protyle-wysiwyg, .b3-typography) {
+:where(.protyle-wysiwyg),
+:where(.b3-typography) {
@each $name, $value in $compact-sizes {
--b3-ui-#{$name}: initial;
}
diff --git a/app/tests/compactModeLayout.test.js b/app/tests/compactModeLayout.test.js
index ec1a9a719b..0c3316e888 100644
--- a/app/tests/compactModeLayout.test.js
+++ b/app/tests/compactModeLayout.test.js
@@ -27,6 +27,13 @@ const browserCases = ({css, desktop, community}) => {
<span class="item__icon">📄</span><span class="item__text">Document</span>
<span class="item__close"><svg><use href="#iconClose"></use></svg></span></li></ul></div>
<div class="protyle-breadcrumb">Notebook / Document</div>
+ <div id="status" class="status fn__flex">
+ <div id="barDock" class="toolbar__item"><svg><use href="#iconDock"></use></svg></div>
+ <div class="status__msg">Ready</div><div class="fn__flex-1"></div>
+ <div class="status__backgroundtask">Indexing</div><div class="status__counter">100 words</div>
+ <div id="statusHelp" class="toolbar__item"><svg><use href="#iconHelp"></use></svg></div>
+ <div id="plugin-status" class="toolbar__item"><svg><use href="#iconPlugin"></use></svg></div>
+ </div>
<div class="protyle-wysiwyg" style="font-size:32px"><div data-node-id="sample" data-type="NodeParagraph">Editor body</div>
<div data-type="NodeAttributeView" class="av"><div class="av__row"><div class="av__cell">Database cell</div></div></div>
<ul class="b3-list" id="content-list">${item}</ul></div>
@@ -53,12 +60,13 @@ const browserCases = ({css, desktop, community}) => {
const snapshot = () => Object.fromEntries([
["toolbar", ".toolbar"], ["tabs", "#tabs"], ["panel", ".block__icons"], ["breadcrumb", ".protyle-breadcrumb"],
["list", "#navigation .b3-list-item"], ["menu", ".b3-menu__item"], ["dialog", ".b3-dialog__header"],
+ ["status", "#status"],
["editor", ".protyle-wysiwyg"], ["database", ".av__cell"], ["content", "#content-list"], ["preview", "#preview-list"],
].map(([key, selector]) => [key, {height: height(selector), font: getComputedStyle(find(selector)).fontSize}]));
const normal = snapshot();
if (desktop && !community) {
for (const [key, expected] of Object.entries({toolbar: 32, tabs: 42, panel: 42, breadcrumb: 42,
- list: 28, menu: 28, dialog: 43})) {
+ list: 28, menu: 28, dialog: 43, status: 32})) {
near(normal[key].height, expected, `${key} retains the default size`);
}
}
@@ -74,10 +82,28 @@ const browserCases = ({css, desktop, community}) => {
}
for (const key of Object.keys(normal)) check.equal(compact[key].font, normal[key].font, `${key} keeps its font size`);
if (!community) {
- for (const key of ["toolbar", "tabs", "panel", "breadcrumb", "list", "menu", "dialog"]) {
+ for (const key of ["toolbar", "tabs", "panel", "breadcrumb", "list", "menu", "dialog", "status"]) {
check.ok(compact[key].height < normal[key].height, `${key} becomes smaller: ${JSON.stringify({normal, compact})}`);
}
near(compact.toolbar.height, 28, "toolbar height");
+ near(compact.status.height, 28, "status bar height");
+ near(number("#status", "lineHeight"), 28, "status bar line height");
+ const statusRect = find("#status").getBoundingClientRect();
+ for (const selector of ["#barDock", "#statusHelp", "#plugin-status", ".status__msg", ".status__counter", ".status__backgroundtask"]) {
+ const rect = find(selector).getBoundingClientRect();
+ check.ok(rect.top >= statusRect.top && rect.bottom <= statusRect.bottom, `${selector} fits the compact status bar`);
+ near((rect.top + rect.bottom) / 2, (statusRect.top + statusRect.bottom) / 2, `${selector} stays vertically centered`);
+ }
+ near(height("#statusHelp svg"), 15.5, "status icon size is preserved");
+ near(number(".status__counter", "fontSize"), 12, "status text size is preserved");
+ document.documentElement.setAttribute("data-ios-window-controls", "");
+ document.documentElement.style.setProperty("--ios-window-safe-bottom", "20px");
+ near(height("#status"), 48, "compact status bar retains the iOS safe area");
+ document.documentElement.removeAttribute("data-ui-density");
+ near(height("#status"), 52, "normal status bar retains the iOS safe area");
+ document.documentElement.setAttribute("data-ui-density", "compact");
+ document.documentElement.removeAttribute("data-ios-window-controls");
+ document.documentElement.style.removeProperty("--ios-window-safe-bottom");
near(compact.panel.height, 34, "panel height");
near(compact.list.height, 24, "list height");
near(compact.menu.height, 26, "menu height");
@@ -122,11 +148,12 @@ const browserCases = ({css, desktop, community}) => {
if (!community) {
// 根变量和既有组件选择器都能覆盖内置尺寸,即使主题样式先于基础样式加载。
const theme = document.createElement("style");
- theme.textContent = ":root{--b3-ui-list-height:36px}.b3-menu__item{line-height:38px}";
+ theme.textContent = ":root{--b3-ui-list-height:36px;--b3-ui-status-height:36px}.b3-menu__item{line-height:38px}";
document.head.prepend(theme);
document.documentElement.setAttribute("data-ui-density", "compact");
settle();
near(height("#navigation .b3-list-item"), 36, "theme root variable wins");
+ near(height("#status"), 36, "theme status height variable wins");
near(height(".b3-menu__item"), 26, "same-specificity early component style follows source order");
document.head.append(theme);
near(height(".b3-menu__item"), 38, "existing component theme override wins in the normal load order");