File tree Expand file tree Collapse file tree
Examples/modules/Checkbox/Types Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "extends": "ta-webapp",
3- "env": {
4- "node": true
5- }
63}
Original file line number Diff line number Diff line change @@ -21,15 +21,15 @@ Semantic UI [Modules](http://semantic-ui.com/introduction/glossary.html) are com
2121These are things that have state, like a [ Dropdown] ( http://semantic-ui.com/modules/dropdown.html ) .
2222
2323** Element**
24- Stardust components exposes the jQuery element on the component as ` element ` :
24+ Stardust components expose the jQuery element on the component as ` element ` :
2525
2626``` jsx
2727let checkbox = < Checkbox / > ;
2828checkbox .element ; // the jQuery element
2929```
3030
3131** Plugin**
32- The jQuery plugin can be called using ` element ` :
32+ The Semantic UI jQuery plugin can be accessed using ` element ` :
3333
3434``` jsx
3535let checkbox = < Checkbox / > ;
Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
2- import { Checkbox } from 'stardust' ;
2+ import { Button , Checkbox } from 'stardust' ;
33
44export default class CheckboxCheckboxExample extends Component {
5+ toggle = ( ) => {
6+ this . refs . checkbox . plugin ( 'toggle' ) ;
7+ } ;
8+
9+ handleChange ( e ) {
10+ console . log ( 'it change' ) ;
11+ console . log ( e ) ;
12+ }
13+
514 render ( ) {
615 return (
7- < Checkbox label = 'Make my profile visible' />
16+ < div >
17+ < Button onClick = { this . toggle } > Toggle it!</ Button >
18+ < Checkbox label = 'Make my profile visible' ref = 'checkbox' onChange = { this . handleChange } />
19+ </ div >
820 ) ;
921 }
1022}
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ gulp.task('generate-docs-json', cb => {
3939 paths . srcViews + '/**/*.js' ,
4040 '!' + paths . src + '/**/Style.js'
4141 ] )
42- . pipe ( g . plumber ( err => {
42+ // do not remove the function keyword
43+ // we need 'this' scope here
44+ . pipe ( g . plumber ( function ( err ) {
4345 g . util . log ( err ) ;
4446 this . emit ( 'end' ) ;
4547 } ) )
Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ export default class Checkbox extends Component {
1414 type : PropTypes . string ,
1515 } ;
1616
17+ state = { checked : false } ;
18+
1719 componentDidMount ( ) {
1820 this . element = $ ( this . refs . element ) ;
19- this . element . checkbox ( this . props . settings ) ;
21+ // this.element.checkbox(this.props.settings);
2022 }
2123
2224 componentWillUnmount ( ) {
@@ -29,16 +31,18 @@ export default class Checkbox extends Component {
2931 type : META . type . module ,
3032 } ;
3133
34+ plugin ( ) {
35+ this . element . checkbox ( ...arguments ) ;
36+ }
37+
3238 render ( ) {
3339 let type = this . props . type ;
34-
3540 if ( ! type ) {
3641 type = 'checkbox' ;
3742 if ( _ . includes ( this . props . className , 'radio' ) ) {
3843 type = 'radio' ;
3944 }
4045 }
41-
4246 const classes = classNames (
4347 'sd-checkbox' ,
4448 'ui' ,
@@ -48,9 +52,7 @@ export default class Checkbox extends Component {
4852 { fitted : ! this . props . label } ,
4953 'checkbox'
5054 ) ;
51-
5255 const props = getUnhandledProps ( this ) ;
53-
5456 return (
5557 < div className = { classes } ref = 'element' >
5658 < input { ...props } type = { type } />
You can’t perform that action at this time.
0 commit comments