Преглед на файлове

enhance: add demo graph alert

Tienson Qin преди 4 години
родител
ревизия
762871c1e1
променени са 4 файла, в които са добавени 50 реда и са изтрити 37 реда
  1. 30 35
      src/main/frontend/components/journal.cljs
  2. 4 1
      src/main/frontend/components/page.cljs
  3. 11 1
      src/main/frontend/components/widgets.cljs
  4. 5 0
      src/main/frontend/config.cljs

+ 30 - 35
src/main/frontend/components/journal.cljs

@@ -52,49 +52,44 @@
            (t :open-a-directory)
            :on-click #(page-handler/ls-dir-files! shortcut/refresh!))])
       [:div.flex-1.journal.page (cond->
-                                 {:class (if intro? "logseq-intro" "")}
-                                 data-page-tags
-                                 (assoc :data-page-tags data-page-tags))
+                                  {:class (if intro? "logseq-intro" "")}
+                                  data-page-tags
+                                  (assoc :data-page-tags data-page-tags))
 
-      (when intro?
-        (ui/admonition
-         :warning
-         [:p (util/format
-              "Feel free to edit anything, no change will be saved at this moment. If you do want to persist your work, click the \"Open\" button to open a local directory%s."
-              (if (util/electron?) "" " or connect Logseq to GitHub"))]))
+       (widgets/demo-graph-alert)
 
-      (ui/foldable
-       [:a.initial-color.title.journal-title
-        {:href     (rfe/href :page {:name page})
-         :on-mouse-down (fn [e]
-                          (when (util/right-click? e)
-                            (state/set-state! :page-title/context {:page page})))
-         :on-click (fn [e]
-                     (when (gobj/get e "shiftKey")
-                       (when-let [page page-entity]
-                         (state/sidebar-add-block!
-                          (state/get-current-repo)
-                          (:db/id page)
-                          :page
-                          {:page     page
-                           :journal? true}))
-                       (.preventDefault e)))}
-        [:h1.title
-         (util/capitalize-all title)]]
+       (ui/foldable
+        [:a.initial-color.title.journal-title
+         {:href     (rfe/href :page {:name page})
+          :on-mouse-down (fn [e]
+                           (when (util/right-click? e)
+                             (state/set-state! :page-title/context {:page page})))
+          :on-click (fn [e]
+                      (when (gobj/get e "shiftKey")
+                        (when-let [page page-entity]
+                          (state/sidebar-add-block!
+                           (state/get-current-repo)
+                           (:db/id page)
+                           :page
+                           {:page     page
+                            :journal? true}))
+                        (.preventDefault e)))}
+         [:h1.title
+          (util/capitalize-all title)]]
 
-       (blocks-cp repo page format)
+        (blocks-cp repo page format)
 
-       {})
+        {})
 
-      (when intro? (widgets/add-graph))
+       (when intro? (widgets/add-graph))
 
-      (page/today-queries repo today? false)
+       (page/today-queries repo today? false)
 
-      (rum/with-key
-        (reference/references title false)
-        (str title "-refs"))
+       (rum/with-key
+         (reference/references title false)
+         (str title "-refs"))
 
-      (when intro? (onboarding/intro))])))
+       (when intro? (onboarding/intro))])))
 
 (rum/defc journals < rum/reactive
   [latest-journals]

+ 4 - 1
src/main/frontend/components/page.cljs

@@ -38,7 +38,8 @@
             [goog.object :as gobj]
             [reitit.frontend.easy :as rfe]
             [medley.core :as medley]
-            [rum.core :as rum]))
+            [rum.core :as rum]
+            [frontend.components.widgets :as widgets]))
 
 (defn- get-page-name
   [state]
@@ -326,6 +327,8 @@
                   {:key path-page-name
                    :class (util/classnames [{:is-journals (or journal? fmt-journal?)}])})
 
+           (widgets/demo-graph-alert)
+
            [:div.relative
             (when (and (not sidebar?)
                        (not block?))

+ 11 - 1
src/main/frontend/components/widgets.cljs

@@ -12,7 +12,8 @@
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.util :as util]
-            [rum.core :as rum]))
+            [rum.core :as rum]
+            [frontend.config :as config]))
 
 (rum/defc choose-preferred-format
   []
@@ -132,3 +133,12 @@
                              (interpose [:b.mt-10.mb-5.opacity-50 "OR"]))]
     (rum/with-context [[t] i18n/*tongue-context*]
       [:div.p-8.flex.flex-col available-graph])))
+
+(rum/defc demo-graph-alert
+  []
+  (when (config/demo-graph?)
+    (ui/admonition
+     :warning
+     [:p (util/format
+          "Feel free to edit anything in this demo graph, no change will be saved at this moment. If you do want to persist your work, click the \"Open\" button to open a local directory%s."
+          (if (util/electron?) "" " or connect Logseq to GitHub"))])))

+ 5 - 0
src/main/frontend/config.cljs

@@ -294,6 +294,11 @@
   (string/includes? path (str (get-journals-directory) "/")))
 
 (defonce local-repo "local")
+
+(defn demo-graph?
+  []
+  (= (state/get-current-repo) local-repo))
+
 (defonce local-assets-dir "assets")
 (defonce recycle-dir ".recycle")
 (def config-file "config.edn")