Skip to content

Commit

Permalink
update component switch
Browse files Browse the repository at this point in the history
  • Loading branch information
icecreamliker committed Nov 22, 2015
1 parent ed3653e commit 150bef9
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 30 deletions.
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ module.exports = function(grunt) {

watch: {
less: {
files: 'less/**/*.less',
tasks: ['clean', 'lesslint', 'less', 'postcss', 'csscomb', 'cssmin', 'copy']
files: ['less/**/*.less', 'js/**'],
tasks: ['clean', 'css', 'webpack:dev', 'usebanner', 'copy']
}
}
});
Expand All @@ -164,7 +164,7 @@ module.exports = function(grunt) {


// Default task.
grunt.registerTask('release', ['clean', 'css', 'js', 'usebanner', 'copy']);
grunt.registerTask('build', ['clean', 'css', 'js', 'usebanner', 'copy']);

// Generate web font
grunt.registerTask('font', ['webfont']);
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
release:
build:
# Make Sure grunt has been installed locally
grunt release
grunt build

clean:
# Clean generated css files
Expand All @@ -18,4 +18,4 @@ test:
# Run tests
grunt test

.PHONY: release clean watch generate_font test
.PHONY: build clean watch generate_font test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Three steps to go:
When Grunt is installed, go ahead and compile all the files:

```
grunt release or make release
grunt build or make build
```
Run the script below to clean the generated files:
```
Expand Down
49 changes: 38 additions & 11 deletions dist/js/uskin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/uskin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/uskin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/uskin.min.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion docs/react_demo/switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@
<script src="../../node_modules/react-dom/dist/react-dom.min.js"></script>
<script src="../../node_modules/babel/dist/browser.min.js"></script>
<script src="../../dist/js/uskin.js"></script>
<style type="text/css">
#example {margin: 40px;}
</style>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
var Switch = uskin.Switch;
ReactDOM.render(
<Switch />,
<Switch onClick={listener} />,
document.getElementById('example')
);
function listener(e) {
console.debug(e);
alert('click triggered!');
}
</script>
</body>
</html>
27 changes: 20 additions & 7 deletions js/components/switch.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import React from 'react';

var Switch = React.createClass({
render: function() {
return <div className="switch">
<input id="uskin-1" type="checkbox" />
<label htmlFor="uskin-1" className="switch-inner"></label>
</div>
class Switch extends React.Component {

constructor(props) {
super(props);

this.clickHandler = this.clickHandler.bind(this);
}

clickHandler(e) {
this.props.onClick && this.props.onClick.call(this, e);
}

render() {
return (
<div className="switch">
<input id="uskin-1" type="checkbox" />
<label htmlFor="uskin-1" className="switch-inner" onClick={this.clickHandler}></label>
</div>
)
}
});
}

export default Switch;
Empty file added js/mixins/advice.js
Empty file.
Empty file added js/mixins/hash.js
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "https://github.com/icecreamliker/uskin",
"author": "Lee Yao <yaoli111144@gmail.com>",
"scripts": {
"release": "grunt release",
"build": "grunt build",
"test": "jest"
},
"repository": {
Expand Down

0 comments on commit 150bef9

Please sign in to comment.