Skip to content

Instantly share code, notes, and snippets.

@dimitertodorov
Created May 11, 2016 14:22
Show Gist options
  • Save dimitertodorov/51e4e7ee144857cd600b5a641acdf5e2 to your computer and use it in GitHub Desktop.
Save dimitertodorov/51e4e7ee144857cd600b5a641acdf5e2 to your computer and use it in GitHub Desktop.
(ns torcaui.components.potato
(:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
[clojure.string :as str]
[torcaui.async :refer [raise!]]
[torcaui.routes :as routes]
[torcaui.state :as state]
[torcaui.utils :as utils :include-macros true]
[om.core :as om :include-macros true]
[cljsjs.react-select])
(:require-macros [torcaui.utils :refer [html]]))
(def Select (js/React.createFactory js/Select))
(def options
[{:label "Option Potato" :value 1}
{:label "Option 2" :value 2}])
(defn potato [data owner]
(reify
om/IDisplayName (display-name [_] "Potato")
om/IInitState
(init-state [_]
{:options options
:value [1]})
om/IRenderState
(render-state [_ state]
(let [options (:options state)
value (:value state)]
(html [:div
[:div {:class "wrapper wrapper-content"}
[:div.row
[:div {:class "col-lg-6"}
[:div {:class "ibox float-e-margins"}
[:div {:class "ibox-title"}
[:h5 "MultiSelect Demo"]]
[:div {:class "ibox-content"}
[:div
(Select
#js {:multi true
:simpleValue true
:disabled false
:value (clj->js value)
:placeholder "Select Faves"
:options (clj->js options)
:onChange (fn [v]
(om/set-state! owner :value (mapv js/parseInt (str/split (js->clj v) ","))))})]]]]
[:div {:class "col-lg-3"}
[:div {:class "ibox float-e-margins"}
[:div {:class "ibox-title"}
[:h5 "Values"]]
[:div {:class "ibox-content"}
[:h1 {:class "no-margins"} (str value)]]]]]]])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment