Skip to content

Commit

Permalink
Scroll to today
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattmann committed Nov 3, 2024
1 parent 0338917 commit 8059636
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@
"title": "Titel"
},
"noEntries": "Keine Aktivitäten gefunden. Versuche die Filter zu entfernen oder lade die Seite neu.",
"today": "Heute",
"welcome": "Willkommen in deinem neuen Lager. Es sind noch keine Aktivitäten erfasst. "
},
"invitation": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@
"title": "Title"
},
"noEntries": "No activities found. Try clearing the selection filters and/or reloading the page.",
"today": "Today",
"welcome": "Welcome to your new camp. There aren't any activities defined yet."
},
"invitation": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@
"title": "Titre"
},
"noEntries": "Aucune activité trouvée. Essaie d'effacer les filtres de sélection et/ou de recharger la page.",
"today": "Aujourd'hui",
"welcome": "Bienvenue dans ton nouveau camp. Il n'y a pas encore d'activités définies."
},
"invitation": {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@
"title": "Titolo"
},
"noEntries": "Non sono state trovate attività. Prova a cancellare i filtri di selezione e/o a ricaricare la pagina.",
"today": "Oggi",
"welcome": "Benvenuto nel tuo nuovo campo. Non ci sono ancora attività definite."
},
"invitation": {
Expand Down
28 changes: 22 additions & 6 deletions frontend/src/views/camp/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<content-card :title="$tc('views.camp.dashboard.activities')" toolbar>
<template #title-actions>
<v-spacer />
<v-btn v-if="today !== null" :icon="true" @click="scrollToToday">
<v-icon>mdi-calendar-today</v-icon>
<v-btn v-if="today !== null" text @click="scrollToToday">
<v-icon left>mdi-calendar-today</v-icon>
{{ $tc('views.camp.dashboard.today') }}
</v-btn>
</template>
<div class="d-flow-root">
Expand Down Expand Up @@ -61,10 +62,11 @@
<template v-if="!periods[uri].days()._meta.loading">
<tbody
v-for="(dayScheduleEntries, dayUri) in periodDays"
:id="days[dayUri].id"
:key="dayUri"
:aria-labelledby="dayUri + 'th'"
>
<tr :ref="days[dayUri].id" class="day-header__row">
<tr class="day-header__row">
<th :id="dayUri + 'th'" colspan="5" scope="colgroup" class="day-header">
<div class="day-header__inner">
{{ dateLong(days[dayUri].start) }}
Expand Down Expand Up @@ -290,9 +292,23 @@ export default {
this.$router.replace({ query }).catch((err) => console.warn(err))
},
scrollToToday() {
const refs = this.$refs[this.today.id]
if (refs.length > 0) {
refs[0].scrollIntoView({ behavior: 'smooth' })
const element = document.getElementById(this.today.id)
if (element) {
const elementPosition = element.getBoundingClientRect().top
let offsetPosition = elementPosition
if (this.$vuetify.breakpoint.mdAndUp) {
offsetPosition = offsetPosition - 50
} else if (this.$vuetify.breakpoint.smAndUp) {
offsetPosition = offsetPosition + 14
} else {
offsetPosition = offsetPosition - 34
}
window.scrollTo({
top: offsetPosition,
behavior: 'smooth',
})
}
},
},
Expand Down

0 comments on commit 8059636

Please sign in to comment.