Răsfoiți Sursa

chore: use admonition instead

Tienson Qin 4 ani în urmă
părinte
comite
9077499ec0
2 a modificat fișierele cu 13 adăugiri și 62 ștergeri
  1. 12 20
      src/main/frontend/components/page.cljs
  2. 1 42
      src/main/frontend/components/page.css

+ 12 - 20
src/main/frontend/components/page.cljs

@@ -52,22 +52,13 @@
         (page-handler/add-page-to-recent! repo page-original-name)
         (db/get-page-blocks repo page-name)))))
 
-(rum/defc page-conflict-file-warning
-  [file-path blocks]
-  [:div.conflict-files-warning-it
-   [:a {:title "Go to change the page title"
-        :key file-path
-        :href (rfe/href :file {:path file-path})} file-path]])
-
 (rum/defc page-blocks-cp < rum/reactive
   db-mixins/query
   [repo page file-path page-name page-original-name encoded-page-name sidebar? journal? block? block-id format]
   (let [raw-page-blocks (get-blocks repo page-name page-original-name block? block-id)
         grouped-blocks-by-file (into {} (for [[k v] (db-utils/group-by-file raw-page-blocks)]
                                           [(:file/path (db-utils/entity (:db/id k))) v]))
-        raw-page-blocks (if (contains? grouped-blocks-by-file file-path)
-                          (get grouped-blocks-by-file file-path)
-                          raw-page-blocks)
+        raw-page-blocks (get grouped-blocks-by-file file-path raw-page-blocks)
         page-blocks (block-handler/with-dummy-block raw-page-blocks format
                       (if (empty? raw-page-blocks)
                         (let [content (db/get-file repo file-path)]
@@ -87,15 +78,17 @@
                        :editor-box editor/box}
         hiccup-config (common-handler/config-with-document-mode hiccup-config)
         hiccup (block/->hiccup page-blocks hiccup-config {})]
-
     [:div.page-blocks-inner
-
-     ;; more than one file conflict
-     (when (seq (dissoc grouped-blocks-by-file file-path))
-       [:div.conflict-files-warning-wrap
-        [:h3 "⚠️ Those pages have the same title, you might want to only keep one file: "]
-        (for [[file-path blocks] (into (sorted-map) grouped-blocks-by-file)]
-          (page-conflict-file-warning file-path blocks))])
+     (when (and (seq grouped-blocks-by-file)
+                (> (count grouped-blocks-by-file) 1))
+       (ui/admonition
+        :warning
+        [:div.text-sm
+         [:p.font-medium "Those pages have the same title, you might want to only keep one file."]
+         [:ol
+          (for [[file-path blocks] (into (sorted-map) grouped-blocks-by-file)]
+            [:li [:a {:key file-path
+                      :href (rfe/href :file {:path file-path})} file-path]])]]))
 
      (rum/with-key
        (content/content page-name
@@ -433,8 +426,7 @@
                   (block/block-parents config repo block-id format)]))
 
              ;; blocks
-             [:div.page-blocks-root
-              (page-blocks-cp repo page file-path page-name page-original-name encoded-page-name sidebar? journal? block? block-id format)]]]
+             (page-blocks-cp repo page file-path page-name page-original-name encoded-page-name sidebar? journal? block? block-id format)]]
 
            (when-not block?
              (today-queries repo today? sidebar?))

+ 1 - 42
src/main/frontend/components/page.css

@@ -2,47 +2,6 @@
   color: var(--ls-title-text-color);
 }
 
-.page-blocks {
-  &-inner {
-    .conflict-files-warning {
-      &-wrap {
-        font-size: 13px;
-        padding: 4px 15px;
-        padding-bottom: 8px;
-        line-height: 1;
-        margin: 5px;
-        margin-bottom: 20px;
-        border-width: 1px;
-        border-style: dotted;
-        border-radius: var(--ls-border-radius-low);
-        border-color: var(--ls-secondary-border-color);
-
-        > h3 {
-          font-weight: bold;
-          padding-top: 8px;
-          padding-bottom: 5px;
-          font-size: 14px;
-          line-height: 1.2em;
-          color: var(--ls-secondary-text-color);
-        }
-      }
-
-      &-it {
-        a {
-          display: flex;
-          align-items: center;
-          padding: 3px 0;
-        }
-
-        svg {
-          display: inline;
-          transform: scale(.6);
-        }
-      }
-    }
-  }
-}
-
 .cp__page {
   &-publish-actions {
     background-color: var(--ls-primary-background-color);
@@ -68,4 +27,4 @@
       }
     }
   }
-}
+}