├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── index.es6.js ├── license ├── package.json └── readme.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | index.js 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "curly": true, 6 | "immed": true, 7 | "mocha": true, 8 | "newcap": true, 9 | "noarg": true, 10 | "undef": true, 11 | "unused": "vars", 12 | "strict": true 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 4 4 | - 6 5 | -------------------------------------------------------------------------------- /index.es6.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React from 'react'; 3 | import {Styles} from 'material-ui'; 4 | import injectTapEventPlugin from 'react-tap-event-plugin'; 5 | injectTapEventPlugin(); 6 | 7 | let ThemeManager = new Styles.ThemeManager(); 8 | 9 | export default class BaseComponent extends React.Component { 10 | constructor () { 11 | super(); 12 | } 13 | getChildContext() { 14 | return { 15 | muiTheme: ThemeManager.getCurrentTheme() 16 | }; 17 | } 18 | } 19 | 20 | BaseComponent.childContextTypes = { 21 | muiTheme: React.PropTypes.object 22 | }; 23 | 24 | BaseComponent.contextTypes = {}; 25 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Hemanth.HM (h3manth.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-mui-base", 3 | "version": "1.2.3", 4 | "description": "BaseComponent for react-material-ui", 5 | "license": "MIT", 6 | "repository": "hemanth/react-mui-base", 7 | "author": { 8 | "name": "Hemanth.HM", 9 | "email": "hemanth.hm@gmail.com", 10 | "url": "h3manth.com" 11 | }, 12 | "engines": { 13 | "node": ">= 4" 14 | }, 15 | "browserify": { 16 | "transform": [ 17 | "babelify" 18 | ] 19 | }, 20 | "scripts": { 21 | "prepublish": "NODE_ENV=production browserify index.es6.js -t babelify -o | uglifyjs -cm > index.js" 22 | }, 23 | "files": [ 24 | "index.js" 25 | ], 26 | "keywords": [ 27 | "material ui", 28 | "material-ui", 29 | "material design", 30 | "react-component", 31 | "react" 32 | ], 33 | "dependencies": { 34 | "babelify": "^6.2.0", 35 | "browserify": "^12.0.0", 36 | "material-ui": "^0.18.0", 37 | "react": "^15.0.0", 38 | "react-dom": "^15.1.0", 39 | "react-tap-event-plugin": "^1.0.0" 40 | }, 41 | "devDependencies": { 42 | "babelify": "^6.2.0", 43 | "browserify": "^10.2.6", 44 | "uglifyjs": "^2.4.10" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # react-mui-base 2 | 3 | > BaseComponent for [react-material-ui](http://material-ui.com/) 4 | 5 | 6 | ## Install 7 | 8 | ``` 9 | $ npm install --save react-mui-base 10 | ``` 11 | 12 | 13 | ## Usage 14 | 15 | Instead of : 16 | 17 | ```js 18 | 'use strict'; 19 | import {Component} from 'react'; 20 | import {Styles} from 'material-ui'; 21 | import injectTapEventPlugin from 'react-tap-event-plugin'; 22 | 23 | injectTapEventPlugin(); 24 | 25 | let ThemeManager = new Styles.ThemeManager(); 26 | 27 | class MyComponent extends Component { 28 | constructor() { 29 | super(); 30 | } 31 | getChildContext() { 32 | return { 33 | muiTheme: ThemeManager.getCurrentTheme() 34 | }; 35 | } 36 | render() { 37 | 38 | } 39 | } 40 | 41 | MyComponent.childContextTypes = { 42 | muiTheme: React.PropTypes.object 43 | }; 44 | 45 | MyComponent.contextTypes = {}; 46 | ``` 47 | 48 | We could do: 49 | 50 | ```js 51 | import BaseComponent from 'react-mui-base' 52 | 53 | class MyComponent extends BaseComponent { 54 | constructor() { 55 | super(); 56 | } 57 | render() { 58 | 59 | } 60 | } 61 | ``` 62 | 63 | ## License 64 | 65 | MIT © [Hemanth.HM](http://h3manth.com) 66 | --------------------------------------------------------------------------------