UNPKG

@lote-design-system/marketing-blocks

Version:
273 lines (243 loc) 8.41 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.Footer1 = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _polished = require("polished"); var _core = require("@lote-design-system/core"); var _svg = require("../svg"); // => Dependent styled-components // Our main component depends upon the following styled-components var ContainerModify = (0, _styledComponents["default"])(_core.Container).withConfig({ displayName: "Footer1__ContainerModify", componentId: "p4c397-0" })(["max-width:", ";"], function (_ref) { var theme = _ref.theme; return theme.maxContainerWidth; }); var ColumnModify = (0, _styledComponents["default"])(_core.Column).withConfig({ displayName: "Footer1__ColumnModify", componentId: "p4c397-1" })(["margin-bottom:30px;"]); var FooterContent = _styledComponents["default"].footer.withConfig({ displayName: "Footer1__FooterContent", componentId: "p4c397-2" })(["background-color:", ";padding:96px 0;"], function (_ref2) { var theme = _ref2.theme; return theme.colors.white; }); var FooterBrand = _styledComponents["default"].a.withConfig({ displayName: "Footer1__FooterBrand", componentId: "p4c397-3" })(["display:inline-flex;align-items:center;padding:", " 0;white-space:nowrap;> svg,> img{width:56px;height:56px;}"], (0, _polished.rem)(4)); var FooterText = _styledComponents["default"].p.withConfig({ displayName: "Footer1__FooterText", componentId: "p4c397-4" })(["color:", ";font-size:14px;"], function (_ref3) { var theme = _ref3.theme; return theme.colors.text.primary; }); var FooterHeading = _styledComponents["default"].h5.withConfig({ displayName: "Footer1__FooterHeading", componentId: "p4c397-5" })(["margin:8px 0;color:", ";font-size:20px;font-weight:700;"], function (_ref4) { var theme = _ref4.theme; return theme.colors.secondary; }); var FooterList = _styledComponents["default"].ul.withConfig({ displayName: "Footer1__FooterList", componentId: "p4c397-6" })(["margin:0;padding:0;li{list-style:none;a{display:inline-block;padding:8px 0;color:", ";font-size:14px;transition:color 0.4s ease;&:hover{color:", ";}}}"], function (_ref5) { var theme = _ref5.theme; return theme.colors.text.primary; }, function (_ref6) { var theme = _ref6.theme; return theme.colors.primary; }); // <= End Dependent styled-components var colCopyrightSchema = { logo: /*#__PURE__*/_react["default"].createElement(_svg.LogoDefault, { fill: "#01a1ff" }), text: '© 2020 UI-Kit, Inc. All rights reserved' }; var colSchema = [{ title: 'Company', links: [{ id: 1, href: '/about', text: 'About' }, { id: 2, href: '/blog', text: 'Blog' }, { id: 3, href: '/jobs', text: 'Jobs' }, { id: 4, href: '/press', text: 'Press' }] }, { title: 'Support', links: [{ id: 1, href: '/pricing', text: 'Pricing' }, { id: 2, href: '/documentation', text: 'Documentation' }, { id: 3, href: '/guides', text: 'Guides' }, { id: 4, href: '/api-status', text: 'API Status' }] }, { title: 'Legal', links: [{ id: 1, href: '/claim', text: 'Claim' }, { id: 2, href: '/privacy', text: 'Privacy' }, { id: 3, href: '/terms', text: 'Terms' }] }]; var colCopyrightShape = { /** The logo appear on the footer on the Copyright column, default it will be ui-kit logo. */ logo: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired, /** The copyright text. */ text: _propTypes["default"].string.isRequired }; var colShape = { /** The main title which represents the category of different links. */ title: _propTypes["default"].string.isRequired, /** Array of links */ links: _propTypes["default"].arrayOf(_propTypes["default"].shape({ id: _propTypes["default"].number.isRequired, href: _propTypes["default"].string.isRequired, text: _propTypes["default"].string.isRequired })).isRequired }; var propTypes = { /* The default footer will have a 12 column structure. Please provide the responsive breakpoint for a column and that breakpoint will be automatically registered for each column. */ colApi: _propTypes["default"].shape({ sm: _propTypes["default"].number, md: _propTypes["default"].number, lg: _propTypes["default"].number, xl: _propTypes["default"].number }).isRequired, /** Copyright column. */ colCopyright: _propTypes["default"].shape(colCopyrightShape).isRequired, /** Define your columns schema based on the 12 column structure. */ cols: _propTypes["default"].arrayOf(_propTypes["default"].shape(colShape)).isRequired }; var defaultProps = { colApi: { lg: 3, md: 4, sm: 4 }, colCopyright: colCopyrightSchema, cols: colSchema }; /** * Returns the JSX or null for the logo. * @param logo {*} - The logo will React.element or a path * @return {null|*} - Returns the JSX or null */ var renderLogo = function renderLogo(logo) { if (_react["default"].isValidElement(logo)) { return logo; } else if (typeof logo === 'string' && logo.length > 0) { return /*#__PURE__*/_react["default"].createElement("img", { src: logo, alt: "Brand Logo" }); } else { return null; } }; /** * Modified Copyright and return a new object. * @param logo {*} - A brand logo * @param text {string} - A copyright text for the footer * @return {{logo: *, text: {string}}} - Returns the object */ var modifiedCopyright = function modifiedCopyright(_ref7) { var logo = _ref7.logo, text = _ref7.text; if (typeof logo === 'string' && !logo.length > 0) { return { logo: /*#__PURE__*/_react["default"].createElement(_svg.LogoDefault, { fill: "#01a1ff" }), text: text }; } else { return { logo: logo, text: text }; } }; /** * Render schema for the Footer. * @param colApi {object} - The breakpoint API for the column * @param copyright {object} - Data for the copyright column * @param cols {Array} - Data for the footer columns * @return {*} - Returns the JSX for the footer */ var renderBody = function renderBody(colApi, _ref8, cols) { var logo = _ref8.logo, text = _ref8.text; return /*#__PURE__*/_react["default"].createElement(_core.Row, null, /*#__PURE__*/_react["default"].createElement(ColumnModify, colApi, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(FooterBrand, { href: "/" }, renderLogo(logo))), /*#__PURE__*/_react["default"].createElement(FooterText, null, text)), Array.isArray(cols) && cols.length > 0 && cols.map(function (_ref9) { var title = _ref9.title, links = _ref9.links; return /*#__PURE__*/_react["default"].createElement(ColumnModify, (0, _extends2["default"])({}, colApi, { key: title }), /*#__PURE__*/_react["default"].createElement(FooterHeading, null, title), /*#__PURE__*/_react["default"].createElement(FooterList, null, links.map(function (_ref10) { var id = _ref10.id, href = _ref10.href, text = _ref10.text; return /*#__PURE__*/_react["default"].createElement("li", { key: id }, /*#__PURE__*/_react["default"].createElement("a", { href: href }, text)); }))); })); }; var Footer1 = function Footer1(props) { var colApi = props.colApi, colCopyright = props.colCopyright, cols = props.cols, attributes = (0, _objectWithoutProperties2["default"])(props, ["colApi", "colCopyright", "cols"]); var copyRight = modifiedCopyright(colCopyright); return /*#__PURE__*/_react["default"].createElement(FooterContent, attributes, /*#__PURE__*/_react["default"].createElement(ContainerModify, { fluid: true }, renderBody(colApi, copyRight, cols))); }; exports.Footer1 = Footer1; Footer1.propTypes = propTypes; Footer1.defaultProps = defaultProps;