|
1 |
| -(ns re-com.core |
| 1 | +(ns re-com.misc |
2 | 2 | (:require-macros [re-com.core :refer [handler-fn]])
|
3 | 3 | (:require [re-com.util :refer [deref-or-value px]]
|
4 | 4 | [re-com.popover :refer [popover-tooltip]]
|
|
7 | 7 | [reagent.core :as reagent]))
|
8 | 8 |
|
9 | 9 |
|
10 |
| -;; ------------------------------------------------------------------------------------ |
11 |
| -;; Component: label |
12 |
| -;; ------------------------------------------------------------------------------------ |
13 |
| - |
14 |
| -(def label-args-desc |
15 |
| - [{:name :label :required true :type "anything" :description "text to display. Can be anything as it will be converted to a string"} |
16 |
| - {:name :on-click :required false :type "() -> nil" :validate-fn fn? :description "function to call when label is clicked"} |
17 |
| - {:name :width :required false :type "string" :validate-fn string? :description "a CSS width"} |
18 |
| - {:name :class :required false :type "string" :validate-fn string? :description "CSS class names, space separated"} |
19 |
| - {:name :style :required false :type "css style map" :validate-fn css-style? :description "additional CSS styles"} |
20 |
| - {: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"]}]) |
21 |
| - |
22 |
| -(def label-args (extract-arg-data label-args-desc)) |
23 |
| - |
24 |
| -(defn label |
25 |
| - "Returns markup for a basic label" |
26 |
| - [& {:keys [label on-click width class style attr] |
27 |
| - :as args}] |
28 |
| - {:pre [(validate-args label-args args "label")]} |
29 |
| - [box |
30 |
| - :width width |
31 |
| - :align :start |
32 |
| - :child [:span |
33 |
| - (merge |
34 |
| - {:class (str "rc-label " class) |
35 |
| - :style (merge {:flex "none"} style)} |
36 |
| - (when on-click |
37 |
| - {:on-click (handler-fn (on-click))}) |
38 |
| - attr) |
39 |
| - (str label)]]) |
40 |
| - |
41 |
| - |
42 | 10 | ;; ------------------------------------------------------------------------------------
|
43 | 11 | ;; Component: input-text
|
44 | 12 | ;; ------------------------------------------------------------------------------------
|
|
388 | 356 | :margin "10px"}}
|
389 | 357 | [:img {:src "resources/img/spinner.gif"
|
390 | 358 | :style {:margin "auto"}}]]])
|
391 |
| - |
392 |
| - |
393 |
| -;; ------------------------------------------------------------------------------------ |
394 |
| -;; Component: title |
395 |
| -;; ------------------------------------------------------------------------------------ |
396 |
| - |
397 |
| -;; TODO: Could add proper :h validation |
398 |
| - |
399 |
| -(def title-args-desc |
400 |
| - [{:name :label :required true :type "anything" :description "text to display. Can be anything as it will be converted to a string"} |
401 |
| - {:name :h :required false :default :h3 :type "keyword" :validate-fn keyword? :description "something like :h3 or :h4"} |
402 |
| - {:name :underline? :required false :default true :type "boolean" :description "determines whether an underline is placed under the title"} |
403 |
| - {:name :class :required false :type "string" :validate-fn string? :description "CSS class names, space separated"} |
404 |
| - {:name :style :required false :type "css style map" :validate-fn css-style? :description "CSS styles to add or override"} |
405 |
| - {: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"]}]) |
406 |
| - |
407 |
| -(def title-args (extract-arg-data title-args-desc)) |
408 |
| - |
409 |
| -(defn title |
410 |
| - "An underlined, left justified, Title. By default :h3" |
411 |
| - [& {:keys [label h underline? class style attr] |
412 |
| - :or {underline? true h :h3} |
413 |
| - :as args}] |
414 |
| - {:pre [(validate-args title-args args "title")]} |
415 |
| - [v-box |
416 |
| - :children [[h (merge {:class (str "rc-title " class) |
417 |
| - :style (merge {:display "flex" :flex "none"} |
418 |
| - style)} |
419 |
| - attr) |
420 |
| - label] |
421 |
| - (when underline? [line :size "1px"])]]) |
0 commit comments