Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion website/app/components/DatePageNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, Group } from "@mantine/core";
import { Link } from "react-router";
import { isTodayUtcDay } from "~/utils/dateTime";

/**
* `historic` has no button of its own — the comparison page is reached from the menu — but
Expand Down Expand Up @@ -31,6 +32,7 @@ const PAGES: Array<{ page: DatePage; label: string; path: string }> = [

export function DatePageNav({ password, urlDate, current }: DatePageNavProps) {
const basePath = `/${password}/${urlDate}`;
const isToday = isTodayUtcDay(urlDate);

Comment on lines 33 to 36
return (
<Group gap="xs">
Expand All @@ -42,7 +44,7 @@ export function DatePageNav({ password, urlDate, current }: DatePageNavProps) {
variant={current === page ? "filled" : "light"}
size="compact-md"
>
{label}
{page === "live" && !isToday ? "Map" : label}
</Button>
))}
</Group>
Expand Down
9 changes: 6 additions & 3 deletions website/app/routes/date/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { Link, type MetaFunction } from "react-router";
import * as Schema from "~/database/schema.d";
import { getDb, getPasswordRouteAccess } from "~/routeContext";
import { formatUtcDay } from "~/utils/dateTime";
import { formatUtcDay, isTodayUtcDay } from "~/utils/dateTime";
import type { Route } from "./+types/index";
import {
IconAntennaBars5,
Expand Down Expand Up @@ -56,6 +56,7 @@ export async function loader({ context }: Route.LoaderArgs) {

export default function Page({ loaderData }: Route.ComponentProps) {
const theme = useMantineTheme();
const isToday = isTodayUtcDay(loaderData.urlDate);
if (!loaderData.hasData) {
Comment on lines 57 to 60
return (
<Container fluid p="md">
Expand Down Expand Up @@ -97,9 +98,11 @@ export default function Page({ loaderData }: Route.ComponentProps) {
>
<IconMap color={theme.colors.pink[6]} size={40} stroke={1.5} />
<div>
<Text fw={600}>Live tracking map</Text>
<Text fw={600}>{isToday ? "Live tracking map" : "Map"}</Text>
<Text size="xs" c="dimmed">
Follow along on the map
{isToday
? "Follow along on the map"
: "See this day on the map"}
</Text>
</div>
</UnstyledButton>
Expand Down
7 changes: 7 additions & 0 deletions website/app/utils/dateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export const formatDateTimeWithSeconds = (rawTimestamp: number) =>
*/
export const formatUtcDay = (dayString: string) => dayString;

/** Today's UTC day bucket, in the same `YYYY-MM-DD` form as `events.date_string`. */
export const todayUtcDay = () => DateTime.now().toUTC().toFormat("yyyy-MM-dd");

/** Whether a `YYYY-MM-DD` UTC day bucket is today. */
export const isTodayUtcDay = (dayString: string) =>
dayString === todayUtcDay();

/**
* A human duration between two stored timestamps, e.g. `2h 14m`, `47m`, `35s`.
*
Expand Down