UNPKG

react-hold

Version:

Hold the empty presentational components in react.js

52 lines (45 loc) 1.45 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; import React from 'react'; import PropTypes from 'prop-types'; import shapes from '../shapes'; import { CENTER } from '../align'; var Fill = function Fill(_ref) { var color = _ref.color, width = _ref.width, height = _ref.height, children = _ref.children, align = _ref.align, fillerStyle = _ref.fillerStyle; var lineHeight = typeof height === 'string' && height.trim() ? height : typeof height === 'number' ? height + 'px' : null; return React.createElement( 'div', { style: { textAlign: align } }, React.createElement( 'div', { style: _extends({ background: color }, fillerStyle, { display: 'inline-block', textAlign: 'center', width: width, height: height, lineHeight: lineHeight }) }, children ) ); }; Fill.propTypes = _extends({}, shapes, { width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), align: PropTypes.string }); Fill.defaultProps = { width: null, height: null, align: CENTER, fillerStyle: null }; export default Fill;