Last active
September 24, 2017 19:22
-
-
Save roman01la/5029fab68412d251709a to your computer and use it in GitHub Desktop.
Reagent + react-motion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Reagent component | |
(defn new-task-input-component [props] | |
(let [new-task (subscribe [:get-new-task])] | |
[view | |
{:style (assoc (:slide-up styles) :transform [{:translateY (- (:y props))}])} | |
[input {:style (:input styles) | |
:default-value @new-task | |
:auto-focus true | |
:on-change-text #(dispatch [:set-new-task %]) | |
:on-submit-editing #(do | |
(dispatch [:create-task]) | |
(dispatch [:hide-task-input]) | |
(dispatch [:clear-new-task]))}] | |
[text | |
{:style | |
{:font-size 20 | |
:text-align "center" | |
:margin-top 20}} | |
"Type in your task description"]])) | |
;; (Reagent -> React) component | |
(def react-new-task-input-component | |
(r/reactify-component new-task-input-component)) | |
;; (React Motion -> Reagent Motion) component | |
(def motion (r/adapt-react-class (.-Motion js/ReactMotion))) | |
;; (Reagent -> React) + (React Motion -> Reagent Motion) component | |
(defn slide-up-input [visible] | |
[motion | |
{:style {:y (spring (if visible 105 0) (if visible (.. presets -wobbly)))}} | |
#(r/create-element react-new-task-input-component %)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment