UNPKG

@bootstrap-styled/rsg-components

Version:

Create documentation layouts for your react-styleguidist using Bootstrap-Styled rsg-component. Boostrap Styled rsg-components use the @bootstrap-styled/v4 for recreating the original rsg-components.

173 lines (143 loc) 8.93 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.propTypes = exports.defaultProps = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _breakpoints = _interopRequireDefault(require("@bootstrap-styled/css-mixins/lib/breakpoints")); var _H = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H1")); var _H2 = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H2")); var _H3 = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H3")); var _H4 = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H4")); var _H5 = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H5")); var _H6 = _interopRequireDefault(require("@bootstrap-styled/v4/lib/H6")); var _lodash = _interopRequireDefault(require("lodash.omit")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _lib = _interopRequireDefault(require("map-to-css-modules/lib")); var _classnames = _interopRequireDefault(require("classnames")); var typoList = { H1: _H.default, H2: _H2.default, H3: _H3.default, H4: _H4.default, H5: _H5.default, H6: _H6.default }; var defaultProps = { theme: { styleguide: { '$rsg-heading-line-height': '1', '$rsg-heading-font-size': { h1: '40px', h2: '38px', h3: '36px', h4: '34px', h5: '32px', h6: '30px' }, '$rsg-heading-margin': '0', '$rsg-heading-color': '#292b2c', '$rsg-heading-padding': '20px 0 15px 0', '$rsg-heading-mobile-line-height': '1', '$rsg-heading-mobile-font-size': { h1: '38px', h2: '36px', h3: '34px', h4: '32px', h5: '30px', h6: '28px' }, '$rsg-heading-font-weight': { h1: 'normal', h2: 'normal', h3: 'normal', h4: 'normal', h5: 'bold', h6: 'bold' } } } }; /* eslint-disable react/require-default-props */ exports.defaultProps = defaultProps; var propTypes = { /** * @ignore */ className: _propTypes.default.string, // eslint-disable-line react/require-default-props /** Specified node element will be passed as children of `<HeadingRenderer />` component. */ children: _propTypes.default.node.isRequired, /** Level used to style heading. Can be: */ level: _propTypes.default.oneOf([1, 2, 3, 4, 5, 6]).isRequired, /** Theme variables. Can be: */ theme: _propTypes.default.shape({ styleguide: _propTypes.default.shape({ '$rsg-heading-line-height': _propTypes.default.string, '$rsg-heading-font-size': _propTypes.default.shape({ h1: _propTypes.default.string, h2: _propTypes.default.string, h3: _propTypes.default.string, h4: _propTypes.default.string, h5: _propTypes.default.string, h6: _propTypes.default.string }), '$rsg-heading-margin': _propTypes.default.string, '$rsg-heading-color': _propTypes.default.string, '$rsg-heading-padding': _propTypes.default.string, '$rsg-heading-mobile-line-height': _propTypes.default.string, '$rsg-heading-mobile-font-size': _propTypes.default.shape({ h1: _propTypes.default.string, h2: _propTypes.default.string, h3: _propTypes.default.string, h4: _propTypes.default.string, h5: _propTypes.default.string, h6: _propTypes.default.string }), '$rsg-heading-font-weight': _propTypes.default.shape({ h1: _propTypes.default.string, h2: _propTypes.default.string, h3: _propTypes.default.string, h4: _propTypes.default.string, h5: _propTypes.default.string, h6: _propTypes.default.string }) }) }), /** * Replace or remove a className from the component. * See example <a href="https://www.npmjs.com/package/map-to-css-modules" target="_blank">here</a>. */ cssModule: _propTypes.default.object // eslint-disable-line react/require-default-props }; /* eslint-enable react/require-default-props */ exports.propTypes = propTypes; var HeadingRendererUnstyled = function HeadingRendererUnstyled(props) { var _omit = (0, _lodash.default)(props, ['theme']), className = _omit.className, children = _omit.children, level = _omit.level, cssModule = _omit.cssModule, attributes = (0, _objectWithoutProperties2.default)(_omit, ["className", "children", "level", "cssModule"]); var Tag = typoList["H".concat(level)] || _H.default; return _react.default.createElement(Tag, (0, _extends2.default)({ className: (0, _lib.default)((0, _classnames.default)(className, 'rsg-heading', "h".concat(level)), cssModule) }, attributes), children); }; HeadingRendererUnstyled.defaultProps = defaultProps; HeadingRendererUnstyled.propTypes = propTypes; var HeadingRenderer = (0, _styledComponents.default)(HeadingRendererUnstyled).withConfig({ displayName: "HeadingRenderer", componentId: "izeyzn-0" })([" ", ""], function (props) { return "\n &.rsg-heading > a {\n color: inherit;\n }\n &.rsg-heading {\n margin: ".concat(props.theme.styleguide['$rsg-heading-margin'], ";\n color: ").concat(props.theme.styleguide['$rsg-heading-color'], ";\n padding: ").concat(props.theme.styleguide['$rsg-heading-padding'], ";\n }\n ").concat(_breakpoints.default.up('xs', props.theme['$grid-breakpoints'], "\n &.rsg-heading {\n line-height: ".concat(props.theme.styleguide['$rsg-heading-mobile-line-height'], ";\n }\n &.rsg-heading.h1 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h1, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h1, ";\n }\n &.rsg-heading.h2 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h2, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h2, ";\n }\n &.rsg-heading.h3 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h3, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h3, ";\n }\n &.rsg-heading.h4 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h4, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h4, ";\n }\n &.rsg-heading.h5 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h5, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h5, ";\n }\n &.rsg-heading.h6 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-mobile-font-size'].h6, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h6, ";\n font-style: 'italic';\n }\n ")), "\n ").concat(_breakpoints.default.up('md', props.theme['$grid-breakpoints'], "\n &.rsg-heading {\n line-height: ".concat(props.theme.styleguide['$rsg-heading-line-height'], ";\n }\n &.rsg-heading.h1 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h1, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h1, ";\n }\n &.rsg-heading.h2 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h2, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h2, ";\n }\n &.rsg-heading.h3 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h3, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h3, ";\n }\n &.rsg-heading.h4 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h4, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h4, ";\n }\n &.rsg-heading.h5 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h5, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h5, ";\n }\n &.rsg-heading.h6 {\n font-size: ").concat(props.theme.styleguide['$rsg-heading-font-size'].h6, ";\n font-weight: ").concat(props.theme.styleguide['$rsg-heading-font-weight'].h6, ";\n font-style: 'italic';\n }\n ")), "\n "); }); HeadingRenderer.defaultProps = defaultProps; HeadingRenderer.propTypes = propTypes; /** @component */ var _default = HeadingRenderer; exports.default = _default;