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

Notification / messaging guidelines #693

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

lukasoppermann
Copy link
Contributor

This PR is a WIP to define guidelines for banner / toast and alert usage.


**Highlights**: bring attention to how and why to engage with a feature
**Feedback**: Communicates the result of a user action (subitting a form, toggling a setting, etc.) Feedback can be positive, negative, or a warning. Feedback is shown in either a **Banner** or **Inline message**. For forms, an inline message is used for individual field validation which may be combined with a banner if multiple fields have errors. Banners are typically placed near the top of the page, but still within the body content. Inline messages are placed near the action they are related to.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure where this belongs, but I think it's important to emphasize that feedback is placed near the source where possible. For example:

  • A form error summary should be placed right above the form it relates.
  • If we want to communicate that a user action failed, the feedback should be placed near where the action was taken rather than all the way at the top of the page (especially if this feedback is shown async).

This will help improve discoverability of the feedback for everyone!

In our Rails pages, a lot of feedback is shown on page reload above the <main> content, but I think this is a pattern we can move away from in our React pages/async interactions.


**Updates**: inform the user of necessary updates or changes to the product as it relates to them.
**Awareness**: Communicates information that is relevant to the user but not necessarily related to an action they've taken. This type of message is typically used to provide context or additional information about a feature or product. A **Callout** might be used to suggest an action or helpful tip, while a **Popover** is typically used to announce a new feature and offers a link to learn more.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we warn that Callout and Banners usage should be reserved/limited on a page?

Plaintext can be used for most information. There's also, just a typical plaintext form caption for providing supplementary information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. I could see some guidelines like this:

  • avoid using callouts and banners next to each other if possible
  • never use multiple callouts after each other

I don't really know how we could create a rule to create a hard limit. I think guidelines is the best we can do, but please let me know if you have ideas for more precise rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm yeah, I'm not quite what the precise rule should be, but I like your suggested guidelines to start with!

On the tooling side, we could consider creating a custom axe rule that flags when there's like.. more than X number of callouts and banners on a given page, or when there are directly adjacent banners/callouts in the DOM.

- the system is experiencing temporary problems that impact the quality of service but do not make working completly impossible


### Error
Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen "danger"/red variant used to communicate when an action is super destructive or something needs immediate attention. Is that appropriate, and would that fall under this state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question.

One the one side, technically it would be invalid because it is not an error state it is a warning state.
On the other side it is a pattern our users have grown accustomed too, so it may be dangerous to change this.

@langermank what do you think?

I feel like it would make sense to extend this definition to include destructive actions, this is also why we use the danger button, which is red as well.

langermank and others added 2 commits January 3, 2024 16:42
Co-authored-by: Lukas Oppermann <lukasoppermann@github.com>
Co-authored-by: Lukas Oppermann <lukasoppermann@github.com>
langermank and others added 2 commits January 4, 2024 08:46
Co-authored-by: Lukas Oppermann <lukasoppermann@github.com>
Co-authored-by: Lukas Oppermann <lukasoppermann@github.com>
@lukasoppermann lukasoppermann changed the title Update messaging.mdx ıanner / Toast guidelines / documentation Jan 9, 2024
@lukasoppermann lukasoppermann changed the title ıanner / Toast guidelines / documentation Banner / Toast guidelines / documentation Jan 9, 2024
@@ -7,25 +7,157 @@ import {Box} from '@primer/react'

Primer includes three different messaging components:
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to rethink the purpose of this page. "Messaging" is a very broad term that includes more than the listed components. You already removed "Popover", which makes sense to me. Maybe it would help to further scope this to "Notifications". For example:

Notifications play a crucial role in communicating with users and offering feedback. They vary from detailed, inline reactions to specific user actions, to broader messages that span across the system.

(image of banner in context)
(image of inline message in context)

### Unavailable
Copy link
Contributor

Choose a reason for hiding this comment

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

The degraded experience where no content is shown is sort of an empty state. Data exists but could not be loaded. I wouldn't consider that a system notification respectively, it's documented as part of the existing degraded experience docs already and in the scope of notifications, it doesn't fit. It would fit if it's "messaging" though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't agree that this is not related to messaging. I think it makes sense to at least mention it in these docs and link to degraded experience docs, as I have below.

Copy link
Member

Choose a reason for hiding this comment

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

We might not need explicit UI elements to show it though. Visual treatment could be added to existing UI to show that data has failed to fetch (e.g. we use spinners to show data is loading, we could provide a new UI pattern that shows data has failed to load that is similar to a spinner, such as an X) - such treatment would be discrete from a banner, and more specific.

- _Flash alerts are best suited for this type of messaging._
(image here)

## Message states
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make this a table for easier overview/consumption? For example something like this:

Status Usage Action Color Icon
Informational Used for non-critical context and information. Examples: view impacts, feature prompts, ongoing processes. Can be dismissed or left to persist based on the significance of the information. Blue info
Success Indicates task completion or successful actions. Examples: confirmation of saved settings, successful issue transfers. Can be dismissed or remain in view without intruding. Green check-circle
Warning Alerts users to potential issues or impactful changes. Examples: important settings, possible connectivity concerns. Requires acknowledgement, often remains visible until the user responds. Yellow alert
Error/Critical Signals critical errors, system failures, or necessary destructive actions. Examples: form submission errors, critical confirmations. Stays visible until the user addresses the issue or completes the required action. Red stop

- [Banner](../components/flash)
- [Popover](../components/popover)
- Toast
- Callout
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say that Callout is not a way to notify users, it's about emphasizing content. I would mention it as part of Banner and refer to it, but wouldn't want to confuse to use it for notifications (unless this page continues to be about all things messaging but it's getting a lot).

Copy link
Contributor

@ichelsea ichelsea left a comment

Choose a reason for hiding this comment

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

Some small comments here as a first pass.

It's a bit harder to review guidance for banners/toasts until we're sure that we want to allow for toasts. I agree with the confusion on callout vs banner though. In general I think more images and examples will help this!

content/ui-patterns/messaging.mdx Outdated Show resolved Hide resolved
Comment on lines +122 to +126
### Visual treatment

Primer offers five states for messaging components: info, warning, success, unavailable, and critical. Each state has a corresponding icon and color combination to help communicate the message's intent.

Icons sized at 14px and above utilize the outline variant, while smaller icons utilize the filled variant.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move the section up to the top of message states since the image is relevant to this section and it also helps people visualize as they go through each of the states

content/ui-patterns/messaging.mdx Outdated Show resolved Hide resolved
content/ui-patterns/messaging.mdx Outdated Show resolved Hide resolved
lukasoppermann and others added 3 commits January 15, 2024 16:35
Co-authored-by: Chelsea Adelman <40274682+ichelsea@users.noreply.github.com>
Co-authored-by: Chelsea Adelman <40274682+ichelsea@users.noreply.github.com>
Co-authored-by: Chelsea Adelman <40274682+ichelsea@users.noreply.github.com>

Examples:
- a setting that impacts the current view
- a nudge towards a new feature
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
- a nudge towards a new feature

A marketing banner should be used instead.

@lukasoppermann
Copy link
Contributor Author

lukasoppermann commented Jan 17, 2024

One big issue we have is that users are not sure which state to use. So, I am trying to define the differences here.

State Use case Examples
Critical Inform user about an error that occurs or an action they are about to perform that results in lost access or content - an error occurred
- the action deletes content irreversibly (e.g. delete repo)
- the action removes access irreversibly (e.g. transfer repo)
Warning Warn users of side-effect of an action they are about to take or if something happens they may not know about which results in a specific state - an action will incur costs as a side-effect
- an action will have additional side-effects, e.g. changing visibility will reset repo url
- part of a search query is invalid and will be ignored, but the search continues with the rest of the query
- informing about an upcoming change that requires your attention as you need to change something to not lose access / have problems
Success Informs about successfully completing action. - content was saved and it is not easily apparent in the UI
- export is ready
- item was created (if not visible in UI)
Info Use to highlight important information that has an influence on the current view or offers an action - some items are hidden due to filters / config that is controlled on a different page / settings file
- an action is possible / suggested due to outer circumstances (e.g. a review is requested)
- an action is restricted due to not having the correct plan (e.g. upgrade to use copilot)

@langermank langermank marked this pull request as ready for review January 17, 2024 19:35
@langermank langermank requested a review from a team as a code owner January 17, 2024 19:35
@langermank langermank marked this pull request as draft January 17, 2024 19:35
Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Some initial thoughts


**Highlights**: bring attention to how and why to engage with a feature
**Feedback**: Communicates the result of a user action (submitting a form, toggling a setting, etc.) Feedback can be positive, negative, or a warning. Feedback is shown in either a **Banner** or **Inline message**. For forms, an inline message is used for individual field validation which may be combined with a banner if multiple fields have errors. Banners are placed at the top of the page or section they are related to, but still within the body content. Inline messages are placed near the action they are related to.
Copy link
Member

Choose a reason for hiding this comment

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

Why would a banner be preferred over, say, multiple inline messages?

Use the `info` state to highlight messages that help users complete a task or that provide additional context. This state is only used for information that is not critical to the user's experience.

Examples:
- a setting that impacts the current view
Copy link
Member

Choose a reason for hiding this comment

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

Where could this be seen? I am imagining this is part of a form? Is this complementary info in a form field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily a form like you'd imagine. It could be information on any page that helps you perform the action by understanding what you are doing. Or by explaining why you may not see something you expect to see (e.g. you have a settings file that hides it.)

Examples:
- a setting that impacts the current view
- a nudge towards a new feature
- a process is in progress
Copy link
Member

Choose a reason for hiding this comment

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

Why would a banner or toast be used instead of a spinner or interstitial page, or are they included in this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you are referring to the last point:

  • a process is in progress

If a loading spinner works, this is preferred. But sometimes there may be a need to show a message as well. Either one that includes the loading spinner or if the process is running for a long time and the user may leave the page and come back. In those cases, info would be the correct state.

Maybe you have an idea of how to better write this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I've ever seen an interstitial page at GitHub 😆 we'll try and add an image for this one

Copy link
Member

@keithamus keithamus Jan 19, 2024

Choose a reason for hiding this comment

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

Kooha-2024-01-19-09-34-10.webm

A screenshot of that page:

<img
width="960"
alt="draft wip"
src="https://github.com/primer/css/assets/18661030/3fa52b6d-7e33-4f27-b0ec-d836375fe21a"
Copy link
Member

Choose a reason for hiding this comment

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

This flow chart lacks a lot of nuance. I worry people may make a distinction that feature announcements are one bucket, and any other messaging falls in the bucket of banner. In reality we'd want to steer engineers away from banners as much as possible, and more toward inline messaging.

content/ui-patterns/messaging.mdx Show resolved Hide resolved

### Success

Use the `success` state to notify users that the results of an action were successful if it is not apparent from the UI.
Copy link
Member

Choose a reason for hiding this comment

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

If it is not apparent from the UI already, maybe there could be guidance on how it could be made apparent from the UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel this is not the correct page for this kind of guidance. If we have this somewhere or add this (great idea) we could link it.

However it is not always possible to make it apparent in the UI.

Use the `success` state to notify users that the results of an action were successful if it is not apparent from the UI.

Examples:
- saving an account setting if its otherwise not clear the save has taken place
Copy link
Member

Choose a reason for hiding this comment

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

This sounds like poor UX. It should be evident, without the need for a banner/toast, that a change I have made has been propagated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not always simple, e.g. when saving on a settings page with a text field, we don't redirect. So, it visually looks the same after the save.

I am actually not sure this really is poor UX or to put it a different way, I have no immediate solution that is better.

(image of banner in context)
(image of inline message in context)

### Unavailable
Copy link
Member

Choose a reason for hiding this comment

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

We might not need explicit UI elements to show it though. Visual treatment could be added to existing UI to show that data has failed to fetch (e.g. we use spinners to show data is loading, we could provide a new UI pattern that shows data has failed to load that is similar to a spinner, such as an X) - such treatment would be discrete from a banner, and more specific.

content/ui-patterns/messaging.mdx Show resolved Hide resolved
content/ui-patterns/messaging.mdx Show resolved Hide resolved
@lukasoppermann lukasoppermann removed their assignment Mar 22, 2024
@lukasoppermann lukasoppermann changed the title Banner / Toast guidelines / documentation Notification / messaging guidelines Mar 27, 2024
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.

None yet

6 participants