UNPKG

optimizely-oui

Version:

Optimizely's Component Library.

47 lines (38 loc) 2.31 kB
import _pt from "prop-types"; function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from "react"; import Col from "./Col"; import { nubbinSize } from "../../tokens/forimport/index.es"; /** * @deprecated This component has been deprecated 2021-06-04. Use Grid or LayoutGrid instead. */ var ColWithNubbin = function ColWithNubbin(_ref) { var children = _ref.children, nubbinRef = _ref.nubbinRef, props = _objectWithoutProperties(_ref, ["children", "nubbinRef"]); var nubbinTopPosition = 0; if (nubbinRef && nubbinRef instanceof HTMLElement) { // 17 is half the distance of the diagonal of the nubbin // Actually used the pythagorean theorem: // Nubbin is 24 x 24, so 24 * √2 = 33.94 / 2 = 17 var nubbinHypotenuse = parseInt(nubbinSize) * Math.sqrt(2); // Adjust the top position to be halfway through the ref's height // minus half the nubbin's height (the hypotenuse) nubbinTopPosition = nubbinRef.offsetTop + nubbinRef.offsetHeight / 2 - nubbinHypotenuse / 2; } return React.createElement(Col, props, React.createElement("div", { className: "height--1-1 soft-double background--light border--left" }, React.createElement("div", { className: "oui-config-panel__nubbin", style: { top: nubbinTopPosition } }), children)); }; ColWithNubbin.propTypes = { children: _pt.node.isRequired, nubbinRef: _pt.oneOfType([_pt.string, _pt.func, _pt.object]).isRequired }; ColWithNubbin.displayName = "ColWithNubbin"; ColWithNubbin.defaultProps = {}; export default ColWithNubbin;