Skip to content

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

:lipstick: Improve conditional color rule layout https://github.com/siyuan-note/siyuan/issues/19889

Daniel8ece25fde707
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index 4478f04808..0b7deb044e 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -2039,9 +2039,9 @@
max-width: 290px;
&.av__conditional-panel:not(.b3-menu--fullscreen) {
- width: fit-content;
- min-width: min(340px, 90vw);
- max-width: 80vw;
+ width: 420px;
+ min-width: min(340px, calc(100vw - 32px));
+ max-width: calc(100vw - 32px);
}
&__items {
@@ -2856,30 +2856,42 @@ img.av__cellassetimg {
.av__conditional-rule {
position: relative;
display: grid;
- gap: 6px;
+ grid-template-columns: minmax(0, 1fr) 22px;
+ align-items: start;
+ gap: 8px 6px;
min-width: 0;
- }
+ padding: 8px;
+ border-radius: var(--b3-border-radius);
+ background-color: var(--b3-theme-surface);
- .av__conditional-condition {
- display: flex;
- align-items: flex-start;
- gap: 6px;
+ > [data-action="remove"] {
+ align-self: start;
+ margin-top: 3px;
+ margin-left: 0;
+ }
- [data-filter] {
- flex: 1;
- min-width: 0;
+ > [data-conditional-drag] {
+ position: absolute;
+ top: 14px;
+ left: -14px;
+ margin: 0;
+ opacity: 0;
+ pointer-events: none;
}
- > .fn__flex {
- flex-shrink: 0;
+ &:hover > [data-conditional-drag],
+ &:focus-within > [data-conditional-drag] {
+ opacity: 1;
+ pointer-events: auto;
}
}
+ .av__conditional-condition {
+ min-width: 0;
+ }
+
.av__filter-rowinner,
- .av__filter-date-controls,
- .av__filter-date-config,
- .av__conditional-controls,
- .av__field-wrapper {
+ .av__filter-date-config {
display: flex;
flex-wrap: wrap;
align-items: center;
@@ -2887,18 +2899,69 @@ img.av__cellassetimg {
min-width: 0;
}
+ .av__filter-date-controls {
+ display: contents;
+ }
+
+ .av__filter-date-config {
+ order: 1;
+ flex-basis: 100%;
+ }
+
.av__filter-value {
- min-width: 100px;
- flex: 1;
+ order: 2;
+ flex-basis: 100%;
+ min-width: 0;
}
- .av__field-wrapper .b3-select {
- max-width: 200px;
+ .av__conditional-controls {
+ grid-column: 1 / -1;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 6px;
+ min-width: 0;
+
+ [data-action="color"] {
+ margin-left: auto;
+ max-width: 100%;
+ white-space: normal;
+ }
+ }
+
+ .av__field-wrapper {
+ width: 128px;
+ max-width: 100%;
+ min-width: 0;
+ }
+
+ .b3-select {
+ max-width: 100%;
}
.av__conditional-swatch {
width: 1em;
height: 1em;
+ flex-shrink: 0;
margin-right: 8px;
}
+
+ @media (hover: none), (any-pointer: coarse) {
+ .av__conditional-rule {
+ grid-template-columns: 20px minmax(0, 1fr) 22px;
+
+ > [data-conditional-drag] {
+ position: static;
+ align-self: start;
+ margin-top: 6px;
+ opacity: 1;
+ pointer-events: auto;
+ }
+ }
+
+ .av__conditional-controls {
+ grid-column: 2 / -1;
+ }
+ }
}
diff --git a/app/src/protyle/render/av/conditionalColorMenu.ts b/app/src/protyle/render/av/conditionalColorMenu.ts
index 8c21957f24..66fded552c 100644
--- a/app/src/protyle/render/av/conditionalColorMenu.ts
+++ b/app/src/protyle/render/av/conditionalColorMenu.ts
@@ -62,16 +62,14 @@ export const openConditionalColorsMenu = async (options: {
};
const render = () => {
root.innerHTML = rules.map(rule => `<div class="av__conditional-rule" data-rule-id="${escapeAttr(rule.id)}">
-<div class="av__conditional-condition">
<span class="block__icon block__icon--show fn__grab ariaLabel" draggable="true" data-conditional-drag aria-label="${lang.move}"><svg><use xlink:href="#iconDrag"></use></svg></span>
-<div data-filter></div>
-<div class="fn__flex">
-<svg class="b3-menu__action b3-menu__action--show b3-menu__action--warning ariaLabel" data-action="remove" role="button" tabindex="0" aria-label="${lang.delete}"><use xlink:href="#iconTrashcan"></use></svg></div></div>
+<div class="av__conditional-condition" data-filter></div>
+<svg class="b3-menu__action b3-menu__action--show b3-menu__action--warning ariaLabel" data-action="remove" role="button" tabindex="0" aria-label="${lang.delete}"><use xlink:href="#iconTrashcan"></use></svg>
<div class="av__conditional-controls">
-<select class="b3-select" data-action="target" aria-label="${lang.conditionalColorTarget}">
+${data.viewType === "table" || rule.target === "property" ? `<select class="b3-select" data-action="target" aria-label="${lang.conditionalColorTarget}">
<option value="item"${rule.target === "item" ? " selected" : ""}>${lang.conditionalColorItem}</option>
-${data.viewType === "table" || rule.target === "property" ? `<option value="property"${rule.target === "property" ? " selected" : ""}>${lang.conditionalColorProperty}</option>` : ""}</select>
-<button type="button" class="b3-button b3-button--outline" data-action="color"><span class="av__conditional-swatch" style="background-color:${getConditionalBackground(rule.color) || "var(--b3-theme-background)"}"></span>${rule.matchOption ? lang.conditionalColorFirstOption : rule.color?.color ? lang.color : lang.default}</button>
+<option value="property"${rule.target === "property" ? " selected" : ""}>${lang.conditionalColorProperty}</option></select>` : ""}
+<button type="button" class="b3-button b3-button--cancel" data-action="color"><span class="av__conditional-swatch" style="background-color:${getConditionalBackground(rule.color) || "var(--b3-theme-background)"}"></span>${rule.matchOption ? lang.conditionalColorFirstOption : rule.color?.color ? lang.color : lang.default}</button>
</div></div>`).join("");
root.querySelectorAll<HTMLElement>("[data-rule-id]").forEach(element => {
const rule = rules.find(rule => rule.id === element.dataset.ruleId);