Skip to content

Commit ee2a5de

Browse files
feat: made variant as optional
1 parent 12fa567 commit ee2a5de

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/components/CircularProgressBar/index.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import clsx from 'clsx';
2-
import React, { ReactNode, useState } from 'react';
1+
import clsx from "clsx";
2+
import React, { ReactNode, useState } from "react";
33
import "./CircularProgressBar.scss"
44

55
type TVariant = "clockwise" | "static" | "selectable"
@@ -13,7 +13,7 @@ type TCircularProgressProps = {
1313
stroke?: number;
1414
warning_limit?: number;
1515
icon?: ReactNode;
16-
variant: TVariant;
16+
variant?: TVariant;
1717
onSelect?: () => void;
1818
};
1919

@@ -43,8 +43,8 @@ export const CircularProgressBar = ({
4343
};
4444

4545
return (
46-
<div className={clsx('deriv-circular-progress', className)}>
47-
<svg height={radius * 2} width={radius * 2} onClick={variant === 'selectable' ? handleSelect : undefined}>
46+
<div className={clsx("deriv-circular-progress", className)}>
47+
<svg height={radius * 2} width={radius * 2} onClick={variant === "selectable" ? handleSelect : undefined}>
4848
{children && (
4949
<foreignObject x="0" y="0" width={radius * 2} height={radius * 2}>
5050
<div className={clsx("deriv-circular-progress__content")}>
@@ -53,28 +53,28 @@ export const CircularProgressBar = ({
5353
</foreignObject>
5454
)}
5555
<circle
56-
className={clsx('deriv-circular-progress__bar', {
57-
'deriv-circular-progress--clockwise': is_clockwise,
58-
'deriv-circular-progress__bar--warning': progress <= warning_limit && progress > danger_limit,
59-
'deriv-circular-progress__bar--danger': progress <= danger_limit,
60-
'deriv-circular-progress__bar--selected': selected && variant === 'selectable'
56+
className={clsx("deriv-circular-progress__bar", {
57+
"deriv-circular-progress--clockwise": is_clockwise,
58+
"deriv-circular-progress__bar--warning": progress <= warning_limit && progress > danger_limit,
59+
"deriv-circular-progress__bar--danger": progress <= danger_limit,
60+
"deriv-circular-progress__bar--selected": selected && variant === "selectable"
6161
})}
6262
cx={radius}
6363
cy={radius}
64-
fill={variant === 'selectable' && selected ? 'blue' : 'transparent'}
64+
fill={variant === "selectable" && selected ? "blue" : "transparent"}
6565
r={normalizedRadius}
6666
strokeDasharray={`${circumference} ${circumference}`}
6767
strokeWidth={stroke}
68-
style={variant != "clockwise" ? { strokeDashoffset: 'none' } : { strokeDashoffset }}
68+
style={variant != "clockwise" ? { strokeDashoffset: "none" } : { strokeDashoffset }}
6969
/>
7070
{
7171
variant != "clockwise" && (
7272
<circle
7373
cx={radius}
7474
cy={radius}
7575
r={normalizedRadius}
76-
fill='none'
77-
stroke='#E8EEFC'
76+
fill="none"
77+
stroke="#E8EEFC"
7878
strokeDasharray={`${circumference} ${circumference}`}
7979
strokeWidth={stroke}
8080
style={{ strokeDashoffset: circumference - strokeDashoffset }}

0 commit comments

Comments
 (0)