Skip to content

v4.2: Add new toasts component#22980

Merged
XhmikosR merged 9 commits intov4-devfrom
boom-toasted
Nov 13, 2018
Merged

v4.2: Add new toasts component#22980
XhmikosR merged 9 commits intov4-devfrom
boom-toasted

Conversation

@mdo
Copy link
Member

@mdo mdo commented Jul 3, 2017

screen shot 2017-07-03 at 4 08 39 pm

Messed around with this toasts component on account of the extended holiday weekend here. There's no JS for this, and I doubt there will be unless someone like @Johann-S or @bardiharborow want to take a crack at it :). However, what we do have is a super simple and highly customizable component for showing push notification style messages to folks.

Fixes #21769.

@patrickhlauke
Copy link
Member

Saying right now that toast messages will need to have an aria-live attribute to ensure that they're announced to assistive technologies when they're shown / updated https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions

@Johann-S
Copy link
Member

Johann-S commented Jul 4, 2017

Toast, Spinner... You're on fire @mdo 👍
I totally like it !

Yes why not add some JS for example, to set Toast placement or to allow folks to set when the toast should be dismissed

@mdo
Copy link
Member Author

mdo commented Jul 4, 2017

Yes why not add some JS for example, to set Toast placement or to allow folks to set when the toast should be dismissed

If you have some vanilla JS to include in the docs, I'll be happy to see it added! :D

@mdo mdo changed the title v4.2/v4.2: Add new toasts component v4.1: Add new toasts component Jul 6, 2017
@odahcam
Copy link

odahcam commented Aug 16, 2017

Guys, I have something here: https://codepen.io/odahcam/pen/oeoYxm
Also: https://github.com/odahcam/bootoast

It was designed for v3, but it's v4 compatibl. I'm working on a new version for 100% supoort BS4. 😀

v4 demonstration:

image

@jipexu
Copy link
Contributor

jipexu commented Aug 16, 2017

this is so cool ..

@mdo
Copy link
Member Author

mdo commented Jan 20, 2018

@patrickhlauke I've resolved conflicts and added a quick section to stub something out about accessibility for live regions. I'm not 100% on how they work or what's required though—can you take a pass at it before we merge this?

@ysds
Copy link
Contributor

ysds commented Jan 22, 2018

Do you have any thoughts about z-index of this toast component?

@mdo
Copy link
Member Author

mdo commented Jan 22, 2018

@ysds Without looking at whatever code I've written thus far, my guy says it should match or perhaps overlap navbars and modals. Perhaps somewhere between those and popovers/tooltips?

@odahcam
Copy link

odahcam commented Jan 22, 2018

If you don't mind, I would like to share some ideas:

I think toasts should have higher index than popovers or tooltips, because the element where the tooltip or popover came from will not be visible when a toast appears over it and the tooltip or popover would still appear if the user don't move the cursor or if in a touch device. So toasts should overplace any visible content behind it.

Also, I think toasts should have a index smaller or the same as dialogs and dropdowns do, because users are focused in the content they're seeing in the dropdown and some dialogs should appear over any already placed toast, also a toast should not necessarily be placed over a dialog because they should force the user focus in the dialog itself, but the dialog could generate new toasts to show some updates.

Also, some kind of persistent dialog, with a higher index could be created and, for example, used to show some upload/download status, where sometimes you need to keep showing the progress.

@ysds
Copy link
Contributor

ysds commented Jan 23, 2018

@mdo Thanks for your response. Are you planning on adding z-index? If not, I think it should be documented.

@mdo
Copy link
Member Author

mdo commented Jan 23, 2018

I'll jump on it after we confirm a11y todos.

@odahcam See the variables file for our current z-index stack:

