Skip to content

Commit

Permalink
wip, wiring plugin on checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Oct 23, 2015
1 parent 7e53f43 commit 326d768
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "ta-webapp",
"env": {
"node": true
}
}
4 changes: 2 additions & 2 deletions docs/app/Component Guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Semantic UI [Modules](http://semantic-ui.com/introduction/glossary.html) are com
These are things that have state, like a [Dropdown](http://semantic-ui.com/modules/dropdown.html).

**Element**
Stardust components exposes the jQuery element on the component as `element`:
Stardust components expose the jQuery element on the component as `element`:

```jsx
let checkbox = <Checkbox />;
checkbox.element; // the jQuery element
```

**Plugin**
The jQuery plugin can be called using `element`:
The Semantic UI jQuery plugin can be accessed using `element`:

```jsx
let checkbox = <Checkbox />;
Expand Down
16 changes: 14 additions & 2 deletions docs/app/Examples/modules/Checkbox/Types/Checkbox.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import React, {Component} from 'react';
import {Checkbox} from 'stardust';
import {Button, Checkbox} from 'stardust';

export default class CheckboxCheckboxExample extends Component {
toggle = () => {
this.refs.checkbox.plugin('toggle');
};

handleChange(e) {
console.log('it change');
console.log(e);
}

render() {
return (
<Checkbox label='Make my profile visible'/>
<div>
<Button onClick={this.toggle}>Toggle it!</Button>
<Checkbox label='Make my profile visible' ref='checkbox' onChange={this.handleChange}/>
</div>
);
}
}
4 changes: 3 additions & 1 deletion gulp/tasks/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ gulp.task('generate-docs-json', cb => {
paths.srcViews + '/**/*.js',
'!' + paths.src + '/**/Style.js'
])
.pipe(g.plumber(err => {
// do not remove the function keyword
// we need 'this' scope here
.pipe(g.plumber(function(err) {
g.util.log(err);
this.emit('end');
}))
Expand Down
12 changes: 7 additions & 5 deletions src/modules/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export default class Checkbox extends Component {
type: PropTypes.string,
};

state = {checked: false};

componentDidMount() {
this.element = $(this.refs.element);
this.element.checkbox(this.props.settings);
// this.element.checkbox(this.props.settings);
}

componentWillUnmount() {
Expand All @@ -29,16 +31,18 @@ export default class Checkbox extends Component {
type: META.type.module,
};

plugin() {
this.element.checkbox(...arguments);
}

render() {
let type = this.props.type;

if (!type) {
type = 'checkbox';
if (_.includes(this.props.className, 'radio')) {
type = 'radio';
}
}

const classes = classNames(
'sd-checkbox',
'ui',
Expand All @@ -48,9 +52,7 @@ export default class Checkbox extends Component {
{fitted: !this.props.label},
'checkbox'
);

const props = getUnhandledProps(this);

return (
<div className={classes} ref='element'>
<input {...props} type={type} />
Expand Down

0 comments on commit 326d768

Please sign in to comment.