forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
72 lines (67 loc) · 1.78 KB
/
index.tsx
File metadata and controls
72 lines (67 loc) · 1.78 KB
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
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import IconBase from 'react-icons/lib/IconBase';
import Color from 'color';
import styled from 'styled-components';
import Tooltip from '../Tooltip';
import getIcon from '../../templates/icons';
import getDefinition from '../../templates';
const IconContainer = styled.div`
max-width: 30%;
left: 50%;
position: absolute;
top: 6px;
transform: translateX(-50%);
svg,
img {
max-width: 100%;
filter: grayscale(0.4);
height: auto;
}
`;
export default ({ style, sandboxesNumber, template }) => {
const templateInfo = getDefinition(template);
const color = templateInfo.color();
const lighter = Color(color)
.lighten(0.2)
.rgb();
const Icon = getIcon(template);
return sandboxesNumber >= 50 ? (
<Tooltip
style={{ display: 'flex', position: 'relative' }}
content={`${sandboxesNumber < 100 ? 'Silver' : 'Gold'} medal for ${
templateInfo.niceName
}`}
>
<IconBase
style={style}
width="1em"
height="0.67em"
viewBox="0 0 204 320"
fill="none"
>
<path d="M162.478 320V182H102v104.895L162.478 320z" fill={color} />
<path
d="M41.522 319.628V182H102v105.639l-60.478 31.989z"
fill={`rgb(${lighter.r},${lighter.g},${lighter.b})`}
/>
<circle
cx={102}
cy="102.355"
r={102}
transform="rotate(180 102 102.355)"
fill={sandboxesNumber < 100 ? '#EBEBEB' : '#EAC17A'}
/>
<circle
cx={102}
cy="102.355"
r="92.7273"
transform="rotate(180 102 102.355)"
fill={sandboxesNumber < 100 ? '#C8C8C8' : '#CFAE72'}
/>
</IconBase>
<IconContainer>
<Icon />
</IconContainer>
</Tooltip>
) : null;
};