Skip to content

Commit 3b94ad7

Browse files
authored
add Modal.scss and export MODAL_SIZES (#239)
* add Modal.scss and export MODAL_SIZES * small fixes
1 parent 49a9b63 commit 3b94ad7

File tree

5 files changed

+83
-2
lines changed

5 files changed

+83
-2
lines changed

scss/modals.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$modal-width-default: 32rem;
2+
$modal-width-wide: 46.5rem;

scss/theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@import './elevations';
77
@import './inputs';
88
@import './lists';
9+
@import './modals.scss';
910
@import './navbar';
1011
@import './spacing';
1112
@import './timing.scss';

src/Modal/Modal.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import classNames from 'classnames';
33
import ReactModal from 'react-modal';
44
import PropTypes from 'prop-types';
55

6+
import './Modal.scss';
7+
68
export const MODAL_SIZES = { SMALL: 'small', LARGE: 'large' };
79

810
const Modal = (props) => {
@@ -24,7 +26,7 @@ Modal.propTypes = {
2426
};
2527

2628
Modal.defaultProps = {
27-
size: MODAL_SIZES.small,
29+
size: MODAL_SIZES.SMALL,
2830
className: undefined,
2931
};
3032

src/Modal/Modal.scss

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
@import '../../scss/theme.scss';
2+
@import '~bootstrap/scss/functions';
3+
@import '~bootstrap/scss/variables';
4+
5+
.ReactModal {
6+
&__Body--open {
7+
overflow: hidden;
8+
}
9+
10+
&__Content {
11+
background-color: white;
12+
border-radius: $ux-border-radius;
13+
box-shadow: $modal-content-box-shadow-xs;
14+
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
15+
font-weight: 400;
16+
max-height: 100%;
17+
overflow: auto;
18+
transform: translate(0, -25%);
19+
transition: transform $ux-duration-long ease-in;
20+
width: $modal-width-default;
21+
22+
&.ReactModal--large {
23+
width: $modal-width-wide;
24+
}
25+
26+
// Bootstrap has the following reset:
27+
//
28+
// [tabindex="-1"]:focus { outline: 0 !important; };
29+
//
30+
// That would cover our needs here, but it’s maybe a surprising default and
31+
// I think it ought be made explicit.
32+
33+
&:focus {
34+
outline: none;
35+
}
36+
37+
&--after-open:not(&--before-close) {
38+
transform: translate(0, 0);
39+
transition-timing-function: $ux-ease-out-circ;
40+
}
41+
42+
// The content children (typically one div) must never be wider than the
43+
// parent, since this would always mean overflowing the viewport.
44+
45+
> * {
46+
max-height: 95vh;
47+
max-width: 100%;
48+
overflow-y: auto;
49+
}
50+
}
51+
52+
// The overlay uses the jQuery modal z-index because the layout must remain
53+
// compatible with the jQuery modal’s layout expectations. If jQuery modal is
54+
// removed, we can isolate #ui-window-root instead and z-index will not be
55+
// needed.
56+
57+
&__Overlay {
58+
align-items: center;
59+
background-color: rgba(0, 0, 0, 0.5);
60+
display: flex;
61+
justify-content: center;
62+
opacity: 0;
63+
padding: $ux-spacing-50;
64+
transition: opacity $ux-duration-short linear;
65+
z-index: $z-index-modal-backdrop;
66+
67+
@media (max-width: 32rem) {
68+
padding: $ux-spacing-40;
69+
}
70+
71+
&--after-open:not(&--before-close) {
72+
opacity: 1;
73+
}
74+
}
75+
}

src/Modal/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import Modal from './Modal';
1+
import Modal, { MODAL_SIZES } from './Modal';
22
import ModalBody from './ModalBody';
33
import ModalFooter from './ModalFooter';
44
import ModalHeader from './ModalHeader';
55

66
export {
77
Modal,
8+
MODAL_SIZES,
89
ModalBody,
910
ModalFooter,
1011
ModalHeader,

0 commit comments

Comments
 (0)