Skip to content

Commit

Permalink
feat: exposes gotoPeriod method to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelR1998 committed Nov 30, 2023
1 parent 170d759 commit e75f3b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Qalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</Transition>

<AppHeader
ref="appHeader"
:key="wasInitialized + mode"
:config="config"
:mode="mode"
Expand Down Expand Up @@ -335,7 +336,11 @@ export default defineComponent({
handleDateWasClicked(payload: string) {
this.$emit('day-was-clicked', payload); // TODO: remove with v4. day-was-clicked is deprecated
this.$emit('date-was-clicked', payload);
}
},
goToPeriod(direction: 'previous' | 'next') {
(this.$refs.appHeader as typeof AppHeader).goToPeriod(direction);
},
},
});
</script>
Expand Down
6 changes: 3 additions & 3 deletions src/components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<FontAwesomeIcon
class="calendar-header__chevron-arrow calendar-header__chevron-arrow-left"
:icon="icons.chevronLeft"
@click="goToPeriod($event, 'previous')"
@click="goToPeriod('previous')"
/>

<FontAwesomeIcon
class="calendar-header__chevron-arrow calendar-header__chevron-arrow-right"
:icon="icons.chevronRight"
@click="goToPeriod($event, 'next')"
@click="goToPeriod('next')"
/>
</div>

Expand Down Expand Up @@ -188,7 +188,7 @@ export default defineComponent({
this.$emit('updated-period', value);
},
goToPeriod(event: MouseEvent, direction: 'previous' | 'next') {
goToPeriod(direction: 'previous' | 'next') {
(this.$refs.periodSelect as typeof DatePicker).goToPeriod(direction);
},
}
Expand Down

0 comments on commit e75f3b4

Please sign in to comment.