UNPKG

@dabapps/roe

Version:

A collection of React components, styles, mixins, and atomic CSS classes to aid with the development of web applications.

46 lines 2.51 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var classNames = require("classnames"); var React = require("react"); var react_transition_group_1 = require("react-transition-group"); var TIMEOUT = { appear: 300, enter: 300, exit: 200, }; /** * This highlight component is used to display a single element while shading everything else out. */ var Highlight = function (props) { var className = props.className, children = props.children, _a = props.open, open = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.backgroundColor, backgroundColor = _c === void 0 ? null : _c, _d = props.component, Component = _d === void 0 ? 'div' : _d, remainingProps = __rest(props, ["className", "children", "open", "disabled", "backgroundColor", "component"]); return (React.createElement(Component, __assign({}, remainingProps, { className: classNames('highlight', className) }), React.createElement(react_transition_group_1.TransitionGroup, null, open && (React.createElement(react_transition_group_1.CSSTransition, { classNames: "highlight-transition", timeout: TIMEOUT }, React.createElement("div", { className: "highlight-overlay" })))), React.createElement("div", { className: classNames('highlight-content', open && 'open'), style: backgroundColor ? { backgroundColor: backgroundColor } : undefined }, children, open && disabled && React.createElement("div", { className: "highlight-overlay-disabled" })))); }; exports.default = React.memo(Highlight); //# sourceMappingURL=highlight.js.map