Browse Source

Add separators to dropdown menu

Devon Zuegel 4 years ago
parent
commit
44b7f3ecf1
2 changed files with 23 additions and 21 deletions
  1. 8 5
      src/main/frontend/components/header.cljs
  2. 15 16
      src/main/frontend/ui.cljs

+ 8 - 5
src/main/frontend/components/header.cljs

@@ -29,9 +29,9 @@
    (if electron-mac?
      svg/home
      (if-let [logo (and config/publishing?
-                       (get-in (state/get-config) [:project :logo]))]
-      [:img.cp__header-logo-img {:src logo}]
-      (svg/logo (not white?))))])
+                        (get-in (state/get-config) [:project :logo]))]
+       [:img.cp__header-logo-img {:src logo}]
+       (svg/logo (not white?))))])
 
 (rum/defc login
   [logged?]
@@ -43,8 +43,7 @@
        (fn [{:keys [toggle-fn]}]
          [:a.fade-link.block.p-2 {:on-click toggle-fn}
           [:span (t :login)]])
-       (let [list [
-                   ;; {:title (t :login-google)
+       (let [list [;; {:title (t :login-google)
                    ;;  :url (str config/website "/login/google")}
                    {:title (t :login-github)
                     :url (str config/website "/login/github")}]]
@@ -84,6 +83,8 @@
          {:title (t :command.ui/toggle-right-sidebar)
           :options {:on-click state/toggle-sidebar-open?!}})
 
+       {:hr true}
+
        (when current-repo
          {:title (t :cards-view)
           :options {:on-click #(state/pub-event! [:modal/show-cards])}})
@@ -108,6 +109,8 @@
           :options {:href (rfe/href :all-journals)}
           :icon svg/calendar-sm})
 
+       {:hr true}
+
        (when-not (state/publishing-enable-editing?)
          {:title (t :settings)
           :options {:on-click state/open-settings!}

+ 15 - 16
src/main/frontend/ui.cljs

@@ -44,7 +44,7 @@
                              (state/set-editor-in-composition! true))))
         props (assoc props
                      :on-change (fn [e] (when-not (state/editor-in-composition?)
-                                         (on-change e)))
+                                          (on-change e)))
                      :on-composition-start on-composition
                      :on-composition-update on-composition
                      :on-composition-end on-composition)]
@@ -91,19 +91,18 @@
    (fn [{:keys [close-fn] :as state}]
      [:div.py-1.rounded-md.shadow-xs
       (when links-header links-header)
-      (for [{:keys [options title icon]} (if (fn? links) (links) links)]
+      (for [{:keys [options title icon hr]} (if (fn? links) (links) links)]
         (let [new-options
               (assoc options
                      :on-click (fn [e]
                                  (when-let [on-click-fn (:on-click options)]
                                    (on-click-fn e))
                                  (close-fn)))
-              child [:div
-                     {:style {:display "flex" :flex-direction "row"}}
-                     [:div {:style {:margin-right "8px"}} title]
-                     ;; [:div {:style {:position "absolute" :right "8px"}}
-                     ;;  icon]
-                     ]]
+              child (if hr
+                      [:hr.my-1]
+                      [:div
+                       {:style {:display "flex" :flex-direction "row"}}
+                       [:div {:style {:margin-right "8px"}} title]])]
           (rum/with-key
             (menu-link new-options child)
             title)))
@@ -211,7 +210,7 @@
                        :key     (name k)}
                       (fn [state]
                         (notification-content state (:content v) (:status v) k)))))
-              contents)))))
+                 contents)))))
 
 (defn checkbox
   [option]
@@ -265,8 +264,8 @@
    when soft keyboard setup"
   []
   (when (and
-       (util/ios?)
-       (not (nil? js/window.visualViewport)))
+         (util/ios?)
+         (not (nil? js/window.visualViewport)))
     (let [viewport js/visualViewport
           style (get-dynamic-style-node)
           sheet (.-sheet style)
@@ -584,15 +583,15 @@
     [:div.flex.flex-col
      [:div.content
       [:div.flex-1.flex-row.foldable-title (cond->
-                                             {:on-mouse-over #(reset! control? true)
-                                              :on-mouse-out  #(reset! control? false)}
+                                            {:on-mouse-over #(reset! control? true)
+                                             :on-mouse-out  #(reset! control? false)}
                                              title-trigger?
                                              (assoc :on-mouse-down on-mouse-down
                                                     :class "cursor"))
        [:div.flex.flex-row.items-center
         [:a.block-control.opacity-50.hover:opacity-100.mr-2
          (cond->
-           {:style    {:width       14
+          {:style    {:width       14
                       :height      16
                       :margin-left -24}}
            (not title-trigger?)
@@ -647,8 +646,8 @@
                    (on-change value)))}
    (for [{:keys [label value selected]} options]
      [:option (cond->
-                {:key   label
-                 :value (or value label)}
+               {:key   label
+                :value (or value label)}
                 selected
                 (assoc :selected selected))
       label])])