-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat: create a button top #242
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const button = document.querySelector(".button-up"); | ||
|
||
const showButtonIfScroll = () => { | ||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | ||
button.style.display = "block"; | ||
} else { | ||
button.style.display = "none"; | ||
} | ||
}; | ||
|
||
const scrollToTop = () => { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: "smooth", | ||
}); | ||
}; | ||
|
||
button.addEventListener("click", scrollToTop); | ||
window.onscroll = () => showButtonIfScroll(); |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||
@import "variables" | ||||||||
|
||||||||
.button-up | ||||||||
background-color: $primary-500 | ||||||||
color: $white | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ao invés de usar Cor pro tema claro:
Cor pro tema escuro: diciotech/assets/sass/dark_theme.sass Line 8 in b094b87
Como usar a variável: diciotech/assets/sass/cookies.sass Line 5 in b094b87
|
||||||||
border: none | ||||||||
border-radius: 5px | ||||||||
padding: 10px 20px | ||||||||
cursor: pointer | ||||||||
position: fixed | ||||||||
top: 90% | ||||||||
right: 20px | ||||||||
display: none |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -16,6 +16,7 @@ | |||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||||
<link rel="stylesheet" href="assets/css/style.css" /> | ||||
<link rel="stylesheet" href="assets/css/button_up.css" /> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. É melhor adicionar o diciotech/assets/sass/style.sass Line 5 in b094b87
|
||||
|
||||
<!-- Phosphor Icons --> | ||||
<script src="https://unpkg.com/@phosphor-icons/web"></script> | ||||
|
@@ -83,9 +84,14 @@ <h2 class="header__subtitle"> | |||
</div> | ||||
</div> | ||||
</div> | ||||
<button class="button-up"> | ||||
Topo | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Só uma opinião, será que é necessária a palavra There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @george-gca @esterfania minha única preocupação em não ter nenhum texto é que incluir a palavra "topo" pode ser mais claro para usuários menos familiarizados com ícones, mas acredito que como essa setinha pra voltar ao topo da página é bem comum, pode não ser um grande problema. |
||||
<i class="ph ph-arrow-up"></i> | ||||
</button> | ||||
</main> | ||||
<script src="assets/js/script.js" type="module"></script> | ||||
<script src="assets/js/cookies.js" type="module"></script> | ||||
<script src="assets/js/scrollToTop.js" type="module"></script> | ||||
</body> | ||||
|
||||
</html> | ||||
</html> |
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.
Acho que o nome
button_top
ou atéscroll_to_top
é melhor. Ou talvez até adicionar isso ao assets/sass/style.sass já que é pouca coisa, não?