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
Refactor Flash alert #1979
Refactor Flash alert #1979
Conversation
🦋 Changeset detectedLatest commit: 2b59674 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! A few questions but not blocking 🙂
| </div> | ||
| )} | ||
|
|
||
| <div className={clsx('Flash-message')} dangerouslySetInnerHTML={{__html: message}}></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about creating a slot for title and description? The <strong> and <br> feel like something we should handle at the component level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to what @langermank is suggesting here. I think that this could be similar to the Blankslate API where both the title and description are styled based on component classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
src/alerts/flash-refactor.scss
Outdated
| grid-area: actions; | ||
|
|
||
| &:last-child { | ||
| align-self: end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My line of thought was that, for banners with multiple lines and no dismiss button, the call-to-action should be aligned to the end of the message, like: "read the message before looking at the button".
If the banner does have a dismiss button, though, I'm still keeping it aligned to the top. For some reason I was imagining that banners that have a dismiss button have call-to-actions that are not as important, since they can be dismissed 🤔 .
Seeing the banners above with the different alignments can definitely seen as jarring, but these usually don't appear next to each other anyways.
@langermank @simurai Do you think that's too weird? 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the call-to-action should be aligned to the end of the message, like: "read the message before looking at the button".
I see. Yeah, I think that makes sense. Let's give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay to allow for two different action button positions 👍
src/alerts/flash-refactor.scss
Outdated
| border: $border-width $border-style var(--color-accent-muted); | ||
| border-radius: $border-radius; | ||
| grid-auto-flow: column; | ||
| grid-template-areas: 'visual message actions close'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
src/alerts/flash-refactor.scss
Outdated
| align-self: start; | ||
|
|
||
| > .octicon { | ||
| margin-block: calc((#{$spacer-1}) / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oOOooo fancy
src/alerts/flash-refactor.scss
Outdated
| grid-area: actions; | ||
|
|
||
| &:last-child { | ||
| align-self: end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/alerts/flash-refactor.scss
Outdated
|
|
||
| // Replace with Primitives' Narrow viewport range | ||
| @media (max-width: #{map-get($breakpoints, 'md') - 0.02px}) { | ||
| &.Flash--full-whenNarrow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full-whenNarrow 👍 This looks useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simurai I'm already using it for #1898 (Example in Storybook) 🎉 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesss... this, exactly!
src/alerts/flash-refactor.scss
Outdated
| .Flash-visual { | ||
| display: grid; | ||
| // stylelint-disable-next-line primer/spacing | ||
| padding: calc((#{$spacer-5} - 20px) / 2) $spacer-2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to use calc() here and 2 more times below? I think the browser will see it as:
padding: calc((32px - 20px) / 2) 8px;but because they are static px values it won't change. So we could also just use the calculated px value and probably improve performance a tiny bit:
padding: 6px $spacer-2;If it was to get around the stylelint-disable, @jonrohan patched that recently. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simurai I'm getting prepared for the use of functional spacing design tokens (link only available for hubbers). $spacer-5 should be --gh-control-medium-size, and 20px --gh-text-body-medium-lineBoxHeight. This calculation adds any extra padding needed so the 16px octicon gets vertically centered with the first line of text, even in case there are multiple lines.
I'll add this as a comment in the file. 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting prepared for the use of functional spacing design tokens
ahhh.. ok ok, in that case let's keep as is for easier updating later. 👍
| type: 'boolean', | ||
| }, | ||
| }, | ||
| hasCloseButton: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After chatting with @ashygee, I'll rename this to "Dismiss button".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
src/alerts/flash-refactor.scss
Outdated
|
|
||
| // Flash alert | ||
|
|
||
| .Flash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After chatting with @ashygee, we agreed to rename this component to "Alert".
Additionally, @alliethu gave some great insights into how to handle accessibility for it:
A couple alert notes:
- Use
role="alert"by default
- If more than one alert can display at once, use
role="status"so the screen reader doesn’t interrupt itself with the latest message.- Provide a cue for the alert type (info, warning, error, success)
- Visually with an icon
- Audibly using visually hidden text that precedes the alert
- If no dismiss/close button, the alert must be present for a minimum of 5 seconds before dismissing.
- Connect title and description using
aria-describedby
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vdepizzol based on the conversation with @langermank I think that "Banner" is a better name for this component. If we do decide to keep "Alert" though we may want to clarify the difference between this and a Toast notification/alert. I also think we may want to audit the usage of the Toast since this alert styling is much more common across the patterns seen within the GitHub experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashygee just renamed the component to Banner.
I haven't updated the stories with WAI-ARIA considerations because I think these are still in flux. Per instance, there are many existing scenarios1 where role="alert" shouldn't be useful. I think we can polish the accessibility definitions directly in the PVC updates.
Footnotes
-
Link only available to hubbers. ↩
|
@vdepizzol after our conversation we had discussed that the full version of the Banner (Flash) component would be what we currently style as |
So, I'm no longer including a
Eventually a system tray should better support system banners. See #1898. In the meantime, a ✌️ ✌️ ✌️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename Flash to Banner
Was also thinking if it should just be called Alert? But maybe it's still good to keep it as a "category" in case we have other kinds of alerts in the future.
| <p className={clsx('Banner-title')} dangerouslySetInnerHTML={{__html: title}}></p> | ||
| {description && ( | ||
| <> | ||
| <p className={clsx('Banner-description')} dangerouslySetInnerHTML={{__html: description}}></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see Banner-description here but not in the CSS, did you mean to add some styles for this guy?
| margin-bottom: 0; | ||
| } | ||
|
|
||
| .Banner-title:not(:only-child) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever ✨ I guess just delete that description class from the stories and use <p>stuff</p>?
|
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
|
👋 @vdepizzol How do you feel about merging this component and start testing it out in production? |
Is there already a need for this in production? I think the main reason this hasn't shipped is that there is no plan for the PVC implementation yet. And we want to avoid using it with custom markup/HTML. So it would just be un-used CSS for now. |
No rush, curious because some of the problems identified in this thread were reported again when I was first responder |
FWIW, it's been shipped in Figma. |
|
Hey everyone! The PVC team has picked this up, see: primer/view_components#1494 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking for primer/view_components#1494
|
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
|
Closing this again since the |






What are you trying to accomplish?
This PR adds a new
Flashcomponent, meant to eventually replace our existingflashalert. This update aims to fix long standing issues found in it, mainly regarding responsive support.✨ Link to Storybook ✨
Main updates:
A lot of the spacing values used in this refactor are hardcoded, and will benefit from the Primer Primitives spacing update once that's available. (link only available for Hubbers).
What approach did you choose and why?
I've kept the current
flashalert in place, and created a newflash-refactor.scssfile, in a similar fashion to how @langermank has considered the refactor for the Button component (#1874).After all instances of
flashare replaced with this new component (specially after updating its ViewComponent, we can clean up these files.Are additional changes needed?
As described in https://github.com/github/primer/issues/62 (internal to hubbers), some alerts may have multiple buttons. This refactor hasn't addressed for these use cases specifically.
Closes https://github.com/github/primer/issues/154.