Implements color clues for history navigation arrows (#1579)

Co-authored-by: Preston <freetubeapp@protonmail.com>
This commit is contained in:
Jason 2021-09-16 22:58:03 +00:00 committed by GitHub
parent 65c2cc091d
commit 59828a101d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 4 deletions

View File

@ -138,6 +138,10 @@ export default Vue.extend({
this.checkForNewBlogPosts() this.checkForNewBlogPosts()
}, 500) }, 500)
}) })
this.$router.afterEach((to, from) => {
this.$refs.topNav.navigateHistory()
})
}) })
}, },
methods: { methods: {
@ -278,10 +282,10 @@ export default Vue.extend({
if (event.altKey) { if (event.altKey) {
switch (event.code) { switch (event.code) {
case 'ArrowRight': case 'ArrowRight':
window.history.forward() this.$refs.topNav.historyForward()
break break
case 'ArrowLeft': case 'ArrowLeft':
window.history.back() this.$refs.topNav.historyBack()
break break
} }
} }

View File

@ -20,6 +20,8 @@ export default Vue.extend({
windowWidth: 0, windowWidth: 0,
showFilters: false, showFilters: false,
searchFilterValueChanged: false, searchFilterValueChanged: false,
historyIndex: 1,
isForwardOrBack: false,
searchSuggestionsDataList: [] searchSuggestionsDataList: []
} }
}, },
@ -257,12 +259,41 @@ export default Vue.extend({
this.searchFilterValueChanged = filterValueChanged this.searchFilterValueChanged = filterValueChanged
}, },
navigateHistory: function() {
if (!this.isForwardOrBack) {
this.historyIndex = window.history.length
$('#historyArrowBack').removeClass('fa-arrow-left')
$('#historyArrowForward').addClass('fa-arrow-right')
} else {
this.isForwardOrBack = false
}
},
historyBack: function () { historyBack: function () {
this.isForwardOrBack = true
window.history.back() window.history.back()
if (this.historyIndex > 1) {
this.historyIndex--
$('#historyArrowForward').removeClass('fa-arrow-right')
if (this.historyIndex === 1) {
$('#historyArrowBack').addClass('fa-arrow-left')
}
}
}, },
historyForward: function () { historyForward: function () {
this.isForwardOrBack = true
window.history.forward() window.history.forward()
if (this.historyIndex < window.history.length) {
this.historyIndex++
$('#historyArrowBack').removeClass('fa-arrow-left')
if (this.historyIndex === window.history.length) {
$('#historyArrowForward').addClass('fa-arrow-right')
}
}
}, },
toggleSideNav: function () { toggleSideNav: function () {

View File

@ -38,6 +38,12 @@
width: 1em width: 1em
height: 1em height: 1em
&.fa-arrow-left, &.fa-arrow-right
color: gray
opacity: 0.5
pointer-events: none
user-select: none
@include top-nav-is-colored @include top-nav-is-colored
color: var(--text-with-main-color) color: var(--text-with-main-color)

View File

@ -13,7 +13,8 @@
@keypress="toggleSideNav" @keypress="toggleSideNav"
/> />
<font-awesome-icon <font-awesome-icon
class="navBackIcon navIcon" id="historyArrowBack"
class="navBackIcon navIcon fa-arrow-left"
icon="arrow-left" icon="arrow-left"
role="button" role="button"
tabindex="0" tabindex="0"
@ -22,7 +23,8 @@
@keypress="historyBack" @keypress="historyBack"
/> />
<font-awesome-icon <font-awesome-icon
class="navForwardIcon navIcon" id="historyArrowForward"
class="navForwardIcon navIcon fa-arrow-right"
icon="arrow-right" icon="arrow-right"
role="button" role="button"
tabindex="0" tabindex="0"