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

Place a scrollable button to the top of the page #2243

Merged
merged 13 commits into from
Feb 23, 2021

Conversation

kazuhitonakayama
Copy link
Contributor

@kazuhitonakayama kazuhitonakayama commented Dec 20, 2020

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

スクリーンショット 2020-12-20 17 26 34

After

When you scroll 100px, its scroll button will be displayed.
スクリーンショット 2020-12-20 17 24 42

Check off the following:

  • All of the tests are passing.
  • I have reviewed my changes in staging. (look for the deploy-to-heroku link in your pull request, then click View deployment)
  • For content changes, I have reviewed the localization checklist
  • For content changes, I have reviewed the Content style guide for GitHub Docs.

@welcome
Copy link

welcome bot commented Dec 20, 2020

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.

@janiceilene
Copy link
Contributor

@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 💖

@kazuhitonakayama
Copy link
Contributor Author

@janiceilene
Thank you for your comment...!✨
Ok! I see that.
I will code and complete the pull request as soon as possible. And I will tell you about it.!

When a site is viewed from a smartphone or other device, the absence of the relevant button may cause difficulty for users.
@kazuhitonakayama kazuhitonakayama marked this pull request as ready for review December 25, 2020 06:34
@kazuhitonakayama kazuhitonakayama requested a review from a team as a code owner December 25, 2020 06:34
@kazuhitonakayama
Copy link
Contributor Author

@janiceilene
My apologies for the delay in getting the PR done!
It's finally done, so please Review🙇‍♂️🙇‍♂️🙇‍♂️

@janiceilene janiceilene added the engineering Will involve Docs Engineering label Dec 28, 2020
Copy link
Contributor

@JasonEtco JasonEtco left a 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!

<div href="" class="arrow-for-scrolling-top" id="js-scroll-top">
<span class="arrow"></span>
</div>
{% include scripts %}
Copy link
Contributor

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!

Suggested change
{% include scripts %}

Copy link
Contributor Author

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 %}

Comment on lines 1 to 3
<div href="" class="arrow-for-scrolling-top" id="js-scroll-top">
<span class="arrow"></span>
</div>
Copy link
Contributor

@JasonEtco JasonEtco Dec 28, 2020

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!

Suggested change
<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.

Copy link
Contributor Author

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!

Comment on lines +12 to +19
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')
}
})
Copy link
Contributor

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 👏

Copy link
Contributor Author

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✨

Comment on lines 4 to 7
-webkit-transition:1s;
-moz-transition:1s;
-ms-transition:1s;
-o-transition:1s;
Copy link
Contributor

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!

Copy link
Contributor Author

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

@simpsoka
Copy link
Contributor

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2021

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.

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Jan 4, 2021
@JasonEtco JasonEtco removed the stale There is no recent activity on this issue or pull request label Jan 4, 2021
@kazuhitonakayama
Copy link
Contributor Author

Thank you for your comments!!

@chiedo chiedo added the never-stale Do not close as stale label Jan 8, 2021
@chiedo chiedo removed the never-stale Do not close as stale label Jan 26, 2021
@janiceilene janiceilene added the waiting for review Issue/PR is waiting for a writer's review label Feb 5, 2021
@chiedo chiedo removed the waiting for review Issue/PR is waiting for a writer's review label Feb 9, 2021
@kazuhitonakayama kazuhitonakayama force-pushed the add-button-for-scrolling-to-top branch 2 times, most recently from f3aebd7 to 389fde5 Compare February 11, 2021 09:03
@kazuhitonakayama kazuhitonakayama requested a review from a team as a code owner February 11, 2021 09:16
Copy link
Contributor

@github-actions github-actions bot left a 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. :octocat:

@janiceilene janiceilene added the waiting for review Issue/PR is waiting for a writer's review label Feb 18, 2021
@Alyana38
Copy link

Благодарю за поддержку!были трудности с переводом страница,и случайно нажаты не те клавиши!ребята вы большие молодцы!!А я только учусь,не ругайте пожалуйста 😊

heiskr
heiskr previously approved these changes Feb 22, 2021
Copy link
Contributor

@heiskr heiskr left a 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;
Copy link
Contributor

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 heiskr disabled auto-merge February 22, 2021 23:02
@chiedo chiedo assigned heiskr and unassigned JasonEtco Feb 23, 2021
@heiskr heiskr dismissed stale reviews from ghost and themself via bae890e February 23, 2021 16:51
heiskr
heiskr previously approved these changes Feb 23, 2021
@heiskr heiskr added ready to merge This pull request is ready to merge and removed waiting for review Issue/PR is waiting for a writer's review labels Feb 23, 2021
@heiskr heiskr disabled auto-merge February 23, 2021 18:18
@heiskr heiskr merged commit bf31f3e into github:main Feb 23, 2021
@kazuhitonakayama
Copy link
Contributor Author

@heiskr
I apologize for not being able to complete the project. Also, thank you very much for fixing and merging the code.🙇‍♂️

@janiceilene
Copy link
Contributor

@kazuhitonakayama I love the button 👏 Thank you so much for all the work you were able to put in 💝

@kazuhitonakayama
Copy link
Contributor Author

@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!

@Abhishek577270
Copy link

Hello world

@kazuhitonakayama kazuhitonakayama deleted the add-button-for-scrolling-to-top branch April 29, 2023 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering Will involve Docs Engineering ready to merge This pull request is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants