Skip to content

Commit e71a671

Browse files
committed
wip, wiring plugin on checkbox
1 parent 69b4737 commit e71a671

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

.eslintrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
22
"extends": "ta-webapp",
3-
"env": {
4-
"node": true
5-
}
63
}

docs/app/Component Guidelines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Semantic UI [Modules](http://semantic-ui.com/introduction/glossary.html) are com
2121
These 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
2727
let checkbox = <Checkbox />;
2828
checkbox.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
3535
let checkbox = <Checkbox />;
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
import React, {Component} from 'react';
2-
import {Checkbox} from 'stardust';
2+
import {Button, Checkbox} from 'stardust';
33

44
export 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
}

gulp/tasks/docs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}))

src/modules/Checkbox/Checkbox.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff 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} />

0 commit comments

Comments
 (0)