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

Create a "Back to Top" Block #50433

Open
beafialho opened this issue May 8, 2023 · 8 comments
Open

Create a "Back to Top" Block #50433

beafialho opened this issue May 8, 2023 · 8 comments
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs Dev Ready for, and needs developer efforts Needs Technical Feedback Needs testing from a developer perspective. New Block Suggestion for a new block [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@beafialho
Copy link

What problem does this address?

The popularity of responsive web design has led to a proliferation of single-column, long-page designs both on mobile and desktop. A consequence of these designs has been the Back to Top button, which is a shortcut that allows users to quickly navigate to the top of the page.

What is your proposed solution?

I suggest adding this feature to the site editor, perhaps it makes sense for it to be a block, instead of a hidden feature in the Button block.

I expect it to be fully customisable (colors, typography, background, sticky vs non-sticky, etc) here are a few example designs:

Captura de ecrã 2023-05-08, às 14 52 26

Captura de ecrã 2023-05-08, às 14 55 55

Captura de ecrã 2023-05-08, às 15 06 30

cc: @iamarinoh @iamtakashi @jasmussen

@beafialho beafialho added Needs Design Feedback Needs general design feedback. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels May 8, 2023
@jasmussen
Copy link
Contributor

I like it, I think it's useful and valid, and as combined with sticky positioning as a separate tool, it seems very feasible to do.

Technically it seems a matter of adding <a href="#top">Back to top</a> in a block, with whatever customization options we might want. Digging a little bit, it seems like that should work out of the box in modern browsers, as supposedly they are able to parse the #top location without the need for a named anchor or an ID. But please if I'm incorrect in this, please correct me, as this is an important aspect to be sure of, before starting. If this is not a safe assumption, it's technically a more challenging issue.

@jasmussen jasmussen added the Needs Technical Feedback Needs testing from a developer perspective. label May 8, 2023
@skorasaurus skorasaurus added the New Block Suggestion for a new block label May 9, 2023
@iamtakashi
Copy link

+1. Thanks for opening the issue, @beafialho!

@gziolo
Copy link
Member

gziolo commented May 9, 2023

I wanted to share another use case for the "Top" link:

image

Example page from the WordPress developer portal:

https://developer.wordpress.org/reference/functions/clean_user_cache/

While you could recreate it with the Group block that displays Heading and Top blocks displayed in sma row, it might be pretty inconvenient to repeat it with all headings on the page. Usually, this type of UI elements you see injected with a plugin that either filters HTML or injects HTML with JavaScript.

Aside, there is a discussion about a new concept in #50029 - Block Behaviors. The scope is still not fully defined, but the idea is that not everything on the page needs to be a block.

@ramonjd
Copy link
Member

ramonjd commented May 10, 2023

Digging a little bit, it seems like that should work out of the box in modern browsers, as supposedly they are able to parse the #top location without the need for a named anchor or an ID. But please if I'm incorrect in this, please correct me, as this is an important aspect to be sure of, before starting. If this is not a safe assumption, it's technically a more challenging issue.

I like this idea.

Seems like the assumption is pretty accurate!

https://caniuse.com/?search=%23top
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#sect6

If we wanted to get tricky we could have a smooth scroll option as well (might require a bit of JS).

@carolinan
Copy link
Contributor

Another reason to allow users to upload svgs so that the icon can be customized...

@jasmussen
Copy link
Contributor

Awesome, thanks for all the feedback!

I'm going to assume that the designs provided are sufficient for a dev to pick this one up. I'm thinking a first version can just be an editable rich text field that defaults to outputting "Back to top", with no inspector options and just regular rich text toolbar options. Any iconography can then be inserted as unicode glyphs (such as ↑) or emoji in the rich text, and hopefully through an "Icon" inline-block or other feature in the future.

But if these do need more design, let me know and we'll put something together.

@jasmussen jasmussen added Needs Dev Ready for, and needs developer efforts and removed Needs Design Feedback Needs general design feedback. labels May 10, 2023
@carolinan carolinan self-assigned this May 10, 2023
@hanneslsm

This comment was marked as outdated.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label May 12, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Jul 19, 2023
@mtias mtias mentioned this issue Aug 2, 2023
65 tasks
@richtabor
Copy link
Member

I think this could be an interesting idea as a standalone block per #58773.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Needs Dev Ready for, and needs developer efforts Needs Technical Feedback Needs testing from a developer perspective. New Block Suggestion for a new block [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants