UNPKG

wix-style-react

Version:
110 lines (89 loc) 4.17 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } import React from 'react'; import PropTypes from 'prop-types'; import { skins, dataHooks } from './constants'; import { stVars as colors } from '../Foundation/stylable/colors.st.css'; import Box from '../Box'; import { st, classes } from './PreviewWidget.st.css'; /** Preview content widget*/ var PreviewWidget = /*#__PURE__*/function (_React$PureComponent) { _inherits(PreviewWidget, _React$PureComponent); var _super = _createSuper(PreviewWidget); function PreviewWidget() { _classCallCheck(this, PreviewWidget); return _super.apply(this, arguments); } _createClass(PreviewWidget, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, skin = _this$props.skin, contentOutline = _this$props.contentOutline, backgroundColor = _this$props.backgroundColor, height = _this$props.height, width = _this$props.width, children = _this$props.children, className = _this$props.className, scrollable = _this$props.scrollable; var rootStyles = { height: "".concat(height), width: "".concat(width), background: skin === skins.custom && (colors[backgroundColor] || backgroundColor) }; return /*#__PURE__*/React.createElement("div", { className: st(classes.root, { skin: skin, contentOutline: contentOutline, scrollable: scrollable }, className), "data-hook": dataHook, style: rootStyles }, /*#__PURE__*/React.createElement("div", { "data-hook": dataHooks.contentArea, className: classes.contentArea }, children)); } }]); return PreviewWidget; }(React.PureComponent); _defineProperty(PreviewWidget, "displayName", 'PreviewWidget'); _defineProperty(PreviewWidget, "propTypes", { /** Preview widget data hook*/ dataHook: PropTypes.string, /** A css class to be applied to the component's root element */ className: PropTypes.string, /** Background skin. To use `custom` skin, set it to custom and use the backgroundColor prop*/ skin: PropTypes.oneOf(['neutral', 'gradient', 'custom']), /** Preview widget background color. Can be set with `design system` colors*/ backgroundColor: PropTypes.string, /** Content area outline*/ contentOutline: PropTypes.oneOf(['shadow', 'border', 'none']), /** Sets the height of the component */ height: PropTypes.string, /** Sets the width of the component */ width: PropTypes.string, /** Node to preview */ children: PropTypes.node.isRequired, /** Enable scroll of the overflowed content **/ scrollable: PropTypes.bool }); _defineProperty(PreviewWidget, "defaultProps", { skin: 'neutral', contentOutline: 'shadow', height: 'auto', width: '100%', scrollable: false, children: /*#__PURE__*/React.createElement(Box, { height: "50px", width: "50px" }) }); export default PreviewWidget;