mozilla / protocol

A design system for Mozilla websites.
https://protocol.mozilla.org/
Mozilla Public License 2.0
260 stars 77 forks source link

New Component Request: Back to Top button #825

Open maureenlholland opened 2 years ago

maureenlholland commented 2 years ago

Please describe the use case(s) for this component

On a long page it is useful to have a quick navigate to top option. (see original bedrock issue: https://github.com/mozilla/bedrock/issues/9910)

The button should not appear on pages that are not long enough to need this option

Please provide any designs or previous implementations of the proposed component

back-to-top

potential to use Neutral button styling: https://protocol.mozilla.org/components/detail/button--neutral.html

Please describe what this component does in the following conditions

Please provide examples of this type of component in use in non-Mozilla web properties

Image examples and general best practices here: https://www.nngroup.com/articles/back-to-top/

  1. Use a Back to Top button for pages that are longer than 4 screens.
  2. Place a persistent Back to Top button in the lower right side of the page.
  3. Label the button Back to Top.
  4. Have one sticky Back to Top link per page instead of including multiple links in every section of the page.
  5. Keep the button small so it doesn’t cover important page elements.
  6. Make the button stand out visually on the page rather than blend in.
  7. Consider delaying the appearance of a Back to Top option until after users scroll a few pages AND indicate that they want to scroll up
  8. Make the button stationary.
  9. Let users control scrolling.

Is the development of this component a blocking dependency for other work? Please explain if so

Protocol team has come to consensus on need after discussion on longstanding bedrock issue. It is not blocking but would be a good UX improvement on pages such as https://www.mozilla.org/en-US/firefox/privacy/book/

maureenlholland commented 2 years ago

Couple of open questions:

  1. is 1.5x viewport long enough to wait for trigger to show button or should we follow NN group recommendation of 4x down scroll AND indication user wants to scroll up?
  2. should the page jump to top or scroll to top or choose which of those to do based on user motion pref?
  3. do we want to use "Back to top" text button instead of icon only?
  4. is this a standalone component that can be dropped in any page or an optional feature that is part of the footer component?
reemhamz commented 2 years ago

Thanks for putting this issue together! As for placement of the button, I would vote for having it appear after a certain height of the viewport rather than all the way down in the footer/end of the page. That way, if it's a long page (i.e. State of Moz), the user has the option to scroll all the way to the top when they're a few sections in.