An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Unify progress indicators and align compact dialog titles
Danielc68af57b6761
diff --git a/app/src/assets/scss/component/_dialog.scss b/app/src/assets/scss/component/_dialog.scssindex 030ab5f196..8a260b96db 100644--- a/app/src/assets/scss/component/_dialog.scss+++ b/app/src/assets/scss/component/_dialog.scss@@ -178,36 +178,87 @@&__loading {position: fixed;- top: 45vh;- width: 70vw;- left: 15vw;+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+ box-sizing: border-box;+ width: min(560px, calc(100vw - 32px));+ max-height: calc(100vh - 32px);+ max-height: calc(100dvh - 32px);+ overflow: auto;color: var(--b3-theme-on-surface);background: var(--b3-theme-background);- padding: 10px;+ padding: 24px;+ border: 1px solid var(--b3-theme-surface-lighter);border-radius: var(--b3-border-radius-b);+ box-shadow: var(--b3-dialog-shadow);}&__progress-label {text-align: right;+ font-variant-numeric: tabular-nums;}&__progress {- margin: 8px 0;- height: 8px;- border-radius: var(--b3-border-radius);+ margin: 12px 0;+ height: 4px;+ border-radius: 999px;overflow: hidden;- background-color: #fff;+ color: var(--b3-loading-color, var(--b3-theme-on-surface));+ background-color: var(--b3-theme-surface-lighter);}&__progressbar {height: 100%;- background-color: var(--b3-theme-primary);- transition: var(--b3-transition);+ border-radius: inherit;+ background-color: currentColor;+ transition: width 150ms linear;}&__progress--indeterminate > .b3-dialog__progressbar {- background-image: linear-gradient(-45deg, rgba(255, 255, 255, .2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .2) 50%, rgba(255, 255, 255, .2) 75%, transparent 75%, transparent);- animation: stripMove 450ms linear infinite;- background-size: 50px 50px;+ background: none;+ transition: none;++ &::before {+ content: "";+ display: block;+ width: 40%;+ height: 100%;+ border-radius: inherit;+ background: linear-gradient(90deg, transparent, currentColor);+ animation: b3-progress-slide var(--b3-loading-duration, 1s) linear infinite;+ }+ }+}++@keyframes b3-progress-slide {+ from {+ transform: translateX(-100%);+ }+ to {+ transform: translateX(250%);+ }+}++@media (prefers-reduced-motion: reduce) {+ .b3-dialog__progressbar {+ transition: none;+ }++ .b3-dialog__progress--indeterminate > .b3-dialog__progressbar::before {+ animation: none;+ transform: translateX(75%);+ }+}++@media (forced-colors: active) {+ .b3-dialog__progress {+ color: CanvasText;+ background-color: Canvas;+ outline: 1px solid GrayText;+ }++ .b3-dialog__progress--indeterminate > .b3-dialog__progressbar::before {+ background: currentColor;}}diff --git a/app/src/assets/scss/util/_density.scss b/app/src/assets/scss/util/_density.scssindex ad05ec28c7..19afdbc1bb 100644--- a/app/src/assets/scss/util/_density.scss+++ b/app/src/assets/scss/util/_density.scss@@ -22,7 +22,7 @@ $compact-sizes: ("toolbar-control-padding": 7px,"toolbar-item-margin": 1px 2px,"window-control-padding": 9.25px,- "dialog-header-padding": 5px 24px,+ "dialog-header-padding": 5px 16px,"dialog-content-padding": 12px 16px,"dialog-action-padding": 5px 16px,"dialog-close-padding": 4px,diff --git a/app/tests/checkoutProgress.test.js b/app/tests/checkoutProgress.test.jsindex e9efba52cb..516d661235 100644--- a/app/tests/checkoutProgress.test.js+++ b/app/tests/checkoutProgress.test.js@@ -48,7 +48,7 @@ const run = async () => {assert.equal(standard.querySelector("img"),null);const sharedBarHeight = getComputedStyle(standard.querySelector(".b3-dialog__progress")).height;const sharedColor = getComputedStyle(standard.querySelector(".b3-dialog__loading")).color;- assert.equal(sharedBarHeight,"8px");+ assert.equal(sharedBarHeight,"4px");progressExports.progressLoading({code:0,msg:"overrun",data:{current:999,total:10}},"standard-progress");assert.equal(standard.querySelector(".b3-dialog__progressbar").style.width,"100%");progressExports.progressLoading({code:0,msg:"unknown",data:{current:NaN,total:0}},"standard-progress");diff --git a/app/tests/compactModeLayout.test.js b/app/tests/compactModeLayout.test.jsindex 72927087aa..53586d4ad9 100644--- a/app/tests/compactModeLayout.test.js+++ b/app/tests/compactModeLayout.test.js@@ -60,6 +60,21 @@ const browserCases = ({css, desktop, community}) => {const number = (selector, property) => parseFloat(getComputedStyle(find(selector))[property]);const near = (actual, expected, label) => check.ok(Math.abs(actual - expected) < 1,`${label}: ${actual} / ${expected}`);+ const checkDialogAlignment = padding => {+ const header = find(".b3-dialog__header");+ const content = document.createRange();+ content.selectNodeContents(find(".b3-dialog__content"));+ for (const title of ["Dialog title", "📚 Dialog title"]) {+ header.textContent = title;+ const text = document.createRange();+ text.selectNodeContents(header);+ near(text.getBoundingClientRect().left, content.getBoundingClientRect().left,+ `${title} aligns with dialog content`);+ near(number(".b3-dialog__header", "paddingLeft"), padding, "dialog title left padding");+ near(number(".b3-dialog__header", "paddingRight"), padding, "dialog title right padding");+ }+ header.textContent = "Dialog title";+ };const settle = () => document.getAnimations().filter(animation => animation instanceof CSSTransition).forEach(animation => animation.finish());const checkTabEdge = () => {@@ -87,6 +102,7 @@ const browserCases = ({css, desktop, community}) => {].map(([key, selector]) => [key, {height: height(selector), font: getComputedStyle(find(selector)).fontSize}]));const normal = snapshot();if (desktop && !community) {+ checkDialogAlignment(24);checkTabEdge();for (const [key, expected] of Object.entries({toolbar: 32, tabs: 42, panel: 42, breadcrumb: 42,list: 28, menu: 28, dialog: 43, status: 32})) {@@ -105,6 +121,7 @@ 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) {+ checkDialogAlignment(16);checkTabEdge();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})}`);diff --git a/app/tests/exitWaiting.test.js b/app/tests/exitWaiting.test.jsindex ef0f8cdaea..4e58b6a7b5 100644--- a/app/tests/exitWaiting.test.js+++ b/app/tests/exitWaiting.test.js@@ -142,13 +142,13 @@ if (process.versions.electron && process.type === "browser") {const status = container.querySelector('[role="status"]');const mask = document.querySelector(".b3-dialog__scrim");const maskBounds = mask.getBoundingClientRect();- const stripe = getComputedStyle(container.querySelector(".b3-dialog__progressbar"));+ const segment = getComputedStyle(container.querySelector(".b3-dialog__progressbar"), "::before");const key = new KeyboardEvent("keydown", {key: "a", bubbles: true, cancelable: true});document.body.dispatchEvent(key);return {visible: bounds.width > 0 && bounds.left >= 0 && bounds.right <= innerWidth,globalMask: maskBounds.left === 0 && maskBounds.top === 0 && maskBounds.width === innerWidth && maskBounds.height === innerHeight,overflow: status.scrollWidth > status.clientWidth, text: status.textContent,- endless: stripe.animationName === "stripMove" && stripe.animationIterationCount === "infinite",+ endless: segment.animationName === "b3-progress-slide" && segment.animationIterationCount === "infinite",noDialog: !document.querySelector(".b3-dialog__container"), inputBlocked: key.defaultPrevented};})()`);assert.equal(waiting.visible, true);diff --git a/app/tests/loadingIndicator.test.js b/app/tests/loadingIndicator.test.jsindex 0961d09d2b..8966b37578 100644--- a/app/tests/loadingIndicator.test.js+++ b/app/tests/loadingIndicator.test.js@@ -76,6 +76,47 @@ const browserCases = async (sources, entries, themes) => {check.equal(forced.borderTopWidth, "2px");await ipcRenderer.invoke("loading-media", []);+ const progress = {};+ new Function("exports", sources.progress)(progress);+ window.siyuan = {zIndex: 1};+ for (const entry of ["base", "mobile"]) {+ for (const theme of ["light", "dark"]) {+ styles.textContent = entries[entry] + themes[theme];+ host.replaceChildren();+ progress.progressLoading({code: 1, msg: "Rebuilding index, please wait..."});+ const panel = document.querySelector(".b3-dialog__loading");+ const track = panel.querySelector('[role="progressbar"]');+ const bar = track.firstElementChild;+ const bounds = panel.getBoundingClientRect();+ check.ok(bounds.left >= 16 && bounds.right <= innerWidth - 16);+ check.ok(bounds.top >= 16 && bounds.bottom <= innerHeight - 16);+ check.ok(Math.abs(bounds.x + bounds.width / 2 - innerWidth / 2) < 1);+ check.equal(getComputedStyle(track).color, getComputedStyle(panel).color);+ check.notEqual(getComputedStyle(track).backgroundColor, "rgb(255, 255, 255)");+ const first = getComputedStyle(bar, "::before").transform;+ await wait(100);+ check.notEqual(getComputedStyle(bar, "::before").transform, first, `${entry}/${theme}: progress animates`);+ await ipcRenderer.invoke("capture-loading", `progress-${entry}-${theme}`);+ custom.textContent = ":root{--b3-loading-color:#345678;--b3-loading-duration:2s}";+ check.equal(getComputedStyle(track).color, "rgb(52, 86, 120)");+ check.equal(getComputedStyle(bar, "::before").animationDuration, "2s");+ custom.textContent = "";+ await ipcRenderer.invoke("loading-media", [{name: "prefers-reduced-motion", value: "reduce"}]);+ check.equal(getComputedStyle(bar, "::before").animationName, "none");+ const segment = bar.getAnimations({subtree: true});+ check.equal(segment.length, 0);+ await ipcRenderer.invoke("loading-media", [{name: "forced-colors", value: "active"}]);+ check.equal(getComputedStyle(bar, "::before").backgroundImage, "none");+ check.notEqual(getComputedStyle(bar, "::before").backgroundColor, "rgba(0, 0, 0, 0)");+ await ipcRenderer.invoke("loading-media", []);+ progress.progressLoading({code: 0, msg: "Rebuilding index", data: {current: 42, total: 100}});+ check.equal(document.querySelector('[role="progressbar"]').getAttribute("aria-valuenow"), "42");+ check.equal(getComputedStyle(document.querySelector(".b3-dialog__progressbar"), "::before").content, "none");+ await ipcRenderer.invoke("capture-loading", `progress-determinate-${entry}-${theme}`);+ progress.progressLoading({code: 2});+ }+ }+styles.textContent = entries.base + themes.light;host.replaceChildren();const editor = {};@@ -162,6 +203,7 @@ if (process.versions.electron && process.type === "browser") {.declarationList.declarations[0].initializer;const method = bazaarObject.properties.find(property => property.name?.getText(bazaarAST) === "_onBazaar");const sources = {+ progress: compile(read("src/dialog/progress.ts")),editor: compile(declarations("src/protyle/ui/initUI.ts", ["addLoading", "removeLoading"])),MobileBookmarks: compile(read("src/mobile/dock/MobileBookmarks.ts")),MobileTags: compile(read("src/mobile/dock/MobileTags.ts")),