import { STANDINGS, type Standing } from "@sportsdataverse/examples/data";
import { defineTable } from "@sportsdataverse/sdvtables";
import { fontsLinkFor, prepare } from "@sportsdataverse/sdvtables/html";
import { SdvTable } from "@sportsdataverse/sdvtables/react";
import { useEffect } from "react";
const spec = defineTable<Standing>()
.columns((c) => [
c.logo("team", { league: "nfl", includeName: true }),
c.text("division", { filterable: true }),
c.int("wins"),
c.int("losses"),
])
.title("AFC, 2024")
.rowKey("team")
.build();
await prepare(spec);
function Standings() {
useEffect(() => document.head.insertAdjacentHTML("beforeend", fontsLinkFor(spec)), []);
return (
<div style={{ display: "grid", gap: 24 }}>
<SdvTable spec={spec} rows={STANDINGS.filter((r) => r.division === "West")} />
<SdvTable spec={spec} rows={STANDINGS} interactive pageSize={4} sort={{ col: "wins", dir: "desc" }} />
</div>
);
}
<Standings />;