فهرست منبع

refactor: move publish actions to modal

charlie 5 سال پیش
والد
کامیت
d938946a70

+ 29 - 17
src/main/frontend/components/page.cljs

@@ -130,9 +130,9 @@
         {:stroke "currentColor", :view-box "0 0 24 24", :fill "none"}
         [:path
          {:d
-          "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z",
-          :stroke-width "2",
-          :stroke-linejoin "round",
+          "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
+          :stroke-width "2"
+          :stroke-linejoin "round"
           :stroke-linecap "round"}]]]
       [:div.mt-3.text-center.sm:mt-0.sm:ml-4.sm:text-left
        [:h3#modal-headline.text-lg.leading-6.font-medium.text-gray-900
@@ -283,20 +283,32 @@
                              :options {:on-click #(state/set-modal! (rename-page-dialog page-name))}}
                             {:title (t :page/delete)
                              :options {:on-click #(state/set-modal! (delete-page-dialog page-name))}}
-                            {:title (t (if public? :page/make-private :page/make-public))
-                             :options {:on-click #(page-handler/update-public-attribute!
-                                                   page-name
-                                                   (if public? false true))}}
-                            {:title (t :page/publish)
-                             :options {:on-click (fn []
-                                                   (page-handler/publish-page! page-name project/add-project))}}
-                            {:title (t :page/publish-as-slide)
-                             :options {:on-click (fn []
-                                                   (page-handler/publish-page-as-slide! page-name project/add-project))}}
-                            (when published?
-                              {:title (t :page/unpublish)
-                               :options {:on-click (fn []
-                                                     (page-handler/unpublish-page! page-name))}})
+                            {:title   (t :page/action-publish)
+                             :options {:on-click
+                                       (fn []
+                                         (state/set-modal!
+                                          (fn []
+                                            [:div.cp__page-publish-actions
+                                             (mapv (fn [{:keys [title options]}]
+                                                     (when title
+                                                       [:div.it
+                                                        {:on-click #(state/close-modal!)}
+                                                        (apply (partial ui/button title) (flatten (seq options)))]))
+                                                   [{:title   (t :page/publish)
+                                                     :options {:on-click (fn []
+                                                                           (page-handler/publish-page! page-name project/add-project))}}
+                                                    {:title   (t :page/publish-as-slide)
+                                                     :options {:on-click (fn []
+                                                                           (page-handler/publish-page-as-slide! page-name project/add-project))}}
+                                                    (when published?
+                                                      {:title   (t :page/unpublish)
+                                                       :options {:on-click (fn []
+                                                                             (page-handler/unpublish-page! page-name))}})
+                                                    {:title   (t (if public? :page/make-private :page/make-public))
+                                                     :options {:background (if public? "gray" "indigo")
+                                                               :on-click #(page-handler/update-public-attribute!
+                                                                           page-name
+                                                                           (if public? false true))}}])])))}}
                             (when developer-mode?
                               {:title "(Dev) Show page data"
                                :options {:on-click (fn []

+ 26 - 0
src/main/frontend/components/page.css

@@ -1,3 +1,29 @@
 .page-references h2 {
   color: var(--ls-title-text-color);
+}
+
+.cp__page {
+  &-publish-actions {
+    background-color: var(--ls-primary-background-color);
+    padding: 50px 0;
+    margin: -1.5rem;
+
+    > h1 {
+      font-size: 18px;
+      padding: 15px;
+      text-align: center;
+    }
+
+    > .it {
+      display: flex;
+      justify-content: center;
+      padding-bottom: 5px;
+
+      button {
+        width: 90%;
+        justify-content: center;
+        padding: 15px;
+      }
+    }
+  }
 }

+ 4 - 0
src/main/frontend/components/sidebar.css

@@ -74,6 +74,10 @@
   max-width: var(--ls-main-content-max-width);
   min-height: 100vh;
   flex: 1;
+
+  h1.title {
+    padding-right: 15px;
+  }
 }
 
 .cp__sidebar-help {

+ 4 - 3
src/main/frontend/dicts.cljs

@@ -2,7 +2,6 @@
   (:require [tongue.core :as tongue]
             [frontend.config :as config]))
 
-
 ;; TODO
 ;; - [ ] Localizing Number Formats
 ;; - [ ] Localizing Dates
@@ -229,9 +228,10 @@ title: How to take dummy notes?
         :page/rename-to "Rename {1}\" to:\""
         :page/priority "Priority {1}\"\""
         :page/re-index "Re-index this page"
-        :page/copy-to-json "Copi the whole page as JSON"
+        :page/copy-to-json "Copy the whole page as JSON"
         :page/rename "Rename page"
-        :page/make-public "Make it public"
+        :page/action-publish "Publish"
+        :page/make-public "Publish it when exporting to an html file"
         :page/make-private "Make it private"
         :page/delete "Delete page (will delete the file too)"
         :page/publish "Publish this page on Logseq"
@@ -702,6 +702,7 @@ title: How to take dummy notes?
            :page/re-index "对此页面重新建立索引"
            :page/copy-to-json "将整页以 JSON 格式复制"
            :page/rename "重命名本页"
+           :page/action-publish "发布"
            :page/make-public "导出 HTML 时发布本页面"
            :page/make-private "导出 HTML 时取消发布本页面"
            :page/delete "删除本页(并删除文件)"