-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.js
More file actions
68 lines (59 loc) · 1.73 KB
/
Copy pathShape.js
File metadata and controls
68 lines (59 loc) · 1.73 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
import React from 'react';
import styled from 'styled-components';
import { getShape } from './schema';
const Box = styled.div`
width: ${props => props.width || '100px'};
height: ${props => props.height || '100px'};
margin: 0 auto;
position: relative;
`;
const Shadow = styled.div`
background-color: ${props => props.backgroundColor || '#00c4ff'};
opacity: 0.25;
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
`;
const Component = styled.div`
clip-path: ${props => props.formula};
background-color: ${props => props.backgroundColor || '#00c4ff'};
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
`;
const Label = styled.span`
text-align: center;
position: absolute;
top: 46%;
left: 40%;
color: #FFF;
font-size: larger;
`;
const Shape = props => {
const backgroundColor = props.backgroundColor || '#12a8d6';
const height = props.height;
const width = props.width;
const showShadow = props.showShadow;
const shapeInfo = getShape(props.name);
const formula = shapeInfo ? shapeInfo.formula : props.formula;
const text = shapeInfo ? shapeInfo.name : props.text;
const showLabel = props.showLabel;
const id = props.id;
const handleClick = props.handleClick;
return (
<Box height={ height } width={ width } onClick={ handleClick }>
{ showShadow && <Shadow backgroundColor = { backgroundColor } /> }
<Component
id = { id }
backgroundColor = { backgroundColor }
formula = { formula }>
{ showLabel && (<Label> { text }</Label>) }
</Component>
</Box>
)
}
export default Shape;