UNPKG

@atlaskit/modal-dialog

Version:

A modal dialog displays content that requires user interaction, in a layer above the page.

49 lines 1.84 kB
/* 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'; const 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) */ const ModalBody = props => { const { children, testId: userDefinedTestId, hasInlinePadding = true } = props; const { testId: modalTestId } = useModal(); const shouldScrollInViewport = useScroll(); const testId = userDefinedTestId || modalTestId && `${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;