Skip to content

Update to 1.4 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ pom.xml.asc
.hgignore
.hg/
/.idea
*.org
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local-install:
lein pom
lein jar
lein install
114 changes: 54 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
# cljs-react-material-ui

This library is interop to get [Material-UI](http://www.material-ui.com/#/) working in Clojurescript.
This library is interop to get [Material-UI](https://v1-4-0.material-ui.com/) working in Clojurescript.

Current Material-UI version: `0.19.0`

###### See Om.Next example app here
https://github.com/madvas/cljs-react-material-ui-example
git

## Warning version update >= 0.2.43
When using [AutoComplete](http://www.material-ui.com/#/components/auto-complete) use props `:dataSource` and
`:dataSourceConfig` in camelCase form, since `data-` is interpreted as HTML data attribute

## Warning version update >= 0.2.48
Since this version you don't need to exclude `cljsjs/react` and `cljsjs/react-dom`. Material-ui bundle doesn't contain own React anymore.
Also don't forget to rename your `on-touch-tap` into `on-click`.
Update your Clojurescript version (>= 1.9.908)
Current Material-UI version: `1.4.0-0`

## Installation
- Add `[cljs-react-material-ui "0.2.48"]` to your dependencies
- Add `[cljsjs/react "15.6.1-1"]` or newer version to your dependencies
- Add `[cljsjs/react-dom "15.6.1-1"]` or newer version to your dependencies
- Add `[cljs-react-material-ui "1.4.0-0"]` to your dependencies

## Usage

@@ -33,33 +18,29 @@ Update your Clojurescript version (>= 1.9.908)
; Including icons is not required
```

You must start your MaterialUI component tree with [ui/mui-theme-provider](http://www.material-ui.com/v0.15.0-beta.2/#/customization/themes), which must have exactly one direct child and defined theme. Use the same pattern when you want to change theme for some children, see example app.
You must start your MaterialUI component tree with ui/mui-theme-provider, which must have exactly one direct child and defined theme. Use the same pattern when you want to change theme for some children, see example app.
```clojure
(ui/mui-theme-provider
{:mui-theme (ui/get-mui-theme)}
{:theme (ui/create-mui-theme)}
(ui/paper "Hello world"))

(ui/mui-theme-provider
{:mui-theme (ui/get-mui-theme
{:palette ; You can use either camelCase or kebab-case
{:primary1-color (ui/color :deep-orange-a100)}
:raised-button
{:primary-text-color (ui/color :light-black)
:font-weight 200}})}
(ui/raised-button
{:mui-theme (ui/create-mui-theme
{:palette {}})}
(ui/button
{:label "Click me"
:primary true}))

(ui/mui-theme-provider
{:mui-theme (ui/get-mui-theme (aget js/MaterialUIStyles "DarkRawTheme"))}
{:theme (ui/create-mui-theme (aget js/MaterialUIStyles "DarkRawTheme"))}
(ui/paper "Hello dark world"))
```

You can use all components (icons also) in their kebab-case form. Either with props or without.
```clojure
(ui/radio-button
{:value "some_val"
:label "Yes"
:children "Yes"
:class-name "my-radio-class"
:checked-icon (ic/action-favorite)
:unchecked-icon (ic/action-favorite-border)})
@@ -76,6 +57,7 @@ js/MaterialUIStyles ; Contains everything from material-ui/src/styles/index.js
js/MaterialUISvgIcons ; Contains constructors to all icons. Exists only when you
; include icons in your code. No need to use directly.
js/MaterialUIUtils ; Contains some of util functions provided by MaterialUI
js/MaterialUIColors ; Contains all of the Material UI colors. Access using the `color` function.
```

##### Using with Reagent
@@ -86,42 +68,53 @@ Works with `reagent "0.6.0-alpha"` and up. So the dependency may be specified li
A simple Reagent example is as follows:

```clojure
(ns crmui-reagent.core
(:require
[cljsjs.material-ui]
[cljs-react-material-ui.core :refer [get-mui-theme color]]
[cljs-react-material-ui.reagent :as ui]
[cljs-react-material-ui.icons :as ic]
[reagent.core :as r]))

; Example with various components
(defn home-page []
(ns mui-reagent-example.app
(:require [reagent.core :as reagent :refer [atom]]
[cljsjs.material-ui]
[material-ui-icons]
[cljs-react-material-ui.core :refer [create-mui-theme color]]
[cljs-react-material-ui.reagent :as ui]
[cljs-react-material-ui.icons :as ic]))

(defonce app-state (atom {:text "Material UI Example"}))

(def base-theme
(create-mui-theme {:palette {:primary {:main (color :light-blue 700)}
:secondary {:main (color :teal :A100)}
:text-color (color :common :white)}}))

(defn root []
[ui/mui-theme-provider
{:mui-theme (get-mui-theme
{:palette {:text-color (color :green600)}})}
[:div
[ui/app-bar {:title "Title"
:icon-element-right
(r/as-element [ui/icon-button
(ic/action-account-balance-wallet)])}]
[ui/paper
[:div "Hello"]
[ui/mui-theme-provider
{:mui-theme (get-mui-theme {:palette {:text-color (color :blue200)}})}
[ui/raised-button {:label "Blue button"}]]
(ic/action-home {:color (color :grey600)})
[ui/raised-button {:label "Click me"
:icon (ic/social-group)
:on-click #(println "clicked")}]]]])

{:theme base-theme}
[ui/css-baseline]
[ui/app-bar
{:position "static"}
[ui/toolbar
[ui/icon-button
{:color "inherit"
:style {:margin-left "-20px"
:margin-right "20px"}}
[ic/chevron-right]]
[ui/typography
{:variant "title"
:color "inherit"
:style {:flex-grow "1"}}
[@app-state :text]]
[:div
[ui/icon-button
{:color "inherit"}
[ic/account-circle]]]]]])

(reagent/render-component [alt-root]
(. js/document (getElementById "app")))
```
 
##### Using with Rum
 
```clojure
(ns crmui-rum.core
(:require
[cljs-react-material-ui.core :refer [get-mui-theme color]]
[cljs-react-material-ui.core :refer [create-mui-theme color]]
[cljs-react-material-ui.icons :as ic]
[cljs-react-material-ui.rum :as ui]
[rum.core :as rum]))
@@ -132,7 +125,7 @@ A simple Reagent example is as follows:

(defn home-page []
(ui/mui-theme-provider
{:mui-theme (get-mui-theme)}
{:mui-theme (create-mui-theme)}
[:div
(ui/app-bar {:icon-element-right (ui/icon-button (ic/action-accessibility))})
(ui/tabs
@@ -157,7 +150,8 @@ See example in reagent:
[ui/selectable-list
{:value @list-item-selected
:on-change (fn [event value]
(reset! list-item-selected value))}

(reset! list-item-selected value))}
[ui/subheader {} "Selectable Contacts"]
[ui/list-item
{:value 1
@@ -205,4 +199,4 @@ Luckily, there is a workaround, which fixes most of use cases: Instead of `:valu
{:id "example"
:default-value @text-state
:on-change (fn [e] (reset! text-state (.. e -target -value)))}])))
```
```
28 changes: 0 additions & 28 deletions cljs-react-material-ui.iml

This file was deleted.

13 changes: 9 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
(defproject cljs-react-material-ui "0.2.48"
(defproject org.clojars.melodylane/cljs-react-material-ui "1.4.0-0.1"
:description "Iterop library for material-ui.com"
:url "https://github.com/madvas/cljs-react-material-ui"
:url "https://github.com/lane-s/cljs-react-material-ui"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[cljsjs/material-ui "0.19.0-0"]
:dependencies [[cljsjs/material-ui "1.4.0-0"]
[cljsjs/material-ui-icons "1.1.0-1"]
[cljsjs/react "15.6.1-1"]
[cljsjs/react-dom "15.6.1-1"]
[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.908"]
[sablono "0.8.0"]])
[sablono "0.8.0"]
[camel-snake-kebab "0.4.0"]
]
:deploy-repositories [["releases" :clojars]
["snapshots" :clojars]])
Loading