Skip to content

Commit 4e1489a

Browse files
committed
feat: display source collection path in header
1 parent e0bcb95 commit 4e1489a

File tree

2 files changed

+107
-60
lines changed

2 files changed

+107
-60
lines changed

packages/web/src/Containers/Containers_AnnotationCollectionHeader/Containers_AnnotationCollectionHeader.re

+2-60
Original file line numberDiff line numberDiff line change
@@ -239,64 +239,6 @@ let make =
239239
/>
240240
</MaterialUi.IconButton>;
241241

242-
let title =
243-
annotationCollection
244-
->Belt.Option.map(annotationCollection => {
245-
let type_ =
246-
annotationCollection##type_
247-
->Belt.Array.getBy(t =>
248-
switch (t) {
249-
| `TAG_COLLECTION
250-
| `SOURCE_COLLECTION => true
251-
| _ => false
252-
}
253-
)
254-
->Belt.Option.getWithDefault(`TAG_COLLECTION);
255-
256-
let (label, icon) =
257-
switch (type_) {
258-
| `SOURCE_COLLECTION => (
259-
annotationCollection##label->Webapi.Url.make->Webapi.Url.host,
260-
Svg.article,
261-
)
262-
| _ => (annotationCollection##label, Svg.label)
263-
};
264-
265-
<div
266-
className={Cn.fromList([
267-
"flex",
268-
"flex-grow-0",
269-
"overflow-hidden",
270-
"items-center",
271-
])}>
272-
<Svg
273-
className={Cn.fromList(["pointer-events-none", "opacity-75"])}
274-
style={ReactDOMRe.Style.make(~width="1rem", ~height="1rem", ())}
275-
icon
276-
/>
277-
<span
278-
className={Cn.fromList([
279-
"ml-2",
280-
"block",
281-
"font-sans",
282-
"text-lightPrimary",
283-
"whitespace-no-wrap",
284-
"overflow-x-hidden",
285-
"truncate",
286-
"font-bold",
287-
"text-lg",
288-
])}>
289-
{React.string(label)}
290-
</span>
291-
</div>;
292-
})
293-
->Belt.Option.getWithDefault(
294-
<Skeleton
295-
variant=`text
296-
className={Cn.fromList(["h-4", "w-32", "ml-6", "transform-none"])}
297-
/>,
298-
);
299-
300242
<>
301243
<Header
302244
className={cn([
@@ -320,9 +262,9 @@ let make =
320262
"flex-shrink",
321263
"overflow-x-auto",
322264
])}>
323-
title
265+
<AnnotationCollectionHeader_Title ?annotationCollection />
324266
</div>
325-
<div className={Cn.fromList(["flex", "items-center", "flex-shrink-0"])}>
267+
<div className={Cn.fromList(["flex", "items-center", "flex-shrink-0", "ml-4"])}>
326268
{switch (identityId) {
327269
| Some(identityId) =>
328270
<Next.Link
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
module TagCollectionTitle = {
2+
[@react.component]
3+
let make = (~title) => {
4+
<span
5+
className={Cn.fromList([
6+
"ml-2",
7+
"block",
8+
"font-sans",
9+
"text-lightPrimary",
10+
"whitespace-no-wrap",
11+
"overflow-x-hidden",
12+
"truncate",
13+
"font-bold",
14+
"text-lg",
15+
])}>
16+
{React.string(title)}
17+
</span>;
18+
};
19+
};
20+
21+
module SourceCollectionTitle = {
22+
[@react.component]
23+
let make = (~title, ~subtitle) => {
24+
<div
25+
className={Cn.fromList(["ml-3", "flex", "flex-col", "overflow-hidden"])}>
26+
<span
27+
className={Cn.fromList([
28+
"block",
29+
"font-sans",
30+
"text-lightPrimary",
31+
"whitespace-no-wrap",
32+
"overflow-x-hidden",
33+
"truncate",
34+
"font-bold",
35+
"text-base",
36+
])}>
37+
{React.string(title)}
38+
</span>
39+
<span
40+
className={Cn.fromList([
41+
"text-lightSecondary",
42+
"text-xs",
43+
"overflow-x-hidden",
44+
"truncate",
45+
])}>
46+
{React.string(subtitle)}
47+
</span>
48+
</div>;
49+
};
50+
};
51+
52+
[@react.component]
53+
let make = (~annotationCollection=?) => {
54+
annotationCollection
55+
->Belt.Option.map(annotationCollection => {
56+
let type_ =
57+
annotationCollection##type_
58+
->Belt.Array.getBy(t =>
59+
switch (t) {
60+
| `TAG_COLLECTION
61+
| `SOURCE_COLLECTION => true
62+
| _ => false
63+
}
64+
)
65+
->Belt.Option.getWithDefault(`TAG_COLLECTION);
66+
67+
let (title, icon) =
68+
switch (type_) {
69+
| `SOURCE_COLLECTION =>
70+
let url = annotationCollection##label->Webapi.Url.make;
71+
(
72+
<SourceCollectionTitle
73+
title={url->Webapi.Url.host}
74+
subtitle={url->Webapi.Url.pathname}
75+
/>,
76+
Svg.article,
77+
);
78+
| _ => (
79+
<TagCollectionTitle title={annotationCollection##label} />,
80+
Svg.label,
81+
)
82+
};
83+
84+
<div
85+
className={Cn.fromList([
86+
"flex",
87+
"flex-grow-0",
88+
"overflow-hidden",
89+
"items-center",
90+
])}>
91+
<Svg
92+
className={Cn.fromList(["pointer-events-none", "opacity-75"])}
93+
style={ReactDOMRe.Style.make(~width="1rem", ~height="1rem", ())}
94+
icon
95+
/>
96+
title
97+
</div>;
98+
})
99+
->Belt.Option.getWithDefault(
100+
<Skeleton
101+
variant=`text
102+
className={Cn.fromList(["h-4", "w-32", "ml-6", "transform-none"])}
103+
/>,
104+
);
105+
};

0 commit comments

Comments
 (0)