Skip to content

Commit

Permalink
attempt, not working
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienR1 committed Feb 1, 2025
1 parent bee5b3a commit b4eeb18
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions packages/web/src/components/Calendar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ const timeMin = 8;
const timeMax = 22;
const timeStep = 1;
function cells(callback: (time: number) => JSX.Element) {
function cells(
label: (time: number) => JSX.Element,
cell: (weekday: number, time: number) => JSX.Element,
) {
return Array.from({ length: (timeMax - timeMin + 1) / timeStep }).map(
(_, i) => {
const time = timeMin + i * timeStep;
return callback(time);
return (
<div>
{label(time)}
{Array.from({ length: 7 }).map((_, weekday) => cell(weekday, time))}
</div>
);
},
);
}
Expand All @@ -28,30 +36,17 @@ function formatTime(time: number): string {
}
---

<!-- this should be a 2d css grid section so that each activity can be placed directly w/ grid-start-n etc -->
<div class="relative w-full">
<div class="flex">
<div>
{
cells((time) => (
<div class="row flex items-center -translate-y-1/2 gap-1">
<span class="text-xs">{formatTime(time)}</span>
<div class="w-2 h-1 bg-black" />
</div>
))
}
</div>

<div class="grid">
{
Array.from({ length: 7 }).map((_, weekday) => (
<div class="flex-1">
{cells((time) => (
<div class="row border-2 border-black text-xs">
{weekday} - {formatTime(time)}
</div>
))}
</div>
))
cells(
(time) => <div>{formatTime(time)}</div>,
(weekday, time) => (
<div>
{weekday} - {formatTime(time)}
</div>
),
)
}
</div>
</div>
Expand Down

0 comments on commit b4eeb18

Please sign in to comment.