Browse Source

enhance(ui): polish block control arrow for the block with emoji/icon

charlie 1 year ago
parent
commit
a4df98903e
2 changed files with 38 additions and 21 deletions
  1. 19 20
      src/main/frontend/components/block.cljs
  2. 19 1
      src/main/frontend/components/block.css

+ 19 - 20
src/main/frontend/components/block.cljs

@@ -2052,9 +2052,18 @@
         order-list-idx     (:own-order-list-index config)
         collapsable?       (editor-handler/collapsable? uuid {:semantic? true
                                                               :ignore-children? (:page-title? config)})
-        link?              (boolean (:original-block config))]
+        link?              (boolean (:original-block config))
+        icon-size          (if collapsed? 12 14)
+        icon               (icon-component/get-node-icon-cp block {:size icon-size :color? true})
+        with-icon?          (and (some? icon)
+                             (or (db/page? block)
+                               (:logseq.property/icon block)
+                               link?
+                               (some :logseq.property/icon (:block/tags block))
+                               (contains? #{"pdf"} (:logseq.property.asset/type block))))]
     [:div.block-control-wrap.flex.flex-row.items-center.h-6
      {:class (util/classnames [{:is-order-list order-list?
+                                :is-with-icon  with-icon?
                                 :bullet-closed collapsed?
                                 :bullet-hidden (:hide-bullet? config)}])}
      (when (and (or (not fold-button-right?) collapsable?) (not (:table? config)))
@@ -2092,25 +2101,15 @@
                                      " hide-inner-bullet")
                                    (when order-list? " as-order-list typed-list"))}
 
-                      (let [icon-size (if collapsed? 12 14)
-                            icon (icon-component/get-node-icon-cp block {:size icon-size :color? true})]
-                        (cond
-                          (and (some? icon)
-                               (or (db/page? block)
-                                   (:logseq.property/icon block)
-                                   link?
-                                   (some :logseq.property/icon (:block/tags block))
-                                   (contains? #{"pdf"} (:logseq.property.asset/type block))))
-                          icon
-
-                          :else
-                          [:span.bullet (cond->
-                                         {:blockid (str uuid)}
-                                          selected?
-                                          (assoc :class "selected"))
-                           (when
-                            order-list?
-                             [:label (str order-list-idx ".")])]))]]]
+                      (if with-icon?
+                        icon
+                        [:span.bullet (cond->
+                                        {:blockid (str uuid)}
+                                        selected?
+                                        (assoc :class "selected"))
+                         (when
+                           order-list?
+                           [:label (str order-list-idx ".")])])]]]
          (cond
            (and (or (mobile-util/native-platform?)
                     (:ui/show-empty-bullets? (state/get-config))

+ 19 - 1
src/main/frontend/components/block.css

@@ -210,6 +210,24 @@
     }
   }
 
+  &.is-with-icon {
+    &.bullet-closed {
+      .block-control .control-hide {}
+    }
+
+    .bullet-container {
+      .icon-cp-container {
+        @apply flex;
+      }
+
+      &.bullet-closed {
+        .ls-icon-color-wrap em-emoji {
+          @apply relative -top-[1px];
+        }
+      }
+    }
+  }
+
   &.bullet-hidden {
     padding-right: 2px;
   }
@@ -270,7 +288,7 @@
 }
 
 .block-control {
-  @apply decoration-0 text-sm cursor-default
+  @apply decoration-0 text-sm cursor-default mt-[1px]
   min-w-[22px] min-h-[22px] p-0.5 select-none opacity-40;
 
   .control-hide {