Skip to content

Commit 8760011

Browse files
committed
add additional names to the interface
1 parent 7f5e521 commit 8760011

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

src/components/core/Hint.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,49 @@ import { Tooltip } from "flowbite-react";
22
import { ReactElement, ReactNode } from "react";
33
import { MdHelpOutline } from "react-icons/md";
44

5+
export type HintPosition = "top" | "left" | "right" | "bottom";
6+
57
interface HintProps {
6-
children: ReactElement;
8+
children?: ReactElement;
79
hintContent: ReactNode;
10+
position?: HintPosition;
811
className?: string;
12+
trigger?: "icon" | "child";
913
}
1014

15+
const tooltipClassName = "bg-gray-600 z-10 border-1 max-w-xl";
16+
const tooltipTheme = { hidden: "invisible opacity-0 pointer-events-none" };
17+
1118
export function Hint(props: HintProps): ReactElement {
19+
const placement = props.position ?? "top";
20+
const trigger = props.trigger ?? "icon";
21+
22+
if (trigger === "child") {
23+
return (
24+
<Tooltip
25+
content={props.hintContent}
26+
arrow={false}
27+
placement={placement}
28+
className={tooltipClassName}
29+
theme={tooltipTheme}
30+
>
31+
{props.children}
32+
</Tooltip>
33+
);
34+
}
35+
1236
return (
1337
<div
14-
className={`flex items-center justify-center gap-2 ${props.className}`}
38+
className={`flex items-center justify-center gap-2 ${props.className ?? ""}`}
1539
>
1640
<div>{props.children}</div>
1741
<div>
1842
<Tooltip
1943
content={props.hintContent}
2044
arrow={false}
21-
placement="top"
22-
className="bg-gray-600 z-10 backdrop-blur-sm bg-opacity-99 border-1 max-w-xl"
45+
placement={placement}
46+
className={tooltipClassName}
47+
theme={tooltipTheme}
2348
>
2449
<MdHelpOutline />
2550
</Tooltip>

src/pages/ObjectDetails.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AladinViewer } from "../components/core/Aladin";
44
import { Loading } from "../components/core/Loading";
55
import { ErrorPage } from "../components/ui/ErrorPage";
66
import { CatalogData } from "../components/ui/CatalogData";
7+
import { Hint } from "../components/core/Hint";
78
import { Link } from "../components/core/Link";
89
import { querySimple } from "../clients/backend/sdk.gen";
910
import { PgcObject, Schema } from "../clients/backend/types.gen";
@@ -40,6 +41,29 @@ function ObjectDetails({ object, schema }: ObjectDetailsProps): ReactElement {
4041
>
4142
OHP Mirror
4243
</Link>
44+
{object.catalogs?.additional_designations &&
45+
object.catalogs.additional_designations.length > 0 && (
46+
<div className="mt-4">
47+
<p className="font-medium mb-1">Also known as:</p>
48+
<ul className="list-none space-y-1">
49+
{object.catalogs.additional_designations.map((d, i) => (
50+
<li key={i} className="flex items-center gap-2">
51+
<span>{d.name}</span>
52+
<Hint
53+
hintContent={
54+
<span>
55+
{d.source.title}
56+
{d.source.authors.length > 0 &&
57+
` — ${d.source.authors.join(", ")} (${d.source.year})`}
58+
</span>
59+
}
60+
className="gap-1"
61+
/>
62+
</li>
63+
))}
64+
</ul>
65+
</div>
66+
)}
4367
</div>
4468
</div>
4569
<CatalogData catalogs={object.catalogs} schema={schema} />

0 commit comments

Comments
 (0)