Skip to content

Commit 109108e

Browse files
authored
Support adding classes to Modal overlay and content (#232)
* Support adding classes to Modal overlay and content * move class to the end * Improve comments
1 parent 00dc917 commit 109108e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog
22

3+
## 2.16.0
4+
5+
- [feature] Support adding classes to Modal overlay and content
6+
37
## 2.15.0
48

59
- [feature] support configuring z-index for Popover component

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mapbox/mr-ui",
3-
"version": "2.15.0",
3+
"version": "2.16.0",
44
"description": "UI components for Mapbox projects",
55
"main": "index.js",
66
"homepage": "./",

src/components/modal/modal.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface Props {
1515
padding?: 'large' | 'none';
1616
margin?: 'large' | 'default';
1717
zIndex?: number | string;
18+
themeOverlay?: string;
19+
themeContent?: string;
1820
onExit?: () => void;
1921
exitOnUnderlayClicked?: boolean;
2022
allowEventBubbling?: boolean;
@@ -61,6 +63,8 @@ export default function Modal({
6163
primaryAction,
6264
secondaryAction,
6365
tertiaryAction,
66+
themeOverlay = '',
67+
themeContent = '',
6468
onExit
6569
}: Props): ReactElement {
6670
const renderActions = (): ReactElement => {
@@ -96,7 +100,7 @@ export default function Modal({
96100
style: CSSProperties;
97101
'data-testid': string;
98102
} = {
99-
className: 'fixed top bottom left right bg-darken50',
103+
className: `fixed top bottom left right bg-darken50 ${themeOverlay}`,
100104
style: {
101105
display: 'grid',
102106
overflowY: 'auto',
@@ -122,7 +126,7 @@ export default function Modal({
122126
onOpenAutoFocus?: (e) => void;
123127
} = {
124128
className: classnames(
125-
`relative ${marginClass} ${widthClass} bg-white round`,
129+
`relative ${marginClass} ${widthClass} bg-white round ${themeContent}`,
126130
{ 'px36 py36': padding === 'large' }
127131
)
128132
};
@@ -223,6 +227,16 @@ Modal.propTypes = {
223227
* z-index of the modal
224228
*/
225229
zIndex: PropTypes.number,
230+
/**
231+
* Additional CSS classes to apply to the overlay,
232+
* along with existing classes `fixed top bottom left right bg-darken50`
233+
*/
234+
themeOverlay: PropTypes.string,
235+
/**
236+
* Additional CSS classes to apply to the content,
237+
* along with existing classes `relative bg-white round`
238+
*/
239+
themeContent: PropTypes.string,
226240
/**
227241
* The modal's primary action. If this is provided, an encouraging
228242
* button will be rendered at the bottom of the modal.

0 commit comments

Comments
 (0)