🗓️ calendar month cells with event/exam pills
Browse files at this commit5b8e6edb05b7ab7dd76e331b3c50601b96853c22Parent: 0fbb97c- feat
- 🗓️ calendar month cells with event/exam pills
1 changed file +29 -11
- src/pages/calendar-page.tsx +29 -11
src/pages/calendar-page.tsxmodified+29 -11
| @@ -142,16 +142,16 @@ function CalendarContent() { | |||
| 142 | <For each={grid()}> | 142 | <For each={grid()}> |
| 143 | {(cell) => { | 143 | {(cell) => { |
| 144 | const key = cell.other ? "" : dateKey(new Date(viewYear(), viewMonth(), cell.day)); | 144 | const key = cell.other ? "" : dateKey(new Date(viewYear(), viewMonth(), cell.day)); |
| 145 | - const items = cell.other ? null : itemsByDay().get(key); | 145 | + const items = () => cell.other ? null : itemsByDay().get(key); |
| 146 | const cellToday = !cell.other && isToday(cell.day); | 146 | const cellToday = !cell.other && isToday(cell.day); |
| 147 | - const cellSelected = !cell.other && key === selectedKey(); | 147 | + const cellSelected = () => !cell.other && key === selectedKey(); |
| 148 | return ( | 148 | return ( |
| 149 | <button | 149 | <button |
| 150 | type="button" | 150 | type="button" |
| 151 | class={cn( | 151 | class={cn( |
| 152 | "relative flex min-h-[4.5rem] flex-col border-b border-r border-border/40 p-1.5 text-left transition-colors last:border-r-0 hover:bg-muted/40", | 152 | "relative flex min-h-[4.5rem] flex-col border-b border-r border-border/40 p-1.5 text-left transition-colors last:border-r-0 hover:bg-muted/40", |
| 153 | cell.other && "pointer-events-none bg-muted/20", | 153 | cell.other && "pointer-events-none bg-muted/20", |
| 154 | - cellSelected ? "bg-sky-50/60 ring-1 ring-inset ring-sky-400/50" : "", | 154 | + cellSelected() ? "bg-sky-50/60 ring-1 ring-inset ring-sky-400/50" : "", |
| 155 | )} | 155 | )} |
| 156 | disabled={cell.other} | 156 | disabled={cell.other} |
| 157 | onClick={() => key && setSelected(key)} | 157 | onClick={() => key && setSelected(key)} |
| @@ -159,22 +159,40 @@ function CalendarContent() { | |||
| 159 | <span | 159 | <span |
| 160 | class={cn( | 160 | class={cn( |
| 161 | "inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium", | 161 | "inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium", |
| 162 | - cellToday && !cellSelected ? "bg-primary text-primary-foreground font-semibold" : "", | 162 | + cellToday ? "bg-primary text-primary-foreground font-semibold" : "", |
| 163 | - cellSelected ? "bg-sky-600 text-white font-semibold" : "", | ||
| 164 | cell.other ? "text-muted-foreground/30" : "text-foreground", | 163 | cell.other ? "text-muted-foreground/30" : "text-foreground", |
| 165 | )} | 164 | )} |
| 166 | > | 165 | > |
| 167 | {cell.day || ""} | 166 | {cell.day || ""} |
| 168 | </span> | 167 | </span> |
| 169 | - <Show when={items && (items.events.length > 0 || items.exams.length > 0)}> | 168 | + <Show when={items()}> |
| 170 | - <div class="mt-auto flex flex-wrap gap-1"> | 169 | + {(dayItems) => ( |
| 171 | - <Show when={items!.events.length > 0}> | 170 | + <div class="mt-1 flex min-h-0 flex-1 flex-col justify-end gap-1 overflow-hidden"> |
| 172 | - <span class="inline-flex h-1.5 w-1.5 rounded-full bg-sky-500" /> | 171 | + {/* ponytail: month cells show one badge per type; selected list has full detail. */} |
| 172 | + <Show when={dayItems().events[0]}> | ||
| 173 | + {(event) => ( | ||
| 174 | + <span class="inline-flex min-w-0 items-center gap-1 rounded bg-sky-100 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700"> | ||
| 175 | + <span class="h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500" /> | ||
| 176 | + <span class="truncate">{event().title}</span> | ||
| 177 | + <Show when={dayItems().events.length > 1}> | ||
| 178 | + <span class="shrink-0 text-sky-600">+{dayItems().events.length - 1}</span> | ||
| 179 | + </Show> | ||
| 180 | + </span> | ||
| 181 | + )} | ||
| 173 | </Show> | 182 | </Show> |
| 174 | - <Show when={items!.exams.length > 0}> | 183 | + <Show when={dayItems().exams[0]}> |
| 175 | - <span class="inline-flex h-1.5 w-1.5 rounded-full bg-amber-500" /> | 184 | + {(exam) => ( |
| 185 | + <span class="inline-flex min-w-0 items-center gap-1 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium leading-none text-amber-700"> | ||
| 186 | + <span class="h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500" /> | ||
| 187 | + <span class="truncate">{exam().title}</span> | ||
| 188 | + <Show when={dayItems().exams.length > 1}> | ||
| 189 | + <span class="shrink-0 text-amber-600">+{dayItems().exams.length - 1}</span> | ||
| 190 | + </Show> | ||
| 191 | + </span> | ||
| 192 | + )} | ||
| 176 | </Show> | 193 | </Show> |
| 177 | </div> | 194 | </div> |
| 195 | + )} | ||
| 178 | </Show> | 196 | </Show> |
| 179 | </button> | 197 | </button> |
| 180 | ); | 198 | ); |