Browse Source

enhance(ui): refactor the shui-related codes

charlie 1 year ago
parent
commit
e9b430b1b0

+ 1 - 4
deps/shui/src/logseq/shui/icon/v2.cljs

@@ -11,9 +11,6 @@
    [logseq.shui.util :as shui-utils]
    [rum.core :as rum]))
 
-(def get-adapt-icon-class
-  (memoize (fn [klass] (shui-utils/react->rum klass true))))
-
 (rum/defc root
   ([name] (root name nil))
   ([name {:keys [extension? font? class] :as opts}]
@@ -29,7 +26,7 @@
                            (dissoc opts :class :extension? :font?))]
 
          ;; tabler svg react
-         (when-let [klass (gobj/get js/tablerIcons (str "Icon" (csk/->PascalCase name)))]
+         (when-let [_klass (gobj/get js/tablerIcons (str "Icon" (csk/->PascalCase name)))]
            (let [f (shui-utils/component-wrap js/tablerIcons (str "Icon" (csk/->PascalCase name)))]
              [:span.ui__icon.ti
               {:class (str "ls-icon-" name " " class)}

+ 0 - 10
deps/shui/src/logseq/shui/shortcut/v1.cljs

@@ -42,16 +42,6 @@
       result
       (string/capitalize result))))
 
-(defn to-string [input]
-  (cond
-    (string? input) input
-    (keyword? input) (name input)
-    (symbol? input) (name input)
-    (number? input) (str input)
-    (uuid? input) (str input)
-    (nil? input) ""
-    :else (pr-str input)))
-
 (defn- parse-shortcuts
   [s]
   (->> (string/split s #" \| ")

+ 0 - 17
deps/shui/src/logseq/shui/util.cljs

@@ -11,23 +11,6 @@
 
 (goog-define NODETEST false)
 
-;;      /--------------- app ------------\
-;;    /-------- left --------\             \
-;;  /l-side\                  \  /- r-side --\
-;;
-;; |--------|-------------------|-------------| \ head
-;; |--------|-------------------|             | /
-;; |        |                   |             |
-;; |--------|-------------------|-------------|
-
-(def $app (partial gdom/getElement "app-container"))
-(def $left (partial gdom/getElement "left-container"))
-(def $head (partial gdom/getElement "head-container"))
-(def $main (partial gdom/getElement "main-container"))
-(def $main-content (partial gdom/getElement "main-content-container"))
-(def $left-sidebar (partial gdom/getElement "left-sidebar"))
-(def $right-sidebar (partial gdom/getElement "right-sidebar"))
-
 (defn el->clj-rect [el]
   (let [rect (.getBoundingClientRect el)]
     {:top    (.-top rect)

+ 14 - 8
src/main/frontend/components/cmdk/list_item.cljs

@@ -4,10 +4,17 @@
    [rum.core :as rum]
    [clojure.string :as string]
    [goog.string :as gstring]
-   [logseq.shui.icon.v2 :as icon]
-   [logseq.shui.shortcut.v1 :as shortcut]))
+   [logseq.shui.ui :as shui]))
 
-(def to-string shortcut/to-string)
+(defn- to-string [input]
+  (cond
+    (string? input) input
+    (keyword? input) (name input)
+    (symbol? input) (name input)
+    (number? input) (str input)
+    (uuid? input) (str input)
+    (nil? input) ""
+    :else (pr-str input)))
 
 (defn- normalize-text [app-config text]
   (cond-> (to-string text)
@@ -17,7 +24,7 @@
 
 (defn highlight-query* [app-config query text]
   (cond
-    (or (vector? text) (object? text))                                     ; hiccup
+    (or (vector? text) (object? text))                      ; hiccup
     text
 
     (string/blank? query)
@@ -84,13 +91,12 @@
                                          (if highlighted "bg-accent-07-alpha" "bg-gray-05")
                                          " dark:text-white")
                  (= icon-theme :gray) (str " bg-gray-05 dark:text-white"))}
-       (icon/root icon {:size "14"
-                        :class ""})]
+       (shui/tabler-icon icon {:size "14" :class ""})]
       [:div.flex.flex-1.flex-col
        (when title
          [:div.text-sm.pb-2.font-bold.text-gray-11 (highlight-query title)])
        [:div {:class "text-sm font-medium text-gray-12"}
-        (if (and (= group :pages) (not= text source-page)) ;; alias
+        (if (and (= group :pages) (not= text source-page))  ;; alias
           [:div.flex.flex-row.items-center.gap-2
            (highlight-query text)
            (if-not hls-page?
@@ -110,4 +116,4 @@
       (when shortcut
         [:div {:class "flex gap-1"
                :style {:opacity (if (or highlighted hover?) 1 0.9)}}
-         (shortcut/root shortcut)])]]))
+         (shui/shortcut shortcut)])]]))