Skip to content

Commit

Permalink
Add link to page from tide table
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbithell committed Jul 17, 2024
1 parent 551bed5 commit 256a0e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/components/templates/TideGraphPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IconArrowRight,
IconDownload,
IconFileTypePdf,
IconHome,
} from "@tabler/icons-react";
import { TideTable } from "../tideTables/TideTable";
import { TideTableMobile } from "../tideTables/TideTableMobile";
Expand Down Expand Up @@ -45,6 +46,11 @@ const Page: React.FC<PageProps> = ({ pageContext }) => {
</Button>
</Link>
) : null}
<Link to={"/"}>
<Button variant="light">
<IconHome size={14} />
</Button>
</Link>
{nextDay ? (
<Link to={"/tide-graph/" + nextDay}>
<Button
Expand Down
28 changes: 18 additions & 10 deletions src/components/tideTables/TideTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import { DateTime } from "luxon";
import { TidesJson_ScheduleObject } from "../../types";
import { IconSunrise, IconSunset } from "@tabler/icons-react";
import { Link } from "gatsby";

export function TideTable({ data }: { data: TidesJson_ScheduleObject[] }) {
return (
Expand All @@ -22,16 +23,23 @@ export function TideTable({ data }: { data: TidesJson_ScheduleObject[] }) {
{data.map((date: TidesJson_ScheduleObject, index: React.Key) => (
<Table.Tr key={index}>
<Table.Td>
<Text>
{DateTime.fromSQL(date.date).toLocaleString({
weekday: "long",
day: "2-digit",
})}
{DateTime.fromSQL(date.date).toJSDate().setHours(0, 0, 0, 0) ==
new Date().setHours(0, 0, 0, 0) ? (
<Badge ml="sm">Today</Badge>
) : null}
</Text>
<Link
to={"/tide-graph/" + date.date}
title="Tidal Graph"
style={{ textDecoration: "none", color: "inherit" }}
>
<Text>
{DateTime.fromSQL(date.date).toLocaleString({
weekday: "long",
day: "2-digit",
})}
{DateTime.fromSQL(date.date)
.toJSDate()
.setHours(0, 0, 0, 0) == new Date().setHours(0, 0, 0, 0) ? (
<Badge ml="sm">Today</Badge>
) : null}
</Text>
</Link>
</Table.Td>
<Table.Td>
<Text>
Expand Down

0 comments on commit 256a0e7

Please sign in to comment.