Skip to content

WP component audit: Modal, Notice, & Snackbar #16726

Closed

Description

@davewhitley

Is your feature request related to a problem? Please describe.

This issue is part of a review on the naming, structure, and composition of the UI components as brought up in #16367

These are the current components that are related to messaging that I considered in this issue:

  • Modal (highest priority, required action)
  • Notice (medium priority, optional action)
  • Snackbar (lowest priority, optional action, or no action)

Reminder: these components are used to communicate app processes to the user, and each one has a certain usage and level of priority.

Modal

Screen Shot 2019-07-15 at 11 12 23 AM

Audit

Opportunities I came across while reviewing this component.

  • See this issue to see why it should be renamed to "Dialog". Modal Component: rename to Dialog #14195
  • Lack of standard modal content and actions.
  • isDismissable was hard to understand at first, with double negatives in the prop description. “closeButton” or “closeIcon” seems more clear to me.

Suggestions

  • Rename component to Dialog.
  • We should add more sub components like DialogTitle, DialogContent, DialogFooter, and DialogButton. This will create more consistent Dialogs and makes it easier to use for adding standard elements.
  • Consider cleaning up the close action prop names (shouldCloseOnEsc, shouldCloseOnClickOutside, isDismissable). We can make all of them enabled by default. Possible new names:
    • disableOutsideClick
    • disableCloseOnEsc
    • disableCloseButton

image

Notice

image

Audit

Opportunities I came across while reviewing this component.

  • Terms like Notice or Alert can be more general and less descriptive.
  • There's seems to be no limit on the number of actions I can provide.
  • isDismissible can be misleading by the description: "whether the notice should be dismissible or not". Even though the icon is not visible, we may provide a dismiss action as one of the action buttons.

Suggestions

  • Rename to "Banner".
  • Banner is more descriptive than notice or alert and reduces confusion with other “messaging” elements. For example, a "Snackbar" could be considered as a type of notice and/or alert.
  • Similar to Snackbar, we should restrict the number of actions to 2 + close icon, instead of an array of actions.

image

Note

There are some missing features of Notice that you'd normally see in WP Admin. We should enhance this component a bit by:

  • Providing an icon option
  • Displaying actions as buttons
  • Providing an option for a title

Inline Banner

Assuming Banners are meant to be displayed at the top of the viewport, I suggest we create an inline variation, similar to Polaris.

Snackbar

image

Audit

Opportunities I came across while reviewing this component.

  • The guidelines restrict the number of actions in a Snackbar, but the component allows me to add many.

Suggestions

  • Add the single action as a prop in the component. This will keep the usage of the Snackbar consistent.
  • Consider consistent of prop naming for when the component is closed (onRemove vs onClose)

Feedback

The feedback I'm looking for is related to naming, structure, and composition. I'm not looking for visual feedback of the components. I'm also not examining each prop for each component; only the ones that I think are relevant for the audit. I know this issue is a lot to take in, and I appreciate any feedback you have.

  • Particularly interested in the rename for Notice to Banner, because it's a rename for an existing component in WP Admin. I'm not sure what implications this may have as these components get more usage outside of the editor.

Activity

  1. davewhitley commented on Jul 23, 2019

    @davewhitley
    ContributorAuthor

    Props audit

    As an addendum, here is a deeper evaluation of the props for these components. This is an effort to expand the components to be more useful and to answer the question, "Are properties well thought out and consistently applied?" This only covers visual props. Event handler props will be evaluated at a later date.

    Dialog

    ✨ New

    • title: like the existing prop it can accept a string, but it can also accept a DialogTitle component. This will allow us to standardize differently styled titles (error, success, warning). Also, we could allow customization of the heading element used (h2, h3, etc.)
    • size: based on current dialog usage, we might need 3 sizes: default, large (media library), and fullscreen.
    • actions: a simple way to include the dialog buttons as an array.

    In addition to those props, there are also the DialogTitle, DialogContent, DialogFooter, and DialogButton components.

    📋 Rename

    • shouldCloseOnEsc → closeOnEscape or disableCloseOnEsc (inverse)
    • shouldCloseOnClickOutside → closeOnClickOutside or disableOutsideClick (inverse)
    • isDismissable → showCloseButton or disableCloseButton (inverse)

    Notice

    ✨ New

    • action: primary action of the notice.
    • secondaryAction: secondary action of the notice.
    • icon: icon to show for the notice.
    • title: title for the notice

    📋 Rename

    • isDismissable → showCloseButton or disableCloseButton (inverse)

    ✂️ Remove

    • actions: consider removing in favor of explicit primary/secondary action props.

    👍 No change

    • status

    Snackbar

    ✨ New

    • action or actionText: action for the snackbar. There should only be one.
    • message: message to show in the snackbar

    ✂️ Remove

    • actions

    Event handler props will be evaluated at a later date.

  2. added
    [Package] Components
    Needs Design Feedback
    Needs Technical Feedback
    [Feature] UI Components
    Needs Accessibility Feedback
    on Jul 23, 2019
  3. mapk commented on May 12, 2020

    @mapk
    Contributor

    I'm closing out the Component Audit issues for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Accessibility FeedbackNeeds Design FeedbackNeeds Technical Feedback[Feature] UI Components[Package] Components

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions