Browse Source

enhance: display a button instead of an area on mobile for adding

a graph
Tienson Qin 4 years ago
parent
commit
2460b6d3e4
1 changed files with 24 additions and 21 deletions
  1. 24 21
      src/main/frontend/components/widgets.cljs

+ 24 - 21
src/main/frontend/components/widgets.cljs

@@ -13,7 +13,8 @@
             [frontend.ui :as ui]
             [frontend.util :as util]
             [rum.core :as rum]
-            [frontend.config :as config]))
+            [frontend.config :as config]
+            [frontend.mobile.util :as mobile-util]))
 
 (rum/defc choose-preferred-format
   []
@@ -88,27 +89,29 @@
     [:div.flex.flex-col
      [:h1.title "Add a graph"]
      (let [nfs-supported? (or (nfs/supported?) (mobile/is-native-platform?))]
-       [:div.cp__widgets-open-local-directory
-        [:div.select-file-wrap.cursor
-         (when nfs-supported?
-           {:on-click #(page-handler/ls-dir-files! shortcut/refresh!)})
+       (if (mobile-util/is-native-platform?)
+         (ui/button "Open a local directory"
+           :on-click #(page-handler/ls-dir-files! shortcut/refresh!))
+         [:div.cp__widgets-open-local-directory
+          [:div.select-file-wrap.cursor
+           (when nfs-supported?
+             {:on-click #(page-handler/ls-dir-files! shortcut/refresh!)})
+           [:div
+            [:h1.title "Open a local directory"]
+            [:p "Logseq supports both Markdown and Org-mode. You can open an existing directory or create a new one on your device, a directory is also known simply as a folder. Your data will be stored only on this device."]
+            [:p "After you have opened your directory, it will create three folders in that directory:"]
+            [:ul
+             [:li "/journals - store your journal pages"]
+             [:li "/pages - store the other pages"]
+             [:li "/logseq - store configuration, custom.css, and some metadata."]]
+            (when-not nfs-supported?
+              (ui/admonition :warning
+                             [:p "It seems that your browser doesn't support the "
 
-         [:div
-          [:h1.title "Open a local directory"]
-          [:p "Logseq supports both Markdown and Org-mode. You can open an existing directory or create a new one on your device, a directory is also known simply as a folder. Your data will be stored only on this device."]
-          [:p "After you have opened your directory, it will create three folders in that directory:"]
-          [:ul
-           [:li "/journals - store your journal pages"]
-           [:li "/pages - store the other pages"]
-           [:li "/logseq - store configuration, custom.css, and some metadata."]]
-          (when-not nfs-supported?
-            (ui/admonition :warning
-                           [:p "It seems that your browser doesn't support the "
-
-                            [:a {:href   "https://web.dev/file-system-access/"
-                                 :target "_blank"}
-                             "new native filesystem API"]
-                            [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]])]))
+                              [:a {:href   "https://web.dev/file-system-access/"
+                                   :target "_blank"}
+                               "new native filesystem API"]
+                              [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]]))]))
 
 (rum/defcs add-graph <
   [state & {:keys [graph-types]