Fix issue with caption on bootstrap 4

Add new prop to check if bootstrap is used
Update component in order to return a custom caption when bootstrap4
is in use
This commit is contained in:
Ymbere Xavier 2019-12-04 01:44:07 -02:00
parent 1d13565824
commit b99a277595

View File

@ -4,16 +4,22 @@ import PropTypes from 'prop-types';
const Caption = (props) => {
if (!props.children) return null;
return (
<caption>{ props.children }</caption>
const caption = props.bootstrap4 ? (
<caption style={ { captionSide: 'top' } }>{props.children}</caption>
) : (
<caption>{props.children}</caption>
);
return caption;
};
Caption.propTypes = {
children: PropTypes.oneOfType([
PropTypes.node,
PropTypes.string
])
]),
bootstrap4: PropTypes.bool
};
export default Caption;