From 952f6223168d3acfb2d9173ab919728d03865c93 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Thu, 25 Sep 2014 10:47:33 -0600 Subject: [PATCH 01/28] saving. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aed3f6..b40b35c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.3.1 (9/25/2014) +## 0.3.0 (9/25/2014) - Upgrade to Schema 0.3.0 From d22693e733bf7c8fd93091b1b0d60d380428335a Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 15 Oct 2014 23:38:23 -0600 Subject: [PATCH 02/28] revert schema upgrade --- CHANGELOG.md | 4 ++++ README.md | 2 -- src/om_bootstrap/button.cljs | 31 +++++++++++++++--------------- src/om_bootstrap/grid.cljs | 9 +++++---- src/om_bootstrap/input.cljs | 31 +++++++++++++++--------------- src/om_bootstrap/mixins.cljs | 7 ++++--- src/om_bootstrap/modal.cljs | 11 ++++++----- src/om_bootstrap/nav.cljs | 21 ++++++++++---------- src/om_bootstrap/panel.cljs | 7 ++++--- src/om_bootstrap/progress_bar.cljs | 13 +++++++------ src/om_bootstrap/random.cljs | 23 +++++++++++----------- src/om_bootstrap/table.cljs | 5 +++-- src/om_bootstrap/types.cljs | 11 ++++++----- src/om_bootstrap/util.cljs | 11 ++++++----- 14 files changed, 100 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40b35c..98afa36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + +- Revert schema upgrade... fancy that :) + ## 0.3.0 (9/25/2014) - Upgrade to Schema 0.3.0 diff --git a/README.md b/README.md index 3b33e7d..2f1b620 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,6 @@ and the latest version of ClojureScript. Please create a [GitHub issue](https:// Note that we've seen trouble with Safari 7.0.x on CLJS versions <= 0.0.2261. See [this ticket](https://github.com/racehub/om-bootstrap/issues/10) for details. -Also, if you're explicitly using [Prismatic's Schema](https://github.com/prismatic/schema), you'll need version `0.3.x` due to the new `:include-macros` syntax. - ## Authors - Sam Ritchie diff --git a/src/om_bootstrap/button.cljs b/src/om_bootstrap/button.cljs index be5bccf..057a9a6 100644 --- a/src/om_bootstrap/button.cljs +++ b/src/om_bootstrap/button.cljs @@ -7,7 +7,8 @@ [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] [om-tools.mixin :refer-macros [defmixin]] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Basic Button @@ -26,7 +27,7 @@ ;; ## Code -(s/defn render-anchor +(sm/defn render-anchor [opts :- {:classes {s/Any s/Any} :disabled? (s/maybe s/Bool) :props {s/Any s/Any}} @@ -38,7 +39,7 @@ (d/a (u/merge-props props (:props opts)) children))) -(s/defn button :- t/Component +(sm/defn button :- t/Component "Renders a button." [props :- Button & children] (let [[bs props] (t/separate Button props {:bs-class "button" @@ -68,7 +69,7 @@ ;; ## Button Toolbar -(s/defn toolbar :- t/Component +(sm/defn toolbar :- t/Component "Renders a button toolbar." [opts & children] (let [[bs props] (t/separate {} opts {:bs-class "button-toolbar"})] @@ -78,7 +79,7 @@ ;; ## Button Group -(s/defn button-group :- t/Component +(sm/defn button-group :- t/Component "Renders the supplied children in a wrapping button-group div." [opts :- ButtonGroup & children] (let [[bs props] (t/separate ButtonGroup opts {:bs-class "button-group"}) @@ -95,8 +96,8 @@ (t/bootstrap {(s/optional-key :title) t/Renderable (s/optional-key :href) s/Str - (s/optional-key :on-click) (s/=> s/Any s/Any) - (s/optional-key :on-select) (s/=> s/Any s/Any) + (s/optional-key :on-click) (sm/=> s/Any s/Any) + (s/optional-key :on-select) (sm/=> s/Any s/Any) (s/optional-key :pull-right?) s/Bool (s/optional-key :dropup?) s/Bool (s/optional-key :nav-item?) s/Bool})) @@ -124,7 +125,7 @@ (s/optional-key :divider?) s/Bool (s/optional-key :href) s/Str (s/optional-key :title) s/Str - (s/optional-key :on-select) (s/=> s/Any s/Any)})) + (s/optional-key :on-select) (sm/=> s/Any s/Any)})) (defcomponentk menu-item* "Generates an Om component of a menu item. Done this way so that @@ -153,7 +154,7 @@ (d/li (u/merge-props props li-attrs) children)))) -(s/defn menu-item :- t/Component +(sm/defn menu-item :- t/Component [opts :- MenuItem & children] (->menu-item* {:opts opts :children children})) @@ -161,9 +162,9 @@ (def DropdownMenu (t/bootstrap {(s/optional-key :pull-right?) s/Bool - (s/optional-key :on-select) (s/=> s/Any s/Any)})) + (s/optional-key :on-select) (sm/=> s/Any s/Any)})) -(s/defn dropdown-menu :- t/Component +(sm/defn dropdown-menu :- t/Component [opts :- DropdownMenu & children] (let [[bs props] (t/separate DropdownMenu opts) classes {:dropdown-menu true @@ -221,7 +222,7 @@ :key 1} (map #(u/clone-with-props % update-child-props) children))])))) -(s/defn dropdown :- t/Component +(sm/defn dropdown :- t/Component "Returns a dropdown button component. The component manages its own dropdown state." [opts :- DropdownButton & children] @@ -238,8 +239,8 @@ (s/optional-key :title) t/Renderable (s/optional-key :href) s/Str (s/optional-key :dropdown-title) t/Renderable - (s/optional-key :on-click) (s/=> s/Any s/Any) - (s/optional-key :on-select) (s/=> s/Any s/Any)})) + (s/optional-key :on-click) (sm/=> s/Any s/Any) + (s/optional-key :on-select) (sm/=> s/Any s/Any)})) (defcomponentk split* "Generates a split button component responsible for its own @@ -286,7 +287,7 @@ :dropup (:dropup? bs)})} btn drop-btn menu)))) -(s/defn split +(sm/defn split [opts :- SplitButton & children] (->split* {:opts opts :children children})) diff --git a/src/om_bootstrap/grid.cljs b/src/om_bootstrap/grid.cljs index cf23bd8..5ecef46 100644 --- a/src/om_bootstrap/grid.cljs +++ b/src/om_bootstrap/grid.cljs @@ -3,7 +3,8 @@ (:require [om-bootstrap.types :as t] [om-bootstrap.util :as u] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Schema @@ -25,7 +26,7 @@ ;; ## Code ;; ;; TODO: Do we want a custom component class, like in react-bootstrap? -(s/defn grid :- t/Component +(sm/defn grid :- t/Component "Generates a wrapper for a bootstrap grid." [opts :- Grid & children] (let [[bs props] (t/separate Grid opts {}) @@ -35,13 +36,13 @@ (d/div (u/merge-props props {:class class}) children))) -(s/defn row :- t/Component +(sm/defn row :- t/Component "Generates a Bootstrap row element." [opts & children] (d/div (u/merge-props opts {:class "row"}) children)) -(s/defn col :- t/Component +(sm/defn col :- t/Component "Generates a Bootstrap column element." [opts :- Col & children] (let [[bs props] (t/separate Col opts {}) diff --git a/src/om_bootstrap/input.cljs b/src/om_bootstrap/input.cljs index 86e96c9..8431df5 100644 --- a/src/om_bootstrap/input.cljs +++ b/src/om_bootstrap/input.cljs @@ -4,7 +4,8 @@ [om-bootstrap.types :as t] [om-bootstrap.util :as u] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Bootstrap Inputs for Om ;; @@ -56,7 +57,7 @@ ;; ### Utilities -(s/defn class-set :- s/Str +(sm/defn class-set :- s/Str "Mimics the class-set behavior from React. Pass in a map of potential class to Boolean; you'll get back a class string that represents the final class to apply. @@ -68,12 +69,12 @@ klasses) (string/join " "))) -(s/defn glyph :- t/Component +(sm/defn glyph :- t/Component "To be used with :addon-before or :addon-after." [glyph-name :- s/Str] (d/span {:class (str "glyphicon glyphicon-" glyph-name)})) -(s/defn render-icon :- t/Component +(sm/defn render-icon :- t/Component [{:keys [feedback? bs-style]} :- FeedbackIcons] (when feedback? (let [klasses {:glyphicon true @@ -83,12 +84,12 @@ :glyphicon-remove (= "error" bs-style)}] (d/span {:class (class-set klasses)})))) -(s/defn render-help +(sm/defn render-help [help :- (s/maybe s/Str)] (when help (d/span {:class "help-block"} help))) -(s/defn render-input-group +(sm/defn render-input-group "Items is a vector of render instances." [{:keys [addon-before addon-after]} :- Addons items :- s/Any] @@ -101,14 +102,14 @@ (d/span {:class "input-group-addon"} addon-after))) items)) -(s/defn checkbox-or-radio? :- s/Bool +(sm/defn checkbox-or-radio? :- s/Bool "Returns true if the supplied input is of type checkbox or radio, false otherwise." [{type :type} :- Input] (or (= type "checkbox") (= type "radio"))) -(s/defn checkbox-or-radio-wrapper :- t/Component +(sm/defn checkbox-or-radio-wrapper :- t/Component "Wraps this business in a div." [{type :type} :- Input children] @@ -117,7 +118,7 @@ (d/div {:class (class-set klasses)} children))) -(s/defn render-label +(sm/defn render-label "This doesn't handle any control group stuff." ([input :- Input] (render-label input nil)) ([{lc :label-classname label :label :as input} :- Input @@ -130,14 +131,14 @@ label) child)))) -(s/defn render-wrapper +(sm/defn render-wrapper [{wc :wrapper-classname} :- Input child] (if wc (d/div {:class wc} child) child)) -(s/defn render-form-group :- t/Component +(sm/defn render-form-group :- t/Component "Wraps the entire form group." [{bs-style :bs-style cn :group-classname :as input} :- Input children] @@ -150,7 +151,7 @@ (d/div {:class (class-set classes)} children))) -(s/defn render-input :- t/Component +(sm/defn render-input :- t/Component [input :- Input attrs children] (let [props (fn [klass] (u/merge-props attrs {:class klass @@ -170,7 +171,7 @@ ;; ### API Methods -(s/defn input :- t/Component +(sm/defn input :- t/Component "Returns an input component. This currently does NOT handle any of the default values or validation messages that we'll need to make this work, though." @@ -197,7 +198,7 @@ ;; These bad dawgs need to be abstracted out into more solid input ;; components. Putting them here for now. -(s/defn radio-option :- t/Component +(sm/defn radio-option :- t/Component "Generates a radio button entry, to place into a radio button grouping." [opts :- Radio] @@ -210,7 +211,7 @@ (d/label {:class "radio-inline"} core label) (d/div {:class "radio"} (d/label {} core label))))) -(s/defn options :- [t/Component] +(sm/defn options :- [t/Component] "Returns a sequence of options for use as the children of a select input." [header :- s/Str diff --git a/src/om_bootstrap/mixins.cljs b/src/om_bootstrap/mixins.cljs index f4441d8..aca94ff 100644 --- a/src/om_bootstrap/mixins.cljs +++ b/src/om_bootstrap/mixins.cljs @@ -2,17 +2,18 @@ (:require [cljs.core.async :as a :refer [put!]] [om.core :as om] [om-tools.mixin :refer-macros [defmixin]] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Listener Mixin -(s/defn event-listener :- (s/=> s/Any) +(sm/defn event-listener :- (sm/=> s/Any) "Registers the callback on the supplied target for events of type `event-type`. Returns a function of no arguments that, when called, unregisters the callback." [target :- s/Any event-type :- s/Str - callback :- (s/=> s/Any s/Any)] + callback :- (sm/=> s/Any s/Any)] (cond (.-addEventListener target) (do (.addEventListener target event-type callback false) (fn [] (.removeEventListener target event-type callback false))) diff --git a/src/om_bootstrap/modal.cljs b/src/om_bootstrap/modal.cljs index dd1d177..b62359e 100644 --- a/src/om_bootstrap/modal.cljs +++ b/src/om_bootstrap/modal.cljs @@ -7,8 +7,9 @@ [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] [om-tools.mixin :refer-macros [defmixin]] - [schema.core :as s :include-macros true]) - (:require-macros [cljs.core.async.macros :refer [go-loop]])) + [schema.core :as s]) + (:require-macros [cljs.core.async.macros :refer [go-loop]] + [schema.macros :as sm])) ;; ## Schema ;; @@ -30,9 +31,9 @@ :close-button? s/Bool :animate? s/Bool :children (s/named s/Any "Child elements, if any.") - :on-request-hide (s/=> s/Any s/Any)}) + :on-request-hide (sm/=> s/Any s/Any)}) -(s/defn render-header :- t/Component +(sm/defn render-header :- t/Component "Renders the header for the modal." [{:keys [close-button? on-request-hide title]} :- Modal] (let [close-button (when close-button? @@ -47,7 +48,7 @@ title (d/h4 {:class "modal-title"} title))))) -(s/defn render-backdrop :- t/Component +(sm/defn render-backdrop :- t/Component "Renders the backdrop behind the modal." [{:keys [animation? backdrop? on-request-hide] :- Modal} modal-elem] (let [klasses {:modal-backdrop true diff --git a/src/om_bootstrap/nav.cljs b/src/om_bootstrap/nav.cljs index f9db143..8f0f650 100644 --- a/src/om_bootstrap/nav.cljs +++ b/src/om_bootstrap/nav.cljs @@ -5,14 +5,15 @@ [om-bootstrap.util :as u] [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## NavItem (def NavItem (t/bootstrap {(s/optional-key :title) s/Str - (s/optional-key :on-select) (s/=> s/Any s/Any) + (s/optional-key :on-select) (sm/=> s/Any s/Any) (s/optional-key :active?) s/Bool (s/optional-key :disabled?) s/Bool (s/optional-key :href) s/Str})) @@ -39,7 +40,7 @@ :on-click handle-click} children))))) -(s/defn nav-item :- t/Component +(sm/defn nav-item :- t/Component [opts :- NavItem & children] (->nav-item* {:opts opts :children children})) @@ -58,7 +59,7 @@ (s/optional-key :navbar?) s/Bool (s/optional-key :pull-right?) s/Bool})) -(s/defn child-active? :- s/Bool +(sm/defn child-active? :- s/Bool "Accepts a NavItem's child props and the current options provided to the Nav bar; returns true if the child component should be active, false otherwise." @@ -70,7 +71,7 @@ (when-let [ak (:active-href opts)] (= ak (:href child-props)))))) -(s/defn clone-nav-item +(sm/defn clone-nav-item "Takes the options supplied to the top level nav and returns a function that will CLONE the inner nav items, transferring all relevant props from the outer code to the inner code." @@ -103,7 +104,7 @@ (d/nav (u/merge-props props {:class (d/class-set classes)}) (d/ul ul-props children)))))) -(s/defn nav :- t/Component +(sm/defn nav :- t/Component [opts :- Nav & children] (->nav* {:opts opts :children children})) @@ -115,14 +116,14 @@ (def NavBar (t/bootstrap - {(s/optional-key :component-fn) (s/=> s/Any s/Any) + {(s/optional-key :component-fn) (sm/=> s/Any s/Any) (s/optional-key :fixed-top?) s/Bool (s/optional-key :fixed-bottom?) s/Bool (s/optional-key :static-top?) s/Bool (s/optional-key :inverse?) s/Bool (s/optional-key :role) s/Str (s/optional-key :brand) t/Renderable - (s/optional-key :on-toggle) (s/=> s/Any s/Any) + (s/optional-key :on-toggle) (sm/=> s/Any s/Any) (s/optional-key :toggle-nav-key) s/Str (s/optional-key :nav-expanded?) s/Bool (s/optional-key :default-nav-expanded?) s/Bool})) @@ -154,7 +155,7 @@ (:toggle-nav-key bs)) (render-toggle-button owner bs)))) -(s/defn clone-nav-item +(sm/defn clone-nav-item "Takes the options supplied to the top level nav and returns a function that will CLONE the inner nav items, transferring all relevant props from the outer code to the inner code." @@ -208,7 +209,7 @@ (render-header owner bs)) (map #(render-navbar-child owner % bs) children)))))) -(s/defn navbar +(sm/defn navbar [opts :- NavBar & children] (->navbar* {:opts opts :children children})) diff --git a/src/om_bootstrap/panel.cljs b/src/om_bootstrap/panel.cljs index 4d53bf0..338cdb5 100644 --- a/src/om_bootstrap/panel.cljs +++ b/src/om_bootstrap/panel.cljs @@ -5,19 +5,20 @@ [om-bootstrap.util :as u] [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; TODO: Dropdown functionality is NOT there yet, so :on-select is ;; ignored (https://github.com/racehub/om-bootstrap/issues/17) (def Panel (t/bootstrap - {(s/optional-key :on-select) (s/=> s/Any s/Any) + {(s/optional-key :on-select) (sm/=> s/Any s/Any) (s/optional-key :header) t/Renderable (s/optional-key :footer) t/Renderable (s/optional-key :list-group) t/Renderable})) -(s/defn panel :- t/Component +(sm/defn panel :- t/Component [opts :- Panel & children] (let [[bs props] (t/separate Panel opts {:bs-class "panel" :bs-style "default"}) diff --git a/src/om_bootstrap/progress_bar.cljs b/src/om_bootstrap/progress_bar.cljs index ab016b5..3565d00 100644 --- a/src/om_bootstrap/progress_bar.cljs +++ b/src/om_bootstrap/progress_bar.cljs @@ -3,7 +3,8 @@ work." (:require [om-bootstrap.types :as t] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Schema @@ -20,20 +21,20 @@ (def defaults {:min 0 :max 100 :bs-class "progress-bar"}) -(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 sr-only-label :- t/Component +(sm/defn sr-only-label :- t/Component "Renders a screenreader-only label." [label :- t/Renderable] (d/span {:class "sr-only"} label)) (comment - (s/defn render-label + (sm/defn render-label "There's some bullshit in here able interpolation that I have to figure out." [percentage :- s/Num] @@ -41,14 +42,14 @@ ) "Actual progress bar rendering." - (s/defn render-progress-bar + (sm/defn render-progress-bar [{:keys [label]} :- ProgressBar] (cond (string? label) (render-label label) (nil?) ))) -(s/defn progress-bar :- t/Component +(sm/defn progress-bar :- t/Component "Generates a Bootstrap progress bar component." [opts :- ProgressBar & children] (let [[bs props] (t/separate ProgressBar opts defaults) diff --git a/src/om_bootstrap/random.cljs b/src/om_bootstrap/random.cljs index 2e9bde7..49df784 100644 --- a/src/om_bootstrap/random.cljs +++ b/src/om_bootstrap/random.cljs @@ -6,11 +6,12 @@ [om-bootstrap.util :as u] [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Jumbotron -(s/defn jumbotron :- t/Component +(sm/defn jumbotron :- t/Component "A lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site." [opts & children] @@ -19,7 +20,7 @@ ;; ## Label -(s/defn label :- t/Component +(sm/defn label :- t/Component "Create a (label {} \"label!\") to show highlight information." [opts & children] (let [[bs props] (t/separate {} opts {:bs-class "label" @@ -30,7 +31,7 @@ ;; ## Well -(s/defn well :- t/Component +(sm/defn well :- t/Component "Use the well as a simple effect on an element to give it an inset effect." [opts & children] (let [[bs props] (t/separate {} opts {:bs-class "well"}) @@ -40,7 +41,7 @@ ;; ## Header -(s/defn page-header :- t/Component +(sm/defn page-header :- t/Component "A simple shell for an h1 to appropriately space out and segment sections of content on a page. It can utilize the h1’s default small element, as well as most other components (with additional styles)." @@ -61,7 +62,7 @@ (s/optional-key :arrow-offset-left) s/Int (s/optional-key :arrow-offset-top) s/Int})) -(s/defn tooltip :- t/Component +(sm/defn tooltip :- t/Component [opts :- ToolTip & children] (let [[bs _] (t/separate ToolTip opts {:placement "right"}) classes {:tooltip true @@ -81,7 +82,7 @@ (def Alert (t/bootstrap - {(s/optional-key :on-dismiss) (s/=> s/Any s/Any) + {(s/optional-key :on-dismiss) (sm/=> s/Any s/Any) (s/optional-key :dismiss-after) s/Int})) (def alert-defaults @@ -110,7 +111,7 @@ dismiss-button children)))) -(s/defn alert :- t/Component +(sm/defn alert :- t/Component "Wrapper for the alert component to allow a better user interface." [opts :- Alert & children] (let [[bs props] (t/separate Alert opts alert-defaults)] @@ -131,7 +132,7 @@ ;; TODO: Abstract out shared style generation between here and ;; tooltip. -(s/defn popover :- t/Component +(sm/defn popover :- t/Component [opts :- Popover & children] (let [[bs _] (t/separate Popover opts {:placement "right"}) classes {:popover true @@ -156,7 +157,7 @@ (t/bootstrap {(s/optional-key :pull-right?) s/Bool})) -(s/defn badge :- t/Component +(sm/defn badge :- t/Component [opts :- Badge & children] (let [[bs props] (t/separate Badge opts) classes {:pull-right (:pull-right? bs) @@ -169,7 +170,7 @@ (def Glyphicon (t/bootstrap {:glyph s/Str})) -(s/defn glyphicon :- t/Component +(sm/defn glyphicon :- t/Component [opts :- Glyphicon & children] (let [[bs props] (t/separate Glyphicon opts {:bs-class "glyphicon"}) classes (assoc (t/bs-class-set bs) diff --git a/src/om_bootstrap/table.cljs b/src/om_bootstrap/table.cljs index faf9679..4ba77f3 100644 --- a/src/om_bootstrap/table.cljs +++ b/src/om_bootstrap/table.cljs @@ -3,7 +3,8 @@ [om-bootstrap.types :as t] [om-bootstrap.util :as u] [om-tools.dom :as d :include-macros true] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) (def Table {(s/optional-key :striped?) s/Bool @@ -12,7 +13,7 @@ (s/optional-key :hover?) s/Bool (s/optional-key :responsive?) s/Bool}) -(s/defn table +(sm/defn table "Generates a Bootstrap table wrapper." [opts :- Table & children] (let [[bs props] (t/separate Table opts) diff --git a/src/om_bootstrap/types.cljs b/src/om_bootstrap/types.cljs index 1445866..34c1ad5 100644 --- a/src/om_bootstrap/types.cljs +++ b/src/om_bootstrap/types.cljs @@ -1,17 +1,18 @@ (ns om-bootstrap.types "Types for working with Bootstrap." - (:require [schema.core :as s :include-macros true])) + (:require [schema.core :as s]) + (:require-macros [schema.macros :as sm])) ;; ## Schema Utilities -(s/defn schema-keys +(sm/defn schema-keys "Returns all keys from a schema." [schema :- {s/Any s/Any}] (map (fn [k] (if (s/optional-key? k) (:k k) k)) (keys schema))) -(s/defn at-least +(sm/defn at-least "Returns a map schema that accepts the supplied map schema, plus any other optional keys that show up in the map. Such a schema can only enforce that required keys are missing." @@ -91,7 +92,7 @@ ;; Separate follows the best practices set out here: ;; https://gist.github.com/sebmarkbage/a6e220b7097eb3c79ab7 -(s/defn separate :- (s/pair +(sm/defn separate :- (s/pair {s/Any s/Any} "om-bootstrap options." {s/Any s/Any} "all other props.") "Returns two maps; the first is all of the schema options, the @@ -104,7 +105,7 @@ [(into {} (filter (comp ks key) opts)) (into {} (remove (comp ks key) opts))]))) -(s/defn bs-class-set :- {s/Str s/Bool} +(sm/defn bs-class-set :- {s/Str s/Bool} "Returns input for class-set." [{:keys [bs-class bs-style bs-size]} :- (at-least BootstrapClass)] (if-let [klass (class-map bs-class)] diff --git a/src/om_bootstrap/util.cljs b/src/om_bootstrap/util.cljs index 06b6a78..f4c1c8b 100644 --- a/src/om_bootstrap/util.cljs +++ b/src/om_bootstrap/util.cljs @@ -1,7 +1,8 @@ (ns om-bootstrap.util "Utilities for the om-bootstrap library." (:require [om.core :as om] - [schema.core :as s :include-macros true])) + [schema.core :as s]) + (:require-macros [schema.macros :as sm])) (defn merge-with-fns "Returns a map that consists of the rest of the maps conj-ed onto @@ -22,7 +23,7 @@ (reduce merge-entry (or m1 {}) (seq m2)))] (reduce merge {} maps))) -(s/defn collectify :- [s/Any] +(sm/defn collectify :- [s/Any] [x :- s/Any] (if (sequential? x) x [x])) @@ -30,13 +31,13 @@ ;; ;; Some of these are rewritten from various React addons. -(s/defn strict-valid-component? :- s/Bool +(sm/defn strict-valid-component? :- s/Bool "TODO: Once Om updates its externs to include this file, we can remove the janky aget call." [child] ((aget js/React "isValidComponent") child)) -(s/defn valid-component? :- s/Bool +(sm/defn valid-component? :- s/Bool "Returns true if the supplied argument is a valid React component, false otherwise." [child] @@ -44,7 +45,7 @@ (number? child) (strict-valid-component? child))) -(s/defn some-valid-component? :- s/Bool +(sm/defn some-valid-component? :- s/Bool "Returns true if the supplied sequence contains some valid React component, false otherwise." [children] From 1c48c9b6152d0e940c94adef9bde4987bf19839d Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 15 Oct 2014 23:43:16 -0600 Subject: [PATCH 03/28] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98afa36..f8eb6c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.3.0 +## 0.3.1 (10/15/2014) - Revert schema upgrade... fancy that :) From 90333ac99257a1f1cdb4b4a8496edf332a693293 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 15 Oct 2014 23:46:25 -0600 Subject: [PATCH 04/28] lein-release plugin: preparing 0.3.1 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index acc0e89..35f333e 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.1-SNAPSHOT" +(defproject racehub/om-bootstrap "0.3.1" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT Licens" From 6173b4b0f063cf234eee0cae9bcda904f5983770 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 15 Oct 2014 23:46:25 -0600 Subject: [PATCH 05/28] lein-release plugin: bumped version from 0.3.1 to 0.3.2-SNAPSHOT for next development cycle --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 35f333e..0902e15 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.1" +(defproject racehub/om-bootstrap "0.3.2-SNAPSHOT" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT Licens" From cfd1fc2516295cc7e9d819a945ce6e4edbe12b07 Mon Sep 17 00:00:00 2001 From: Daniel Glauser Date: Sat, 25 Oct 2014 12:09:20 -0600 Subject: [PATCH 06/28] 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 ad97134712213c20c29919cfd35c6931d57bbe4a Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Tue, 11 Nov 2014 10:33:51 -0700 Subject: [PATCH 07/28] Closes #34 --- CHANGELOG.md | 4 ++++ docs/src/cljs/om_bootstrap/docs/example.cljs | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8eb6c9..ec2819c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 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 :) diff --git a/docs/src/cljs/om_bootstrap/docs/example.cljs b/docs/src/cljs/om_bootstrap/docs/example.cljs index c540fbf..e1aa0b1 100644 --- a/docs/src/cljs/om_bootstrap/docs/example.cljs +++ b/docs/src/cljs/om_bootstrap/docs/example.cljs @@ -33,10 +33,13 @@ (bs-example body) (when open? (->code-block {:code code})) - (d/a {:class (d/class-set + (d/a {:href "#" + :class (d/class-set {:code-toggle true :open open?}) - :on-click #(swap! state update-in [:open?] not)} + :on-click (fn [e] + (swap! state update-in [:open?] not) + (.preventDefault e))} (if open? "hide code" "show code"))))) From 2e7e5f4aa8a2e9f41403df56efbc50bc327bac27 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Fri, 21 Nov 2014 06:29:59 -0700 Subject: [PATCH 08/28] shorten name for doc site --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index 6e405fc..0c3bec3 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,5 @@ { - "name": "Om-Bootstrap Documentation Site", + "name": "Om-Bootstrap Doc Site", "description": "Documentation site for Om-Bootstrap; Bootstrap components on Om.", "repository": "https://github.com/racehub/om-bootstrap", "keywords": ["om", "react", "bootstrap", "ui"] From b0ffa2b505d5e0d75ff0985b67d4514711dd2aa5 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 10 Dec 2014 09:32:07 -0700 Subject: [PATCH 09/28] add component check --- src/om_bootstrap/util.cljs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/om_bootstrap/util.cljs b/src/om_bootstrap/util.cljs index f4c1c8b..9a27baa 100644 --- a/src/om_bootstrap/util.cljs +++ b/src/om_bootstrap/util.cljs @@ -31,6 +31,11 @@ ;; ;; Some of these are rewritten from various React addons. +(sm/defn om-component? :- s/Bool + [x] + (boolean + (aget (.-props x) "__om_cursor"))) + (sm/defn strict-valid-component? :- s/Bool "TODO: Once Om updates its externs to include this file, we can remove the janky aget call." @@ -152,5 +157,5 @@ (cond (not (strict-valid-component? child)) child (and (map? extra-props) (empty? extra-props)) (.constructor child (.-props child)) - (om/get-props child) (clone-om child extra-props) + (om-component? child) (clone-om child extra-props) :else (clone-basic-react child extra-props)))) From 769304b1277bbfa3ce0d1d974ff4f3530d5148cd Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 11:03:46 -0800 Subject: [PATCH 10/28] dependency upgrades, fixes weasel REPL issue --- project.clj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/project.clj b/project.clj index 0902e15..14a3bc6 100644 --- a/project.clj +++ b/project.clj @@ -15,16 +15,16 @@ :min-lein-version "2.3.0" :uberjar-name "om-bootstrap.jar" :jar-exclusions [#".DS_Store"] - :dependencies [[org.clojure/clojure "1.6.0"] + :dependencies [[org.clojure/clojure "1.7.0-alpha2"] [org.clojure/core.async "0.1.267.0-0d7780-alpha"] - [prismatic/om-tools "0.3.3"] - [prismatic/schema "0.3.0" - :exclude [org.clojure/clojurescript]] + [prismatic/om-tools "0.3.6" :exclusions [om]] + [prismatic/schema "0.3.1" + :exclusions [org.clojure/clojurescript]] [om "0.7.1"]] :profiles {:provided - {:dependencies [[org.clojure/clojurescript "0.0-2322"] + {:dependencies [[org.clojure/clojurescript "0.0-2371"] [secretary "1.2.0"] - [weasel "0.4.0-SNAPSHOT"]]} + [weasel "0.4.2"]]} :docs {:aot :all :omit-source true :main om-bootstrap.server From 249d7176c542ccc7a9ab569d19a8245cb68dc221 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 11:53:41 -0800 Subject: [PATCH 11/28] om-component? test --- test/om_bootstrap/util_test.cljs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/om_bootstrap/util_test.cljs b/test/om_bootstrap/util_test.cljs index 17830bb..f8d49bd 100644 --- a/test/om_bootstrap/util_test.cljs +++ b/test/om_bootstrap/util_test.cljs @@ -3,6 +3,7 @@ :include-macros true :refer [deftest is are use-fixtures]] [om.core :as om] + [om-bootstrap.button :refer [dropdown]] [om-bootstrap.util :as u] [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] @@ -90,6 +91,11 @@ "The chained version executes the side effects of `adder` twice, incrementing the counter by two more."))) +(deftest om-component-test + [] + (is (not (u/om-component? (d/p "Just a p")))) + (is (u/om-component? (dropdown {:title "Title!"})))) + (deftest merge-props-test (is (= (u/merge-props {:face "cake" :class "first"} {:cake "face" :className "second"}) From 8de721158d743a2aa921df3d9a90014a01acebc5 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 10 Dec 2014 15:01:07 -0700 Subject: [PATCH 12/28] add tests for 0.8 and compatibility and everything is better now oh god please be true --- .travis.yml | 2 +- docs/src/cljs/om_bootstrap/docs.cljs | 2 +- project.clj | 8 +++++--- src/om_bootstrap/util.cljs | 8 +++++++- test/om_bootstrap/input_test.cljs | 3 +-- test/om_bootstrap/types_test.cljs | 4 +--- test/om_bootstrap/util_test.cljs | 13 ++++++------- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66073ae..342ec1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: clojure lein: lein2 -script: lein2 test +script: lein2 do test, test-8 branches: only: - develop diff --git a/docs/src/cljs/om_bootstrap/docs.cljs b/docs/src/cljs/om_bootstrap/docs.cljs index 31cca19..2aa151b 100644 --- a/docs/src/cljs/om_bootstrap/docs.cljs +++ b/docs/src/cljs/om_bootstrap/docs.cljs @@ -10,7 +10,7 @@ [om-bootstrap.docs.shared :refer [four-oh-four]] [om-tools.core :refer-macros [defcomponentk]] [om-tools.dom :as d :include-macros true] - [secretary.core :as route :include-macros true :refer [defroute]] + [secretary.core :as route :refer-macros [defroute]] [weasel.repl :as ws-repl]) (:require-macros [cljs.core.async.macros :refer [go-loop]]) (:import [goog.history EventType])) diff --git a/project.clj b/project.clj index 14a3bc6..d19d4cc 100644 --- a/project.clj +++ b/project.clj @@ -16,13 +16,13 @@ :uberjar-name "om-bootstrap.jar" :jar-exclusions [#".DS_Store"] :dependencies [[org.clojure/clojure "1.7.0-alpha2"] - [org.clojure/core.async "0.1.267.0-0d7780-alpha"] + [org.clojure/core.async "0.1.346.0-17112a-alpha"] [prismatic/om-tools "0.3.6" :exclusions [om]] [prismatic/schema "0.3.1" :exclusions [org.clojure/clojurescript]] [om "0.7.1"]] :profiles {:provided - {:dependencies [[org.clojure/clojurescript "0.0-2371"] + {:dependencies [[org.clojure/clojurescript "0.0-2411"] [secretary "1.2.0"] [weasel "0.4.2"]]} :docs {:aot :all @@ -37,8 +37,9 @@ :dependencies ~server-deps :source-paths ["docs/src/clj"] :resource-paths ["dev"]} + :om-8 {:dependencies [[om "0.8.0-beta3"]]} :dev {:plugins [[lein-cljsbuild "1.0.3"] - [com.cemerick/clojurescript.test "0.3.0"] + [com.cemerick/clojurescript.test "0.3.1"] [paddleguru/lein-gitflow "0.1.2"]] :dependencies ~(conj server-deps '[com.cemerick/piggieback "0.1.3"]) :source-paths ["docs/src/clj" "docs/src-dev"] @@ -47,6 +48,7 @@ :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}} :aliases {"test" ["cljsbuild" "test"] + "test-8" ["do" "clean," "cljsbuild" "clean," "with-profile" "+om-8" "cljsbuild" "test"] "repl" ["do" "cljsbuild" "once" "docs," "repl"] "uberjar" ["with-profile" "docs" "uberjar"]} :cljsbuild diff --git a/src/om_bootstrap/util.cljs b/src/om_bootstrap/util.cljs index 9a27baa..732e442 100644 --- a/src/om_bootstrap/util.cljs +++ b/src/om_bootstrap/util.cljs @@ -36,6 +36,12 @@ (boolean (aget (.-props x) "__om_cursor"))) +(defn get-props + "This is the same as om.core/get-props. We added it to get around + the new precondition in Om 0.8.0." + [x] + (aget (.-props x) "__om_cursor")) + (sm/defn strict-valid-component? :- s/Bool "TODO: Once Om updates its externs to include this file, we can remove the janky aget call." @@ -118,7 +124,7 @@ Requires that the supplied child has an Om cursor attached to it! " [child extra-props] - (let [om-props (om/get-props child)] + (let [om-props (get-props child)] (->> (doto (copy-js (.-props child)) (aset "__om_cursor" (if (fn? extra-props) diff --git a/test/om_bootstrap/input_test.cljs b/test/om_bootstrap/input_test.cljs index 7e8f542..9933991 100644 --- a/test/om_bootstrap/input_test.cljs +++ b/test/om_bootstrap/input_test.cljs @@ -1,7 +1,6 @@ (ns om-bootstrap.input-test (:require [cemerick.cljs.test :as t - :include-macros true - :refer [deftest is use-fixtures]] + :refer-macros [deftest is use-fixtures]] [schema.test :as st])) (use-fixtures :once st/validate-schemas) diff --git a/test/om_bootstrap/types_test.cljs b/test/om_bootstrap/types_test.cljs index 2f3b6c1..63ccadf 100644 --- a/test/om_bootstrap/types_test.cljs +++ b/test/om_bootstrap/types_test.cljs @@ -1,7 +1,5 @@ (ns om-bootstrap.types-test - (:require [cemerick.cljs.test - :include-macros true - :refer [deftest is]] + (:require [cemerick.cljs.test :refer-macros [deftest is]] [om-bootstrap.types :as t] [schema.core :as s])) diff --git a/test/om_bootstrap/util_test.cljs b/test/om_bootstrap/util_test.cljs index f8d49bd..0b01ded 100644 --- a/test/om_bootstrap/util_test.cljs +++ b/test/om_bootstrap/util_test.cljs @@ -1,8 +1,7 @@ (ns om-bootstrap.util-test (:require [cemerick.cljs.test :as t - :include-macros true - :refer [deftest is are use-fixtures]] - [om.core :as om] + :refer-macros [deftest is are use-fixtures]] + [om.core :as om :refer-macros [component]] [om-bootstrap.button :refer [dropdown]] [om-bootstrap.util :as u] [om-tools.core :refer-macros [defcomponentk]] @@ -127,8 +126,8 @@ :class "walrus"}))) (is (= {:x "one" :y "two" :z "three"} - (om/get-props (->fake-div {:x "one" :y "two" :z "three"}))) - "om/get-props returns the inner Om props, as expected. These + (u/get-props (->fake-div {:x "one" :y "two" :z "three"}))) + "u/get-props returns the inner Om props, as expected. These are trapped inside the actual props in a field called __om_cursor.") @@ -140,7 +139,7 @@ (-> (->fake-div {:x "one" :y "two" :z "three" :class "cake"}) (u/clone-with-props {:x "alpha", :class "walrus"}) - (om/get-props))) + (u/get-props))) "Cloning an om component merges the extra properties into the cursor, NOT into the overall props.") @@ -155,7 +154,7 @@ :class "cake-hut!"} (-> (->fake-div {:x "one" :y "two" :z "three" :class "cake"}) (u/clone-with-props hut-the-vals) - (om/get-props))) + (u/get-props))) "clone-with-props can take a function as well. This one adds hut! onto the end of all string values. From 2333ab2651e8bcb76c208fcb629471cd1ae7850e Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Wed, 10 Dec 2014 15:13:38 -0700 Subject: [PATCH 13/28] refactor --- src/om_bootstrap/util.cljs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/om_bootstrap/util.cljs b/src/om_bootstrap/util.cljs index 732e442..4f511d1 100644 --- a/src/om_bootstrap/util.cljs +++ b/src/om_bootstrap/util.cljs @@ -31,17 +31,16 @@ ;; ;; Some of these are rewritten from various React addons. -(sm/defn om-component? :- s/Bool - [x] - (boolean - (aget (.-props x) "__om_cursor"))) - (defn get-props "This is the same as om.core/get-props. We added it to get around the new precondition in Om 0.8.0." [x] (aget (.-props x) "__om_cursor")) +(sm/defn om-component? :- s/Bool + [x] + (boolean (get-props x))) + (sm/defn strict-valid-component? :- s/Bool "TODO: Once Om updates its externs to include this file, we can remove the janky aget call." From ade98a4b8b828b9ad553b4b63a805169d179dbeb Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:02:12 -0800 Subject: [PATCH 14/28] udpate changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec2819c..11e7f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.3.3 (12/9/2014) + +- 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 +- Upgraded om-tools to 0.3.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) From 7c34d6638156528197dcce322d03b2c16a9a8623 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:19:58 -0800 Subject: [PATCH 15/28] lein-release plugin: preparing 0.3.2 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index d19d4cc..d1fffc2 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.2-SNAPSHOT" +(defproject racehub/om-bootstrap "0.3.2" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT Licens" From f23ca3a157b51421988f1dad795b9a0253b8b57b Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:19:58 -0800 Subject: [PATCH 16/28] lein-release plugin: bumped version from 0.3.2 to 0.3.3-SNAPSHOT for next development cycle --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index d1fffc2..c5d1eb0 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.2" +(defproject racehub/om-bootstrap "0.3.3-SNAPSHOT" :description "Bootstrap meets Om." :url "http://github.com/racehub/om-bootstrap" :license {:name "MIT Licens" From 92263f08a80664685a0c89b6b6b8c8a73b97ca1e Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:23:26 -0800 Subject: [PATCH 17/28] fix changelog --- 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 2582cfba508592b7d4dbd77af52f7765cde46233 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Wed, 10 Dec 2014 15:27:18 -0800 Subject: [PATCH 18/28] 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 825fa41a115089bb1069f5848113f1f54df8dba1 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Thu, 11 Dec 2014 05:59:34 -0500 Subject: [PATCH 19/28] fix issue with lein 2.5 --- project.clj | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/project.clj b/project.clj index c5d1eb0..4ab3b8a 100644 --- a/project.clj +++ b/project.clj @@ -25,6 +25,22 @@ {:dependencies [[org.clojure/clojurescript "0.0-2411"] [secretary "1.2.0"] [weasel "0.4.2"]]} + ;; Change to the first version of the uberjar profile + ;; when this bug gets fixed: + ;; https://github.com/technomancy/leiningen/issues/1694 + ;; :uberjar [:docs {}] + :uberjar {:aot :all + :omit-source true + :main om-bootstrap.server + :plugins [[lein-cljsbuild "1.0.3"]] + :prep-tasks ^:replace [["clean"] + ["cljsbuild" "clean"] + ["cljsbuild" "once" "heroku"] + ["javac"] + ["compile" ":all"]] + :dependencies ~server-deps + :source-paths ["docs/src/clj"] + :resource-paths ["dev"]} :docs {:aot :all :omit-source true :main om-bootstrap.server @@ -49,8 +65,7 @@ {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}} :aliases {"test" ["cljsbuild" "test"] "test-8" ["do" "clean," "cljsbuild" "clean," "with-profile" "+om-8" "cljsbuild" "test"] - "repl" ["do" "cljsbuild" "once" "docs," "repl"] - "uberjar" ["with-profile" "docs" "uberjar"]} + "repl" ["do" "cljsbuild" "once" "docs," "repl"]} :cljsbuild {:test-commands {"unit" ["phantomjs" :runner From f2c28b48e2225e7da6f0eec703bd19bffb881353 Mon Sep 17 00:00:00 2001 From: David Petrovics Date: Mon, 12 Jan 2015 09:35:43 -0800 Subject: [PATCH 20/28] 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 21/28] 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 22/28] 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 23/28] 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 24/28] 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 25/28] 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 26/28] 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 27/28] 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 28/28] 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"}))