-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): Display dataset metadata in dialog
- Loading branch information
1 parent
c738faa
commit ce83b06
Showing
14 changed files
with
1,012 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import Link from "next/link"; | ||
|
||
import Markdown from "@/components/markdown"; | ||
import { DialogHeader, DialogTitle } from "@/components/ui/dialog"; | ||
import { MetadataItemComponent } from "@/types/generated/strapi.schemas"; | ||
|
||
interface DatasetMetadataProps { | ||
name: string; | ||
metadata: MetadataItemComponent; | ||
} | ||
|
||
const DatasetMetadata = ({ name, metadata }: DatasetMetadataProps) => { | ||
return ( | ||
<> | ||
<DialogHeader> | ||
<DialogTitle>{name}</DialogTitle> | ||
</DialogHeader> | ||
<dl className="mt-8 flex flex-col gap-2 text-xs"> | ||
{!!metadata.full_name && ( | ||
<div> | ||
<dt className="font-bold">Full name</dt> | ||
<dd>{metadata.full_name}</dd> | ||
</div> | ||
)} | ||
{!!metadata.source && ( | ||
<div> | ||
<dt className="font-bold">Source</dt> | ||
<dd>{metadata.source}</dd> | ||
</div> | ||
)} | ||
{!!metadata.website && ( | ||
<div> | ||
<dt className="font-bold">Website</dt> | ||
<dd> | ||
<Link | ||
href={metadata.website} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="break-all underline" | ||
> | ||
{metadata.website} | ||
</Link> | ||
</dd> | ||
</div> | ||
)} | ||
{!!metadata.description && ( | ||
<div> | ||
<dt className="font-bold">Description</dt> | ||
<dd>{metadata.description}</dd> | ||
</div> | ||
)} | ||
{!!metadata.main_applications && ( | ||
<div> | ||
<dt className="font-bold">Main applications</dt> | ||
<dd> | ||
<Markdown>{metadata.main_applications}</Markdown> | ||
</dd> | ||
</div> | ||
)} | ||
{!!metadata.temporal_resolution && ( | ||
<div> | ||
<dt className="font-bold">Temporal resolution</dt> | ||
<dd> | ||
<Markdown>{metadata.temporal_resolution}</Markdown> | ||
</dd> | ||
</div> | ||
)} | ||
{!!metadata.temporal_coverage && ( | ||
<div> | ||
<dt className="font-bold">Temporal coverage</dt> | ||
<dd> | ||
<Markdown>{metadata.temporal_coverage}</Markdown> | ||
</dd> | ||
</div> | ||
)} | ||
{!!metadata.spatial_resolution && ( | ||
<div> | ||
<dt className="font-bold">Spatial resolution</dt> | ||
<dd>{metadata.spatial_resolution}</dd> | ||
</div> | ||
)} | ||
{!!metadata.units && ( | ||
<div> | ||
<dt className="font-bold">Units</dt> | ||
<dd>{metadata.units}</dd> | ||
</div> | ||
)} | ||
</dl> | ||
</> | ||
); | ||
}; | ||
|
||
export default DatasetMetadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Link from "next/link"; | ||
import ReactMarkdown from "react-markdown"; | ||
|
||
interface MarkdownProps { | ||
children: string | null | undefined; | ||
} | ||
|
||
const Markdown = ({ children }: MarkdownProps) => { | ||
return ( | ||
<ReactMarkdown | ||
allowedElements={["ul", "ol", "li", "b", "strong", "em", "i", "a", "br", "p"]} | ||
components={{ | ||
ul: ({ children }) => <ul className="list-inside list-disc">{children}</ul>, | ||
ol: ({ children }) => <ol className="list-inside list-decimal">{children}</ol>, | ||
a: ({ children, href }) => ( | ||
<Link | ||
href={href!} | ||
target={href?.startsWith("http") ? "_blank" : undefined} | ||
rel={href?.startsWith("http") ? "noopener noreferrer" : undefined} | ||
className="break-all underline" | ||
> | ||
{children} | ||
</Link> | ||
), | ||
}} | ||
> | ||
{children} | ||
</ReactMarkdown> | ||
); | ||
}; | ||
|
||
export default Markdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.