mirror of https://github.com/logseq/logseq
parent
8d2d857ca3
commit
12ddf65a22
|
@ -1,29 +1,34 @@
|
||||||
(ns logseq.shui.core
|
(ns logseq.shui.core
|
||||||
(:require
|
(:require
|
||||||
[logseq.shui.button.v2 :as shui.button.v2]
|
[logseq.shui.button.v2 :as shui.button.v2]
|
||||||
[logseq.shui.context :as shui.context]
|
[logseq.shui.context :as shui.context]
|
||||||
[logseq.shui.dialog.v1 :as shui.dialog.v1]
|
[logseq.shui.dialog.v1 :as shui.dialog.v1]
|
||||||
[logseq.shui.icon.v2 :as shui.icon.v2]
|
[logseq.shui.icon.v2 :as shui.icon.v2]
|
||||||
[logseq.shui.list-item.v1 :as shui.list-item.v1]
|
[logseq.shui.list-item.v1 :as shui.list-item.v1]
|
||||||
[logseq.shui.table.v2 :as shui.table.v2]))
|
[logseq.shui.table.v2 :as shui.table.v2]
|
||||||
|
[logseq.shui.shortcut.v1 :as shui.shortcut.v1]))
|
||||||
|
|
||||||
;; table component
|
;; table component
|
||||||
(def table shui.table.v2/root)
|
(def table shui.table.v2/root)
|
||||||
(def table-v2 shui.table.v2/root)
|
(def table-v2 shui.table.v2/root)
|
||||||
|
|
||||||
;; button component
|
;; shortcut
|
||||||
|
(def shortcut shui.shortcut.v1/root)
|
||||||
|
(def shortcut-v2 shui.shortcut.v1/root)
|
||||||
|
|
||||||
|
;; button component
|
||||||
(def button shui.button.v2/root)
|
(def button shui.button.v2/root)
|
||||||
(def button-v2 shui.button.v2/root)
|
(def button-v2 shui.button.v2/root)
|
||||||
|
|
||||||
;; icon
|
;; icon
|
||||||
(def icon shui.icon.v2/root)
|
(def icon shui.icon.v2/root)
|
||||||
(def icon-v2 shui.icon.v2/root)
|
(def icon-v2 shui.icon.v2/root)
|
||||||
|
|
||||||
;; list-item
|
;; list-item
|
||||||
(def list-item shui.list-item.v1/root)
|
(def list-item shui.list-item.v1/root)
|
||||||
(def list-item-v1 shui.list-item.v1/root)
|
(def list-item-v1 shui.list-item.v1/root)
|
||||||
|
|
||||||
;; dialog
|
;; dialog
|
||||||
(def dialog shui.dialog.v1/root)
|
(def dialog shui.dialog.v1/root)
|
||||||
(def dialog-v1 shui.dialog.v1/root)
|
(def dialog-v1 shui.dialog.v1/root)
|
||||||
|
|
||||||
|
|
|
@ -4,35 +4,9 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[logseq.shui.icon.v2 :as icon]
|
[logseq.shui.icon.v2 :as icon]
|
||||||
[logseq.shui.button.v2 :as button]))
|
[logseq.shui.shortcut.v1 :as shortcut]))
|
||||||
|
|
||||||
(defn to-string [input]
|
(def to-string shortcut/to-string)
|
||||||
(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 print-shortcut-key [key]
|
|
||||||
(case key
|
|
||||||
("cmd" "command" "mod" "⌘") "⌘"
|
|
||||||
("return" "enter" "⏎") "⏎"
|
|
||||||
("shift" "⇧") "⇧"
|
|
||||||
("alt" "option" "opt" "⌥") "⌥"
|
|
||||||
("ctrl" "control" "⌃") "⌃"
|
|
||||||
("space" " ") " "
|
|
||||||
("up" "↑") "↑"
|
|
||||||
("down" "↓") "↓"
|
|
||||||
("left" "←") "←"
|
|
||||||
("right" "→") "→"
|
|
||||||
("disabled" "Disabled") ""
|
|
||||||
("backspace" "delete") ""
|
|
||||||
("tab") ""
|
|
||||||
(nil) ""
|
|
||||||
(name key)))
|
|
||||||
|
|
||||||
(defn normalize-text [app-config text]
|
(defn normalize-text [app-config text]
|
||||||
(cond-> (to-string text)
|
(cond-> (to-string text)
|
||||||
|
@ -97,7 +71,6 @@
|
||||||
:else
|
:else
|
||||||
[:span text-string]))))))
|
[:span text-string]))))))
|
||||||
|
|
||||||
;; result-item
|
|
||||||
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value title highlighted on-highlight on-highlight-dep header on-click hoverable compact rounded on-mouse-enter component-opts] :as _props :or {hoverable true rounded true}}
|
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value title highlighted on-highlight on-highlight-dep header on-click hoverable compact rounded on-mouse-enter component-opts] :as _props :or {hoverable true rounded true}}
|
||||||
{:keys [app-config] :as context}]
|
{:keys [app-config] :as context}]
|
||||||
(let [ref (rum/create-ref)
|
(let [ref (rum/create-ref)
|
||||||
|
@ -153,17 +126,4 @@
|
||||||
(when shortcut
|
(when shortcut
|
||||||
[:div {:class "flex gap-1"
|
[:div {:class "flex gap-1"
|
||||||
:style {:opacity (if highlighted 1 0.5)}}
|
:style {:opacity (if highlighted 1 0.5)}}
|
||||||
(for [[index option] (map-indexed vector (string/split shortcut #" \| "))]
|
(shortcut/root shortcut context)])]]))
|
||||||
[:<>
|
|
||||||
(when (< 0 index)
|
|
||||||
[:div.text-gray-11.text-sm "|"])
|
|
||||||
(for [sequence (string/split option #" ")
|
|
||||||
:let [text (->> (string/split sequence #"\+")
|
|
||||||
(map print-shortcut-key)
|
|
||||||
(apply str))]]
|
|
||||||
(button/root {:theme :gray
|
|
||||||
:interactive false
|
|
||||||
:text (string/upper-case (to-string text))
|
|
||||||
:tiled true
|
|
||||||
:size :sm}
|
|
||||||
context))])])]]))
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
(ns logseq.shui.shortcut.v1
|
||||||
|
(:require [clojure.string :as string]
|
||||||
|
[logseq.shui.button.v2 :as button]
|
||||||
|
[rum.core :as rum]))
|
||||||
|
|
||||||
|
(defn print-shortcut-key [key]
|
||||||
|
(case key
|
||||||
|
("cmd" "command" "mod" "⌘") "⌘"
|
||||||
|
("return" "enter" "⏎") "⏎"
|
||||||
|
("shift" "⇧") "⇧"
|
||||||
|
("alt" "option" "opt" "⌥") "⌥"
|
||||||
|
("ctrl" "control" "⌃") "⌃"
|
||||||
|
("space" " ") " "
|
||||||
|
("up" "↑") "↑"
|
||||||
|
("down" "↓") "↓"
|
||||||
|
("left" "←") "←"
|
||||||
|
("right" "→") "→"
|
||||||
|
("disabled" "Disabled") ""
|
||||||
|
("backspace" "delete") ""
|
||||||
|
("tab") ""
|
||||||
|
(nil) ""
|
||||||
|
(name key)))
|
||||||
|
|
||||||
|
;; TODO: shortcut component shouldn't worry about this
|
||||||
|
(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)))
|
||||||
|
|
||||||
|
(rum/defc root
|
||||||
|
[shortcut context]
|
||||||
|
[:<>
|
||||||
|
(for [[index option] (map-indexed vector (string/split shortcut #" \| "))]
|
||||||
|
[:<>
|
||||||
|
(when (< 0 index)
|
||||||
|
[:div.text-gray-11.text-sm "|"])
|
||||||
|
(for [sequence (string/split option #" ")
|
||||||
|
:let [text (->> (string/split sequence #"\+")
|
||||||
|
(map print-shortcut-key)
|
||||||
|
(apply str))]]
|
||||||
|
(button/root {:theme :gray
|
||||||
|
:interactive false
|
||||||
|
:text (string/upper-case (to-string text))
|
||||||
|
:tiled true
|
||||||
|
:size :sm
|
||||||
|
:mused true}
|
||||||
|
context))])])
|
|
@ -367,8 +367,12 @@
|
||||||
(when (or can-show-more? can-show-less?)
|
(when (or can-show-more? can-show-less?)
|
||||||
[:a.fade-link.select-node {:on-click (if (= show :more) show-less show-more)}
|
[:a.fade-link.select-node {:on-click (if (= show :more) show-less show-more)}
|
||||||
(if (= show :more)
|
(if (= show :more)
|
||||||
"Show less"
|
[:div.flex.flex-row.gap-1.items-center
|
||||||
"Show more")])]
|
"Show less"
|
||||||
|
(shui/shortcut "mod up" nil)]
|
||||||
|
[:div.flex.flex-row.gap-1.items-center
|
||||||
|
"Show more"
|
||||||
|
(shui/shortcut "mod down" nil)])])]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
(for [item visible-items
|
(for [item visible-items
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
"~" "shift+`"
|
"~" "shift+`"
|
||||||
"⇧" "shift"
|
"⇧" "shift"
|
||||||
"←" "left"
|
"←" "left"
|
||||||
"→" "right"}]
|
"→" "right"
|
||||||
|
"↑" "up"
|
||||||
|
"↓" "down"}]
|
||||||
(-> binding
|
(-> binding
|
||||||
(str/replace #"[;=-\[\]'\(\)\~\→\←\⇧]" #(get keynames %))
|
(str/replace #"[;=-\[\]'\(\)\~\→\←\⇧]" #(get keynames %))
|
||||||
(str/replace #"\s+" " ")
|
(str/replace #"\s+" " ")
|
||||||
|
@ -50,6 +52,8 @@
|
||||||
(str/replace "shift+/" "?")
|
(str/replace "shift+/" "?")
|
||||||
(str/replace "left" "←")
|
(str/replace "left" "←")
|
||||||
(str/replace "right" "→")
|
(str/replace "right" "→")
|
||||||
|
(str/replace "up" "↑")
|
||||||
|
(str/replace "down" "↓")
|
||||||
(str/replace "shift" "⇧")
|
(str/replace "shift" "⇧")
|
||||||
(str/replace "open-square-bracket" "[")
|
(str/replace "open-square-bracket" "[")
|
||||||
(str/replace "close-square-bracket" "]")
|
(str/replace "close-square-bracket" "]")
|
||||||
|
|
Loading…
Reference in New Issue