Skip to content

Commit

Permalink
Merge pull request #2172 from skbkontur/modal-no-padding
Browse files Browse the repository at this point in the history
[ModalBody] no padding
  • Loading branch information
zhzz authored Oct 19, 2020
2 parents 6f7bf4a + d18600e commit 94034a3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/react-ui/components/Modal/Modal.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ const styles = {
`;
},

bodyWithoutPadding() {
return css`
padding: 0 !important;
`;
},

bodyAddPadding() {
return css`
padding-bottom: 30px;
Expand Down
11 changes: 10 additions & 1 deletion packages/react-ui/components/Modal/ModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ import { ZIndex } from '../../internal/ZIndex';
import { ModalContext } from './ModalContext';
import { jsStyles } from './Modal.styles';

export interface ModalBodyProps {
/**
* убирает отступы
*/
noPadding?: boolean;
}

/**
* Контейнер с отступами от края модалки
*
* @visibleName Modal.Body
*/
export class ModalBody extends React.Component {
export class ModalBody extends React.Component<ModalBodyProps> {
public static __KONTUR_REACT_UI__ = 'ModalBody';
public static __MODAL_BODY__ = true;

public render(): JSX.Element {
const { noPadding } = this.props;
return (
<ModalContext.Consumer>
{({ additionalPadding, hasHeader }) => (
Expand All @@ -26,6 +34,7 @@ export class ModalBody extends React.Component {
[jsStyles.body()]: true,
[jsStyles.bodyWithoutHeader()]: !hasHeader,
[jsStyles.bodyAddPadding()]: additionalPadding,
[jsStyles.bodyWithoutPadding()]: noPadding,
})}
>
{this.props.children}
Expand Down
17 changes: 17 additions & 0 deletions packages/react-ui/components/Modal/__stories__/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,20 @@ ModalWithVeryLongHeaderWithoutSpaces.story = {
name: 'Modal with veryLongHeaderWithoutSpaces',
parameters: { creevey: { captureElement: null } },
};

export const ModalBodyWithoutPadding = () => (
<Modal width={250}>
<Modal.Body noPadding>
<div style={{ background: 'white' }}>
<p>Loooooooong content content content</p>
<p>Loooooooong content content content</p>
<p>Loooooooong content content content</p>
<p>Loooooooong content content content</p>
</div>
</Modal.Body>
</Modal>
);
ModalBodyWithoutPadding.story = {
name: 'Modal with no-padding',
parameters: { creevey: { captureElement: null } },
};

0 comments on commit 94034a3

Please sign in to comment.