// Z-index master list
//
// Warning: Avoid customizing these values. They're used for a bird's eye view
// of components dependent on the z-axis and are designed to all work together.
$zindex-dropdown: 1000 !default;
$zindex-sticky: 1020 !default;
$zindex-fixed: 1030 !default;
$zindex-modal-backdrop: 1040 !default;
$zindex-modal: 1050 !default;
$zindex-popover: 1060 !default;
$zindex-tooltip: 1070 !default;

Tooltips/popovers are currently the highest priority, above modals and navbars, because any element within a modal or navbar can tigger a tooltip/popover. Toast could arguably have tooltips/popovers within them, but that doesn't seem as likely. I'm thinking they might go above? Will need to experiment a bit more, but they cannot go below modals and dropdowns.

@odahcam
Copy link

odahcam commented Feb 3, 2018

sorry @mdo, I did not had time to take a deep look at the way this kinda things work.

So if everything is fixed, when I have an open popover and I open some modal, wont the popover persists over the modal? If it doesn't and the same logic works for the toasts, I think toasts could go between the modal and the popover, so users would be free to use tooltips and popovers as they want from the toast.

I just think that in no way the toast can have a higher z-index than the tooltip, because as long as toasts usually shows some short timing information, toasts could be well used to show extra timing info. Also, popovers could be used to confirm some toast's action.

@patrickhlauke
Copy link
Member

would be nice to see this in action with a super-basic dynamic example. looking at this "cold", the live region advice seems appropriate (noted a few tweaks). sadly, live regions are quite fickle when it comes to the precise timing...generally, you'll want to keep a container with aria-live="..." "primed" in the document at first, and then inject things (like toasts) into it...generating both at the same time generally confuses browsers/assistive tech, as they don't have enough time to work out/watch the new live region for changes.

@bastienmoulia

This comment has been minimized.

@bastienmoulia
Copy link
Contributor

I made some changes with a fork of this to add theme color, JS example and z-index. Should I do a new PR ?
bastienmoulia@a94aeac

@guillaumewrobel

This comment has been minimized.

@Johann-S
Copy link
Member

Johann-S commented Aug 23, 2018

Hi @mdo, I updated your branch because I work on a small plugins for the Toastr

  • Create Toast plugin
  • Unit test
  • Documentation

@Johann-S Johann-S force-pushed the boom-toasted branch 2 times, most recently from 8681a10 to 223c72c Compare August 23, 2018 17:29
@XhmikosR

This comment has been minimized.

@XhmikosR

This comment has been minimized.

Copy link
Member

@patrickhlauke patrickhlauke left a comment

Choose a reason for hiding this comment

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

This LGTM. Only thing I'd maybe change is remove holder.js and use something like:

<span class="rounded mr-2 d-block bg-primary" style="width: 20px; height: 20px;" aria-hidden="true"></span>

Not sure if we need aria-hidden or not there, though.

if there's nothing there, you don't need to hide it no

@XhmikosR

This comment has been minimized.

@XhmikosR
Copy link
Member

@patrickhlauke: I added your suggested text changes. If you could add the remaining aria-related suggestions we could merge this soon after a cleanup.

@mdo mdo requested review from a team as code owners November 3, 2018 18:47
@mdo
Copy link
Member Author

mdo commented Nov 3, 2018

Some some docs changes, but I went and updated the aria roles. May have done too many of those? @patrickhlauke's comments mentioned polite, but the rest were assertive—which is it?

@XhmikosR XhmikosR force-pushed the boom-toasted branch 2 times, most recently from ec3d4a1 to e1d148b Compare November 11, 2018 09:28
@mdo mdo mentioned this pull request Nov 11, 2018
mdo and others added 8 commits November 13, 2018 08:30
Also remove close button everywhere just let it when autohide is set to false
- Add headings to examples section
- Clarify styles and customization options in examples
- Add dismiss buttons to all toasts
- Missing period added for consistency
- Update roles, tweak text
@XhmikosR XhmikosR merged commit fceee8d into v4-dev Nov 13, 2018
@XhmikosR XhmikosR deleted the boom-toasted branch November 13, 2018 06:47
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.