Skip to content

Commit

Permalink
Merge branch 'feature/gregg-31' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregg8 committed Mar 24, 2015
2 parents 906b7f3 + c448689 commit 6567dc0
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 255 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

;; ---------------------------------------------------------------------------------------

(defproject re-com "0.2.5"
(defproject re-com "0.2.6"
:description "Reusable UI components for Reagent"
:url "https://github.com/Day8/re-com.git"

Expand Down
13 changes: 9 additions & 4 deletions run/resources/public/resources/css/re-com.css
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ html, body {
background:rgba(0,0,0,0.45);
}

::-moz-selection { color: gold; background: red; }
::selection { color: gold; background: red; }
/*----------------------------------------------------------------------------------------
Override bootstrap input text placeholder colour (it's too dark)
----------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -947,7 +949,6 @@ code {
border-radius: 50%;
background-color: inherit;
opacity: 0.9;
-webkit-user-select: none;
}

.rc-md-circle-icon-button > i {
Expand Down Expand Up @@ -1016,7 +1017,6 @@ code {
text-align: center; /* to horizontally center the icon */
background-color: inherit;
border-radius: 3px;
-webkit-user-select: none;
}

.rc-md-icon-button > i {
Expand Down Expand Up @@ -1074,7 +1074,6 @@ code {
padding-left: 3px;
padding-right: 3px;
fill: #bdbdbd;
-webkit-user-select: none;
}

.rc-info-button:hover {
Expand Down Expand Up @@ -1118,7 +1117,6 @@ code {
background-color: inherit;
opacity: 0;
cursor: pointer;
-webkit-user-select: none;
}

.rc-row-button > i {
Expand Down Expand Up @@ -1223,3 +1221,10 @@ code {
font-variant: small-caps;
flex: none;
}

.noselect {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
11 changes: 6 additions & 5 deletions src/re_com/alert.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(:require [re-com.util :refer [deref-or-value]]
[re-com.buttons :refer [button]]
[re-com.box :refer [h-box v-box box scroller border]]
[re-com.validate :refer [extract-arg-data validate-args string-or-hiccup? alert-type? alert-types-list vector-of-maps? css-style? html-attr?]]))
[re-com.validate :refer [extract-arg-data string-or-hiccup? alert-type? alert-types-list
vector-of-maps? css-style? html-attr?] :refer-macros [validate-args-macro]]))

;;--------------------------------------------------------------------------------------------------
;; Component: alert
Expand All @@ -21,14 +22,14 @@
{:name :style :required false :type "css style map" :validate-fn css-style? :description "CSS styles. Applied to outer container"}
{:name :attr :required false :type "html attr map" :validate-fn html-attr? :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed. Applied to outer container"]}])

(def alert-box-args (extract-arg-data alert-box-args-desc))
;(def alert-box-args (extract-arg-data alert-box-args-desc))

(defn alert-box
"Displays one alert box. A close button allows the message to be removed"
[& {:keys [id alert-type heading body padding closeable? on-close class style attr]
:or {alert-type "info"}
:as args}]
{:pre [(validate-args alert-box-args args "alert-box")]}
{:pre [(validate-args-macro alert-box-args-desc args "alert-box")]}
(let [close-button [button
:label "×"
:on-click (handler-fn (on-close id))
Expand Down Expand Up @@ -74,7 +75,7 @@
{:name :style :required false :type "css style map" :validate-fn css-style? :description "CSS styles. Applied to outer container"}
{:name :attr :required false :type "html attr map" :validate-fn html-attr? :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed. Applied to outer container"]}])

(def alert-list-args (extract-arg-data alert-list-args-desc))
;(def alert-list-args (extract-arg-data alert-list-args-desc))

(defn alert-list
"Displays a list of alert-box components in a v-box. Sample alerts object:
Expand All @@ -91,7 +92,7 @@
[& {:keys [alerts on-close max-height padding border-style class style attr]
:or {padding "4px"}
:as args}]
{:pre [(validate-args alert-list-args args "alert-list")]}
{:pre [(validate-args-macro alert-list-args-desc args "alert-list")]}
(let [alerts (deref-or-value alerts)]
[box
:child [border
Expand Down
38 changes: 19 additions & 19 deletions src/re_com/box.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns re-com.box
(:require [clojure.string :as string]
[re-com.validate :refer [extract-arg-data validate-args justify-style? justify-options-list align-style? align-options-list
scroll-style? scroll-options-list string-or-hiccup? css-style? html-attr?]]))
[re-com.validate :refer [extract-arg-data justify-style? justify-options-list align-style? align-options-list
scroll-style? scroll-options-list string-or-hiccup? css-style? html-attr?] :refer-macros [validate-args-macro]]))

(def debug false)

Expand Down Expand Up @@ -152,13 +152,13 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def gap-args (extract-arg-data gap-args-desc))
;(def gap-args (extract-arg-data gap-args-desc))

(defn gap
"Returns a component which produces a gap between children in a v-box/h-box along the main axis"
[& {:keys [size width height class style attr]
:as args}]
{:pre [(validate-args gap-args args "gap")]}
{:pre [(validate-args-macro gap-args-desc args "gap")]}
(let [s (merge
(when size (flex-child-style size))
(when width {:width width})
Expand All @@ -182,15 +182,15 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def line-args (extract-arg-data line-args-desc))
;(def line-args (extract-arg-data line-args-desc))

(defn line
"Returns a component which produces a line between children in a v-box/h-box along the main axis.
Specify size in pixels and a stancard CSS colour. Defaults to a 1px red line"
[& {:keys [size color class style attr]
:or {size "1px" color "lightgray"}
:as args}]
{:pre [(validate-args line-args args "line")]}
{:pre [(validate-args-macro line-args-desc args "line")]}
(let [s (merge
{:flex (str "0 0 " size)}
{:background-color color}
Expand Down Expand Up @@ -221,7 +221,7 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def h-box-args (extract-arg-data h-box-args-desc))
;(def h-box-args (extract-arg-data h-box-args-desc))

(defn h-box
"Returns hiccup which produces a horizontal box.
Expand All @@ -230,7 +230,7 @@
[& {:keys [size width height min-width min-height justify align margin padding gap children class style attr]
:or {size "none" justify :start align :stretch}
:as args}]
{:pre [(validate-args h-box-args args "h-box")]}
{:pre [(validate-args-macro h-box-args-desc args "h-box")]}
(let [s (merge
{:display "flex" :flex-flow "row nowrap"}
(flex-child-style size)
Expand Down Expand Up @@ -259,7 +259,7 @@
;; Component: v-box (debug colour: antiquewhite)
;; ------------------------------------------------------------------------------------

(def v-box-args-desc
(def v-box-args-desc
[{:name :children :required true :type "vector" :validate-fn sequential? :description "a vector (or list) of components"}
{:name :size :required false :default "none" :type "string" :validate-fn string? :description [:span "a flexbox type size. Examples: " [:code "initial"] ", " [:code "auto"] ", " [:code "100px"] ", " [:code "60%"] " or the generic :flex version " [:code "{grow} {shrink} {basis}"]]}
{:name :width :required false :type "string" :validate-fn string? :description "a CSS width style"}
Expand All @@ -275,7 +275,7 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def v-box-args (extract-arg-data v-box-args-desc))
;(def v-box-args (extract-arg-data v-box-args-desc))

(defn v-box
"Returns hiccup which produces a vertical box.
Expand All @@ -284,7 +284,7 @@
[& {:keys [size width height min-width min-height justify align margin padding gap children class style attr]
:or {size "none" justify :start align :stretch}
:as args}]
{:pre [(validate-args v-box-args args "v-box")]}
{:pre [(validate-args-macro v-box-args-desc args "v-box")]}
(let [s (merge
{:display "flex" :flex-flow "column nowrap"}
(flex-child-style size)
Expand Down Expand Up @@ -313,7 +313,7 @@
;; Component: box
;; ------------------------------------------------------------------------------------

(def box-args-desc
(def box-args-desc
[{:name :child :required true :type "string | hiccup" :validate-fn string-or-hiccup? :description "a component (or string)"}
{:name :size :required false :default "none" :type "string" :validate-fn string? :description [:span "a flexbox type size. Examples: " [:code "initial"] ", " [:code "auto"] ", " [:code "100px"] ", " [:code "60%"] " or the generic :flex version " [:code "{grow} {shrink} {basis}"]]}
{:name :width :required false :type "string" :validate-fn string? :description "a CSS width style"}
Expand All @@ -329,15 +329,15 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def box-args (extract-arg-data box-args-desc))
;(def box-args (extract-arg-data box-args-desc))

(defn box
"Returns hiccup which produces a box, which is generally used as a child of a v-box or an h-box.
By default, it also acts as a container for further child compenents, or another h-box or v-box"
[& {:keys [size width height min-width min-height justify align align-self margin padding child class style attr]
:or {size "none"}
:as args}]
{:pre [(validate-args box-args args "box")]}
{:pre [(validate-args-macro box-args-desc args "box")]}
(box-base :size size
:width width
:height height
Expand Down Expand Up @@ -382,7 +382,7 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def scroller-args (extract-arg-data scroller-args-desc))
;(def scroller-args (extract-arg-data scroller-args-desc))

(defn scroller
"Returns hiccup which produces a scoller component.
Expand All @@ -400,7 +400,7 @@
[& {:keys [size scroll h-scroll v-scroll width height min-width min-height justify align align-self margin padding child class style attr]
:or {size "auto"}
:as args}]
{:pre [(validate-args scroller-args args "scroller")]}
{:pre [(validate-args-macro scroller-args-desc args "scroller")]}
(let [not-v-or-h (and (nil? v-scroll) (nil? h-scroll))
scroll (if (and (nil? scroll) not-v-or-h) :auto scroll)]
(box-base :size size
Expand Down Expand Up @@ -445,7 +445,7 @@
{:name :style :required false :type "map" :validate-fn css-style? :description "CSS styles to add or override"}
{:name :attr :required false :type "map" :validate-fn html-attr? :description [:span "html attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])

(def border-args (extract-arg-data border-args-desc))
;(def border-args (extract-arg-data border-args-desc))

(defn border
"Returns hiccup which produces a border component.
Expand All @@ -457,7 +457,7 @@
[& {:keys [size width height min-width min-height margin padding border l-border r-border t-border b-border radius child class style attr]
:or {size "auto"}
:as args}]
{:pre [(validate-args border-args args "border")]}
{:pre [(validate-args-macro border-args-desc args "border")]}
(let [no-border (every? nil? [border l-border r-border t-border b-border])
default-border "1px solid lightgrey"]
(box-base :size size
Expand All @@ -476,4 +476,4 @@
:child child
:class (str "rc-border " class)
:style style
:attr attr)))
:attr attr)))
Loading

0 comments on commit 6567dc0

Please sign in to comment.