File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 2525 const span = $state (' week' );
2626 const spanDays = $derived (span == ' week' ? 7 : _throw (' Invalid span value' ));
2727 const weekDays = $derived (weekDaysFor (start ));
28+ const eventsForWeekDays = $derived (
29+ Object .groupBy (
30+ data .calendars .flatMap (cal => cal .events ?? []),
31+ ev => ev ?.start .getDay ()
32+ )
33+ );
2834
2935 let dialogs = $state <Record <string , HTMLDialogElement >>({});
3036
134140 < / div >
135141 {#if span == ' week' }
136142 < div class = " cal-content week" >
137- {#each weekDays as day }
143+ {#each weekDays as day , i }
138144 < div class = " day" >
139145 < div class = " day-header" >
140146 < span class = " subtle" > {day.toLocaleString(' en' , { weekday : ' short' })}< / span >
141147 < span class = {[' day-number' , today .getTime () == day .getTime () && ' today' ]}>{day.getDate()}</span>
142148 </div>
149+
150+ {#each eventsForWeekDays[i ] ?? [] as event}
151+ {@const start = event.start.getHours() * 60 + event.start.getMinutes()}
152+ {@const end = event.end.getHours() * 60 + event.end.getMinutes()}
153+ <div class="event" style:top = " {start / 14.4}%" style :height = " {(end - start) / 14.4}%" >
154+ <span >{event.summary }< / span >
155+ < / div >
156+ {/each }
143157 < / div >
144158 {/each }
145159 < / div >
381395 align - items : center ;
382396 justify - content : center ;
383397 gap : 0.5em ;
398+ user - select : none ;
384399
385400 .day - number {
386401 border-radius: 0.3em ;
396411 }
397412 }
398413 }
414+
415+ .event {
416+ width: 100 % ;
417+ position : relative ;
418+ border - radius : 0.5em ;
419+ padding : 0.25em ;
420+ background - color : var (-- bg - alt );
421+ display : flex ;
422+ flex - direction : column ;
423+ align - items : flex - start ;
424+ justify - content : flex - start ;
425+ }
399426 }
400427 }
401428< / style >
You can’t perform that action at this time.
0 commit comments