UNPKG

wix-style-react

Version:
64 lines (45 loc) 1.99 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.APPEARANCES = undefined; 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; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _HeadingSt = require('./Heading.st.css'); var _HeadingSt2 = _interopRequireDefault(_HeadingSt); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var APPEARANCES = exports.APPEARANCES = { H1: 'H1', H2: 'H2', H3: 'H3', H4: 'H4', H5: 'H5', H6: 'H6' }; var Heading = function Heading(_ref) { var light = _ref.light, appearance = _ref.appearance, children = _ref.children, rest = _objectWithoutProperties(_ref, ['light', 'appearance', 'children']); /* eslint-disable no-unused-vars */ var dataHook = rest.dataHook, headingProps = _objectWithoutProperties(rest, ['dataHook']); return _react2.default.createElement(appearance.toLowerCase(), _extends({}, headingProps, (0, _HeadingSt2.default)('root', { light: light, appearance: appearance }, rest)), children); }; Heading.displayName = 'Heading'; Heading.propTypes = { /** any nodes to be rendered (usually text nodes) */ children: _propTypes.any, /** is the text has dark or light skin */ light: _propTypes.bool, /** typography of the heading */ appearance: (0, _propTypes.oneOf)(Object.keys(APPEARANCES)) }; Heading.defaultProps = { appearance: APPEARANCES.H1, light: false }; exports.default = Heading;