Skip to content

Commit da55f2d

Browse files
committed
highlighted today timeline
1 parent d76daa3 commit da55f2d

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/components/AllDayBar.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import { useEventModal } from '@/composables/modals/useEventModal';
33
import type { CalendarEvent } from '@/types/core';
44
import { getCurrentViewDatetime } from '@/utils';
5+
import { DateTime } from 'luxon';
56
import { computed } from 'vue';
67
import { useRoute } from 'vue-router';
7-
import AllDayEvent from './AllDayEvent.vue';
8+
import AllDayEvent from '@/components/AllDayEvent.vue';
89
import { getTag } from '@/services/calendarCache';
910
1011
const route = useRoute();
@@ -20,6 +21,20 @@ const props = defineProps<{
2021
// Must be computed so route changes properly invalidate compEvents
2122
const currentDate = computed(() => getCurrentViewDatetime(route.params).startOf('day'));
2223
24+
const todayGridColumn = computed(() => {
25+
const today = DateTime.now()
26+
.setZone(currentDate.value.zoneName ?? undefined)
27+
.startOf('day');
28+
29+
for (let i = 0; i < props.numOfDays; i++) {
30+
if (currentDate.value.plus({ days: i }).hasSame(today, 'day')) {
31+
return `${i + 1} / span 1`;
32+
}
33+
}
34+
35+
return '';
36+
});
37+
2338
const compEvents = computed(() => {
2439
const date = currentDate.value;
2540
@@ -76,11 +91,13 @@ const compEvents = computed(() => {
7691
:color="getTag(v.event.calendar, v.event.tagId ?? '')?.color"
7792
@click="eventModal.open(v.event)"
7893
/>
94+
<div v-if="todayGridColumn" class="today-highlighter" :style="{ gridColumn: todayGridColumn }" />
7995
</div>
8096
</template>
8197

8298
<style scoped>
8399
#allday-bar {
100+
position: relative;
84101
display: grid;
85102
grid-template-columns: repeat(v-bind('props.numOfDays'), minmax(0, 1fr));
86103
grid-auto-rows: 1.2rem;
@@ -90,4 +107,14 @@ const compEvents = computed(() => {
90107
gap: 2.5px;
91108
padding-bottom: 1.5%;
92109
}
110+
111+
.today-highlighter {
112+
position: absolute;
113+
top: 0;
114+
bottom: 0;
115+
left: -1px;
116+
right: -1px;
117+
background-color: color-mix(in srgb, var(--git-color-real) 8%, transparent);
118+
pointer-events: none;
119+
}
93120
</style>

src/components/timeline/DayTimeline.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ const { drag, placeholderTop, placeholderHeight, placeholderSubtitle, dragStart
211211
touch-action: none;
212212
user-select: none;
213213
-webkit-user-select: none;
214+
215+
&:has(.today-highlight) {
216+
background-color: color-mix(in srgb, var(--git-color-real) 8%, transparent);
217+
}
214218
}
215219
216220
.timeline-grid {

0 commit comments

Comments
 (0)