Browse Source

enhance(ux): capture submit button

Tienson Qin 2 days ago
parent
commit
1dc6a05fba

+ 9 - 8
src/main/frontend/components/quick_add.cljs

@@ -49,18 +49,19 @@
                          (when-not mobile? (shui/shortcut ["mod" "e"]))
                          "Add to today")]]
         [:div.ls-quick-add.flex.flex-1.flex-col.w-full.gap-4
-         [:div.flex.flex-row.justify-between.gap-4.items-center
-          {:class (if mobile?
-                    "pt-4"
-                    "border-b pb-4")}
-          [:div.font-medium
-           "Quick add"]
-          (when mobile? add-button)]
+         (when-not (util/mobile?)
+           [:div.flex.flex-row.justify-between.gap-4.items-center
+            {:class (if mobile?
+                      "pt-4"
+                      "border-b pb-4")}
+            [:div.font-medium
+             "Quick add"]
+            add-button])
          (if mobile?
            [:main#app-container-wrapper.ls-fold-button-on-right
             [:div#app-container.pt-2
              [:div#main-container.flex.flex-1
-              [:div.w-full
+              [:div.w-full.mt-4
                (page-blocks add-page)]]]]
            [:div.content {:class "block -ml-6"}
             (page-blocks add-page)])

+ 26 - 17
src/main/mobile/components/editor_toolbar.cljs

@@ -64,7 +64,6 @@
   {:id (if indent? "indent" "outdent")
    :title (if indent? "Indent" "Outdent")
    :system-icon (if indent? "arrow.right" "arrow.left")
-   :icon (if indent? "arrow-right-to-arc" "arrow-left-to-arc")
    :handler (fn []
               (blur-if-compositing)
               (editor-handler/indent-outdent indent?))})
@@ -74,7 +73,6 @@
   {:id "todo"
    :title "Todo"
    :system-icon "checkmark.square"
-   :icon "checkbox"
    :event? true
    :handler (fn []
               (blur-if-compositing)
@@ -85,7 +83,6 @@
   {:id "tag"
    :title "Tag"
    :system-icon "number"
-   :icon "hash"
    :event? true
    :handler #(insert-text "#" {})})
 
@@ -95,7 +92,6 @@
    :title "Reference"
    ;; TODO: create sf symbol for brackets
    :system-icon "parentheses"
-   :icon "brackets"
    :event? true
    :handler insert-page-ref!})
 
@@ -104,7 +100,6 @@
   {:id "slash"
    :title "Slash"
    :system-icon "command"
-   :icon "command"
    :event? true
    :handler #(insert-text "/" {})})
 
@@ -113,7 +108,6 @@
   {:id "camera"
    :title "Photo"
    :system-icon "camera"
-   :icon "camera"
    :event? true
    :handler #(when-let [parent-id (state/get-edit-input-id)]
                (mobile-camera/embed-photo parent-id))})
@@ -123,7 +117,6 @@
   {:id "audio"
    :title "Audio"
    :system-icon "waveform"
-   :icon (svg/audio-lines 20)
    :handler #(recorder/record!)})
 
 (defn- keyboard-action
@@ -131,26 +124,42 @@
   {:id "keyboard"
    :title "Hide"
    :system-icon "keyboard.chevron.compact.down"
-   :icon "keyboard-show"
    :handler #(p/do!
               (editor-handler/save-current-block!)
               (state/clear-edit!)
               (mobile-init/keyboard-hide))})
 
+(defn- capture-action
+  []
+  {:id "capture"
+   :title "Capture"
+   :system-icon "paperplane"
+   :handler (fn []
+              (state/clear-edit!)
+              (mobile-init/keyboard-hide)
+              (editor-handler/quick-add-blocks!))})
+
 (defn- toolbar-actions
   [quick-add?]
   (let [audio (audio-action)
         keyboard (keyboard-action)
-        main-actions (cond-> [(todo-action)
-                              (indent-outdent-action false)
-                              (indent-outdent-action true)
-                              (tag-action)
-                              (camera-action)
-                              (page-ref-action)
-                              (slash-action)]
-                       (not quick-add?) (conj audio))]
+        main-actions (if quick-add?
+                       [(todo-action)
+                        audio
+                        (camera-action)
+                        (tag-action)
+                        (page-ref-action)
+                        (indent-outdent-action false)
+                        (indent-outdent-action true)]
+                       [(todo-action)
+                        (indent-outdent-action false)
+                        (indent-outdent-action true)
+                        (tag-action)
+                        (camera-action)
+                        (page-ref-action)
+                        (slash-action)])]
     {:main main-actions
-     :trailing (if quick-add? audio keyboard)}))
+     :trailing (if quick-add? (capture-action) keyboard)}))
 
 (defn- action->native
   [{:keys [id title system-icon]}]