Skip to content

Instantly share code, notes, and snippets.

@taylorSando
Created March 12, 2015 04:10
Show Gist options
  • Save taylorSando/9f779d58a34939e38f8b to your computer and use it in GitHub Desktop.
Save taylorSando/9f779d58a34939e38f8b to your computer and use it in GitHub Desktop.
Material UI Reagent
;; material-ui.macros.clj
(ns material-ui.macros)
(def material-tags
'[AppBar
AppCanvas
Circle
Checkbox
DatePicker
DialogWindow
Dialog
DropDownIcon
DropDownMenu
EnhancedButton
FlatButton
FloatingActionButton
FocusRipple
FontIcon
IconButton
Icon
InkBar
Input
LeftNav
MenuItem
Menu
Overlay
Paper
RadioButton
RadioButtonGroup
RaisedButton
Slider
SlideIn
Snackbar
SvgIcon
Tab
TabTemplate
Tabs
TableHeader
TableRowsItem
TableRows
TextField
Toggle
ToolbarGroup
Toolbar
Tooltip
TouchRipple])
(defn material-ui-react-import [tname]
`(def ~tname (reagent.core/adapt-react-class (aget js/MaterialUI ~(name tname)))))
(defmacro export-material-ui-react-classes []
`(do ~@(map material-ui-react-import material-tags)))
;; material-ui.core.cljs
(ns material-ui.core
(:require-macros [material-ui.macros :refer [export-material-ui-react-classes]]))
(export-material-ui-react-classes)
;; You can use https://github.com/taylorSando/om-material-ui/tree/master/build-mui
;; to build the js and css files that should be included in the html
;; Also when importing reagent
[reagent "0.5.0" :exclusions [cljsjs/react]]
;; Create a file in the source direction cljsjs/react.cljs
(ns cljsjs.react)
@danielytics
Copy link

Hi,

I've been playing with this for a few weeks and this code is great, thanks very much!

Would it be possible to add a license to this? I'd love to use it in a project, but am wary of random code on the internet that doesn't include a license.

Also, should you put this into its own lib, we could start a discussion around how to best access the raw react component (so that its methods can be called, eg Checkbox has isChecked()). Something like this: https://groups.google.com/forum/#!topic/reagent-project/PObizfFMWes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment