Skip to content

Commit 69b4737

Browse files
committed
rebase from master, finish tests
1 parent b72f62d commit 69b4737

9 files changed

Lines changed: 51 additions & 38 deletions

File tree

docs/app/Components/ComponentDoc/ComponentExample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ export default class ComponentExample extends Component {
4242
</Column>
4343
);
4444

45-
let linkIconStyle = {
45+
const linkIconStyle = {
4646
display: this.state.showLink ? 'inline-block' : 'none',
4747
marginLeft: '0.25em',
4848
};
4949

50-
let children = <Column>{this.props.children}</Column>;
50+
const children = <Column>{this.props.children}</Column>;
5151

5252
return (
5353
<Grid className='one column' style={{marginBottom: '4em'}} id={this.anchor}>
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
import React, {Component} from 'react';
1+
import React from 'react';
22
import {Checkbox} from 'stardust';
33

4-
export default class CheckboxCheckedExample extends Component {
5-
state = {isChecked: true};
6-
7-
handleChange = e => {
8-
this.setState({
9-
isChecked: !this.state.isChecked
10-
});
11-
};
12-
13-
render() {
14-
return (
15-
<Checkbox defaultChecked={true} label='This checkbox comes prechecked' />
16-
);
17-
}
18-
}
4+
export default CheckboxCheckedExample => {
5+
return (
6+
<Checkbox defaultChecked label='This checkbox comes prechecked' />
7+
);
8+
};

src/elements/Input/Input.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export default class Input extends Component {
4343
const actionChildren = [];
4444

4545
Children.forEach(this.props.children, child => {
46-
// TODO: use child._meta here, once merged, to determine component type
4746
const isButton = child.type.name === 'Button';
4847
const isDropdown = child.type.name === 'Dropdown';
4948
// TODO: use child.type.name === 'Label' once Label component is merged.

src/modules/Dropdown/Dropdown.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import $ from 'jquery';
33
import classNames from 'classnames';
44
import React, {Component, PropTypes} from 'react';
55
import META from 'src/utils/Meta';
6+
import getUnhandledProps from 'src/utils/getUnhandledProps';
67

78
export default class Dropdown extends Component {
89
static propTypes = {
@@ -11,11 +12,12 @@ export default class Dropdown extends Component {
1112
value: PropTypes.string,
1213
text: PropTypes.string,
1314
})),
15+
settings: PropTypes.object,
1416
};
1517

1618
componentDidMount() {
1719
this.element = $(this.refs.select);
18-
this.element.dropdown();
20+
this.element.dropdown(this.props.settings);
1921
}
2022

2123
componentDidUpdate(prevProps, prevState) {
@@ -43,8 +45,7 @@ export default class Dropdown extends Component {
4345
'dropdown'
4446
);
4547

46-
const props = _.clone(this.props);
47-
delete props.options;
48+
const props = getUnhandledProps(this);
4849

4950
return (
5051
<select {...props} className={classes} ref='select'>

src/modules/Modal/Modal.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import React, {Component, PropTypes} from 'react';
22
import classNames from 'classnames';
33
import META from 'src/utils/Meta';
4+
import getUnhandledProps from 'src/utils/getUnhandledProps';
45

5-
class Modal extends Component {
6+
export default class Modal extends Component {
67
static propTypes = {
78
children: PropTypes.any,
89
className: PropTypes.string,
910
ref: PropTypes.string,
11+
settings: PropTypes.object,
1012
};
1113

1214
static defaultProps = {
@@ -38,12 +40,12 @@ class Modal extends Component {
3840
{'transition visible active': this.state.isShown},
3941
);
4042

43+
const props = getUnhandledProps(this);
44+
4145
return (
42-
<div {...this.props} className={classes}>
46+
<div {...props} className={classes}>
4347
{this.props.children}
4448
</div>
4549
);
4650
}
4751
}
48-
49-
export default Modal;

src/modules/Modal/ModalHeader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class ModalHeader extends Component {
66
static propTypes = {
77
children: PropTypes.any,
88
className: PropTypes.string,
9+
settings: PropTypes.object,
910
};
1011

1112
static _meta = {

src/utils/Meta.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,22 @@ const META = {
1515
element: 'element',
1616
view: 'view',
1717
module: 'module',
18-
}
18+
},
19+
20+
// library
21+
isSemanticUI: ({_meta}) => _meta.library === META.library.semanticUI,
22+
isStardust: ({_meta}) => _meta.library === META.library.stardust,
23+
24+
// type
25+
isAddon: ({_meta}) => _meta.type === META.type.addon,
26+
isGlobal: ({_meta}) => _meta.type === META.type.global,
27+
isCollection: ({_meta}) => _meta.type === META.type.collection,
28+
isElement: ({_meta}) => _meta.type === META.type.element,
29+
isView: ({_meta}) => _meta.type === META.type.view,
30+
isModule: ({_meta}) => _meta.type === META.type.module,
31+
32+
// parent
33+
isChild: ({_meta}) => !!_meta.parent,
1934
};
2035

2136
export default META;

test/specs/Conformance-test.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,20 @@ describe('Conformance', () => {
127127
});
128128
}
129129

130-
// TODO: this is only true for "module" type components
131-
// Update this test once we get component meta data
132-
it('does not spread the settings prop', () => {
133-
const props = {settings: {}};
134-
render(<SDComponent {...props} />)
135-
.children()
136-
.some(element => _.has(element.props, 'settings'))
137-
.should.equal(false);
138-
});
130+
if (META.isModule(SDComponent) && !META.isChild(SDComponent)) {
131+
describe('settings', () => {
132+
it('is defined in propTypes', () => {
133+
SDComponent.propTypes.settings.should.be.a('function');
134+
});
135+
it('is not spread', () => {
136+
const props = {settings: {}};
137+
render(<SDComponent {...props} />)
138+
.children()
139+
.some(element => _.has(element.props, 'settings'))
140+
.should.equal(false);
141+
});
142+
});
143+
}
139144
});
140145
});
141146
});

test/specs/modules/Checkbox/Checkbox-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {Checkbox} from 'stardust';
44
describe('Checkbox', () => {
55
it('can be checked by default', () => {
66
render(<Checkbox defaultChecked name='firstName' />)
7-
.first()
8-
.refs.checkbox.checked.should.equal(true);
7+
.findTag('input')
8+
.checked.should.equal(true);
99
});
1010
it('should have a semantic ui plugin to handle the check action', () => {
1111
render(<Checkbox name='firstName' label='Include First' />)

0 commit comments

Comments
 (0)