Skip to content

Commit bdbc24c

Browse files
authored
Merge pull request #16 from jakewtaylor/master
Allow passing classes to the modal div
2 parents 503aad8 + 562994d commit bdbc24c

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CI
2-
on: [push]
2+
on: [push, pull_request]
33
jobs:
44
build:
55
runs-on: ubuntu-latest

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ import 'react-simple-hook-modal/dist/styles.css';
7676

7777
- `backdropClassName` which can contain one or more classes to append and override the default styles (e.g. Changing the backdrop colour can be done by adding the class `bg-blue-800`).
7878

79+
`Modal` also takes optional props:
80+
- `modalClassName` which can contain one or more classes to append to the default modal div.
81+
7982
# Example
8083

8184
See the `example` directory in the repository for a full example including multiple stacked modals.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ModalProps {
1010
onBackdropClick?: () => void;
1111
footer?: React.ReactNode;
1212
transition?: ModalTransition;
13+
modalClassName?: string;
1314
}
1415

1516
function hasDOM() {

src/components/ModalContainer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const ModalContainer: React.FC<ModalProps & Props> = ({
1717
transition,
1818
onBackdropClick,
1919
transformDistance,
20+
modalClassName,
2021
}) => {
2122
const modalTransitions = useModalTransition(transition, isOpen);
2223

@@ -32,7 +33,8 @@ export const ModalContainer: React.FC<ModalProps & Props> = ({
3233
onClick={onBackdropClick}
3334
>
3435
<div
35-
className="rsm-bg-white rsm-rounded-md rsm-overflow-auto rsm-max-h-full rsm-w-full md:rsm-w-10/12 xl:rsm-w-1/2 rsm-opactiy-100 rsm-shadow-lg rsm-z-50 rsm-border rsm-border-gray-200 rsm-flex rsm-flex-col"
36+
className={`rsm-bg-white rsm-rounded-md rsm-overflow-auto rsm-max-h-full rsm-w-full md:rsm-w-10/12 xl:rsm-w-1/2 rsm-opactiy-100 rsm-shadow-lg rsm-z-50 rsm-border rsm-border-gray-200 rsm-flex rsm-flex-col ${modalClassName ??
37+
''}`}
3638
style={{
3739
minHeight: '70%',
3840
transition:

0 commit comments

Comments
 (0)