UNPKG

pure-styled-components

Version:

Styled Component design system based on Pure CSS for React/Preact

95 lines (77 loc) 3.59 kB
function _templateObject() { var data = _taggedTemplateLiteral(["\n ", "\n ", "\n ", "\n ", "\n display: inline-block;\n *display: inline; /* IE < 8: fake inline-block */\n zoom: 1;\n letter-spacing: normal;\n word-spacing: normal;\n vertical-align: top;\n text-rendering: auto;\n"]); _templateObject = function _templateObject() { return data; }; return data; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _extends() { _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; }; return _extends.apply(this, arguments); } import React from "react"; import PropTypes from "prop-types"; import styled from "styled-components"; import { space, width, fontSize, color } from "styled-system"; var GridUnit = function GridUnit(_ref) { var className = _ref.className, children = _ref.children; for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { rest[_key - 1] = arguments[_key]; } return React.createElement("div", _extends({ className: className }, rest), children); }; /** * Creates a "unit" inside of the flexbox grid. * Comparable to a column in Bootstrap or cell in a spreadsheet. * * @param {object} {className, children} */ var Unit = styled(GridUnit)(_templateObject(), space, width, fontSize, color); Unit.propTypes = { /** * Responsive margin values (string or array). * Similar props: `mt: margin-top`, `mx: margin-left and margin-right` */ m: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]), /** * Responsive padding values (string or array) * Similar props: `pt: padding-top`, `px: padding-left and padding-right` */ p: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]), /** * Responsive width values (number or array) * Numbers from 0-1 are converted to percentage widths. * Numbers greater than 1 are converted to pixel values. * String values are passed as raw CSS values. * And arrays are converted to responsive width styles. */ width: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]), /** * Responsive width values (number or array) * Numbers from 0-8 (or theme.fontSizes.length) are converted to values on the font size scale. * Numbers greater than theme.fontSizes.length are converted to raw pixel values. * String values are passed as raw CSS values. * And array values are converted into responsive values. */ fontSize: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]), /** * Set text alignment inside component */ textAlign: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.string]), /** * Set font color of component */ color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.string]), /** * Set background color of component */ bg: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.string]), /** * Child components (array or single element) */ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired }; /** @component */ export default Unit; //# sourceMappingURL=Grid.Unit.js.map