@atlaskit/modal-dialog
Version:
A modal dialog displays content that requires user interaction, in a layer above the page.
47 lines • 1.99 kB
JavaScript
/* modal-body.tsx generated by @compiled/babel-plugin v0.39.1 */
import "./modal-body.compiled.css";
import { ax, ix } from "@compiled/react/runtime";
import React from 'react';
import { TouchScrollable } from 'react-scrolllock';
import { useModal } from './hooks';
import ScrollContainer from './internal/components/scroll-container';
import useScroll from './internal/hooks/use-scroll';
var styles = {
root: "_16jlkb7n _1o9zkb7n _i0dl1wug _11c8fhey",
paddingBlock: "_1rjcv77o",
paddingInline: "_18zr1ejb"
};
/**
* __Modal body__
*
* A modal body is used to display the main content of a modal.
*
* - [Examples](https://atlassian.design/components/modal-dialog/examples)
* - [Code](https://atlassian.design/components/modal-dialog/code#modal-body-props)
* - [Usage](https://atlassian.design/components/modal-dialog/usage)
*/
var ModalBody = function ModalBody(props) {
var children = props.children,
userDefinedTestId = props.testId,
_props$hasInlinePaddi = props.hasInlinePadding,
hasInlinePadding = _props$hasInlinePaddi === void 0 ? true : _props$hasInlinePaddi;
var _useModal = useModal(),
modalTestId = _useModal.testId;
var shouldScrollInViewport = useScroll();
var testId = userDefinedTestId || modalTestId && "".concat(modalTestId, "--body");
return shouldScrollInViewport ? /*#__PURE__*/React.createElement("div", {
"data-testid": testId,
className: ax([styles.root, hasInlinePadding && styles.paddingInline])
}, children) : /*#__PURE__*/React.createElement(TouchScrollable, null, /*#__PURE__*/React.createElement(ScrollContainer, {
testId: userDefinedTestId || modalTestId
}, /*#__PURE__*/React.createElement("div", {
"data-testid": testId,
className: ax([styles.root,
/**
* Adding block padding for scroll keylines, which are only shown when the scrolling
* is on the container.
*/
styles.paddingBlock, hasInlinePadding && styles.paddingInline])
}, children)));
};
export default ModalBody;