organism-react-onboarding
Version:
Create guided tours with react.
94 lines (81 loc) • 3.08 kB
JavaScript
import _extends from "reshow-runtime/es/helpers/extends";
import _objectSpread from "reshow-runtime/es/helpers/objectSpread2";
import _objectWithoutProperties from "reshow-runtime/es/helpers/objectWithoutProperties";
import _classCallCheck from "reshow-runtime/es/helpers/classCallCheck";
import _createClass from "reshow-runtime/es/helpers/createClass";
import _assertThisInitialized from "reshow-runtime/es/helpers/assertThisInitialized";
import _inherits from "reshow-runtime/es/helpers/inherits";
import _createSuper from "reshow-runtime/es/helpers/createSuper";
import _defineProperty from "reshow-runtime/es/helpers/defineProperty";
var _excluded = ["targetEl", "styles", "style", "name"];
import React from "react";
import getOffset from "getoffset";
import { isFixed } from "get-window-offset";
import { reactStyle, SemanticUI } from "react-atomic-molecule";
import { PopupFloatEl } from "organism-react-popup";
var GROUP_KEY = "react-onboarding";
var GROUP_FLOATS = "react-onboarding-floats";
var Highlight = /*#__PURE__*/function (_PopupFloatEl) {
_inherits(Highlight, _PopupFloatEl);
var _super = _createSuper(Highlight);
function Highlight() {
var _this;
_classCallCheck(this, Highlight);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "calPos", function () {
var _this$props = _this.props,
targetEl = _this$props.targetEl,
padding = _this$props.padding;
var pos = getOffset(targetEl, isFixed(targetEl));
var width = pos.right - pos.left + padding * 2;
var height = pos.bottom - pos.top + padding * 2;
var top = pos.top - padding;
var left = pos.left - padding;
var result = {
top: top,
left: left,
width: width,
height: height
};
return result;
});
return _this;
}
_createClass(Highlight, [{
key: "renderOverlay",
value: function renderOverlay(props) {
var targetEl = props.targetEl,
styles = props.styles,
style = props.style,
name = props.name,
others = _objectWithoutProperties(props, _excluded);
var thisStyles = [reactStyle(_objectSpread(_objectSpread({}, Styles.container), style), null, false), styles];
return /*#__PURE__*/React.createElement(SemanticUI, _extends({}, others, {
className: name,
styles: thisStyles
}));
}
}]);
return Highlight;
}(PopupFloatEl);
_defineProperty(Highlight, "defaultProps", {
className: GROUP_KEY + "-highlight",
name: GROUP_KEY + "-highlight",
group: [GROUP_KEY, GROUP_FLOATS],
isFollowTransform: true,
padding: 5
});
export default Highlight;
var Styles = {
container: {
position: "absolute",
borderRadius: 4,
border: "2px solid rgb(255, 157, 126)",
boxShadow: ["0px 0px 10px 6px rgba(255, 155, 141, 0.57)"],
zIndex: 99999,
pointerEvents: "none"
}
};