Skip to content

Commit

Permalink
extract sidebar-item into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
devonzuegel authored and tiensonqin committed Nov 15, 2021
1 parent b9045ad commit f137a22
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/main/frontend/components/sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,17 @@
default-home
(dissoc default-home :page)))))

(defn sidebar-item [{class :class title :title on-click-handler :on-click-handler icon :icon}]
(defn sidebar-item
[{on-click-handler :on-click-handler
class :class
title :title
icon :icon
href :href}]
[:div
{:class class}
[:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
{:on-click on-click-handler}
{:on-click on-click-handler
:href href}
(ui/icon (str icon " mr-3") {:style {:font-size 20}})
[:span.flex-1 title]]])

Expand Down Expand Up @@ -249,17 +255,17 @@
[:div.flashcards-nav
(flashcards)]

[:div.graph-view-nav
[:a.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
{:href (rfe/href :graph)}
(ui/icon "hierarchy mr-3" {:style {:font-size 20}})
[:span.flex-1 "Graph view"]]]
(sidebar-item
{:class "graph-view-nav"
:title "Graph view"
:href (rfe/href :graph)
:icon "hierarchy"})

[:div.all-pages-nav
[:a.all-pages-nav.item.group.flex.items-center.px-2.py-2.text-sm.font-medium.rounded-md
{:href (rfe/href :all-pages)}
(ui/icon "files mr-3" {:style {:font-size 20}})
[:span.flex-1 "All pages"]]]]]
(sidebar-item
{:class "all-pages-nav"
:title "All pages"
:href (rfe/href :all-pages)
:icon "files"})]]

(favorites t)

Expand Down Expand Up @@ -434,7 +440,7 @@
:exit 300}}
links
;; (custom-context-menu-content)
))))
))))

(rum/defc new-block-mode < rum/reactive
[]
Expand Down Expand Up @@ -533,10 +539,10 @@
{:class (util/classnames [{:ls-left-sidebar-open left-sidebar-open?}])}

(sidebar-mobile-sidebar
{:open? open?
:left-sidebar-open? left-sidebar-open?
:close-fn close-fn
:route-match route-match})
{:open? open?
:left-sidebar-open? left-sidebar-open?
:close-fn close-fn
:route-match route-match})

[:div.#app-container.h-screen.flex
[:div.flex-1.h-full.flex.flex-col#left-container.relative
Expand Down

0 comments on commit f137a22

Please sign in to comment.