Skip to content

Commit d609b5b

Browse files
authored
Merge pull request #3 from vicdotexe/defaultEventProperties
feat: default event properties
2 parents 5477ac8 + 9c6cb5c commit d609b5b

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

dev/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@event-created="onEventCreation"
1111
@event-clicked="(e) => console.log(e)"
1212
:concurrency-mode="'stack'"
13+
:default-event-properties="{ color: 'grey' }"
1314
>
1415
<template #calendarEvent="{ event }">
1516
<div
@@ -21,6 +22,7 @@
2122
}"
2223
>
2324
<div>
25+
{{ event.color }}
2426
{{ format(event.startDate, "HH:mm") }} -
2527
{{ format(event.endDate, "HH:mm") }}
2628
</div>
@@ -145,7 +147,6 @@ function onEventCreation(event: CalendarEvent) {
145147

146148
<style scoped lang="scss">
147149
.material-card {
148-
background-color: white;
149150
border-radius: 4px;
150151
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.1);
151152
padding: 0.5rem;

src/components/EventCalendar.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
:scrollToHour="scrollToHour"
3030
:concurrency-mode="concurrencyMode"
3131
:hours-past-midnight="hoursPastMidnight"
32+
:default-event-properties="defaultEventProperties"
3233
@event-created="emit('event-created', $event)"
3334
@event-clicked="emit('event-clicked', $event)"
3435
@event-updated="emit('event-updated', $event)"
@@ -76,6 +77,7 @@ withDefaults(
7677
scrollToHour?: number;
7778
concurrencyMode?: "stack" | "split";
7879
hoursPastMidnight?: number;
80+
defaultEventProperties?: Partial<CalendarEvent>;
7981
}>(),
8082
{
8183
hideWeekends: false,

src/components/Week.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const props = defineProps<{
206206
scrollToHour: number;
207207
concurrencyMode: "stack" | "split";
208208
hoursPastMidnight: number;
209+
defaultEventProperties?: Partial<$CalendarEvent>;
209210
}>();
210211
211212
let startY = 0;
@@ -400,7 +401,9 @@ function createEvent() {
400401
}
401402
402403
let event: $CalendarEvent = reactive({
403-
id: guid(),
404+
id: props.defaultEventProperties?.id ?? guid(),
405+
description: props.defaultEventProperties?.description,
406+
color: props.defaultEventProperties?.color ?? "#2196f3",
404407
startDate: start,
405408
endDate: addMinutes(start, props.intervalMinutes),
406409
nOfPreviousConcurrentEvents: 0,

0 commit comments

Comments
 (0)