Skip to content

Commit

Permalink
modal :action-brand, optional action
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jun 6, 2016
1 parent 0e60946 commit 76ada48
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
19 changes: 7 additions & 12 deletions src/cljs/ulysses/components/layout.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@
on-close (partial dispatch [:modal-close])]
(fn []
(when-let [ms @mss]
(let [{:keys [title action-label on-action children]} ms]
[modal-panel
:wrap-nicely? false
:backdrop-on-click on-close
:class (classes :modal-alpha)
:child
[modal-dialog
title
action-label
(fn [] (on-action) (on-close))
on-close
children]])))))
[modal-panel
:wrap-nicely? false
:backdrop-on-click on-close
:class (classes :modal-alpha)
:child
[modal-dialog
(assoc ms :on-close on-close)]]))))

(defn shell [page-name page]
[:div.shell
Expand Down
31 changes: 21 additions & 10 deletions src/cljs/ulysses/components/misc.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@
;; ----------------------------------------------------------------------------

(defn modal-dialog
[title action-label on-action on-close & body]
[:div.modal-content
[:div.modal-header
[:button {:type :button :class :close :on-click on-close}
[:span "×"]]
[:h4.modal-title title]]
(into [:div.modal-body] body)
[:div.modal-footer
[:button {:type :button :class (classes :btn :btn-secondary) :on-click on-close} "Close"]
[:button {:type :button :class (classes :btn :btn-primary) :on-click on-action} action-label]]])
[{:keys [title action-label action-brand on-action on-close children]
:or {action-brand :primary}}]
(let [on-action-close (fn [] (on-action) (on-close))]
[:div.modal-content
[:div.modal-header
[:button {:type :button :class :close :on-click on-close}
[:span "×"]]
[:h4.modal-title title]]
(into [:div.modal-body] children)
[:div.modal-footer
[:button
{:type :button
:class (classes :btn :btn-secondary)
:on-click on-close}
"Close"]
(when action-label
[:button
{:type :button
:class (classes :btn (str "btn-" (name action-brand)))
:on-click on-action-close}
action-label])]]))
1 change: 1 addition & 0 deletions src/cljs/ulysses/pages/builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
[:modal
{:title [:span "Delete Workspace " [:i (:name workspace-current)]]
:action-label "Delete"
:action-brand :danger
:on-action #(dispatch [:workspace-delete])
:children "Are you sure you want to delete this workspace?"}]))
(classes-attr :btn :btn-sm :btn-danger)
Expand Down

0 comments on commit 76ada48

Please sign in to comment.