Skip to content

Commit

Permalink
Support adding classes to Modal overlay and content (#232)
Browse files Browse the repository at this point in the history
* Support adding classes to Modal overlay and content

* move class to the end

* Improve comments
  • Loading branch information
miafan23 authored Dec 9, 2024
1 parent 00dc917 commit 109108e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

## 2.16.0

- [feature] Support adding classes to Modal overlay and content

## 2.15.0

- [feature] support configuring z-index for Popover component
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/mr-ui",
"version": "2.15.0",
"version": "2.16.0",
"description": "UI components for Mapbox projects",
"main": "index.js",
"homepage": "./",
Expand Down
18 changes: 16 additions & 2 deletions src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface Props {
padding?: 'large' | 'none';
margin?: 'large' | 'default';
zIndex?: number | string;
themeOverlay?: string;
themeContent?: string;
onExit?: () => void;
exitOnUnderlayClicked?: boolean;
allowEventBubbling?: boolean;
Expand Down Expand Up @@ -61,6 +63,8 @@ export default function Modal({
primaryAction,
secondaryAction,
tertiaryAction,
themeOverlay = '',
themeContent = '',
onExit
}: Props): ReactElement {
const renderActions = (): ReactElement => {
Expand Down Expand Up @@ -96,7 +100,7 @@ export default function Modal({
style: CSSProperties;
'data-testid': string;
} = {
className: 'fixed top bottom left right bg-darken50',
className: `fixed top bottom left right bg-darken50 ${themeOverlay}`,
style: {
display: 'grid',
overflowY: 'auto',
Expand All @@ -122,7 +126,7 @@ export default function Modal({
onOpenAutoFocus?: (e) => void;
} = {
className: classnames(
`relative ${marginClass} ${widthClass} bg-white round`,
`relative ${marginClass} ${widthClass} bg-white round ${themeContent}`,
{ 'px36 py36': padding === 'large' }
)
};
Expand Down Expand Up @@ -223,6 +227,16 @@ Modal.propTypes = {
* z-index of the modal
*/
zIndex: PropTypes.number,
/**
* Additional CSS classes to apply to the overlay,
* along with existing classes `fixed top bottom left right bg-darken50`
*/
themeOverlay: PropTypes.string,
/**
* Additional CSS classes to apply to the content,
* along with existing classes `relative bg-white round`
*/
themeContent: PropTypes.string,
/**
* The modal's primary action. If this is provided, an encouraging
* button will be rendered at the bottom of the modal.
Expand Down

0 comments on commit 109108e

Please sign in to comment.