-
Notifications
You must be signed in to change notification settings - Fork 59.6k
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
Place a scrollable button to the top of the page #2243
Place a scrollable button to the top of the page #2243
Conversation
Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines. |
@kazuhitonakayama Thanks for opening a PR! I see that this is currently a draft, please feel free to let me know when you're ready for this to be put up for review 💖 |
@janiceilene |
When a site is viewed from a smartphone or other device, the absence of the relevant button may cause difficulty for users.
2fd2ee9
to
389fde5
Compare
@janiceilene |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome @kazuhitonakayama 👏 A great idea, and well executed! I left a couple of notes below, please let me know if I can clarify anything.
One other thing - there's a lot of custom CSS here, and that's fine but we can move a lot of it to use Primer's utility classes (like position-fixed
, etc). I can be more specific if that's helpful!
includes/scroll-button.html
Outdated
<div href="" class="arrow-for-scrolling-top" id="js-scroll-top"> | ||
<span class="arrow"></span> | ||
</div> | ||
{% include scripts %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including scripts
here will duplicate them on some pages - do you mind removing this line? For example, in the default
layout its already included via includes/small-footer.html
!
{% include scripts %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JasonEtco
Thank you for your advice!
I remove the including scripts {% include scripts %}
includes/scroll-button.html
Outdated
<div href="" class="arrow-for-scrolling-top" id="js-scroll-top"> | ||
<span class="arrow"></span> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this button a semantic <button>
? That way it follows things like tab ordering, hover/focus/click behavior - all really helpful for screen readers and keyboard controls!
<div href="" class="arrow-for-scrolling-top" id="js-scroll-top"> | |
<span class="arrow"></span> | |
</div> | |
<button class="arrow-for-scrolling-top" id="js-scroll-top"> | |
{% octicon "chevron-up" %} | |
</button> |
This might require some additional style tweaking, but it's worth it!
I also used an Octicon here, so that we use a consistent visual language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JasonEtco
Thank you for your advices🙇♂️
I rewrite 'div' to 'button' and changed to use octicon!
window.addEventListener('scroll', function () { | ||
const y = document.documentElement.scrollTop // get the height from page top | ||
if (y < 100) { | ||
PageTopBtn.classList.remove('show') | ||
} else if (y >= 100) { | ||
PageTopBtn.classList.add('show') | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this! Great addition 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JasonEtco I'm really glad to hear that✨
stylesheets/scroll-button.scss
Outdated
-webkit-transition:1s; | ||
-moz-transition:1s; | ||
-ms-transition:1s; | ||
-o-transition:1s; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can omit the compatibility prefixes, our Webpack pipeline generates those for us!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I omitted the compatibility prefixes🙇♂️
@JasonEtco
Thanks for adding this, @kazuhitonakayama! Curious if there's a way to have this button only shows up if the user has scrolled past a certain point? The example you show has it showing up when the user is already at the top of the page. Ideally, it shows up when you've scrolled past the first fold. |
This PR is stale because it has been open 7 days with no activity and will be automatically closed in 3 days. To keep this PR open, update the PR by adding a comment or pushing a commit. |
Thank you for your comments!! |
f3aebd7
to
389fde5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:
translations/**
lib/rest/static/**
.github/workflows/**
.github/CODEOWNERS
translations/**
assets/fonts/**
data/graphql/**
lib/graphql/**
lib/redirects/**
lib/rest/**
lib/webhooks/**
You'll need to revert all of the files you changed in that list using GitHub Desktop or git checkout origin/main <file name>
. Once you get those files reverted, we can continue with the review process.
8ca202f
to
389fde5
Compare
Благодарю за поддержку!были трудности с переводом страница,и случайно нажаты не те клавиши!ребята вы большие молодцы!!А я только учусь,не ругайте пожалуйста 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it
button.arrow-for-scrolling-top { | ||
opacity: 0; | ||
transition: 1s; | ||
background-color: #0367d6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to use a primer variable
@heiskr |
@kazuhitonakayama I love the button 👏 Thank you so much for all the work you were able to put in 💝 |
@janiceilene So glad to hear that, and to be able to contribute to the Github we all love! |
Hello world |
Why:
When a site is viewed from a smartphone or other device, the absence of the relevant button may cause difficulty for users.
please refer to the issue #1894
What's being changed:
Before
After
When you scroll 100px, its scroll button will be displayed.
Check off the following: