Skip to content

[changed] use object className and overlayClassName prop to override … - #330

Merged
claydiffrient merged 1 commit into
reactjs:masterfrom
nikmilson:master
May 14, 2017
Merged

[changed] use object className and overlayClassName prop to override …#330
claydiffrient merged 1 commit into
reactjs:masterfrom
nikmilson:master

Conversation

@nikmilson

Copy link
Copy Markdown

Changes proposed:

  • use object className and overlayClassName prop to override the default content and overlay classes;
  • use bodyOpenClassName to override body class name when modal opened.

Upgrade Path (for changed or removed APIs):
For overriding default content and overlay classes you can pass object
with three required properties: base, afterOpen, beforeClose.

<Modal
  ...
  className={{
    base: 'myClass',
    afterOpen: 'myClass_after-open',
    beforeClose: 'myClass_before-close'
  }}
  overlayClassName={{
    base: 'myOverlayClass',
    afterOpen: 'myOverlayClass_after-open',
    beforeClose: 'myOverlayClass_before-close'
  }}
  ...
>

Old behavior is saved, when passed a string.

Acceptance Checklist:

  • All commits have been squashed to one.
  • The commit message follows the guidelines in CONTRIBUTING.md.
  • Documentation (README.md) and examples have been updated as needed.
  • If this is a code change, a spec testing the functionality has been added.
  • If the commit message has [changed] or [removed], there is an upgrade path above.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.5%) to 81.185% when pulling 9719ff5 on cassln:master into a8b7aa0 on reactjs:master.

@diasbruno

diasbruno commented Feb 26, 2017

Copy link
Copy Markdown
Collaborator

hey @cassln, this PR looks good, but why would you want to replace the class names?
what if we could have something like this:

sass or less style (replace react-modal-* with the actual classes, sorry for been lazy :)).

.{my-class}.react-modal-base { ... }
.{my-class}.react-modal {
  .react-modal-overlay { ... }
  .react-modal-content { ... }
}

@nikmilson

nikmilson commented Feb 27, 2017

Copy link
Copy Markdown
Author

Hey @diasbruno. I want to replace the class names because of I'm sticking BEM notation. And cascades like .{my-class}.react-modal-base { ... } are working, but it is wrong for BEM.

Also, this feature makes possible getting clean markup for react-modal in result. :)

@nikmilson

Copy link
Copy Markdown
Author

What about merge the feature? :) I really need this in working project.

@diasbruno

Copy link
Copy Markdown
Collaborator

@cassln don't wait, use it from your fork. :)

@diasbruno

diasbruno commented Mar 1, 2017

Copy link
Copy Markdown
Collaborator

Be patient. I do think this PR is good. there is some work going on to get a version in between 1.6.5 and 2.0.

base: PropTypes.string.isRequired,
afterOpen: PropTypes.string.isRequired,
beforeClose: PropTypes.string.isRequired
})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that only the base of the classes change. Maybe we can short this changes by keeping the suffixes unchanged like {ReactModal}_before-open and {ReactModal}_after-open. Any thoughts?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffixes are not flexible. There are BEM alternative naming schemes. The suffixes make impossible of using them. Also, we can pass props like this (without BEM example):

{
  base: 'modal',
  afterOpen: 'open',
  beforeClose: 'close'
}

@nikmilson

Copy link
Copy Markdown
Author

there is some work going on to get a version in between 1.6.5 and 2.0

Do you have ability to release version between 1.6.5 and 2.0. This It would be very helpful. 👍

@claydiffrient

Copy link
Copy Markdown
Contributor

@cassln 1.7.0, 1.7.1, and 1.7.2 have been released.

…the default content and overlay classes;

use bodyOpenClassName to override body class name when modal opened
@nikmilson

Copy link
Copy Markdown
Author

The branch has been rebased.

@viniciusffj

Copy link
Copy Markdown

@cassln @diasbruno Is there a chance to this get merged? I really need the bodyOpenClassName funcionality

@diasbruno

Copy link
Copy Markdown
Collaborator

cc @claydiffrient @cassln

@pamelipluas

Copy link
Copy Markdown

@cassln @diasbruno Hi everyone! Any update about this pl? In my project we are using this lib and we really need can change the body classname

@abdennour

abdennour commented May 14, 2017

Copy link
Copy Markdown

Why this PR is not merged yet ?

@claydiffrient
claydiffrient merged commit 6442387 into reactjs:master May 14, 2017
diasbruno added a commit to diasbruno/react-modal that referenced this pull request Jun 11, 2017
This is a backport of @cassln's feature to version 1.8.x.

Original PR is reactjs#330.

reactjs#330
diasbruno added a commit to diasbruno/react-modal that referenced this pull request Jun 11, 2017
This is a backport of @cassln's feature to version 1.8.x.

Original PR is reactjs#330.

reactjs#330
diasbruno added a commit to diasbruno/react-modal that referenced this pull request Jun 12, 2017
This is a backport of @cassln's feature to version 1.8.x.

Original PR is reactjs#330.

reactjs#330
diasbruno added a commit to diasbruno/react-modal that referenced this pull request Jun 12, 2017
This is a backport of @cassln's feature to version 1.8.x.

Original PR is reactjs#330.

reactjs#330
diasbruno added a commit that referenced this pull request Jun 12, 2017
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

#330
techwizard210 pushed a commit to techwizard210/react-modal that referenced this pull request Aug 28, 2022
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

reactjs/react-modal#330
Happypower1103 added a commit to Happypower1103/react-modal that referenced this pull request May 12, 2023
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

reactjs/react-modal#330
DevStar1016 pushed a commit to DevStar1016/react_modal that referenced this pull request Sep 11, 2023
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

reactjs/react-modal#330
fortinjose916 pushed a commit to fortinjose916/react-modal that referenced this pull request Feb 4, 2025
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

reactjs/react-modal#330
djgpp6 added a commit to djgpp6/react_modal that referenced this pull request Mar 15, 2026
This is a backport of @cassln's feature to version 1.8.x.

Original PR is #330.

reactjs/react-modal#330
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants