nice-ui
Version:
React design system, components, and utilities
29 lines (28 loc) • 1.19 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const useWindowSize_1 = require("react-use/lib/useWindowSize");
const useSize_1 = require("react-use/lib/useSize");
const DocsMd_1 = require("../DocsMd");
const constants_1 = require("../../../../constants");
const Wide = ({ node }) => {
// tslint:disable-next-line: no-eval ban
const options = node.meta ? eval('(' + (node.meta || '') + ')') : {};
const wndSize = (0, useWindowSize_1.default)();
const [element] = (0, useSize_1.default)((state) => {
let width = constants_1.NiceUiSizes.SiteWidth;
width = Math.min(width, wndSize.width - 32);
if (width < state.width)
width = state.width;
let marginLeft = width > state.width ? -((width - state.width) / 2) : 0;
if (options.rightOnly) {
width += marginLeft;
marginLeft = 0;
}
return (React.createElement("div", null,
React.createElement("div", { style: { width, marginLeft } },
React.createElement(DocsMd_1.default, { md: node.value }))));
});
return element;
};
exports.default = Wide;
;