From 5cccc9a06377af7eefd1ee5113f993d468a2837f Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Sun, 25 Feb 2024 05:57:59 +0800 Subject: [PATCH] enhance: show page info border only when hovering the info title --- .../frontend/components/db_based/page.cljs | 37 ++++++++++--------- src/main/frontend/components/page.css | 4 ++ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/frontend/components/db_based/page.cljs b/src/main/frontend/components/db_based/page.cljs index d539f2496..f5d26c075 100644 --- a/src/main/frontend/components/db_based/page.cljs +++ b/src/main/frontend/components/db_based/page.cljs @@ -162,33 +162,35 @@ collapsed? (rum/react *collapsed?) has-tags? (seq (:block/tags page)) has-properties? (seq (:block/properties page)) - hover-or-expanded? (or @*hover? hover-title? (not collapsed?))] + hover-or-expanded? (or @*hover? hover-title? (not collapsed?)) + show-info? (or hover-or-expanded? has-tags? has-properties? class?)] (when (if config/publishing? ;; Since publishing is read-only, hide this component if it has no info to show ;; as it creates a fair amount of empty vertical space (or has-tags? (some? types)) true) - [:div.page-info {:on-mouse-over #(reset! *hover? true) - :on-mouse-leave #(reset! *hover? false)} - (when (or hover-or-expanded? has-tags? has-properties? class?) - [:div.py-2 {:class (if (or @*hover? (not collapsed?)) - "border rounded" - "border rounded border-transparent")} - [:div.info-title.cursor {:on-click - (if config/publishing? - (fn [_] - (when (seq (set/intersection #{"class" "property"} types)) - (swap! *collapsed? not))) - #(swap! *collapsed? not))} + [:div.page-info + [:div.py-2 {:class (if (or @*hover? (not collapsed?)) + "border rounded" + "border rounded border-transparent")} + [:div.info-title.cursor + {:on-mouse-over #(reset! *hover? true) + :on-mouse-leave #(reset! *hover? false) + :on-click (if config/publishing? + (fn [_] + (when (seq (set/intersection #{"class" "property"} types)) + (swap! *collapsed? not))) + #(swap! *collapsed? not))} + (when show-info? [:div.flex.flex-row.items-center.gap-2.justify-between.pl-1 [:div.flex.flex-row.items-center.gap-2 (if collapsed? (if (or has-tags? @*hover? config/publishing?) [:<> (if has-tags? - [:div.px-1] + [:div.px-1 {:style {:min-height 28}}] (shui-ui/button {:variant :ghost :size :sm :class "fade-link"} - (ui/icon "tags"))) + (ui/icon "tags"))) (if (and config/publishing? (seq (set/intersection #{"class" "property"} types))) [:div [:div.opacity-50.pointer.text-sm "Expand for more info"]] @@ -206,11 +208,12 @@ {:variant :ghost :size :sm :class "fade-link"} (ui/icon (if collapsed? "chevron-down" - "chevron-up"))))]] + "chevron-up"))))])] + (when show-info? (if collapsed? (when (or (seq (:block/properties page)) (and class? (seq (:properties (:block/schema page))))) [:div.py-2.px-4 (page-properties page {:mode (if class? :class :page)})]) [:div.py-2.px-4 - (page-configure page *mode)])])]))) + (page-configure page *mode)]))]]))) diff --git a/src/main/frontend/components/page.css b/src/main/frontend/components/page.css index 964a662b9..3d6d6f8a7 100644 --- a/src/main/frontend/components/page.css +++ b/src/main/frontend/components/page.css @@ -390,6 +390,10 @@ html.is-native-ios { .page-info { min-height: 46px; margin-left: -15px; + + .info-title { + min-height: 28px; + } } .sidebar-item .page-info {