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

Add 'Back to top' links to main and about pages #135

Merged

Conversation

MikeCoats
Copy link
Contributor

This PR adds a 'back to top' link to the main and about pages. It will appear once you've scrolled down by half a page and will stay overlayed on the screen until you hit the bottom of the page, where it then nestles between the content and the footer. It appears to work well at mobile resolutions and aspect ratios too.

Screenshots

No link at top of page

image

Overlayed link when scrolled down page

image

Inline link when scrolled down page

image

No link at top of page on mobile

image

Overlayed link when scrolled down page on mobile

image

Inline link when scrolled down page on mobile

image

Fixes #97

MikeCoats and others added 5 commits April 30, 2020 15:47
Previously, the app mounted to the `#root` element. The meant that we
couldn't also _really_ use it for back-to-top navigation as the fragment
in the url name would look weird. Instead, this renames the containing
element to `#top` for navigation purposes and we instruct React to mount
via a class based querySelector on the new `.app-root` class.

Issue: UKHSA-Internal#97
This is largly un-styled, but the proof-of-concept for the logic is
there.

Issue: UKHSA-Internal#97
This makes the links only appear on `/` and `/about`.

Issue: UKHSA-Internal#97
This includes making a small, internal-only, component to hold the svg
content for the up arrow and improving the logic on how the overlay and
inline modes made themselves visible.

The back-to-top link SVG, HTML & CSS comes from
https://github.com/alphagov/govuk-design-system/blob/master/views/partials/_back-to-top.njk
and
https://github.com/alphagov/govuk-design-system/blob/master/src/stylesheets/components/_back-to-top.scss
but doesn't appear to be in the `govuk-react-jsx` package, so I included
it directly for simplicity.

Issue: UKHSA-Internal#97
@xenatisch xenatisch self-assigned this May 1, 2020
@xenatisch xenatisch added accessibility Improvements that address accessibility problems enhancement New feature or request labels May 1, 2020
Comment on lines +15 to +17
<svg role="presentation" focusable="false" class="back-to-top" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17">
<path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path>
</svg>Back to top
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice touch!

Copy link
Contributor

@xenatisch xenatisch left a comment

Choose a reason for hiding this comment

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

Needs a couple of docs / comment to clarify the options and the usage to other contributors.

Great job, @MikeCoats. Thank you for the contribution.

src/App.js Outdated Show resolved Hide resolved
src/components/BackToTop/BackToTop.js Show resolved Hide resolved
@MikeCoats
Copy link
Contributor Author

Yeah, no worries. I’ll fire in some more details when I’m back at my computer.

@xenatisch
Copy link
Contributor

How are we doing with the docs / comments @MikeCoats?

I'm hoping to include this PR in the next release tomorrow.

@MikeCoats
Copy link
Contributor Author

MikeCoats commented May 3, 2020 via email

Add javadoc style comments for components and functions and some inline
comments to explain the why, not just the how.

Issue: UKHSA-Internal#97
@MikeCoats
Copy link
Contributor Author

@xenatisch That's the comments added. If they need a bit more clarification, let me know - I'll be WFH from about 8:15-8:30 tomorrow, and I'll update them as quick as I can.

@xenatisch
Copy link
Contributor

@MikeCoats It's all good. Thank you! :)

@xenatisch xenatisch self-requested a review May 3, 2020 23:41
@xenatisch xenatisch merged commit 6fb3b6c into UKHSA-Internal:development May 3, 2020
@xenatisch
Copy link
Contributor

Add a "back to top" link

xenatisch added a commit that referenced this pull request May 5, 2020
Essentials updates and improvements - fixes #79, #80, #125, #128, #134, #135, and #139. 

With thanks to @MikeCoats, @richardTowers, and @dracos for their contributions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Improvements that address accessibility problems enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "back to top" link
4 participants