Skip to content
New issue

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

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

Already on GitHub? # to your account

Add modal organism (Fixes #78) #118

Merged
merged 1 commit into from
May 23, 2018
Merged

Add modal organism (Fixes #78) #118

merged 1 commit into from
May 23, 2018

Conversation

alexgibson
Copy link
Member

@alexgibson alexgibson commented May 18, 2018

  • Adds modal organism (replicating style seen on the new mozilla.org home page)
  • Adds a light-links mixin, for better link contrast on dark backgrounds.

Note: I had originally hoped to use <dialog> and a polyfill, but I discovered some a11y shortcomings in the polyfill that I don't think we can lose to justify switching yet 😢. Maybe once more browsers have native support. For now, this is a direct port of the bedrock modal JS (just replacing the jQuery for native JS).

We still need to bikeshed the styles here (including things like the close icon, which needs to be moved to the design assets repo once we decide what to use).

Demo: https://demo1--mozilla-protocol.netlify.com/patterns/organisms/modal.html

@alexgibson alexgibson added WIP 🚧 Work In Progress Do Not Merge ⚠️ Do Not Merge labels May 18, 2018
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42"><style>.st0{fill:none;stroke:#fff;stroke-miterlimit:10}</style><path class="st0" d="M0 0l42 42M0 42L42 0"/></svg>
Copy link
Member Author

@alexgibson alexgibson May 18, 2018

Choose a reason for hiding this comment

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

Once we decide on an icon to use, this needs to be moved to the design assets repo.

a:hover,
a:focus,
a:active {
color: darken($color-secondary, 5%);
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this be a new link style atom?

a:hover,
a:focus,
a:active {
color: darken($color-secondary, 5%);
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this link style be a new atom?

Copy link
Member

Choose a reason for hiding this comment

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

I've been thinking we probably need to standardize a style for links on dark backgrounds and make a mixin for it, something like @include light-links;

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a light-links mixin 👍

@alexgibson alexgibson removed the WIP 🚧 Work In Progress label May 21, 2018
@craigcook craigcook self-assigned this May 21, 2018
@vincejoyiv
Copy link

@alexgibson I'm going to review this today. My thinking is that it can be improved, and become a better foundation for a standard modal component—it's a bit weird to start with a specialized component like a video player and then try to reverse engineer a simple modal from that, but let's give it a try.

@alexgibson
Copy link
Member Author

Ok, looks like we already have a close icon in the design-assets repo, so I updated the modal here to reuse that instead of introduce a new icon. It also has slightly thicker paths, so contrast is improved.

@alexgibson alexgibson removed the Do Not Merge ⚠️ Do Not Merge label May 23, 2018
Copy link
Member

@craigcook craigcook left a comment

Choose a reason for hiding this comment

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

Looks good! We should probably use our new naming convention for the noscroll class but that's my only real nitpick.

There are some suggestions for more notes/documentation but those can wait and needn't block merging. The close button could use a better :focus state for keyboards but I know there will be some style changes forthcoming and we can improve it then.

title: 'Example headline with 35 characters',
closeText: 'Close modal',
onCreate: function() {
console.log('Modal opened');
Copy link
Member

Choose a reason for hiding this comment

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

Maybe worth adding a comment (directly in the script or just in the notes) that this is a demonstration, we don't want people including these console bits in production.

Copy link
Member

Choose a reason for hiding this comment

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

On second thought the notes already explain what onCreate and onDestroy do and this whole thing is clearly just an example already, maybe no need to drive that point home any further.


Mozilla.Modal.createModal(e.target, content, {
title: 'Example headline with 35 characters',
closeText: 'Close modal',
Copy link
Member

Choose a reason for hiding this comment

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

We probably need some better documentation around this, but we can at least comment that this is a demo and ideally one shouldn't have translatable strings in JS (unless you have a system for translating JS files or aren't localizing anyway). The title could be a heading in the DOM, closeText could be a data attribute, etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it may be best (for now at least) to try and shy away from too much hand-holding when it comes to l10n, as different sites all have different methods of doing things. It's not directly related to the component itself, so to avoid over-complicating the instructions here, I think a generic l10n section may be a better time to explain this type of thing?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm probably overly paranoid about people following this example when hopefully it's clear that it's JUST an example. We're working on general l10n guidelines and "no strings in JS" is a good rule.

@import '../includes/lib';
@import '../includes/animations';

html.noscroll {
Copy link
Member

Choose a reason for hiding this comment

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

mzp-is-noscroll?

}
}

@keyframes mzp-a-fade-in {
Copy link
Member

Choose a reason for hiding this comment

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

We should add the a- prefix to our naming convention.

'</div>';

if ((options && !options.allowScroll) || isSmallViewport) {
html.classList.add('noscroll');
Copy link
Member

Choose a reason for hiding this comment

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

Should this class follow the naming convention for states? So it would be mzp-is-noscroll

@alexgibson
Copy link
Member Author

Thanks @craigcook - I updated the noscroll class, and also added a basic focus outline for the close button (better than the miniscule scale effect).

Copy link
Member

@craigcook craigcook left a comment

Choose a reason for hiding this comment

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

🛵

@craigcook craigcook merged commit 890d80e into mozilla:master May 23, 2018
@alexgibson alexgibson deleted the port-bedrock-modal branch May 25, 2018 09:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants