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
|
/**
* Category list in the corner
*/
import React, { useState, useEffect } from "react";
var categories = [
// tag ID = array offset + 1
"1620s",
"painting",
"blunt",
"National Gallery of Canada",
"Art Gallery of Ontario",
"Courtauld Institute",
"Stankievech",
"connsoeurship",
"double agent",
"forensics",
"black box",
];
export default function Legend({ visible, selected, onSelect }) {
return (
<div className="legend" style={{ opacity: visible ? 1 : 0 }}>
{selected && (
<div className="removeSelection" onClick={() => onSelect(selected)}>
{"View all"}
</div>
)}
{categories.map((category, index) => (
<div
key={category}
className={
selected
? selected === index + 1
? "category selected"
: "category unselected"
: "category"
}
onClick={() => onSelect(index + 1)}
>
{category}
</div>
))}
</div>
);
}
|