diff --git a/src/lib/components/Button.svelte b/src/lib/components/Button.svelte index 8944bc2..a1e724f 100644 --- a/src/lib/components/Button.svelte +++ b/src/lib/components/Button.svelte @@ -5,7 +5,7 @@ onclick?: (event: MouseEvent) => void; disabled?: boolean; type?: "button" | "submit" | "reset"; - style?: "normal" | "red"; + style?: "normal" | "red" | "invisible"; formaction?: string; children?: Snippet; } @@ -45,6 +45,9 @@ .red { background-color: #bd4949; } + .invisible { + background: none; + } .button:focus { outline: 2px solid #007bff; } diff --git a/src/lib/components/CompulsoryTags.svelte b/src/lib/components/CompulsoryTags.svelte index ba5a23b..a8d205e 100644 --- a/src/lib/components/CompulsoryTags.svelte +++ b/src/lib/components/CompulsoryTags.svelte @@ -12,7 +12,7 @@ "No Outlets": "compulsoryTagRed", "Some Outlets": "compulsoryTagYellow", "Good WiFi": "compulsoryTagGreen", - "Bad WiFi": "compulsoryTagRed", + "Bad/No WiFi": "compulsoryTagRed", "Moderate WiFi": "compulsoryTagYellow", "No WiFi": "compulsoryTagRed" }; diff --git a/src/lib/components/OpeningTimes.svelte b/src/lib/components/OpeningTimes.svelte index fbd3242..51911bd 100644 --- a/src/lib/components/OpeningTimes.svelte +++ b/src/lib/components/OpeningTimes.svelte @@ -18,7 +18,7 @@ // Compute the display string for opening times let openingDisplay = $state(""); if (todayHours) { - openingDisplay = todayHours.is_24_7 + openingDisplay = todayHours.open_today_status ? "Open 24/7" : `${formatTime(todayHours.opens_at)} - ${formatTime(todayHours.closes_at)}`; } else { diff --git a/src/lib/components/inputs/OpeningTimesDay.svelte b/src/lib/components/inputs/OpeningTimesDay.svelte new file mode 100644 index 0000000..e321cfa --- /dev/null +++ b/src/lib/components/inputs/OpeningTimesDay.svelte @@ -0,0 +1,131 @@ + + +
@@ -167,7 +181,7 @@
background-color: #2e3c42;
width: 70%;
border: none;
- margin: 0 auto;
+ margin: 1rem auto 0;
}
.nameContainer {
@@ -260,22 +274,30 @@
}
.opening-entry {
- display: grid;
- grid-template-columns: auto 1fr;
+ display: flex;
gap: 0.75rem;
padding: 0.5rem 1.4rem;
align-items: center;
+ background-color: #2e4653;
+ margin: 0.2rem;
+ border-radius: 0.5rem;
}
.opening-entry .day {
font-weight: bold;
color: #ffffff;
- white-space: nowrap;
+ align-items: center;
+ justify-content: center;
}
.opening-entry .times {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ gap: 0.25rem 1.5rem;
+ flex: 1;
+ align-items: end;
+ }
+ .opening-entry .time {
font-family: monospace;
- background-color: rgba(255, 255, 255, 0.1);
- padding: 0.25rem 0.5rem;
- border-radius: 0.25rem;
color: #eaffeb;
}
diff --git a/src/routes/space/[id]/edit/+page.server.ts b/src/routes/space/[id]/edit/+page.server.ts
index 78baabf..66d2c65 100644
--- a/src/routes/space/[id]/edit/+page.server.ts
+++ b/src/routes/space/[id]/edit/+page.server.ts
@@ -12,7 +12,7 @@ type StudySpaceData = Omit<
day_of_week: number;
opens_at: string;
closes_at: string;
- is_24_7: boolean;
+ open_today_status: boolean | null;
}[];
};
@@ -42,7 +42,7 @@ export const load: PageServerLoad = async ({ params, locals: { supabase } }) =>
const images = studySpaceData.study_space_images || [];
const { data: hours, error: hoursErr } = await supabase
.from("study_space_hours")
- .select("day_of_week, opens_at, closes_at, is_24_7")
+ .select("day_of_week, opens_at, closes_at, open_today_status")
.eq("study_space_id", params.id)
.order("day_of_week", { ascending: true });
if (hoursErr) error(500, "Failed to load opening times");
diff --git a/src/routes/space/[id]/edit/+page.svelte b/src/routes/space/[id]/edit/+page.svelte
index 5302a2c..a1d0253 100644
--- a/src/routes/space/[id]/edit/+page.svelte
+++ b/src/routes/space/[id]/edit/+page.svelte
@@ -6,13 +6,15 @@
import crossUrl from "$lib/assets/cross.svg";
import Button from "$lib/components/Button.svelte";
import Images from "$lib/components/inputs/Images.svelte";
+ import OpeningTimesDay from "$lib/components/inputs/OpeningTimesDay.svelte";
import {
availableStudySpaceTags,
wifiTags,
powerOutletTags,
volumeTags,
gmapsLoader,
- daysOfWeek
+ daysOfWeek,
+ timeToMins
} from "$lib";
import { onMount } from "svelte";
import type { Json } from "$lib/database.js";
@@ -21,13 +23,15 @@
const { supabase } = $derived(data);
const { space, images } = $derived(data);
+
+ interface OpeningTime {
+ day_of_week: number;
+ opens_at: string;
+ closes_at: string;
+ open_today_status: boolean | null;
+ }
const studySpaceData = $state({
- opening_times: daysOfWeek.map((_, index) => ({
- day_of_week: index,
- opens_at: "",
- closes_at: "",
- is_24_7: false
- })),
+ opening_times: [] as OpeningTime[],
...space
});
@@ -57,12 +61,83 @@
);
let spaceImgs = $state
{/each}
+