Skip to content

Commit 0f36374

Browse files
All circuits update json and contributors (#386)
* Removed the component of search bar and filter options * Replace single string for contributors and organization by a list of items * Added condition for view more if list is bigger than the slicing --------- Co-authored-by: Loris Olivier <53363974+loris-maru@users.noreply.github.com>
1 parent 2eb12b9 commit 0f36374

File tree

5 files changed

+127
-10
lines changed

5 files changed

+127
-10
lines changed

public/circuits/ALL_CIRCUITS.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { useState } from 'react';
2+
import { ContributorsProps } from '../../type';
3+
4+
import { CloseIcon } from '@/components/icons';
5+
6+
export function SingleContributorPill({ name, lastName }: { name: string; lastName: string }) {
7+
return (
8+
<div className="flex flex-row flex-nowrap rounded-full border border-solid border-gray-200 px-4 py-1 text-lg font-normal text-primary-9">
9+
<span>
10+
{name} {lastName}
11+
</span>
12+
</div>
13+
);
14+
}
15+
16+
export default function ListParameterBox({
17+
name,
18+
value,
19+
slice = 5,
20+
}: {
21+
name: string;
22+
value: ContributorsProps[] | string[];
23+
slice?: number;
24+
}) {
25+
const [viewMore, setViewMore] = useState<boolean>(false);
26+
27+
const contentList = viewMore ? value : value.slice(0, slice);
28+
29+
return (
30+
<div className="relative flex w-full flex-col items-start">
31+
<div className="text-sm font-light uppercase tracking-wider text-gray-500">{name}</div>
32+
33+
<div className="mt-2 flex flex-row flex-wrap gap-2">
34+
{contentList.map((item: ContributorsProps | string) => {
35+
if (typeof item === 'string') {
36+
return (
37+
<span
38+
key={item}
39+
className="hyphens-auto text-xl font-normal leading-normal text-primary-9"
40+
>
41+
{item}
42+
</span>
43+
);
44+
}
45+
return (
46+
<SingleContributorPill
47+
key={`${item.name}-${item.lastName}`}
48+
name={item.name}
49+
lastName={item.lastName}
50+
/>
51+
);
52+
})}
53+
</div>
54+
55+
{value.length > slice && (
56+
<button
57+
type="button"
58+
aria-label="View more"
59+
className="mt-2 rounded-full border border-solid border-gray-300 bg-white px-4 py-2 text-base font-normal text-neutral-5"
60+
onClick={() => setViewMore(true)}
61+
>
62+
View more
63+
</button>
64+
)}
65+
66+
{viewMore && (
67+
<div className="fixed left-0 top-0 z-[99999] flex h-screen w-screen items-center justify-center bg-black/60">
68+
<div className="flex w-2/3 flex-col rounded-md bg-white p-10 text-primary-9">
69+
<div className="mb-2 flex flex-row justify-between">
70+
<div className="text-xl font-bold">{name}</div>
71+
<button
72+
type="button"
73+
aria-label="Close view more modal"
74+
onClick={() => setViewMore(false)}
75+
>
76+
<CloseIcon className="h-4 w-4 text-primary-9" />
77+
</button>
78+
</div>
79+
<div className="flex flex-row flex-wrap gap-2">
80+
{contentList.map((item: ContributorsProps | string) => {
81+
if (typeof item === 'string') {
82+
return (
83+
<span
84+
key={item}
85+
className="flex flex-row items-center hyphens-auto text-xl font-normal leading-normal text-primary-9 before:mr-2 before:block before:h-2 before:w-2 before:rounded-full before:bg-primary-9 before:content-['']"
86+
>
87+
{item}.
88+
</span>
89+
);
90+
}
91+
return (
92+
<SingleContributorPill
93+
key={`${item.name}-${item.lastName}`}
94+
name={item.name}
95+
lastName={item.lastName}
96+
/>
97+
);
98+
})}
99+
</div>
100+
</div>
101+
</div>
102+
)}
103+
</div>
104+
);
105+
}

src/components/explore-section/Circuit/DetailView/global/ParameterBox.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import { useState } from 'react';
55

66
import { CloseIcon } from '@/components/icons';
77

8+
export function SingleContributorPill({ name, lastName }: { name: string; lastName: string }) {
9+
return (
10+
<div className="border border-solid border-gray-200 text-sm font-normal text-primary-9">
11+
<div>{name}</div>
12+
<div>{lastName}</div>
13+
</div>
14+
);
15+
}
16+
817
export default function ParameterBox({
918
name,
1019
value,

src/components/explore-section/Circuit/DetailView/header/circuit-metadata.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CircuitSchemaProps } from '../../type';
2+
import ListParameterBox from '../global/ListParameterBox';
23
import ParameterBox from '../global/ParameterBox';
34

45
export default function CircuitMetadata({ content }: { content: CircuitSchemaProps }) {
@@ -8,17 +9,13 @@ export default function CircuitMetadata({ content }: { content: CircuitSchemaPro
89
<ParameterBox name="Description" value={content.description} />
910
</div>
1011
<div>
11-
<ParameterBox
12-
name="Contributors"
13-
value={content.metadata.contributors || '–'}
14-
hasViewMore
15-
/>
12+
<ListParameterBox name="Contributors" value={content.metadata.contributors ?? []} />
1613
</div>
1714
<div>
18-
<ParameterBox
15+
<ListParameterBox
1916
name="Contributing institutions"
20-
value={content.metadata.contributingInstitution || '–'}
21-
hasViewMore
17+
value={content.metadata.organizations}
18+
slice={2}
2219
/>
2320
</div>
2421
</div>

src/components/explore-section/Circuit/type/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export type CircuitSchemaProps = {
3939
numberOfSynapses: number;
4040
metadata: {
4141
contributorSimple?: string;
42-
contributors?: string;
42+
contributors?: ContributorsProps[];
43+
organizations: string[];
4344
contributingInstitution?: string;
4445
publishedIn?: string;
4546
registrationDate?: string;
@@ -142,3 +143,8 @@ export type FileTypeHeaderProps = {
142143
export interface FilteredCircuit extends CircuitSchemaProps {
143144
isNonMatchingParent?: boolean;
144145
}
146+
147+
export type ContributorsProps = {
148+
name: string;
149+
lastName: string;
150+
};

0 commit comments

Comments
 (0)