Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 415x 415x 341x | import React from "react";
import "./SourceProvenancePanel.scss";
export interface SourceProvenanceRecord {
id: string;
label: string;
source: string;
sourceUrl: string;
license: string;
licenseUrl: string;
retrievedDate: string;
updatedDate?: string;
coverage?: React.ReactNode;
}
export interface SourceProvenancePanelProps {
title?: string;
description?: React.ReactNode;
sources: readonly SourceProvenanceRecord[];
notice?: React.ReactNode;
noticeAfter?: number;
}
export function SourceProvenancePanel({
title = "Data sources and coverage",
description,
sources,
notice,
noticeAfter = 0,
}: SourceProvenancePanelProps) {
const noticeIndex = Math.max(0, Math.min(sources.length, noticeAfter));
return (
<details className="transit-places-notices">
<summary>{title}</summary>
{description}
{noticeIndex === 0 && notice}
{sources.map((source, index) => (
<React.Fragment key={source.id}>
<p>
<strong>{source.label}</strong>
<br />
<a href={source.sourceUrl} target="_blank" rel="noreferrer">
{source.source}
</a>
{" ยท "}
<a href={source.licenseUrl} target="_blank" rel="noreferrer">
{source.license}
</a>
<br />
Retrieved {source.retrievedDate}.
{source.updatedDate && (
<> Source data as of {source.updatedDate}.</>
)}{" "}
{source.coverage}
</p>
{index + 1 === noticeIndex && notice}
</React.Fragment>
))}
</details>
);
}
|