gpt-engineer-app[bot] commited on
Commit
2b96622
·
1 Parent(s): c0627c7

Improve calendar event display

Browse files

The calendar event display will be improved to show a single straight line for multi-day events instead of separate lines for each day.

Files changed (1) hide show
  1. src/pages/Calendar.tsx +15 -3
src/pages/Calendar.tsx CHANGED
@@ -188,14 +188,26 @@ const CalendarPage = () => {
188
  {dayEvents.conferences.map((conf) => {
189
  const startDate = safeParseISO(conf.start);
190
  const endDate = safeParseISO(conf.end);
191
- const isFirstDay = startDate && isSameDay(startDate, day);
192
- const isLastDay = endDate && isSameDay(endDate, day);
 
 
 
193
  const categoryColor = conf.tags?.[0] ? categoryColors[conf.tags[0]] || "bg-purple-600" : "bg-purple-600";
194
 
 
 
 
 
 
 
195
  return (
196
  <div
197
  key={conf.id}
198
- className={`h-0.5 w-full ${categoryColor} ${!isFirstDay ? '-ml-[1px]' : ''} ${!isLastDay ? '-mr-[1px]' : ''}`}
 
 
 
199
  title={conf.title}
200
  />
201
  );
 
188
  {dayEvents.conferences.map((conf) => {
189
  const startDate = safeParseISO(conf.start);
190
  const endDate = safeParseISO(conf.end);
191
+
192
+ if (startDate && !isSameDay(startDate, day)) {
193
+ return null;
194
+ }
195
+
196
  const categoryColor = conf.tags?.[0] ? categoryColors[conf.tags[0]] || "bg-purple-600" : "bg-purple-600";
197
 
198
+ let width = "w-full";
199
+ if (startDate && endDate) {
200
+ const daysBetween = Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
201
+ width = `w-[calc(100%_*_${daysBetween})]`;
202
+ }
203
+
204
  return (
205
  <div
206
  key={conf.id}
207
+ className={`h-0.5 ${categoryColor} absolute ${width} -mr-[1px]`}
208
+ style={{
209
+ width: startDate && endDate ? `calc(100% * ${Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24))})` : '100%'
210
+ }}
211
  title={conf.title}
212
  />
213
  );