Skip to content

Commit

Permalink
fix(Modal): allow overflow to be set by consumer (#299)
Browse files Browse the repository at this point in the history
* fix(Modal): pointer cursor on close button

* fix(Modal): allow overflow to be set by consumer
  • Loading branch information
nathanyoung authored Oct 26, 2020
1 parent cadc94c commit 55790b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ export interface BoxProps {
*/
maxWidth?: DimensionSize | ResponsiveProp<DimensionSize> | string;
/**
* The overflow property is specified as one or two keywords.
* If two keywords are specified, the first applies to overflow-x and the second to overflow-y.
* Otherwise, both overflow-x and overflow-y are set to the same value.
* The css overflow behavior of the Box
*/
overflow?: CssOverflowValue | ResponsiveProp<CssOverflowValue>;
/**
Expand Down
1 change: 0 additions & 1 deletion src/components/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
background-color: var(--modal-background-color);
padding: 0;
width: 100%;
overflow: hidden;
animation: fadeIn 0.3s;

@media (min-width: $size-breakpoint-tablet) {
Expand Down
10 changes: 9 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC, ReactNode, RefObject } from 'react';
import { DialogOverlay, DialogContent } from '@reach/dialog';
import classNames from 'classnames';
import { ModalFooter, ModalHeader, ModalBody } from './components';
import { CssOverflowValue } from '../../types';
import styles from './Modal.module.scss';

interface ModalProps {
Expand Down Expand Up @@ -47,6 +48,10 @@ interface ModalProps {
* Function that is called whenever the user hits "Esacape" key or clicks outside the modal.
*/
onDismiss: (event?: React.SyntheticEvent) => void;
/**
* The css overflow behavior of the Modal
*/
overflow?: CssOverflowValue;
}

const Modal: FC<ModalProps> & {
Expand All @@ -63,11 +68,14 @@ const Modal: FC<ModalProps> & {
initialFocusRef,
isOpen,
onDismiss,
overflow = 'hidden',
}) => {
const overylayClassnames = classNames(styles.overlay, {
fullscreen: fullScreenMobile,
});
const contentClassnames = classNames(styles['modal-content'], className);
const contentClassnames = classNames(styles['modal-content'], className, {
[`overflow-${overflow}`]: overflow,
});

return (
<DialogOverlay
Expand Down

0 comments on commit 55790b9

Please sign in to comment.