Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Modal): add prop to toggle modal position to scrollable/fixed #377

Merged
merged 3 commits into from Sep 1, 2020

Conversation

eszthoff
Copy link
Contributor

@eszthoff eszthoff commented Aug 27, 2020

Story: JF-2367

Checklist

  • The implementation has been manually tested and complies with Textkernel browser support guidelines
  • The implementation complies with accessibility standards.
  • The component has a displayName defined.
  • The component comes with a detailed PropTypes (and defaultProps) definition.
  • Component PropTypes are sufficiently described / documented.
  • There is a story in Storybook.

Copy link
Contributor

@antipin antipin left a comment

Choose a reason for hiding this comment

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

Nice improvement! Left few comments

&__overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;

width: 100%;
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

All the sizes of the other elements are in vh/vw units, here as well width: 100vw; height: 100vh; can be used for consistency

overlayClassName?: string;
/** Additional class to be applied to the portal */
portalClassName?: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice enhancement 👍

@@ -1,10 +1,19 @@
.Modal {
&__body--open {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having element body with modifier open doesn't make much sense because if it is in a DOM tree, it is already open (in other words such thing as body--closed doesn't exists).

So, can be just body.

@@ -19,6 +45,7 @@ export const Modal = (props) => {
} = props;

const { className: portalClass } = block({ className: portalClassName, ...rest });
const { className: bodyOpenClass } = elem('body--open', props);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, if we'd need to have a class name body--open, that proper way to achieve it would be:
elem('body', { ...props, open: true });

But since we don't need open modifier at all, it can be just elem('body', props);

@@ -29,12 +56,24 @@ export const Modal = (props) => {
const { className: contentEnteredClass } = elem('content--entered', props);
const { className: contentExitedClass } = elem('content--exited', props);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I believe you copypasted elem('body--open', props); from here, bu these are examples of not correct usage of elem function.

Should be:

const { className: contentEnteredClass } = elem('content', { ...props, entered: true });
const { className: contentExitedClass } = elem('content', { ...props, exited: true });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the way this is used in React Modal, setting it in this way makes final DOM having repeated classes, that looks messy. So I kept it as it is now. Alternatively we could rename the enter/exit classes in the scss files so that they don't use the usual modifier patterns to avoid internal confusion, e.g. &__enteredContent instead of &__content--entered.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. Now I remember there was a task to cover this case in bem. Ok, let's keep it this way then so far.

Copy link
Contributor

@antipin antipin left a comment

Choose a reason for hiding this comment

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

👍

@eszthoff eszthoff merged commit d9e4a8e into master Sep 1, 2020
@eszthoff eszthoff deleted the JF-2367-scrollable-modal branch September 1, 2020 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants