-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgressCell.tsx
62 lines (59 loc) · 2.12 KB
/
ProgressCell.tsx
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import cx from 'classnames';
import { FC } from 'react';
import { PartyEvent } from '@/api/party/events';
import { backgroundColorBySeed } from '@/util/user';
export const ProgressCell: FC<{
code: string;
triedCodes: Map<string, PartyEvent[]>;
visibleCodes: Map<string, string[]>;
}> = ({ code, triedCodes, visibleCodes }) => {
// Visible codes key is user_id, value is an array of codes. Find first user_id that has this code
const userId = Array.from(visibleCodes.entries()).find(([_, codes]) =>
codes.includes(code)
)?.[0];
return (
<div
className={cx(
'flex justify-center items-center w-full h-full rounded-sm text-[0.8rem]',
triedCodes.has(code) ? 'bg-tertiary text-white' : 'bg-tertiary text-secondary'
)}
style={{
...(triedCodes.has(code)
? {
backgroundColor: backgroundColorBySeed(
(triedCodes.get(code) || [])[0]?.user_id,
{
saturation: 25,
lightness: 40,
}
),
}
: {}),
...(userId
? {
borderBottom: `2px solid ${backgroundColorBySeed(userId)}`,
}
: {}),
}}
>
<div
style={
triedCodes.has(code)
? {
backgroundColor: backgroundColorBySeed(
(triedCodes.get(code) || [])[0]?.user_id,
{
saturation: 25,
lightness: 40,
}
),
borderRadius: '2px',
}
: {}
}
>
{code}
</div>
</div>
);
};