From cfd1fc2516295cc7e9d819a945ce6e4edbe12b07 Mon Sep 17 00:00:00 2001 From: Daniel Glauser Date: Sat, 25 Oct 2014 12:09:20 -0600 Subject: [PATCH 01/29] Minor spelling fix. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f1b620..22fd878 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Om-Bootstrap's [documentation site](http://om-bootstrap.herokuapp.com/) has usag ## Mixins -The project contains a few mixins that help in writing active Om components. THe current set of mixins makes it easy to set listeners and timeouts on some component, and guarantee that they'll be cleaned up when the component unmounts: +The project contains a few mixins that help in writing active Om components. The current set of mixins makes it easy to set listeners and timeouts on some component, and guarantee that they'll be cleaned up when the component unmounts: * `set-listener-mixin` (mixins.cljs) * `set-timeout-mixin` (mixins.cljs) From 2582cfba508592b7d4dbd77af52f7765cde46233 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:27:18 -0800 Subject: [PATCH 02/29] Update CHANGELOG.md --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11e7f68..c64e1b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## 0.3.3 (12/9/2014) +## 0.3.2 (12/9/2014) +- Added `href` tags to all `Show Code` links. Without these they weren't expanding on mobile browsers (https://github.com/racehub/om-bootstrap/issues/34) - Fixed compatibility issue with om-0.8.0-beta3, and added tests. - Upgraded clojure to 1.7.0-alpha2 - Upgraded core.async to 0.1.346.0-17112a-alpha @@ -7,10 +8,6 @@ - Upgraded schema to 0.3.1 - Upgraded weasel to 0.4.2 -## 0.3.2 - -- Added `href` tags to all `Show Code` links. Without these they weren't expanding on mobile browsers (https://github.com/racehub/om-bootstrap/issues/34) - ## 0.3.1 (10/15/2014) - Revert schema upgrade... fancy that :) From f2c28b48e2225e7da6f0eec703bd19bffb881353 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 09:35:43 -0800 Subject: [PATCH 03/29] add collapsible classes in render-navbar-child --- src/om_bootstrap/nav.cljs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index 8f0f650..67d839b 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -89,7 +89,6 @@ [_] (let [{:keys [opts children]} (om/get-props owner) [bs props] (t/separate Nav opts {:bs-class "nav"}) - classes {:navbar-collapse (:collapsible? bs)} ul-props {:ref "ul" :class (d/class-set (merge (t/bs-class-set bs) @@ -101,8 +100,7 @@ (if (and (:navbar? bs) (not (:collapsible? bs))) (d/ul (u/merge-props props ul-props) children) - (d/nav (u/merge-props props {:class (d/class-set classes)}) - (d/ul ul-props children)))))) + (d/nav props (d/ul ul-props children)))))) (sm/defn nav :- t/Component [opts :- Nav & children] @@ -130,11 +128,11 @@ (defn render-toggle-button [owner bs] (let [handle-toggle (fn [] + (om/set-state! owner [:changing?] true) (when-let [f (:on-toggle bs)] - (om/set-state-nr! owner [:changing?] true) - (f) - (om/set-state-nr! owner [:changing?] false)) - (om/update-state-nr! owner [:changing?] not)) + (f)) + (om/set-state! owner [:changing?] false) + (om/update-state! owner [:nav-open?] not)) tb (u/clone-with-props (:toggle-button bs) {:class "navbar-toggle" :on-click handle-toggle})] @@ -169,15 +167,22 @@ (u/clone-with-props child prop-fn)))) (defn render-navbar-child [owner child bs] - (let [f (fn [props] + (let [nav-open? (om/get-state owner :nav-open?) + changing? (om/get-state owner :changing?) + f (fn [props] (let [opts (:opts props) collapsible? (when (:toggle-nav-key bs) (= (:key opts) (:toggle-nav-key bs))) + expanded? (and collapsible? + (or (:nav-expanded? bs) + nav-open?)) + collapsed? (not expanded?) base {:navbar? true - :collapsible? collapsible? - :expanded? (and collapsible? - (or (:nav-expanded? bs) - (om/get-state owner :nav-open?)))}] + :class (d/class-set {:navbar-collapse collapsible? + :collapse (not changing?) + :collapsing changing? + :in (and (not changing?) + expanded?)})}] (update-in props [:opts] u/merge-props base)))] (u/clone-with-props child f))) @@ -206,6 +211,10 @@ (when (or (:brand bs) (:toggle-button bs) (:toggle-nav-key bs)) + ;;TODO: Think about `render-header`, and if brand and + ;;toggle button are the only things that would ever go + ;;in there. What if someone wants a brand, and some + ;;text? (render-header owner bs)) (map #(render-navbar-child owner % bs) children)))))) From aea0cb8c47e8c6a27d82dc88d610e1612f1b60cb Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 14:04:51 -0800 Subject: [PATCH 04/29] revert some changes --- src/om_bootstrap/nav.cljs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index 67d839b..9367cf0 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -89,6 +89,7 @@ [_] (let [{:keys [opts children]} (om/get-props owner) [bs props] (t/separate Nav opts {:bs-class "nav"}) + classes {:navbar-collapse (:collapsible? bs)} ul-props {:ref "ul" :class (d/class-set (merge (t/bs-class-set bs) @@ -100,7 +101,8 @@ (if (and (:navbar? bs) (not (:collapsible? bs))) (d/ul (u/merge-props props ul-props) children) - (d/nav props (d/ul ul-props children)))))) + (d/nav (u/merge-props props {:class (d/class-set classes)}) + (d/ul ul-props children)))))) (sm/defn nav :- t/Component [opts :- Nav & children] @@ -128,10 +130,10 @@ (defn render-toggle-button [owner bs] (let [handle-toggle (fn [] - (om/set-state! owner [:changing?] true) (when-let [f (:on-toggle bs)] - (f)) - (om/set-state! owner [:changing?] false) + (om/set-state! owner [:changing?] true) + (f) + (om/set-state! owner [:changing?] false)) (om/update-state! owner [:nav-open?] not)) tb (u/clone-with-props (:toggle-button bs) {:class "navbar-toggle" @@ -167,15 +169,14 @@ (u/clone-with-props child prop-fn)))) (defn render-navbar-child [owner child bs] - (let [nav-open? (om/get-state owner :nav-open?) - changing? (om/get-state owner :changing?) + (let [changing? (om/get-state owner :changing?) f (fn [props] (let [opts (:opts props) collapsible? (when (:toggle-nav-key bs) (= (:key opts) (:toggle-nav-key bs))) expanded? (and collapsible? (or (:nav-expanded? bs) - nav-open?)) + (om/get-state owner :nav-open?))) collapsed? (not expanded?) base {:navbar? true :class (d/class-set {:navbar-collapse collapsible? @@ -211,10 +212,6 @@ (when (or (:brand bs) (:toggle-button bs) (:toggle-nav-key bs)) - ;;TODO: Think about `render-header`, and if brand and - ;;toggle button are the only things that would ever go - ;;in there. What if someone wants a brand, and some - ;;text? (render-header owner bs)) (map #(render-navbar-child owner % bs) children)))))) From 81fc633375935951f3b23d96df28bf8c7c8b3c1b Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 14:33:04 -0800 Subject: [PATCH 05/29] add example --- dev/snippets/nav/bar_basic.cljs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/snippets/nav/bar_basic.cljs b/dev/snippets/nav/bar_basic.cljs index c58e9a7..a1b0267 100644 --- a/dev/snippets/nav/bar_basic.cljs +++ b/dev/snippets/nav/bar_basic.cljs @@ -1,11 +1,14 @@ #_ (:require [om-bootstrap.button :as b] - [om-bootstrap.nav :as n]) + [om-bootstrap.nav :as n] + [om-tools.dom :as d :include-macros true]) (n/navbar - {} + {:brand (d/a {:href "#"} + "Navbar") + :toggle-nav-key 0} (n/nav - {:collapsible? true} + {:key 0} (n/nav-item {:key 1 :href "#"} "Link") (n/nav-item {:key 2 :href "#"} "Link") (b/dropdown {:key 3, :title "Dropdown"} From 53b63afc3583ff683dfcf415275db13de5ce5671 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 20:03:58 -0800 Subject: [PATCH 06/29] move class setting inside nav, edit changelog, revert update change --- CHANGELOG.md | 3 +++ src/om_bootstrap/nav.cljs | 24 ++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c64e1b6..6c054bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.3 +- Added collapse functionality for navbars (https://github.com/racehub/om-bootstrap/pull/41) + ## 0.3.2 (12/9/2014) - Added `href` tags to all `Show Code` links. Without these they weren't expanding on mobile browsers (https://github.com/racehub/om-bootstrap/issues/34) diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index 9367cf0..f71d645 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -89,7 +89,9 @@ [_] (let [{:keys [opts children]} (om/get-props owner) [bs props] (t/separate Nav opts {:bs-class "nav"}) - classes {:navbar-collapse (:collapsible? bs)} + classes (d/class-set {:navbar-collapse (:collapsible? bs) + :collapse (not (:expanded? bs)) + :in (:expanded? bs)}) ul-props {:ref "ul" :class (d/class-set (merge (t/bs-class-set bs) @@ -131,9 +133,9 @@ (defn render-toggle-button [owner bs] (let [handle-toggle (fn [] (when-let [f (:on-toggle bs)] - (om/set-state! owner [:changing?] true) + (om/set-state-nr! owner [:changing?] true) (f) - (om/set-state! owner [:changing?] false)) + (om/set-state-nr! owner [:changing?] false)) (om/update-state! owner [:nav-open?] not)) tb (u/clone-with-props (:toggle-button bs) {:class "navbar-toggle" @@ -169,21 +171,15 @@ (u/clone-with-props child prop-fn)))) (defn render-navbar-child [owner child bs] - (let [changing? (om/get-state owner :changing?) - f (fn [props] + (let [f (fn [props] (let [opts (:opts props) collapsible? (when (:toggle-nav-key bs) (= (:key opts) (:toggle-nav-key bs))) - expanded? (and collapsible? - (or (:nav-expanded? bs) - (om/get-state owner :nav-open?))) - collapsed? (not expanded?) base {:navbar? true - :class (d/class-set {:navbar-collapse collapsible? - :collapse (not changing?) - :collapsing changing? - :in (and (not changing?) - expanded?)})}] + :collapsible? collapsible? + :expanded? (and collapsible? + (or (:nav-expanded? bs) + (om/get-state owner :nav-open?)))}] (update-in props [:opts] u/merge-props base)))] (u/clone-with-props child f))) From 589f2afa76880b2efab41b82f628213a48f5bd6b Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 22:51:01 -0800 Subject: [PATCH 07/29] fix class-set error, and add :collapsible? support to navs in navbars --- dev/snippets/nav/bar_basic.cljs | 5 ++--- src/om_bootstrap/nav.cljs | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dev/snippets/nav/bar_basic.cljs b/dev/snippets/nav/bar_basic.cljs index a1b0267..3f3be6c 100644 --- a/dev/snippets/nav/bar_basic.cljs +++ b/dev/snippets/nav/bar_basic.cljs @@ -5,10 +5,9 @@ (n/navbar {:brand (d/a {:href "#"} - "Navbar") - :toggle-nav-key 0} + "Navbar")} (n/nav - {:key 0} + {:collapsible? true} (n/nav-item {:key 1 :href "#"} "Link") (n/nav-item {:key 2 :href "#"} "Link") (b/dropdown {:key 3, :title "Dropdown"} diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index f71d645..f794bec 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -89,9 +89,9 @@ [_] (let [{:keys [opts children]} (om/get-props owner) [bs props] (t/separate Nav opts {:bs-class "nav"}) - classes (d/class-set {:navbar-collapse (:collapsible? bs) - :collapse (not (:expanded? bs)) - :in (:expanded? bs)}) + classes {:navbar-collapse (:collapsible? bs) + :collapse (not (:expanded? bs)) + :in (:expanded? bs)} ul-props {:ref "ul" :class (d/class-set (merge (t/bs-class-set bs) @@ -148,13 +148,20 @@ (d/span {:class "icon-bar" :key 2}) (d/span {:class "icon-bar" :key 3})])))) +(sm/defn render-header-and-toggle-btn? :- s/Bool + "Returns true if any of the necessary properties are in place to + render the navbar-header and toggle button." + [bs] + (or (:brand bs) + (:toggle-button bs) + (:toggle-nav-key bs))) + (defn render-header [owner bs] (d/div {:class "navbar-header"} (if (u/strict-valid-component? (:brand bs)) (u/clone-with-props (:brand bs) {:class "navbar-brand"}) (d/span {:class "navbar-brand"} (:brand bs))) - (when (or (:toggle-button bs) - (:toggle-nav-key bs)) + (when (render-header-and-toggle-btn? bs) (render-toggle-button owner bs)))) (sm/defn clone-nav-item @@ -173,8 +180,9 @@ (defn render-navbar-child [owner child bs] (let [f (fn [props] (let [opts (:opts props) - collapsible? (when (:toggle-nav-key bs) - (= (:key opts) (:toggle-nav-key bs))) + collapsible? (or (:collapsible? opts) + (when (:toggle-nav-key bs) + (= (:key opts) (:toggle-nav-key bs)))) base {:navbar? true :collapsible? collapsible? :expanded? (and collapsible? @@ -205,9 +213,7 @@ ((:component-fn bs) (u/merge-props (merge bs props) {:class (d/class-set classes)}) (d/div {:class (if (:fluid props) "container-fluid" "container")} - (when (or (:brand bs) - (:toggle-button bs) - (:toggle-nav-key bs)) + (when (render-header-and-toggle-btn? bs) (render-header owner bs)) (map #(render-navbar-child owner % bs) children)))))) From 11e2513d32d838192d44156a780598756b957599 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 13 Jan 2015 18:23:33 -0800 Subject: [PATCH 08/29] lein-release plugin: preparing 0.3.3 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 4ab3b8a..ff30fa4 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ [http-kit "2.1.18"] [hiccup "1.0.5"]]) -(defproject racehub/om-bootstrap "0.3.3-SNAPSHOT" +(defproject racehub/om-bootstrap "0.3.3" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT Licens" From 36e03f3338da000f7581f736da637685b1676ab9 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 13 Jan 2015 18:25:41 -0800 Subject: [PATCH 09/29] saving. --- project.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index b3a6366..0feb88f 100644 --- a/project.clj +++ b/project.clj @@ -4,10 +4,10 @@ [http-kit "2.1.18"] [hiccup "1.0.5"]]) -(defproject racehub/om-bootstrap "0.3.4-SNAPSHOT" +(defproject racehub/om-bootstrap "0.3.3" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" - :license {:name "MIT Licens" + :license {:name "MIT License" :url "http://www.opensource.org/licenses/mit-license.php" :distribution :repo} :scm {:name "git" From 8c050f290a54e5a421edd4c0678f95f1abb59aa6 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 13 Jan 2015 18:25:57 -0800 Subject: [PATCH 10/29] bump snapshot --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 0feb88f..cae3427 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ [http-kit "2.1.18"] [hiccup "1.0.5"]]) -(defproject racehub/om-bootstrap "0.3.3" +(defproject racehub/om-bootstrap "0.3.4-SNAPSHOT" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT License" From c796f02c2b364af66c4f9d72838d73dd2aeb1e68 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 20 Jan 2015 17:02:52 -0700 Subject: [PATCH 11/29] fix static example on doc site --- dev/snippets/input/types.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/snippets/input/types.cljs b/dev/snippets/input/types.cljs index 53a8f88..b53b688 100644 --- a/dev/snippets/input/types.cljs +++ b/dev/snippets/input/types.cljs @@ -20,4 +20,4 @@ (d/option {:value "select"} "select") (d/option {:value "other"} "...")) (i/input {:type "textarea" :default-value "textarea"}) - (i/input {:type "static"} "static")) + (i/input {:type "static" :value "Static Text"})) From 6f387f3a44954666d30e68fa37b6e4ddbb66da66 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 21 Jan 2015 13:13:02 -0700 Subject: [PATCH 12/29] provided om --- CHANGELOG.md | 3 +++ README.md | 6 ++++++ project.clj | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f56d76..6b8d560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.3 (1/21/2015) +- Turned Om into a provided dependency. + ## 0.3.3 (1/13/2015) - Added collapse functionality for navbars (https://github.com/racehub/om-bootstrap/pull/41) diff --git a/README.md b/README.md index 22fd878..db2d4ab 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ Here's the latest Leiningen version info: [![Clojars Project](http://clojars.org/racehub/om-bootstrap/latest-version.svg)](http://clojars.org/racehub/om-bootstrap) +You'll also need to add Om: + +```clojure +[om "0.7.3"] +``` + You can find more detailed information on how to configure your Clojurescript project to use Om-Bootstrap on the documentation site's [Getting Started section](http://om-bootstrap.herokuapp.com/getting-started). **This is an alpha release. The API and organizational structure are diff --git a/project.clj b/project.clj index cae3427..396cf70 100644 --- a/project.clj +++ b/project.clj @@ -20,7 +20,7 @@ [prismatic/om-tools "0.3.6" :exclusions [om]] [prismatic/schema "0.3.1" :exclusions [org.clojure/clojurescript]] - [om "0.7.1"]] + [om "0.7.1" :scope "provided"]] :profiles {:provided {:dependencies [[org.clojure/clojurescript "0.0-2411"] [secretary "1.2.0"] From 86f394aa00924f334c30aa3a34ae65aa05ccbdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Thu, 22 Jan 2015 15:48:24 +0100 Subject: [PATCH 13/29] Support for collapsible panels --- dev/snippets/panel/collapsible.cljs | 2 + .../cljs/om_bootstrap/docs/components.cljs | 5 +++ src/om_bootstrap/mixins.cljs | 11 ++++++ src/om_bootstrap/panel.cljs | 37 ++++++++++++++++--- 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 dev/snippets/panel/collapsible.cljs diff --git a/dev/snippets/panel/collapsible.cljs b/dev/snippets/panel/collapsible.cljs new file mode 100644 index 0000000..95db362 --- /dev/null +++ b/dev/snippets/panel/collapsible.cljs @@ -0,0 +1,2 @@ +(om-bootstrap.panel/collapsible-panel {:header "Collapse Me!"} + (d/span "Sometimes I'm here, sometimes I'm not")) \ No newline at end of file diff --git a/docs/src/cljs/om_bootstrap/docs/components.cljs b/docs/src/cljs/om_bootstrap/docs/components.cljs index 1ea15c0..504f7ff 100644 --- a/docs/src/cljs/om_bootstrap/docs/components.cljs +++ b/docs/src/cljs/om_bootstrap/docs/components.cljs @@ -214,6 +214,11 @@ particular context by adding a " (d/code ":bs-style") " prop.") (->example (slurp-example "panel/contextual")) + (d/h3 "Collapsible panels") + (d/p "This panel is collapsed by default and can be extended by clicking + on the title") + (->example (slurp-example "panel/collapsible")) + (d/h3 "Controlled PanelGroups") (d/p (d/code "p/panel-group") "s can be controlled by a parent component. The " (d/code ":active-key") " prop dictates which panel diff --git a/src/om_bootstrap/mixins.cljs b/src/om_bootstrap/mixins.cljs index f4441d8..e2c7eeb 100644 --- a/src/om_bootstrap/mixins.cljs +++ b/src/om_bootstrap/mixins.cljs @@ -103,3 +103,14 @@ (bind-root-close-handlers! owner) (unbind-root-close-handlers! owner)) (om/set-state! owner [:open?] open?))) + + +(defmixin collapsible-mixin + "Mixin that enables collapsible Panels. Similar to the Dropdown + Mixin it only manages a single piece of state - :collapsed?. The Panel + is opened and closen by clicking on the header." + (init-state [_] {:collapsed? false}) + (isPanelCollapsed [owner] (om/get-state owner :collapsed?)) + (toggleCollapsed + [owner] + (om/update-state! owner [:collapsed?] not))) \ No newline at end of file diff --git a/src/om_bootstrap/panel.cljs b/src/om_bootstrap/panel.cljs index 4d53bf0..70257f5 100644 --- a/src/om_bootstrap/panel.cljs +++ b/src/om_bootstrap/panel.cljs @@ -15,21 +15,48 @@ {(s/optional-key :on-select) (s/=> s/Any s/Any) (s/optional-key :header) t/Renderable (s/optional-key :footer) t/Renderable - (s/optional-key :list-group) t/Renderable})) + (s/optional-key :list-group) t/Renderable + (s/optional-key :collapsed?) s/Bool})) (s/defn panel :- t/Component [opts :- Panel & children] (let [[bs props] (t/separate Panel opts {:bs-class "panel" :bs-style "default"}) - classes (assoc (t/bs-class-set bs) - :panel true)] + classes (assoc (t/bs-class-set bs) :panel true)] (d/div (u/merge-props props {:class (d/class-set classes)}) (when-let [header (:header bs)] (d/div {:class "panel-heading"} (u/clone-with-props header {:class "panel-title"}))) (when-not (= 0 (count (filter identity children))) - (d/div {:class "panel-body" :ref "body"} children)) + (d/div {:class (str "panel-body" (when (:collapsed? bs) " collapse")) + :ref "body"} + children)) (when-let [list-group (:list-group bs)] list-group) - (when-let [footer(:footer bs)] + (when-let [footer (:footer bs)] (d/div {:class "panel-footer"} footer))))) + +;; ## Collapsible Panel + +(defcomponentk collapsible-panel* + "Generates a collapsible panel component resposible for its own toggled state. + The :collapsed? state is handled through a collapsible mixin." + [owner state] + (:mixins m/collapsible-mixin) + (render [_] + (let [{:keys [opts children]} (om/get-props owner) + is-collapsed? ((aget owner "isPanelCollapsed") owner) + toggle! (fn [_] ((aget owner "toggleCollapsed") owner) false) + collapsible-header (d/h4 + (d/a {:href "#" + :on-click toggle!} + (:header opts)))] + (panel (u/merge-props opts {:header collapsible-header + :collapsed? is-collapsed?}) + children)))) + +(s/defn collapsible-panel :- t/Component + "Returns a collapsible panel" + [opts :- Panel & children] + (->collapsible-panel* {:opts opts + :children children})) \ No newline at end of file From 03b570e2bfb65b868884384b383416790b3bc18b Mon Sep 17 00:00:00 2001 From: dignati Date: Sun, 25 Jan 2015 14:44:45 +0100 Subject: [PATCH 14/29] Support for Progress-bars --- dev/snippets/progressbar/active.cljs | 4 + dev/snippets/progressbar/basic.cljs | 4 + dev/snippets/progressbar/contextual.cljs | 6 ++ dev/snippets/progressbar/label.cljs | 4 + dev/snippets/progressbar/sr_only_label.cljs | 4 + dev/snippets/progressbar/striped.cljs | 4 + .../cljs/om_bootstrap/docs/components.cljs | 13 ++-- src/om_bootstrap/progress_bar.cljs | 75 +++++++++---------- 8 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 dev/snippets/progressbar/active.cljs create mode 100644 dev/snippets/progressbar/basic.cljs create mode 100644 dev/snippets/progressbar/contextual.cljs create mode 100644 dev/snippets/progressbar/label.cljs create mode 100644 dev/snippets/progressbar/sr_only_label.cljs create mode 100644 dev/snippets/progressbar/striped.cljs diff --git a/dev/snippets/progressbar/active.cljs b/dev/snippets/progressbar/active.cljs new file mode 100644 index 0000000..8f01563 --- /dev/null +++ b/dev/snippets/progressbar/active.cljs @@ -0,0 +1,4 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {:now 70 :active? true}) \ No newline at end of file diff --git a/dev/snippets/progressbar/basic.cljs b/dev/snippets/progressbar/basic.cljs new file mode 100644 index 0000000..ffc66af --- /dev/null +++ b/dev/snippets/progressbar/basic.cljs @@ -0,0 +1,4 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {:min 0 :max 100 :now 50}) \ No newline at end of file diff --git a/dev/snippets/progressbar/contextual.cljs b/dev/snippets/progressbar/contextual.cljs new file mode 100644 index 0000000..b1903ab --- /dev/null +++ b/dev/snippets/progressbar/contextual.cljs @@ -0,0 +1,6 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(for [context [nil "primary" "success" "info" "warning" "danger"]] + (pb/progress-bar (merge {:now 50 :label "50%"} + (when context {:bs-style context})))) \ No newline at end of file diff --git a/dev/snippets/progressbar/label.cljs b/dev/snippets/progressbar/label.cljs new file mode 100644 index 0000000..0e2a130 --- /dev/null +++ b/dev/snippets/progressbar/label.cljs @@ -0,0 +1,4 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {:min 0 :max 100 :now 50 :label "Loading"}) \ No newline at end of file diff --git a/dev/snippets/progressbar/sr_only_label.cljs b/dev/snippets/progressbar/sr_only_label.cljs new file mode 100644 index 0000000..d2a0012 --- /dev/null +++ b/dev/snippets/progressbar/sr_only_label.cljs @@ -0,0 +1,4 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {:min 0 :max 100 :now 50 :label "50%" :sr-only? true}) \ No newline at end of file diff --git a/dev/snippets/progressbar/striped.cljs b/dev/snippets/progressbar/striped.cljs new file mode 100644 index 0000000..7c25775 --- /dev/null +++ b/dev/snippets/progressbar/striped.cljs @@ -0,0 +1,4 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {:now 70 :striped? true}) \ No newline at end of file diff --git a/docs/src/cljs/om_bootstrap/docs/components.cljs b/docs/src/cljs/om_bootstrap/docs/components.cljs index 1ea15c0..89e1b75 100644 --- a/docs/src/cljs/om_bootstrap/docs/components.cljs +++ b/docs/src/cljs/om_bootstrap/docs/components.cljs @@ -314,6 +314,7 @@ ;; ## Progress Bars + (defn progress-bar-block [] (section "progress" @@ -323,33 +324,33 @@ action with simple yet flexible progress bars.") (d/h3 "Basic example") (d/p "Default progress bar.") - (TODO) + (->example (slurp-example "progressbar/basic")) (d/h3 "With label") (d/p "Add a " (d/code ":label") " prop to show a visible percentage. For low percentages, consider adding a" (d/code ":min-width") " to ensure the label's text is fully visible.") - (TODO) + (->example (slurp-example "progressbar/label")) (d/h3 "Screenreader only label") (d/p "Add the " (d/code ":sr-only? true") " option to hide the label visually.") - (TODO) + (->example (slurp-example "progressbar/sr_only_label")) (d/h3 "Contextual alternatives") (d/p "Progress bars use some of the same button and alert classes for consistent styles.") - (TODO) + (->example (slurp-example "progressbar/contextual")) (d/h3 "Striped") (d/p "Uses a gradient to create a striped effect. Not available in IE8.") - (TODO) + (->example (slurp-example "progressbar/striped")) (d/h3 "Animated") (d/p "Add the " (d/code ":active? true") " option to animate the stripes right to left. Not available in IE9 and below.") - (TODO) + (->example (slurp-example "progressbar/active")) (d/h3 "Stacked") (d/p "Nest " (d/code "pb/progress-bar") "s to stack them.") diff --git a/src/om_bootstrap/progress_bar.cljs b/src/om_bootstrap/progress_bar.cljs index 3565d00..79a3d48 100644 --- a/src/om_bootstrap/progress_bar.cljs +++ b/src/om_bootstrap/progress_bar.cljs @@ -3,61 +3,56 @@ work." (:require [om-bootstrap.types :as t] [om-tools.dom :as d :include-macros true] - [schema.core :as s]) - (:require-macros [schema.macros :as sm])) + [schema.core :as s :include-macros true] + [om-bootstrap.util :as u])) ;; ## Schema (def ProgressBar (t/bootstrap - {:min s/Int + {(s/optional-key :min) s/Int :now s/Int - :max s/Int - :label t/Renderable - :sr-only? (s/named s/Bool "Screenreader-only? Hide the label?") - :striped? s/Bool - :active? s/Bool})) + (s/optional-key :max) s/Int + (s/optional-key :label) t/Renderable + (s/optional-key :sr-only?) (s/named s/Bool "Screenreader-only? Hide the label?") + (s/optional-key :striped?) s/Bool + (s/optional-key :active?) s/Bool})) (def defaults - {:min 0 :max 100 :bs-class "progress-bar"}) + {:min 0 + :max 100 + :bs-class "progress-bar" + :striped? false + :active? false}) -(sm/defn percentage :- s/Num +(s/defn percentage :- s/Num [min :- s/Int now :- s/Int max :- s/Int] (-> (/ (- now min) (- max min)) (* 100) (Math/ceil))) -(sm/defn sr-only-label :- t/Component - "Renders a screenreader-only label." - [label :- t/Renderable] - (d/span {:class "sr-only"} label)) - -(comment - (sm/defn render-label - "There's some bullshit in here able interpolation that I have to - figure out." - [percentage :- s/Num] - - ) - - "Actual progress bar rendering." - (sm/defn render-progress-bar - [{:keys [label]} :- ProgressBar] - (cond - (string? label) (render-label label) - (nil?) - ))) - -(sm/defn progress-bar :- t/Component +(s/defn progress-bar :- t/Component "Generates a Bootstrap progress bar component." [opts :- ProgressBar & children] (let [[bs props] (t/separate ProgressBar opts defaults) - classes (-> (cond - (:active? bs) {:progress-striped true - :active true} - (:striped? bs) {:progress-striped true} - :else {}) - (assoc :progress true)) - ] - )) + classes (merge + (t/bs-class-set bs) + {:progress-bar true} + (when (:active? bs) {:progress-bar-striped true + :active true}) + (when (:striped? bs) {:progress-bar-striped true})) + values {:aria-value-min (:min bs) + :aria-value-max (:max bs) + :aria-value-now (:now bs)} + style {:width (str (percentage (:min bs) (:now bs) (:max bs)) "%")}] + (d/div {:class "progress"} + (d/div (u/merge-props props + {:class (d/class-set classes)} + values + {:style style}) + (when-let [label (:label bs)] + (if (:sr-only? bs) + (d/span {:class "sr-only"} label) + label))) + children))) From fab55bb86760c17790eef9189ad4701232cd7457 Mon Sep 17 00:00:00 2001 From: dignati Date: Sun, 25 Jan 2015 15:27:28 +0100 Subject: [PATCH 15/29] Adjust documentation and readme --- README.md | 1 - dev/snippets/panel/collapsible.cljs | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b33e7d..5ee7ecb 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,6 @@ These, and the mixins below, are the project's biggest TODOs. * FadeMixin * OverlayMixin -* CollapsibleMixin ## ClojureScript Repl diff --git a/dev/snippets/panel/collapsible.cljs b/dev/snippets/panel/collapsible.cljs index 95db362..305d87b 100644 --- a/dev/snippets/panel/collapsible.cljs +++ b/dev/snippets/panel/collapsible.cljs @@ -1,2 +1,5 @@ -(om-bootstrap.panel/collapsible-panel {:header "Collapse Me!"} - (d/span "Sometimes I'm here, sometimes I'm not")) \ No newline at end of file +#_ +(:require [om-bootstrap.panel :as p]) + +(p/collapsible-panel {:header "Collapse Me!"} + (d/span "Sometimes I'm here, sometimes I'm not")) \ No newline at end of file From db5299f3507cf64071be33e4305eaebaa2827849 Mon Sep 17 00:00:00 2001 From: dignati Date: Sun, 25 Jan 2015 17:23:02 +0100 Subject: [PATCH 16/29] Support for pagination --- dev/snippets/pagination/active.cljs | 9 +++++ dev/snippets/pagination/basic.cljs | 7 ++++ dev/snippets/pagination/disabled.cljs | 9 +++++ dev/snippets/pagination/navigation.cljs | 9 +++++ .../cljs/om_bootstrap/docs/components.cljs | 21 ++++++++++ src/om_bootstrap/pagination.cljs | 38 +++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 dev/snippets/pagination/active.cljs create mode 100644 dev/snippets/pagination/basic.cljs create mode 100644 dev/snippets/pagination/disabled.cljs create mode 100644 dev/snippets/pagination/navigation.cljs create mode 100644 src/om_bootstrap/pagination.cljs diff --git a/dev/snippets/pagination/active.cljs b/dev/snippets/pagination/active.cljs new file mode 100644 index 0000000..37ddbbd --- /dev/null +++ b/dev/snippets/pagination/active.cljs @@ -0,0 +1,9 @@ +#_ +(:require [om-bootstrap.pager :as pg]) + +(pg/pagination {} + (pg/previous {:disabled? true}) + (pg/page {} "1") + (pg/page {} "2") + (pg/page {:active? true} "3") + (pg/next {})) \ No newline at end of file diff --git a/dev/snippets/pagination/basic.cljs b/dev/snippets/pagination/basic.cljs new file mode 100644 index 0000000..987ef38 --- /dev/null +++ b/dev/snippets/pagination/basic.cljs @@ -0,0 +1,7 @@ +#_ +(:require [om-bootstrap.pager :as pg]) + +(pg/pagination {} + (pg/page {} "1") + (pg/page {} "2") + (pg/page {} "3")) \ No newline at end of file diff --git a/dev/snippets/pagination/disabled.cljs b/dev/snippets/pagination/disabled.cljs new file mode 100644 index 0000000..78e0442 --- /dev/null +++ b/dev/snippets/pagination/disabled.cljs @@ -0,0 +1,9 @@ +#_ +(:require [om-bootstrap.pager :as pg]) + +(pg/pagination {} + (pg/previous {:disabled? true}) + (pg/page {} "1") + (pg/page {} "2") + (pg/page {} "3") + (pg/next {})) \ No newline at end of file diff --git a/dev/snippets/pagination/navigation.cljs b/dev/snippets/pagination/navigation.cljs new file mode 100644 index 0000000..fcd2329 --- /dev/null +++ b/dev/snippets/pagination/navigation.cljs @@ -0,0 +1,9 @@ +#_ +(:require [om-bootstrap.pager :as pg]) + +(pg/pagination {} + (pg/previous {}) + (pg/page {} "1") + (pg/page {} "2") + (pg/page {} "3") + (pg/next {})) \ No newline at end of file diff --git a/docs/src/cljs/om_bootstrap/docs/components.cljs b/docs/src/cljs/om_bootstrap/docs/components.cljs index 1ea15c0..249fbeb 100644 --- a/docs/src/cljs/om_bootstrap/docs/components.cljs +++ b/docs/src/cljs/om_bootstrap/docs/components.cljs @@ -8,6 +8,7 @@ [om-bootstrap.input :as i] [om-bootstrap.mixins :as m] [om-bootstrap.nav :as n] + [om-bootstrap.pagination :as pg] [om-bootstrap.panel :as p] [om-bootstrap.progress-bar :as pb] [om-bootstrap.random :as r] @@ -405,6 +406,24 @@ (d/a {:href "#navs"} "tabbed navigation component") " to add tabbable areas."]))) +;; ## Pagination +(defn pagination-block [] + (section + "pagination" + ["Pagination " (d/small "basic.cljs")] + (d/p "Creates pages that can have " (d/code ":href") " or " (d/code ":on-click") " set to navigate between pages") + (d/h3 "Basic Pagination") + (->example (slurp-example "pagination/basic")) + + (d/h3 "Pagination with previous and next") + (->example (slurp-example "pagination/navigation")) + + (d/h3 "Pages can be disabled") + (->example (slurp-example "pagination/disabled")) + + (d/h3 "Pages can be marked as active") + (->example (slurp-example "pagination/active")))) + ;; ## Pager (defn pager-block [] @@ -639,6 +658,7 @@ (n/nav-item {:href "#navs"} "Navs") (n/nav-item {:href "#navbars"} "Navbars") (n/nav-item {:href "#tabs"} "Toggleable Tabs") + (n/nav-item {:href "#pagination"} "Pagination") (n/nav-item {:href "#pager"} "Pager") (n/nav-item {:href "#alerts"} "Alerts") (n/nav-item {:href "#carousels"} "Carousels") @@ -681,6 +701,7 @@ (nav-block) (navbar-block) (tab-block) + (pagination-block) (pager-block) (alert-block) (carousel-block) diff --git a/src/om_bootstrap/pagination.cljs b/src/om_bootstrap/pagination.cljs new file mode 100644 index 0000000..e8ffa3e --- /dev/null +++ b/src/om_bootstrap/pagination.cljs @@ -0,0 +1,38 @@ +(ns om-bootstrap.pagination + (:require [om.core :as om] + [om-bootstrap.types :as t] + [om-bootstrap.util :as u] + [om-tools.dom :as d :include-macros true] + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) + +(def Page + (t/bootstrap + {(s/optional-key :disabled?) s/Bool + (s/optional-key :active?) s/Bool + (s/optional-key :href) s/Str + (s/optional-key :on-click) (sm/=> s/Any s/Any)})) + +(sm/defn page :- t/Component [opts :- Page & children] + (let [[bs props] (t/separate Page opts {:href "#"}) + classes {:disabled (:disabled? bs) + :active (:active? bs)} + on-click (when-let [f (:on-click bs)] + (fn [e] + (.preventDefault e) + (f e)))] + (d/li (u/merge-props props {:class (d/class-set classes)}) + (d/a {:href (:href bs) + :on-click on-click} + children)))) + +(sm/defn previous :- t/Component [opts :- Page] + (page (assoc opts :aria-label "Previous") (d/span {:aria-hidden "true"} "«"))) + +(sm/defn next :- t/Component [opts :- Page] + (page (assoc opts :aria-label "Next") (d/span {:aria-hidden "true"} "»"))) + +(sm/defn pagination :- t/Component [opts & children] + (d/nav + (d/ul {:class "pagination"} + children))) \ No newline at end of file From a4ab56fe39d51a08bfbfdcfb77e4d9836178cb76 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 26 Jan 2015 15:33:12 -0800 Subject: [PATCH 17/29] expanded key default to true --- src/om_bootstrap/nav.cljs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index f794bec..8e8dd88 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -88,7 +88,8 @@ (render [_] (let [{:keys [opts children]} (om/get-props owner) - [bs props] (t/separate Nav opts {:bs-class "nav"}) + [bs props] (t/separate Nav opts {:expanded? true + :bs-class "nav"}) classes {:navbar-collapse (:collapsible? bs) :collapse (not (:expanded? bs)) :in (:expanded? bs)} From 2d8c260115d88cd685b46142f66a411d078ba696 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 26 Jan 2015 15:51:28 -0800 Subject: [PATCH 18/29] remove prevent default --- src/om_bootstrap/pagination.cljs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/om_bootstrap/pagination.cljs b/src/om_bootstrap/pagination.cljs index e8ffa3e..518b0f6 100644 --- a/src/om_bootstrap/pagination.cljs +++ b/src/om_bootstrap/pagination.cljs @@ -16,11 +16,7 @@ (sm/defn page :- t/Component [opts :- Page & children] (let [[bs props] (t/separate Page opts {:href "#"}) classes {:disabled (:disabled? bs) - :active (:active? bs)} - on-click (when-let [f (:on-click bs)] - (fn [e] - (.preventDefault e) - (f e)))] + :active (:active? bs)}] (d/li (u/merge-props props {:class (d/class-set classes)}) (d/a {:href (:href bs) :on-click on-click} @@ -35,4 +31,4 @@ (sm/defn pagination :- t/Component [opts & children] (d/nav (d/ul {:class "pagination"} - children))) \ No newline at end of file + children))) From 20e73d95dfc2934fd2467bb362cc0831ab18cfdb Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 26 Jan 2015 16:09:30 -0800 Subject: [PATCH 19/29] fix onclick --- src/om_bootstrap/pagination.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/om_bootstrap/pagination.cljs b/src/om_bootstrap/pagination.cljs index 518b0f6..97ef505 100644 --- a/src/om_bootstrap/pagination.cljs +++ b/src/om_bootstrap/pagination.cljs @@ -18,9 +18,9 @@ classes {:disabled (:disabled? bs) :active (:active? bs)}] (d/li (u/merge-props props {:class (d/class-set classes)}) - (d/a {:href (:href bs) - :on-click on-click} - children)))) + (d/a {:href (:href bs) + :on-click (:on-click bs)} + children)))) (sm/defn previous :- t/Component [opts :- Page] (page (assoc opts :aria-label "Previous") (d/span {:aria-hidden "true"} "«"))) From 7ef1b155d09f79e3fb87f84b2840935360937dc4 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 26 Jan 2015 17:06:31 -0800 Subject: [PATCH 20/29] stacked progress bars --- dev/snippets/progressbar/stacked.cljs | 7 +++ .../cljs/om_bootstrap/docs/components.cljs | 2 +- src/om_bootstrap/progress_bar.cljs | 49 +++++++++++-------- 3 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 dev/snippets/progressbar/stacked.cljs diff --git a/dev/snippets/progressbar/stacked.cljs b/dev/snippets/progressbar/stacked.cljs new file mode 100644 index 0000000..4da4cc5 --- /dev/null +++ b/dev/snippets/progressbar/stacked.cljs @@ -0,0 +1,7 @@ +#_ +(:require [om-bootstrap.progress-bar :as pb]) + +(pb/progress-bar {} + (pb/progress-bar {:now 35 :bs-style "success" :nested? true}) + (pb/progress-bar {:now 20 :bs-style "warning" :striped? true :nested? true}) + (pb/progress-bar {:now 10 :bs-style "danger" :nested? true})) diff --git a/docs/src/cljs/om_bootstrap/docs/components.cljs b/docs/src/cljs/om_bootstrap/docs/components.cljs index 86b60d9..0b681af 100644 --- a/docs/src/cljs/om_bootstrap/docs/components.cljs +++ b/docs/src/cljs/om_bootstrap/docs/components.cljs @@ -355,7 +355,7 @@ (d/h3 "Stacked") (d/p "Nest " (d/code "pb/progress-bar") "s to stack them.") - (TODO))) + (->example (slurp-example "progressbar/stacked")))) ;; ## Navs diff --git a/src/om_bootstrap/progress_bar.cljs b/src/om_bootstrap/progress_bar.cljs index 79a3d48..4034212 100644 --- a/src/om_bootstrap/progress_bar.cljs +++ b/src/om_bootstrap/progress_bar.cljs @@ -10,20 +10,22 @@ (def ProgressBar (t/bootstrap - {(s/optional-key :min) s/Int - :now s/Int + {:now s/Int + (s/optional-key :min) s/Int (s/optional-key :max) s/Int (s/optional-key :label) t/Renderable (s/optional-key :sr-only?) (s/named s/Bool "Screenreader-only? Hide the label?") (s/optional-key :striped?) s/Bool - (s/optional-key :active?) s/Bool})) + (s/optional-key :active?) s/Bool + (s/optional-key :nested?) (s/named s/Bool "Specify this for a nested ProgressBar inside a stacked ProgerssBar.")})) (def defaults {:min 0 :max 100 :bs-class "progress-bar" :striped? false - :active? false}) + :active? false + :nested? false}) (s/defn percentage :- s/Num [min :- s/Int now :- s/Int max :- s/Int] @@ -32,27 +34,34 @@ (* 100) (Math/ceil))) -(s/defn progress-bar :- t/Component - "Generates a Bootstrap progress bar component." +(s/defn child-bar :- t/Component + "Generates a progress bar child." [opts :- ProgressBar & children] (let [[bs props] (t/separate ProgressBar opts defaults) classes (merge - (t/bs-class-set bs) - {:progress-bar true} - (when (:active? bs) {:progress-bar-striped true - :active true}) - (when (:striped? bs) {:progress-bar-striped true})) + (t/bs-class-set bs) + {:progress-bar true} + (when (:active? bs) {:progress-bar-striped true + :active true}) + (when (:striped? bs) {:progress-bar-striped true})) values {:aria-value-min (:min bs) :aria-value-max (:max bs) :aria-value-now (:now bs)} - style {:width (str (percentage (:min bs) (:now bs) (:max bs)) "%")}] + style {:width (str (percentage (:min bs) (:now bs) (:max bs)) "%")}] + (d/div (u/merge-props props + {:class (d/class-set classes)} + values + {:style style}) + (when-let [label (:label bs)] + (if (:sr-only? bs) + (d/span {:class "sr-only"} label) + label))))) + +(s/defn progress-bar + "Generates a progress bar component." + [opts :- ProgressBar & children] + (if (:nested? opts) + (child-bar opts children) (d/div {:class "progress"} - (d/div (u/merge-props props - {:class (d/class-set classes)} - values - {:style style}) - (when-let [label (:label bs)] - (if (:sr-only? bs) - (d/span {:class "sr-only"} label) - label))) + (child-bar opts children) children))) From 4a7e8aff93888e51d75cbf769d089d5d6e4bab13 Mon Sep 17 00:00:00 2001 From: dignati Date: Tue, 27 Jan 2015 12:27:58 +0100 Subject: [PATCH 21/29] Fix namespace --- src/om_bootstrap/panel.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/om_bootstrap/panel.cljs b/src/om_bootstrap/panel.cljs index cb871d8..db7648a 100644 --- a/src/om_bootstrap/panel.cljs +++ b/src/om_bootstrap/panel.cljs @@ -56,7 +56,7 @@ :collapsed? is-collapsed?}) children)))) -(s/defn collapsible-panel :- t/Component +(sm/defn collapsible-panel :- t/Component "Returns a collapsible panel" [opts :- Panel & children] (->collapsible-panel* {:opts opts From b8b67c53f3f67b89c9c1d2385c9f726d69082270 Mon Sep 17 00:00:00 2001 From: dignati Date: Tue, 27 Jan 2015 12:44:17 +0100 Subject: [PATCH 22/29] Let panel provide the collapsible functionality --- dev/snippets/panel/collapsible.cljs | 5 ++-- src/om_bootstrap/panel.cljs | 36 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/dev/snippets/panel/collapsible.cljs b/dev/snippets/panel/collapsible.cljs index 305d87b..89cd1cf 100644 --- a/dev/snippets/panel/collapsible.cljs +++ b/dev/snippets/panel/collapsible.cljs @@ -1,5 +1,6 @@ #_ (:require [om-bootstrap.panel :as p]) -(p/collapsible-panel {:header "Collapse Me!"} - (d/span "Sometimes I'm here, sometimes I'm not")) \ No newline at end of file +(p/panel {:header "Collapse Me!" + :collapsible? true} + (d/span "Sometimes I'm here, sometimes I'm not")) \ No newline at end of file diff --git a/src/om_bootstrap/panel.cljs b/src/om_bootstrap/panel.cljs index db7648a..8da676e 100644 --- a/src/om_bootstrap/panel.cljs +++ b/src/om_bootstrap/panel.cljs @@ -17,25 +17,31 @@ (s/optional-key :header) t/Renderable (s/optional-key :footer) t/Renderable (s/optional-key :list-group) t/Renderable + (s/optional-key :collapsible?) s/Bool (s/optional-key :collapsed?) s/Bool})) +(declare ->collapsible-panel*) + (sm/defn panel :- t/Component [opts :- Panel & children] (let [[bs props] (t/separate Panel opts {:bs-class "panel" :bs-style "default"}) classes (assoc (t/bs-class-set bs) :panel true)] - (d/div (u/merge-props props {:class (d/class-set classes)}) - (when-let [header (:header bs)] - (d/div {:class "panel-heading"} - (u/clone-with-props header {:class "panel-title"}))) - (when-not (= 0 (count (filter identity children))) - (d/div {:class (str "panel-body" (when (:collapsed? bs) " collapse")) - :ref "body"} - children)) - (when-let [list-group (:list-group bs)] - list-group) - (when-let [footer (:footer bs)] - (d/div {:class "panel-footer"} footer))))) + (if (:collapsible? bs) + (->collapsible-panel* {:opts (dissoc opts :collapsible?) + :children children}) + (d/div (u/merge-props props {:class (d/class-set classes)}) + (when-let [header (:header bs)] + (d/div {:class "panel-heading"} + (u/clone-with-props header {:class "panel-title"}))) + (when-not (= 0 (count (filter identity children))) + (d/div {:class (str "panel-body" (when (:collapsed? bs) " collapse")) + :ref "body"} + children)) + (when-let [list-group (:list-group bs)] + list-group) + (when-let [footer (:footer bs)] + (d/div {:class "panel-footer"} footer)))))) ;; ## Collapsible Panel @@ -55,9 +61,3 @@ (panel (u/merge-props opts {:header collapsible-header :collapsed? is-collapsed?}) children)))) - -(sm/defn collapsible-panel :- t/Component - "Returns a collapsible panel" - [opts :- Panel & children] - (->collapsible-panel* {:opts opts - :children children})) From 3a8080f1db1e58dd3d1422a9fcc5c41b174dd589 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 27 Jan 2015 08:26:16 -0700 Subject: [PATCH 23/29] update readme and changelog --- CHANGELOG.md | 7 +++++-- README.md | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b8d560..6609d44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ -## 0.3.3 (1/21/2015) -- Turned Om into a provided dependency. +## 0.3.4 + +- Turned Om into a provided dependency (https://github.com/racehub/om-bootstrap/pull/44) +- add Pagination, thanks to @dignati (https://github.com/racehub/om-bootstrap/pull/47) +- Fixes a bug where navs were un-expanded by default (https://github.com/racehub/om-bootstrap/pull/48) ## 0.3.3 (1/13/2015) diff --git a/README.md b/README.md index db2d4ab..bdd8a6a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ These, and the mixins below, are the project's biggest TODOs. * Subnav (?) * Panel (hard), PanelGroup (easy), Accordion (easy) * TabbedArea, TabPane -* Pager * Carousel * CarouselItem From 106ce973c7271b1d309191d7dbf0f0b346fbb4a1 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 27 Jan 2015 08:31:24 -0700 Subject: [PATCH 24/29] fix the next exclusion --- CHANGELOG.md | 2 +- src/om_bootstrap/pagination.cljs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6609d44..6341c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.3.4 +## 0.3.4 (1/27/2015) - Turned Om into a provided dependency (https://github.com/racehub/om-bootstrap/pull/44) - add Pagination, thanks to @dignati (https://github.com/racehub/om-bootstrap/pull/47) diff --git a/src/om_bootstrap/pagination.cljs b/src/om_bootstrap/pagination.cljs index 97ef505..d222a63 100644 --- a/src/om_bootstrap/pagination.cljs +++ b/src/om_bootstrap/pagination.cljs @@ -1,4 +1,5 @@ (ns om-bootstrap.pagination + (:refer-clojure :exclude [next]) (:require [om.core :as om] [om-bootstrap.types :as t] [om-bootstrap.util :as u] From f155e538515af9aafb32819541e42b6729786c9f Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 27 Jan 2015 08:32:05 -0700 Subject: [PATCH 25/29] lein-release plugin: preparing 0.3.4 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 396cf70..812b029 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ [http-kit "2.1.18"] [hiccup "1.0.5"]]) -(defproject racehub/om-bootstrap "0.3.4-SNAPSHOT" +(defproject racehub/om-bootstrap "0.3.4" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT License" From ff6f0ed3008aedd6f8c3ead020b2926697e5a467 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 27 Jan 2015 08:32:06 -0700 Subject: [PATCH 26/29] lein-release plugin: bumped version from 0.3.4 to 0.3.5-SNAPSHOT for next development cycle --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 812b029..57717b0 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ [http-kit "2.1.18"] [hiccup "1.0.5"]]) -(defproject racehub/om-bootstrap "0.3.4" +(defproject racehub/om-bootstrap "0.3.5-SNAPSHOT" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT License" From 4ff96a09afcf0ef87ea87704a2a51c67d5d72af9 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 27 Jan 2015 08:37:17 -0700 Subject: [PATCH 27/29] bump versions on doc site --- docs/src/cljs/om_bootstrap/docs/getting_started.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/cljs/om_bootstrap/docs/getting_started.cljs b/docs/src/cljs/om_bootstrap/docs/getting_started.cljs index d480366..941084c 100644 --- a/docs/src/cljs/om_bootstrap/docs/getting_started.cljs +++ b/docs/src/cljs/om_bootstrap/docs/getting_started.cljs @@ -31,8 +31,8 @@ (->code-block {:code "(defproject foo \"0.1.0\" ... :dependencies [[org.clojure/clojure \"1.6.0\"] - [org.clojure/clojurescript \"0.0-2322\"] - [racehub/om-bootstrap \"0.3.1\"] + [org.clojure/clojurescript \"0.0-2411\"] + [racehub/om-bootstrap \"0.3.4\"] [om \"0.7.3\"]] ...)"}) (d/p "Om-Bootstrap requires Om 0.7.0 or later, and has been tested against Bootstrap 3.1.0 and later. The " From 67dc152ba422d5369014eac09ef487c6e752e90f Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Tue, 27 Jan 2015 11:24:52 -0800 Subject: [PATCH 28/29] address comments --- src/om_bootstrap/progress_bar.cljs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/om_bootstrap/progress_bar.cljs b/src/om_bootstrap/progress_bar.cljs index 4034212..8aa51aa 100644 --- a/src/om_bootstrap/progress_bar.cljs +++ b/src/om_bootstrap/progress_bar.cljs @@ -3,8 +3,9 @@ work." (:require [om-bootstrap.types :as t] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true] - [om-bootstrap.util :as u])) + [om-bootstrap.util :as u] + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Schema @@ -17,7 +18,7 @@ (s/optional-key :sr-only?) (s/named s/Bool "Screenreader-only? Hide the label?") (s/optional-key :striped?) s/Bool (s/optional-key :active?) s/Bool - (s/optional-key :nested?) (s/named s/Bool "Specify this for a nested ProgressBar inside a stacked ProgerssBar.")})) + (s/optional-key :nested?) (s/named s/Bool "Specify this for a nested ProgressBar inside a stacked ProgressBar.")})) (def defaults {:min 0 @@ -27,14 +28,14 @@ :active? false :nested? false}) -(s/defn percentage :- s/Num +(sm/defn percentage :- s/Num [min :- s/Int now :- s/Int max :- s/Int] (-> (/ (- now min) (- max min)) (* 100) (Math/ceil))) -(s/defn child-bar :- t/Component +(sm/defn child-bar :- t/Component "Generates a progress bar child." [opts :- ProgressBar & children] (let [[bs props] (t/separate ProgressBar opts defaults) @@ -57,7 +58,7 @@ (d/span {:class "sr-only"} label) label))))) -(s/defn progress-bar +(sm/defn progress-bar "Generates a progress bar component." [opts :- ProgressBar & children] (if (:nested? opts) From f198c7075a30e5f0678ee959c242d9bdda2ab2de Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Thu, 29 Jan 2015 07:42:16 -0700 Subject: [PATCH 29/29] adjust changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6341c2a..383376b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.5 (1/27/2015) + +- Support for collapsible panels, thanks to @dignati (https://github.com/racehub/om-bootstrap/pull/45) + ## 0.3.4 (1/27/2015) - Turned Om into a provided dependency (https://github.com/racehub/om-bootstrap/pull/44)