jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
35 lines (29 loc) • 2.44 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
var constants = require('./constants.js');
require('../../../react-style-singleton/dist/es2015/singleton.js');
require('../../../react-style-singleton/dist/es2015/hook.js');
var component = require('../../../react-style-singleton/dist/es2015/component.js');
var utils = require('./utils.js');
var Style = component.styleSingleton();
var getStyles = function (_a, allowRelative, gapMode, important) {
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
if (gapMode === void 0) { gapMode = 'margin'; }
return "\n ." + constants.noScrollbarsClassName + " {\n overflow: hidden " + important + ";\n padding-right: " + gap + "px " + important + ";\n }\n body {\n overflow: hidden " + important + ";\n " + [
allowRelative && "position: relative " + important + ";",
gapMode === 'margin' && "\n padding-left: " + left + "px;\n padding-top: " + top + "px;\n padding-right: " + right + "px;\n margin-left:0;\n margin-top:0;\n margin-right: " + gap + "px " + important + ";\n ",
gapMode === 'padding' && "padding-right: " + gap + "px " + important + ";",
].filter(Boolean).join('') + "\n }\n \n ." + constants.zeroRightClassName + " {\n right: " + gap + "px " + important + ";\n }\n \n ." + constants.fullWidthClassName + " {\n margin-right: " + gap + "px " + important + ";\n }\n \n ." + constants.zeroRightClassName + " ." + constants.zeroRightClassName + " {\n right: 0 " + important + ";\n }\n \n ." + constants.fullWidthClassName + " ." + constants.fullWidthClassName + " {\n margin-right: 0 " + important + ";\n }\n";
};
var RemoveScrollBar = function (props) {
var _a = React.useState(utils.getGapWidth(props.gapMode)), gap = _a[0], setGap = _a[1];
React.useEffect(function () {
setGap(utils.getGapWidth(props.gapMode));
}, [props.gapMode]);
var noRelative = props.noRelative, noImportant = props.noImportant, _b = props.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : '') });
};
exports.RemoveScrollBar = RemoveScrollBar;