-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircleWidget.js
79 lines (72 loc) · 2.12 KB
/
CircleWidget.js
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
73
74
75
76
77
78
79
import React, { useRef } from "react";
import "./CircleWidget.css";
export const CircleWidget = ({
width = "400",
height = "400",
title = "",
strokeWidth = "9",
fillValue = "30",
isRadioButton = false,
isSelected = false,
onClick,
propColor = "#6f6fff",
animation = "",
className=""
}) => {
const circleWidgetRef = useRef(null);
const style = {
"--fillValue": `${fillValue}`,
};
return (
<div className="circle-svg" style={{ width: width, height: height }}>
<svg viewBox="-4 -4 46 46">
<path
stroke="gray"
strokeWidth="4.8"
strokeOpacity="0.5"
fill="none"
strokeDasharray="70, 100"
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
></path>
<path
stroke="gray"
strokeOpacity="0.4"
strokeWidth="4.8"
fill="none"
strokeDasharray="90, 100"
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
></path>
<path
stroke="gray"
strokeOpacity="0.3"
strokeWidth="4.8"
fill="none"
strokeDasharray="100, 100"
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
></path>
<path
className={className}
style={style}
strokeWidth={strokeWidth}
ref={circleWidgetRef}
stroke={
isRadioButton && isSelected
? propColor
: isRadioButton && !isSelected
? "gray"
: propColor
}
fill={isRadioButton ? "transparent" : "none"}
strokeDasharray={`${fillValue}, 100`}
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
onClick={onClick}
></path>
<text x={12} y="20" style={{ fontSize: "8px", fontWeight: "bold" }}>
{" "}
{title}
{!isRadioButton ? "k" : null}
</text>
</svg>
</div>
);
};