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

[docs] Improve UX with back to top #32896

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented May 25, 2022

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation design This is about UI or UX design, please involve a designer labels May 25, 2022
import useScrollTrigger from '@mui/material/useScrollTrigger';
import Box from '@mui/material/Box';
import Fab from '@mui/material/Fab';
import Tooltip from '@mui/material/Tooltip';
import KeyboardArrowUpRoundedIcon from '@mui/icons-material/KeyboardArrowUpRounded';
import Zoom from '@mui/material/Zoom';
import Fade from '@mui/material/Fade';
Copy link
Member Author

Choose a reason for hiding this comment

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

Replace the Zoom with a Fade animation to fix the broken tooltip animation and to reduce the visual distraction when scrolling

sx={[
{ position: 'fixed', bottom: 24, right: 24, zIndex: 10 },
...(Array.isArray(sx) ? sx : [sx]),
]}
>
<Tooltip title="Scroll to top">
<Fab
color="primary"
Copy link
Member Author

Choose a reason for hiding this comment

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

Change the color of the Fab color to a less distracting color, primary to grey

@@ -248,7 +247,6 @@ export default function MyApp(props) {

return (
<AppWrapper emotionCache={emotionCache} pageProps={pageProps}>
<BackToTop />
Copy link
Member Author

Choose a reason for hiding this comment

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

Move the component to only be visible on the docs pages, having it in https://mui.com/material-ui/getting-started/templates/blog/ feels deceptive, it's not what the template includes

Comment on lines 38 to 39
data-ga-event-category="docs"
data-ga-event-action="click-back-to-top"
Copy link
Member Author

@oliviertassinari oliviertassinari May 25, 2022

Choose a reason for hiding this comment

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

Add ga event to see if it's used at scale (>0.01%)

window.scrollTo({ top: 0, behavior: 'smooth' });
onClick?.(event);
const handleClick = () => {
window.scrollTo({ top: 0 });
Copy link
Member Author

Choose a reason for hiding this comment

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

The pain point this button solve is being able to quickly move back to the top. I assume that making the scroll to top transition instant is helping to better solve the problem.

@mui-bot
Copy link

mui-bot commented May 25, 2022

No bundle size changes

Generated by 🚫 dangerJS against f904ec3

@oliviertassinari oliviertassinari force-pushed the back-to-top-polish branch 3 times, most recently from a839a13 to 5693f06 Compare May 25, 2022 11:13
@oliviertassinari oliviertassinari marked this pull request as ready for review May 25, 2022 11:16
@samuelsycamore
Copy link
Member

I like it! 👍 This will make a big difference on massive pages like the migration guides!

@oliviertassinari
Copy link
Member Author

oliviertassinari commented May 25, 2022

@samuelsycamore Thanks for the feedback, let's wait for Danilo to come back from holiday, it's ultimately about UX, so its core area of ownership.

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Pushed just a couple of styling adjustments-other than that, looking great! Good improvements!

@oliviertassinari
Copy link
Member Author

Rebased on HEAD

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Jun 2, 2022

@danilo-leal Perfect, I have pushed two last commits:

  1. One to migrate the component to TypeScript, we try to write all-new logic with TS rather than JS (Migrate to TypeScript #15984)
  2. One to fix the lagging UX of the tooltip, it always felt like moving behind. It now behaves more closely to https://docs.github.com/en/site-policy. To compare:

Before

Screen.Recording.2022-06-02.at.11.44.29.mov

After

Screen.Recording.2022-06-02.at.11.44.07.mov

@oliviertassinari oliviertassinari merged commit 1021292 into mui:master Jun 3, 2022
@oliviertassinari oliviertassinari deleted the back-to-top-polish branch June 3, 2022 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design This is about UI or UX design, please involve a designer docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants