UNPKG

pure-styled-components

Version:

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

106 lines (82 loc) 6.63 kB
function _templateObject() { var data = _taggedTemplateLiteral(["\n letter-spacing: -0.31em; /* Webkit: collapse white-space between units */\n *letter-spacing: normal; /* reset IE < 8 */\n *word-spacing: -0.43em; /* IE < 8: collapse white-space between units */\n text-rendering: optimizespeed; /* Webkit: fixes text-rendering: optimizeLegibility */\n\n /*\n Sets the font stack to fonts known to work properly with the above letter\n and word spacings. See: https://github.com/pure-css/pure/issues/41/\n The following font stack makes Pure Grids work on all known environments.\n * FreeSans: Ships with many Linux distros, including Ubuntu\n * Arimo: Ships with Chrome OS. Arimo has to be defined before Helvetica and\n Arial to get picked up by the browser, even though neither is available\n in Chrome OS.\n * Droid Sans: Ships with all versions of Android.\n * Helvetica, Arial, sans-serif: Common font stack on OS X and Windows.\n */\n font-family: FreeSans, Arimo, \"Droid Sans\", Helvetica, Arial, sans-serif;\n\n /* Use flexbox when possible to avoid 'letter-spacing' side-effects. */\n display: flex;\n flex-flow: row wrap;\n\n /* Prevents distributing space between rows */\n align-content: flex-start;\n\n /* IE10 display: -ms-flexbox (and display: flex in IE 11) does not work inside a table; fall back to block and rely on font hack */\n @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {\n table .pure-g {\n display: block;\n }\n }\n\n /* Opera as of 12 on Windows needs word-spacing.\n The \".opera-only\" selector is used to prevent actual prefocus styling\n and is not required in markup.\n*/\n .opera-only :-o-prefocus,\n & {\n word-spacing: -0.43em;\n }\n /*\nResets the font family back to the OS/browser's default sans-serif font,\nthis the same font stack that Normalize.css sets for the 'body'.\n*/\n & [class*=\"pure-u\"] {\n font-family: sans-serif;\n }\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 _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } import React, { PureComponent } from "react"; import PropTypes from "prop-types"; import styled from "styled-components"; import Unit from "./Grid.Unit"; import findByType from "../../utils/findByType"; /** * Pure CSS and React Grid. * * Creates a grid using any wrapped <Grid.Unit> components. * This is purely a Flexbox wrapper for the "units", which * define their own width. * * @param {object} {className: string, children: node || array(node)} */ var BaseGrid = /*#__PURE__*/ function (_PureComponent) { _inherits(BaseGrid, _PureComponent); function BaseGrid() { _classCallCheck(this, BaseGrid); return _possibleConstructorReturn(this, _getPrototypeOf(BaseGrid).apply(this, arguments)); } _createClass(BaseGrid, [{ key: "renderUnits", value: function renderUnits() { var children = this.props.children; var units = findByType(children, Unit); // // Check if is array, if not, check if it single element // if (!units.isArray()) { // if (units.length == 0) { // return units; // } // return null; // } var items = units.map(function (item) { return React.createElement(Unit, _extends({ key: item.props.children }, item.props), item.props.children); }); if (!items) { return null; } return items; } }, { key: "render", value: function render() { return React.createElement("nav", { className: this.props.className }, this.renderUnits()); } }]); return BaseGrid; }(PureComponent); BaseGrid.Unit = Unit; var Grid = styled(BaseGrid)(_templateObject()); Grid.propTypes = { /** * Child components (array or single element) */ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired }; /** @component */ export default Grid; //# sourceMappingURL=Grid.js.map