Skip to content

Instantly share code, notes, and snippets.

@tylermorten
Last active June 11, 2016 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylermorten/64657949067f72a449a87801574a15c7 to your computer and use it in GitHub Desktop.
Save tylermorten/64657949067f72a449a87801574a15c7 to your computer and use it in GitHub Desktop.
(ns style-sheet)
(def ReactNative (js/require "react-native"))
(defn platform-style
[style-map & addl]
(let [platform (-> (.. ReactNative -Platform -OS) keyword)]
(cond-> style-map
(contains? style-map platform) (->
(merge (get style-map platform))
(dissoc platform))
(map? (first addl)) (merge (first addl)))))
(comment
(def style {:container {:flex 1
:android {:backgroundColor "#ccc"}
:ios {:backgroundColor "#000"}}})
(view {:style (platform-style (style :container) {:addlStyle "blah blah"}}) ...))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment