-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addon info: make propTypes table better
* more details for arrayOf, objectOf, shape, oneOf, oneOfType * refactored into cleaner code + many smaller components
- Loading branch information
Showing
12 changed files
with
401 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
hasProperty: { | ||
whiteSpace: 'nowrap', | ||
}, | ||
code: { | ||
whiteSpace: 'nowrap', | ||
fontFamily: 'Monaco, Consolas, "Courier New", monospace', | ||
}, | ||
propTable: { | ||
marginTop: 10, | ||
borderCollapse: 'collapse', | ||
}, | ||
propTableCell: { | ||
border: '1px solid #ccc', | ||
padding: '2px 6px', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
|
||
import PrettyPropType from './PrettyPropType'; | ||
import { TypeInfo } from './proptypes'; | ||
|
||
const ArrayOf = ({ propType }) => | ||
<span> | ||
<span>[</span> | ||
<span> | ||
<PrettyPropType propType={propType.value} /> | ||
</span> | ||
<span>]</span> | ||
</span>; | ||
|
||
ArrayOf.propTypes = { | ||
propType: TypeInfo.isRequired, | ||
}; | ||
|
||
export default ArrayOf; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
export default class HighlightButton extends React.Component { | ||
static propTypes = { | ||
children: PropTypes.node.isRequired, | ||
highlight: PropTypes.bool, | ||
}; | ||
|
||
static defaultProps = { | ||
highlight: false, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
hover: false, | ||
}; | ||
} | ||
|
||
handleMouseEnter = () => { | ||
this.setState({ hover: true }); | ||
}; | ||
|
||
handleMouseLeave = () => { | ||
this.setState({ hover: false }); | ||
}; | ||
|
||
render() { | ||
const { children, highlight, ...otherProps } = this.props; | ||
const style = | ||
highlight || this.state.hover | ||
? { | ||
backgroundColor: 'rgba(0, 0, 0, 0.05)', | ||
border: '1px solid #ccc', | ||
} | ||
: {}; | ||
return ( | ||
<span | ||
role="button" | ||
tabIndex={-1} | ||
onMouseEnter={this.handleMouseEnter} | ||
onMouseLeave={this.handleMouseLeave} | ||
style={{ | ||
...style, | ||
...{ | ||
cursor: 'pointer', | ||
}, | ||
}} | ||
{...otherProps} | ||
> | ||
{children} | ||
</span> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
|
||
import PrettyPropType from './PrettyPropType'; | ||
import { TypeInfo } from './proptypes'; | ||
|
||
const ObjectOf = ({ propType }) => | ||
<span> | ||
<span> | ||
{'{'} | ||
</span> | ||
<span /> | ||
<span> | ||
{'[<key>]:'} | ||
</span> | ||
<span /> | ||
<span> | ||
<PrettyPropType propType={propType.value} /> | ||
</span> | ||
<span> | ||
{'}'} | ||
</span> | ||
</span>; | ||
|
||
ObjectOf.propTypes = { | ||
propType: TypeInfo.isRequired, | ||
}; | ||
|
||
export default ObjectOf; |
Oops, something went wrong.