Просмотр исходного кода

enhance: show icons for class, property and node

Tienson Qin 1 год назад
Родитель
Сommit
dafa090fdc

+ 18 - 8
src/main/frontend/components/cmdk/core.cljs

@@ -35,7 +35,8 @@
    [electron.ipc :as ipc]
    [frontend.util.text :as text-util]
    [goog.userAgent]
-   [frontend.db.async :as db-async]))
+   [frontend.db.async :as db-async]
+   [logseq.db :as ldb]))
 
 (defn translate [t {:keys [id desc]}]
   (when id
@@ -48,7 +49,7 @@
 
 (def search-actions
   [{:filter {:group :current-page} :text "Search only current page" :info "Add filter to search" :icon-theme :gray :icon "page"}
-   {:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "block"}
+   {:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "letter-n"}
    {:filter {:group :commands} :text "Search only commands" :info "Add filter to search" :icon-theme :gray :icon "command"}
    {:filter {:group :files} :text "Search only files" :info "Add filter to search" :icon-theme :gray :icon "file"}
    {:filter {:group :themes} :text "Search only themes" :info "Add filter to search" :icon-theme :gray :icon "palette"}])
@@ -220,9 +221,17 @@
 (defn- page-item
   [repo page]
   (let [entity (db/entity [:block/uuid (:block/uuid page)])
-        whiteboard? (contains? (:block/type entity) "whiteboard")
-        source-page (model/get-alias-source-page repo (:db/id entity))]
-    (hash-map :icon (if whiteboard? "whiteboard" "page")
+        source-page (model/get-alias-source-page repo (:db/id entity))
+        icon (cond
+               (ldb/class? entity)
+               "hash"
+               (ldb/property? entity)
+               "letter-p"
+               (ldb/whiteboard-page? entity)
+               "whiteboard"
+               :else
+               "page")]
+    (hash-map :icon icon
               :icon-theme :gray
               :text (title/block-unique-title page)
               :source-page (or source-page page))))
@@ -231,8 +240,9 @@
   [repo block current-page !input]
   (let [id (:block/uuid block)
         object? (seq (:block/tags block))
-        text (title/block-unique-title block)]
-    {:icon (if object? "topology-star" "block")
+        text (title/block-unique-title block)
+        icon "letter-n"]
+    {:icon icon
      :icon-theme :gray
      :text (highlight-content-query text @!input)
      :header (when-not object? (block/breadcrumb {:search? true} repo id {}))
@@ -335,7 +345,7 @@
                            (let [id (if (uuid? (:block/uuid block))
                                       (:block/uuid block)
                                       (uuid (:block/uuid block)))]
-                             {:icon "block"
+                             {:icon "node"
                               :icon-theme :gray
                               :text (highlight-content-query (:block/title block) @!input)
                               :header (block/breadcrumb {:search? true} repo id {})

+ 6 - 3
src/main/frontend/components/editor.cljs

@@ -8,6 +8,7 @@
             [frontend.components.title :as title]
             [frontend.context.i18n :refer [t]]
             [frontend.db :as db]
+            [logseq.db :as ldb]
             [frontend.db.model :as db-model]
             [frontend.extensions.zotero :as zotero]
             [frontend.handler.editor :as editor-handler :refer [get-state]]
@@ -171,17 +172,19 @@
                        [:div.flex.flex-row.items-center.gap-1
                         (when-not db-tag?
                           (cond
+                            (ldb/class? block)
+                            [:div (ui/icon "hash" {:size 14})]
+                            (ldb/property? block)
+                            [:div (ui/icon "letter-p" {:size 14})]
                             (db-model/whiteboard-page? block)
                             [:div (ui/icon "whiteboard" {:extension? true})]
                             (db/page? block)
                             [:div (ui/icon "page" {:extension? true})]
-                            (seq (:block/tags block))
-                            [:div.flex (ui/icon "topology-star" {:size 14})]
                             (or (string/starts-with? (:block/title block) (t :new-class))
                                 (string/starts-with? (:block/title block) (t :new-page)))
                             nil
                             :else
-                            [:div (ui/icon "block" {:extension? true})]))
+                            [:div (ui/icon "letter-n" {:size 14})]))
 
                         (let [title (if db-tag?
                                       (:block/title block)

+ 5 - 3
src/main/frontend/components/icon.cljs

@@ -32,12 +32,14 @@
 (defn get-node-icon
   [node-entity opts]
   (let [default-icon-id (cond
-                          (and (:block/tags node-entity) (not (ldb/page? node-entity)))
-                          "topology-star"
+                          (ldb/class? node-entity)
+                          "hash"
+                          (ldb/property? node-entity)
+                          "letter-p"
                           (ldb/page? node-entity)
                           "page"
                           :else
-                          "block")
+                          "letter-n")
         default-icon (ui/icon default-icon-id (assoc opts :size 14))
         node-icon (get node-entity (pu/get-pid :logseq.property/icon))]
     (or

+ 22 - 12
src/main/frontend/components/page.cljs

@@ -331,12 +331,20 @@
     (let [page (db/sub-block (:db/id page))
           title (:block/title page)]
       (when title
-        (let [journal? (ldb/journal-page? page)
-              icon (get page (pu/get-pid :logseq.property/icon))
+        (let [repo (state/get-current-repo)
+              db-based? (config/db-based-graph? repo)
+              journal? (ldb/journal-page? page)
+              icon (or (get page (pu/get-pid :logseq.property/icon))
+                       (when db-based?
+                         (or (when (ldb/class? page)
+                               {:type :tabler-icon
+                                :id "hash"})
+                             (when (ldb/property? page)
+                               {:type :tabler-icon
+                                :id "letter-p"}))))
               *title-value (get state ::title-value)
               *edit? (get state ::edit?)
               *input-value (get state ::input-value)
-              repo (state/get-current-repo)
               hls-page? (pdf-utils/hls-file? title)
               whiteboard-page? (model/whiteboard-page? page)
               untitled? (and whiteboard-page? (parse-uuid title)) ;; normal page cannot be untitled right?
@@ -345,22 +353,24 @@
                       (if fmt-journal?
                         (date/journal-title->custom-format title)
                         title))
-              old-name title
-              db-based? (config/db-based-graph? repo)]
+              old-name title]
           [:div.ls-page-title.flex.flex-1.flex-row.flex-wrap.w-full.relative.items-center.gap-2
            {:on-mouse-over #(when-not @*edit? (reset! *hover? true))
             :on-mouse-out #(reset! *hover? false)}
            (when icon
              [:div.page-icon
               {:on-pointer-down util/stop-propagation}
-              (if (and (map? icon) db-based?)
+              (cond
+                (and (map? icon) db-based?)
                 (icon-component/icon-picker icon
-                  {:on-chosen (fn [_e icon]
-                                (db-property-handler/set-block-property!
-                                  (:db/id page)
-                                  (pu/get-pid :logseq.property/icon)
-                                  (select-keys icon [:id :type :color])))
-                   :icon-props {:size 38}})
+                                            {:on-chosen (fn [_e icon]
+                                                          (db-property-handler/set-block-property!
+                                                           (:db/id page)
+                                                           (pu/get-pid :logseq.property/icon)
+                                                           (select-keys icon [:id :type :color])))
+                                             :icon-props {:size 38}})
+
+                :else
                 icon)])
            [:h1.page-title.flex-1.cursor-pointer.gap-1
             {:class (when-not whiteboard-page? "title")

+ 1 - 1
src/main/frontend/components/property.cljs

@@ -445,7 +445,7 @@
                  :checkbox "checkbox"
                  :url "link"
                  :page "page"
-                 :node "topology-star"
+                 :node "letter-n"
                  "letter-t"))]
     (ui/icon icon {:class "opacity-50"
                    :size 15})))

+ 6 - 4
src/main/frontend/components/property/value.cljs

@@ -311,12 +311,14 @@
 (defn- get-node-icon
   [node]
   (cond
-    (db/page? node)
+    (ldb/class? node)
+    "hash"
+    (ldb/property? node)
+    "letter-p"
+    (ldb/page? node)
     "page"
-    (seq (:block/tags node))
-    "topology-star"
     :else
-    "block"))
+    "letter-n"))
 
 (rum/defc select-node < rum/reactive db-mixins/query
   [property

+ 1 - 1
src/main/frontend/components/right_sidebar.cljs

@@ -62,7 +62,7 @@
   [repo block idx sidebar-key ref?]
   (when-let [block-id (:block/uuid block)]
     [[:.flex.items-center {:class (when ref? "ml-2")}
-      (ui/icon "block" {:class "text-md mr-2"})
+      (ui/icon "letter-n" {:class "text-md mr-2"})
       (block/breadcrumb {:id     "block-parent"
                          :block? true
                          :sidebar-key sidebar-key} repo block-id {:indent? false})]

+ 2 - 2
src/resources/dicts/en.edn

@@ -638,8 +638,8 @@
  :header/go-back                     "Go back"
  :header/go-forward                  "Go forward"
 
- ;; E.g. 1 Object or 2 Objects
- :views.table/default-title (fn [total] (str total (if (= total 1) " Object" " Objects")))
+ ;; E.g. 1 node or 2 nodes
+ :views.table/default-title (fn [total] (str total (if (= total 1) " Node" " Nodes")))
 
  ;; Commands are nested for now to stay in sync with the shortcuts system.
  ;; Other languages should not nest keys under :commands