File tree Expand file tree Collapse file tree
Examples/modules/Checkbox/States Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } >
Original file line number Diff line number Diff line change 1- import React , { Component } from 'react' ;
1+ import React from 'react' ;
22import { 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+ } ;
Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import $ from 'jquery';
33import classNames from 'classnames' ;
44import React , { Component , PropTypes } from 'react' ;
55import META from 'src/utils/Meta' ;
6+ import getUnhandledProps from 'src/utils/getUnhandledProps' ;
67
78export 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' >
Original file line number Diff line number Diff line change 11import React , { Component , PropTypes } from 'react' ;
22import classNames from 'classnames' ;
33import 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 ;
Original file line number Diff line number Diff 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 = {
Original file line number Diff line number Diff 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
2136export default META ;
Original file line number Diff line number Diff 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 } ) ;
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import {Checkbox} from 'stardust';
44describe ( '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' /> )
You can’t perform that action at this time.
0 commit comments