@alfalab/core-components-circular-progress-bar 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component.d.ts +12 -3
- package/Component.js +20 -48
- package/consts.d.ts +34 -0
- package/consts.js +43 -0
- package/cssm/Component.d.ts +12 -3
- package/cssm/Component.js +19 -47
- package/cssm/consts.d.ts +34 -0
- package/cssm/consts.js +43 -0
- package/cssm/index.js +1 -0
- package/cssm/index.module.css +9 -7
- package/esm/Component.d.ts +12 -3
- package/esm/Component.js +15 -43
- package/esm/consts.d.ts +34 -0
- package/esm/consts.js +35 -0
- package/esm/index.css +54 -52
- package/esm/index.js +1 -0
- package/index.css +54 -52
- package/index.js +1 -0
- package/modern/Component.d.ts +12 -3
- package/modern/Component.js +21 -40
- package/modern/consts.d.ts +34 -0
- package/modern/consts.js +35 -0
- package/modern/index.css +54 -52
- package/modern/index.js +1 -0
- package/package.json +2 -2
- package/src/Component.tsx +40 -44
- package/src/consts.ts +37 -0
- package/src/index.module.css +9 -8
package/modern/Component.js
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Typography } from '@alfalab/core-components-typography/modern';
|
|
4
|
+
import { STROKE, SIZES, TYPOGRAPHY_COLOR, VIEW_TITLE, VIEW_TEXT } from './consts.js';
|
|
4
5
|
|
|
5
|
-
const styles = {"component":"circular-progress-
|
|
6
|
+
const styles = {"component":"circular-progress-bar__component_kekau","bg-positive":"circular-progress-bar__bg-positive_kekau","bg-negative":"circular-progress-bar__bg-negative_kekau","svg":"circular-progress-bar__svg_kekau","title":"circular-progress-bar__title_kekau","subtitle":"circular-progress-bar__subtitle_kekau","labelWrapper":"circular-progress-bar__labelWrapper_kekau","label":"circular-progress-bar__label_kekau","typography":"circular-progress-bar__typography_kekau","xxl":"circular-progress-bar__xxl_kekau","xl":"circular-progress-bar__xl_kekau","l":"circular-progress-bar__l_kekau","m":"circular-progress-bar__m_kekau","s":"circular-progress-bar__s_kekau","xs":"circular-progress-bar__xs_kekau","backgroundCircle":"circular-progress-bar__backgroundCircle_kekau","progressCircle":"circular-progress-bar__progressCircle_kekau","positive":"circular-progress-bar__positive_kekau","negative":"circular-progress-bar__negative_kekau","stroke":"circular-progress-bar__stroke_kekau","iconWrapper":"circular-progress-bar__iconWrapper_kekau","icon-tertiary":"circular-progress-bar__icon-tertiary_kekau","icon-positive":"circular-progress-bar__icon-positive_kekau","icon-negative":"circular-progress-bar__icon-negative_kekau","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_kekau","icon-primary":"circular-progress-bar__icon-primary_kekau","icon-secondary":"circular-progress-bar__icon-secondary_kekau","icon":"circular-progress-bar__icon_kekau"};
|
|
6
7
|
require('./index.css')
|
|
7
8
|
|
|
8
|
-
const SIZES = {
|
|
9
|
-
xs: 24,
|
|
10
|
-
s: 48,
|
|
11
|
-
m: 64,
|
|
12
|
-
l: 80,
|
|
13
|
-
xl: 128,
|
|
14
|
-
xxl: 144,
|
|
15
|
-
};
|
|
16
|
-
const STROKE = {
|
|
17
|
-
xs: 4,
|
|
18
|
-
s: 4,
|
|
19
|
-
m: 6,
|
|
20
|
-
l: 8,
|
|
21
|
-
xl: 10,
|
|
22
|
-
xxl: 12,
|
|
23
|
-
};
|
|
24
|
-
const VIEW_TITLE = {
|
|
25
|
-
xs: 'small',
|
|
26
|
-
s: 'small',
|
|
27
|
-
m: 'small',
|
|
28
|
-
l: 'xsmall',
|
|
29
|
-
xl: 'medium',
|
|
30
|
-
xxl: 'medium',
|
|
31
|
-
};
|
|
32
|
-
const VIEW_TEXT = {
|
|
33
|
-
xs: 'secondary-small',
|
|
34
|
-
s: 'secondary-small',
|
|
35
|
-
m: 'secondary-large',
|
|
36
|
-
l: 'secondary-large',
|
|
37
|
-
xl: 'secondary-large',
|
|
38
|
-
xxl: 'secondary-large',
|
|
39
|
-
};
|
|
40
9
|
/**
|
|
41
10
|
* Компонент круглого прогресс бара.
|
|
42
11
|
*/
|
|
43
|
-
const CircularProgressBar = ({ value, view = 'positive', size = 'm', className, dataTestId, title = value ? value.toString() : '0', titleComplete, subtitle, contentColor = 'secondary', subtitleComplete, stroke = true, fillComplete, icon: Icon, iconComplete: IconComplete, completeTextColor, completeIconColor = 'tertiary', direction = 'clockwise', height, children, }) => {
|
|
12
|
+
const CircularProgressBar = ({ value, view = 'positive', size = 'm', className, dataTestId, title = value ? value.toString() : '0', titleComplete, subtitle, contentColor = 'secondary', subtitleComplete, stroke = true, fillComplete, icon: Icon, iconComplete: IconComplete, completeTextColor, completeIconColor = 'tertiary', direction = 'clockwise', height, children, progressStrokeColor, circleColor, }) => {
|
|
44
13
|
const memorized = useMemo(() => {
|
|
45
14
|
const strokeWidth = STROKE[size];
|
|
46
15
|
const maxProgress = 100;
|
|
@@ -67,25 +36,37 @@ const CircularProgressBar = ({ value, view = 'positive', size = 'm', className,
|
|
|
67
36
|
const titleContent = titleComplete && isComplete ? titleComplete : title;
|
|
68
37
|
const subtitleContent = subtitleComplete && isComplete ? subtitleComplete : subtitle;
|
|
69
38
|
const IconComponent = IconComplete && isComplete ? IconComplete : Icon;
|
|
70
|
-
const
|
|
39
|
+
const typographyContentColor = TYPOGRAPHY_COLOR.includes(contentColor)
|
|
40
|
+
? contentColor
|
|
41
|
+
: undefined;
|
|
42
|
+
const renderTitleString = () => SIZES[size] > 64 ? (React.createElement(Typography.TitleMobile, { className: cn(styles.typography, styles.title), color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', font: 'system', view: VIEW_TITLE[size], style: {
|
|
43
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
44
|
+
} }, titleContent)) : (React.createElement(Typography.Text, { className: styles.title, color: isCompleteTextColor ? completeTextColor : typographyContentColor, tag: 'div', weight: 'bold', view: VIEW_TEXT[size], style: {
|
|
45
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
46
|
+
} }, titleContent));
|
|
71
47
|
const renderTitle = () => (typeof title === 'string' ? renderTitleString() : titleContent);
|
|
72
|
-
const renderSubTitle = () => typeof subtitle === 'string' ? (React.createElement(Typography.Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor :
|
|
48
|
+
const renderSubTitle = () => typeof subtitle === 'string' ? (React.createElement(Typography.Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor : typographyContentColor, view: 'primary-small', style: {
|
|
49
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
50
|
+
} }, subtitleContent)) : (subtitleContent);
|
|
73
51
|
const renderIcon = () => (React.createElement("span", { className: cn(styles.iconWrapper, styles[size], styles.tertiary, styles[`icon-${contentColor}`], {
|
|
74
52
|
[styles[`icon-${completeIconColor}`]]: completeIconColor,
|
|
75
53
|
}) }, IconComponent && React.createElement(IconComponent, { className: styles.icon })));
|
|
76
54
|
const renderContent = () => Icon || (IconComplete && isComplete) ? (renderIcon()) : (React.createElement(React.Fragment, null,
|
|
77
55
|
SIZES[size] > 24 && renderTitle(),
|
|
78
56
|
SIZES[size] > 64 && renderSubTitle()));
|
|
79
|
-
return (React.createElement("div", { className: cn(styles.component, styles[size], className
|
|
57
|
+
return (React.createElement("div", { className: cn(styles.component, styles[size], className, {
|
|
58
|
+
[styles[`bg-${view}`]]: fillComplete && isComplete,
|
|
59
|
+
}), style: {
|
|
80
60
|
...(height && { height, width: height }),
|
|
61
|
+
...(circleColor && { backgroundColor: circleColor }),
|
|
81
62
|
}, "data-test-id": dataTestId },
|
|
82
63
|
React.createElement("svg", { viewBox: `0 0 ${memorized.widthSVG} ${memorized.heightSVG}`, className: styles.svg, xmlns: 'http://www.w3.org/2000/svg' },
|
|
83
64
|
React.createElement("circle", { className: cn(styles.backgroundCircle, styles[size], {
|
|
84
65
|
[styles.stroke]: !stroke,
|
|
85
66
|
}), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size] }),
|
|
86
|
-
React.createElement("circle", { className: cn(styles.progressCircle, styles[view], styles[size], {
|
|
87
|
-
|
|
88
|
-
}
|
|
67
|
+
React.createElement("circle", { className: cn(styles.progressCircle, styles[view], styles[size]), style: {
|
|
68
|
+
...(progressStrokeColor && { stroke: progressStrokeColor }),
|
|
69
|
+
}, cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
|
|
89
70
|
? -memorized.strokeDashoffset
|
|
90
71
|
: memorized.strokeDashoffset, transform: `rotate(${-90} ${memorized.center} ${memorized.center})` })),
|
|
91
72
|
React.createElement("div", { className: cn(styles.labelWrapper, {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const SIZES: {
|
|
2
|
+
xs: number;
|
|
3
|
+
s: number;
|
|
4
|
+
m: number;
|
|
5
|
+
l: number;
|
|
6
|
+
xl: number;
|
|
7
|
+
xxl: number;
|
|
8
|
+
};
|
|
9
|
+
declare const STROKE: {
|
|
10
|
+
xs: number;
|
|
11
|
+
s: number;
|
|
12
|
+
m: number;
|
|
13
|
+
l: number;
|
|
14
|
+
xl: number;
|
|
15
|
+
xxl: number;
|
|
16
|
+
};
|
|
17
|
+
declare const VIEW_TITLE: {
|
|
18
|
+
readonly xs: "small";
|
|
19
|
+
readonly s: "small";
|
|
20
|
+
readonly m: "small";
|
|
21
|
+
readonly l: "xsmall";
|
|
22
|
+
readonly xl: "medium";
|
|
23
|
+
readonly xxl: "medium";
|
|
24
|
+
};
|
|
25
|
+
declare const VIEW_TEXT: {
|
|
26
|
+
readonly xs: "secondary-small";
|
|
27
|
+
readonly s: "secondary-small";
|
|
28
|
+
readonly m: "secondary-large";
|
|
29
|
+
readonly l: "secondary-large";
|
|
30
|
+
readonly xl: "secondary-large";
|
|
31
|
+
readonly xxl: "secondary-large";
|
|
32
|
+
};
|
|
33
|
+
declare const TYPOGRAPHY_COLOR: string[];
|
|
34
|
+
export { SIZES, STROKE, VIEW_TITLE, VIEW_TEXT, TYPOGRAPHY_COLOR };
|
package/modern/consts.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const SIZES = {
|
|
2
|
+
xs: 24,
|
|
3
|
+
s: 48,
|
|
4
|
+
m: 64,
|
|
5
|
+
l: 80,
|
|
6
|
+
xl: 128,
|
|
7
|
+
xxl: 144,
|
|
8
|
+
};
|
|
9
|
+
const STROKE = {
|
|
10
|
+
xs: 4,
|
|
11
|
+
s: 4,
|
|
12
|
+
m: 6,
|
|
13
|
+
l: 8,
|
|
14
|
+
xl: 10,
|
|
15
|
+
xxl: 12,
|
|
16
|
+
};
|
|
17
|
+
const VIEW_TITLE = {
|
|
18
|
+
xs: 'small',
|
|
19
|
+
s: 'small',
|
|
20
|
+
m: 'small',
|
|
21
|
+
l: 'xsmall',
|
|
22
|
+
xl: 'medium',
|
|
23
|
+
xxl: 'medium',
|
|
24
|
+
};
|
|
25
|
+
const VIEW_TEXT = {
|
|
26
|
+
xs: 'secondary-small',
|
|
27
|
+
s: 'secondary-small',
|
|
28
|
+
m: 'secondary-large',
|
|
29
|
+
l: 'secondary-large',
|
|
30
|
+
xl: 'secondary-large',
|
|
31
|
+
xxl: 'secondary-large',
|
|
32
|
+
};
|
|
33
|
+
const TYPOGRAPHY_COLOR = ['primary', 'secondary', 'tertiary', 'positive', 'negative'];
|
|
34
|
+
|
|
35
|
+
export { SIZES, STROKE, TYPOGRAPHY_COLOR, VIEW_TEXT, VIEW_TITLE };
|
package/modern/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: mxnd9 */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-border-primary: #dcdcdd;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
/* Hard up */
|
|
20
20
|
} :root {
|
|
21
|
+
--border-radius-pill: 99px;
|
|
21
22
|
} :root {
|
|
22
23
|
} :root {
|
|
23
24
|
--font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
|
|
@@ -36,134 +37,135 @@
|
|
|
36
37
|
/* theme */
|
|
37
38
|
--circular-progress-bar-font-family: var(--font-family-system);
|
|
38
39
|
--circular-progress-bar-font-weight: 600;
|
|
39
|
-
} .circular-progress-
|
|
40
|
+
} .circular-progress-bar__component_kekau {
|
|
40
41
|
position: relative;
|
|
41
42
|
display: flex;
|
|
42
43
|
justify-content: center;
|
|
43
44
|
align-items: center;
|
|
44
|
-
|
|
45
|
+
border-radius: var(--border-radius-pill)
|
|
46
|
+
} .circular-progress-bar__component_kekau.circular-progress-bar__bg-positive_kekau {
|
|
47
|
+
background: var(--circular-progress-bar-positive-color);
|
|
48
|
+
} .circular-progress-bar__component_kekau.circular-progress-bar__bg-negative_kekau {
|
|
49
|
+
background: var(--circular-progress-bar-negative-color);
|
|
50
|
+
} .circular-progress-bar__svg_kekau {
|
|
45
51
|
display: block;
|
|
46
52
|
width: 100%;
|
|
47
|
-
} .circular-progress-
|
|
48
|
-
.circular-progress-
|
|
53
|
+
} .circular-progress-bar__title_kekau,
|
|
54
|
+
.circular-progress-bar__subtitle_kekau {
|
|
49
55
|
overflow: hidden;
|
|
50
56
|
word-break: break-word;
|
|
51
57
|
white-space: nowrap;
|
|
52
58
|
text-overflow: ellipsis;
|
|
53
59
|
margin: 0 6px;
|
|
54
|
-
} .circular-progress-
|
|
60
|
+
} .circular-progress-bar__subtitle_kekau {
|
|
55
61
|
max-height: 40px;
|
|
56
|
-
} .circular-progress-
|
|
62
|
+
} .circular-progress-bar__labelWrapper_kekau {
|
|
57
63
|
text-align: center;
|
|
58
64
|
position: absolute;
|
|
59
65
|
top: 50%;
|
|
60
66
|
left: 50%;
|
|
61
67
|
width: 100%;
|
|
62
68
|
transform: translate(-50%, -50%)
|
|
63
|
-
} .circular-progress-
|
|
69
|
+
} .circular-progress-bar__labelWrapper_kekau.circular-progress-bar__label_kekau {
|
|
64
70
|
display: flex;
|
|
65
71
|
align-items: center;
|
|
66
72
|
justify-content: center;
|
|
67
|
-
} .circular-progress-
|
|
73
|
+
} .circular-progress-bar__typography_kekau {
|
|
68
74
|
font-feature-settings: 'ss01';
|
|
69
75
|
font-weight: var(--circular-progress-bar-font-weight);
|
|
70
76
|
font-family: var(--circular-progress-bar-font-family);
|
|
71
|
-
} .circular-progress-
|
|
77
|
+
} .circular-progress-bar__xxl_kekau {
|
|
72
78
|
width: 144px;
|
|
73
79
|
height: 144px
|
|
74
|
-
} .circular-progress-
|
|
80
|
+
} .circular-progress-bar__xxl_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
75
81
|
max-width: 128px;
|
|
76
|
-
} .circular-progress-
|
|
82
|
+
} .circular-progress-bar__xxl_kekau .circular-progress-bar__title_kekau {
|
|
77
83
|
max-height: 32px;
|
|
78
|
-
} .circular-progress-
|
|
84
|
+
} .circular-progress-bar__xl_kekau {
|
|
79
85
|
width: 128px;
|
|
80
86
|
height: 128px
|
|
81
|
-
} .circular-progress-
|
|
87
|
+
} .circular-progress-bar__xl_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
82
88
|
max-width: 108px;
|
|
83
|
-
} .circular-progress-
|
|
89
|
+
} .circular-progress-bar__xl_kekau .circular-progress-bar__title_kekau {
|
|
84
90
|
max-height: 32px;
|
|
85
|
-
} .circular-progress-
|
|
91
|
+
} .circular-progress-bar__l_kekau {
|
|
86
92
|
width: 80px;
|
|
87
93
|
height: 80px
|
|
88
|
-
} .circular-progress-
|
|
94
|
+
} .circular-progress-bar__l_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
89
95
|
max-width: 64px;
|
|
90
|
-
} .circular-progress-
|
|
96
|
+
} .circular-progress-bar__l_kekau .circular-progress-bar__title_kekau {
|
|
91
97
|
max-height: 24px;
|
|
92
|
-
} .circular-progress-
|
|
98
|
+
} .circular-progress-bar__m_kekau {
|
|
93
99
|
width: 64px;
|
|
94
100
|
height: 64px
|
|
95
|
-
} .circular-progress-
|
|
101
|
+
} .circular-progress-bar__m_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
96
102
|
max-width: 48px;
|
|
97
|
-
} .circular-progress-
|
|
103
|
+
} .circular-progress-bar__m_kekau .circular-progress-bar__title_kekau {
|
|
98
104
|
max-height: 16px;
|
|
99
105
|
margin: 0;
|
|
100
|
-
} .circular-progress-
|
|
106
|
+
} .circular-progress-bar__s_kekau {
|
|
101
107
|
width: 48px;
|
|
102
108
|
height: 48px
|
|
103
|
-
} .circular-progress-
|
|
109
|
+
} .circular-progress-bar__s_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
104
110
|
max-width: 40px;
|
|
105
|
-
} .circular-progress-
|
|
111
|
+
} .circular-progress-bar__s_kekau .circular-progress-bar__title_kekau {
|
|
106
112
|
max-height: 16px;
|
|
107
113
|
margin: 0;
|
|
108
|
-
} .circular-progress-
|
|
114
|
+
} .circular-progress-bar__xs_kekau {
|
|
109
115
|
width: 24px;
|
|
110
116
|
height: 24px
|
|
111
|
-
} .circular-progress-
|
|
117
|
+
} .circular-progress-bar__xs_kekau .circular-progress-bar__labelWrapper_kekau {
|
|
112
118
|
max-width: 24px;
|
|
113
|
-
} .circular-progress-
|
|
114
|
-
.circular-progress-
|
|
119
|
+
} .circular-progress-bar__backgroundCircle_kekau,
|
|
120
|
+
.circular-progress-bar__progressCircle_kekau {
|
|
115
121
|
width: 100%;
|
|
116
122
|
height: 100%;
|
|
117
123
|
fill: transparent;
|
|
118
|
-
} .circular-progress-
|
|
124
|
+
} .circular-progress-bar__positive_kekau {
|
|
119
125
|
stroke: var(--circular-progress-bar-positive-color);
|
|
120
|
-
} .circular-progress-
|
|
126
|
+
} .circular-progress-bar__negative_kekau {
|
|
121
127
|
stroke: var(--circular-progress-bar-negative-color);
|
|
122
|
-
} .circular-progress-
|
|
128
|
+
} .circular-progress-bar__backgroundCircle_kekau {
|
|
123
129
|
stroke: var(--circular-progress-bar-stroke-color)
|
|
124
|
-
} .circular-progress-
|
|
130
|
+
} .circular-progress-bar__backgroundCircle_kekau.circular-progress-bar__stroke_kekau {
|
|
125
131
|
stroke: transparent;
|
|
126
|
-
} .circular-progress-
|
|
127
|
-
stroke-linecap: round
|
|
128
|
-
} .circular-progress-
|
|
129
|
-
fill: var(--circular-progress-bar-positive-color);
|
|
130
|
-
} .circular-progress-bar__progressCircle_xzi53.circular-progress-bar__bg-negative_xzi53 {
|
|
131
|
-
fill: var(--circular-progress-bar-negative-color);
|
|
132
|
-
} .circular-progress-bar__iconWrapper_xzi53 {
|
|
132
|
+
} .circular-progress-bar__progressCircle_kekau {
|
|
133
|
+
stroke-linecap: round;
|
|
134
|
+
} .circular-progress-bar__iconWrapper_kekau {
|
|
133
135
|
display: flex;
|
|
134
136
|
align-items: center;
|
|
135
137
|
justify-content: center
|
|
136
|
-
} .circular-progress-
|
|
138
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xxl_kekau {
|
|
137
139
|
max-width: 64px;
|
|
138
140
|
max-height: 64px;
|
|
139
|
-
} .circular-progress-
|
|
141
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xl_kekau {
|
|
140
142
|
max-width: 64px;
|
|
141
143
|
max-height: 64px;
|
|
142
|
-
} .circular-progress-
|
|
144
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__l_kekau {
|
|
143
145
|
max-width: 48px;
|
|
144
146
|
max-height: 48px;
|
|
145
|
-
} .circular-progress-
|
|
147
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__m_kekau {
|
|
146
148
|
max-width: 36px;
|
|
147
149
|
max-height: 36px;
|
|
148
|
-
} .circular-progress-
|
|
150
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__s_kekau {
|
|
149
151
|
max-width: 24px;
|
|
150
152
|
max-height: 24px;
|
|
151
|
-
} .circular-progress-
|
|
153
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xs_kekau {
|
|
152
154
|
max-width: 16px;
|
|
153
155
|
max-height: 16px;
|
|
154
|
-
} .circular-progress-
|
|
156
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-tertiary_kekau {
|
|
155
157
|
color: var(--color-light-graphic-tertiary);
|
|
156
|
-
} .circular-progress-
|
|
158
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-positive_kekau {
|
|
157
159
|
color: var(--color-light-graphic-positive);
|
|
158
|
-
} .circular-progress-
|
|
160
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-negative_kekau {
|
|
159
161
|
color: var(--color-light-graphic-negative);
|
|
160
|
-
} .circular-progress-
|
|
162
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-primary-inverted_kekau {
|
|
161
163
|
color: var(--color-light-graphic-primary-inverted);
|
|
162
|
-
} .circular-progress-
|
|
164
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-primary_kekau {
|
|
163
165
|
color: var(--color-light-graphic-primary);
|
|
164
|
-
} .circular-progress-
|
|
166
|
+
} .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-secondary_kekau {
|
|
165
167
|
color: var(--color-light-graphic-secondary);
|
|
166
|
-
} .circular-progress-
|
|
168
|
+
} .circular-progress-bar__icon_kekau {
|
|
167
169
|
width: 100%;
|
|
168
170
|
height: 100%;
|
|
169
171
|
}
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-circular-progress-bar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "dist"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@alfalab/core-components-typography": "^4.
|
|
14
|
+
"@alfalab/core-components-typography": "^4.1.0",
|
|
15
15
|
"classnames": "^2.3.1",
|
|
16
16
|
"tslib": "^2.4.0"
|
|
17
17
|
},
|
package/src/Component.tsx
CHANGED
|
@@ -3,43 +3,11 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import { Typography } from '@alfalab/core-components-typography';
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
const SIZES = {
|
|
9
|
-
xs: 24,
|
|
10
|
-
s: 48,
|
|
11
|
-
m: 64,
|
|
12
|
-
l: 80,
|
|
13
|
-
xl: 128,
|
|
14
|
-
xxl: 144,
|
|
15
|
-
};
|
|
6
|
+
import { SIZES, STROKE, TYPOGRAPHY_COLOR, VIEW_TEXT, VIEW_TITLE } from './consts';
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
xs: 4,
|
|
19
|
-
s: 4,
|
|
20
|
-
m: 6,
|
|
21
|
-
l: 8,
|
|
22
|
-
xl: 10,
|
|
23
|
-
xxl: 12,
|
|
24
|
-
};
|
|
8
|
+
import styles from './index.module.css';
|
|
25
9
|
|
|
26
|
-
|
|
27
|
-
xs: 'small',
|
|
28
|
-
s: 'small',
|
|
29
|
-
m: 'small',
|
|
30
|
-
l: 'xsmall',
|
|
31
|
-
xl: 'medium',
|
|
32
|
-
xxl: 'medium',
|
|
33
|
-
} as const;
|
|
34
|
-
|
|
35
|
-
const VIEW_TEXT = {
|
|
36
|
-
xs: 'secondary-small',
|
|
37
|
-
s: 'secondary-small',
|
|
38
|
-
m: 'secondary-large',
|
|
39
|
-
l: 'secondary-large',
|
|
40
|
-
xl: 'secondary-large',
|
|
41
|
-
xxl: 'secondary-large',
|
|
42
|
-
} as const;
|
|
10
|
+
export type TypographyColor = 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
|
|
43
11
|
|
|
44
12
|
export type CircularProgressBarProps = {
|
|
45
13
|
/**
|
|
@@ -60,7 +28,7 @@ export type CircularProgressBarProps = {
|
|
|
60
28
|
/**
|
|
61
29
|
* Цвет контента
|
|
62
30
|
*/
|
|
63
|
-
contentColor?:
|
|
31
|
+
contentColor?: TypographyColor | string;
|
|
64
32
|
|
|
65
33
|
/**
|
|
66
34
|
* Дополнительный текст
|
|
@@ -140,9 +108,19 @@ export type CircularProgressBarProps = {
|
|
|
140
108
|
dataTestId?: string;
|
|
141
109
|
|
|
142
110
|
/**
|
|
143
|
-
* Дочерние
|
|
111
|
+
* Дочерние элементы
|
|
144
112
|
*/
|
|
145
113
|
children?: ReactNode;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Цвет прогресса
|
|
117
|
+
*/
|
|
118
|
+
progressStrokeColor?: string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Цвет заливки внутри круга
|
|
122
|
+
*/
|
|
123
|
+
circleColor?: string;
|
|
146
124
|
};
|
|
147
125
|
|
|
148
126
|
/**
|
|
@@ -168,6 +146,8 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
168
146
|
direction = 'clockwise',
|
|
169
147
|
height,
|
|
170
148
|
children,
|
|
149
|
+
progressStrokeColor,
|
|
150
|
+
circleColor,
|
|
171
151
|
}) => {
|
|
172
152
|
const memorized = useMemo(() => {
|
|
173
153
|
const strokeWidth = STROKE[size];
|
|
@@ -197,25 +177,34 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
197
177
|
const titleContent = titleComplete && isComplete ? titleComplete : title;
|
|
198
178
|
const subtitleContent = subtitleComplete && isComplete ? subtitleComplete : subtitle;
|
|
199
179
|
const IconComponent = IconComplete && isComplete ? IconComplete : Icon;
|
|
180
|
+
const typographyContentColor = TYPOGRAPHY_COLOR.includes(contentColor)
|
|
181
|
+
? (contentColor as TypographyColor)
|
|
182
|
+
: undefined;
|
|
200
183
|
|
|
201
184
|
const renderTitleString = () =>
|
|
202
185
|
SIZES[size] > 64 ? (
|
|
203
186
|
<Typography.TitleMobile
|
|
204
187
|
className={cn(styles.typography, styles.title)}
|
|
205
|
-
color={isCompleteTextColor ? completeTextColor :
|
|
188
|
+
color={isCompleteTextColor ? completeTextColor : typographyContentColor}
|
|
206
189
|
tag='div'
|
|
207
190
|
font='system'
|
|
208
191
|
view={VIEW_TITLE[size]}
|
|
192
|
+
style={{
|
|
193
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
194
|
+
}}
|
|
209
195
|
>
|
|
210
196
|
{titleContent}
|
|
211
197
|
</Typography.TitleMobile>
|
|
212
198
|
) : (
|
|
213
199
|
<Typography.Text
|
|
214
200
|
className={styles.title}
|
|
215
|
-
color={isCompleteTextColor ? completeTextColor :
|
|
201
|
+
color={isCompleteTextColor ? completeTextColor : typographyContentColor}
|
|
216
202
|
tag='div'
|
|
217
203
|
weight='bold'
|
|
218
204
|
view={VIEW_TEXT[size]}
|
|
205
|
+
style={{
|
|
206
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
207
|
+
}}
|
|
219
208
|
>
|
|
220
209
|
{titleContent}
|
|
221
210
|
</Typography.Text>
|
|
@@ -228,8 +217,11 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
228
217
|
<Typography.Text
|
|
229
218
|
tag='div'
|
|
230
219
|
className={styles.subtitle}
|
|
231
|
-
color={isCompleteTextColor ? completeTextColor :
|
|
220
|
+
color={isCompleteTextColor ? completeTextColor : typographyContentColor}
|
|
232
221
|
view='primary-small'
|
|
222
|
+
style={{
|
|
223
|
+
...(!typographyContentColor && { color: contentColor }),
|
|
224
|
+
}}
|
|
233
225
|
>
|
|
234
226
|
{subtitleContent}
|
|
235
227
|
</Typography.Text>
|
|
@@ -265,9 +257,12 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
265
257
|
|
|
266
258
|
return (
|
|
267
259
|
<div
|
|
268
|
-
className={cn(styles.component, styles[size], className
|
|
260
|
+
className={cn(styles.component, styles[size], className, {
|
|
261
|
+
[styles[`bg-${view}`]]: fillComplete && isComplete,
|
|
262
|
+
})}
|
|
269
263
|
style={{
|
|
270
264
|
...(height && { height, width: height }),
|
|
265
|
+
...(circleColor && { backgroundColor: circleColor }),
|
|
271
266
|
}}
|
|
272
267
|
data-test-id={dataTestId}
|
|
273
268
|
>
|
|
@@ -286,9 +281,10 @@ export const CircularProgressBar: React.FC<CircularProgressBarProps> = ({
|
|
|
286
281
|
strokeWidth={STROKE[size]}
|
|
287
282
|
/>
|
|
288
283
|
<circle
|
|
289
|
-
className={cn(styles.progressCircle, styles[view], styles[size]
|
|
290
|
-
|
|
291
|
-
|
|
284
|
+
className={cn(styles.progressCircle, styles[view], styles[size])}
|
|
285
|
+
style={{
|
|
286
|
+
...(progressStrokeColor && { stroke: progressStrokeColor }),
|
|
287
|
+
}}
|
|
292
288
|
cx={memorized.center}
|
|
293
289
|
cy={memorized.center}
|
|
294
290
|
r={memorized.radius}
|
package/src/consts.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const SIZES = {
|
|
2
|
+
xs: 24,
|
|
3
|
+
s: 48,
|
|
4
|
+
m: 64,
|
|
5
|
+
l: 80,
|
|
6
|
+
xl: 128,
|
|
7
|
+
xxl: 144,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const STROKE = {
|
|
11
|
+
xs: 4,
|
|
12
|
+
s: 4,
|
|
13
|
+
m: 6,
|
|
14
|
+
l: 8,
|
|
15
|
+
xl: 10,
|
|
16
|
+
xxl: 12,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const VIEW_TITLE = {
|
|
20
|
+
xs: 'small',
|
|
21
|
+
s: 'small',
|
|
22
|
+
m: 'small',
|
|
23
|
+
l: 'xsmall',
|
|
24
|
+
xl: 'medium',
|
|
25
|
+
xxl: 'medium',
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
export const VIEW_TEXT = {
|
|
29
|
+
xs: 'secondary-small',
|
|
30
|
+
s: 'secondary-small',
|
|
31
|
+
m: 'secondary-large',
|
|
32
|
+
l: 'secondary-large',
|
|
33
|
+
xl: 'secondary-large',
|
|
34
|
+
xxl: 'secondary-large',
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
export const TYPOGRAPHY_COLOR = ['primary', 'secondary', 'tertiary', 'positive', 'negative'];
|
package/src/index.module.css
CHANGED
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
display: flex;
|
|
21
21
|
justify-content: center;
|
|
22
22
|
align-items: center;
|
|
23
|
+
border-radius: var(--border-radius-pill);
|
|
24
|
+
|
|
25
|
+
&.bg-positive {
|
|
26
|
+
background: var(--circular-progress-bar-positive-color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.bg-negative {
|
|
30
|
+
background: var(--circular-progress-bar-negative-color);
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
.svg {
|
|
@@ -162,14 +171,6 @@
|
|
|
162
171
|
|
|
163
172
|
.progressCircle {
|
|
164
173
|
stroke-linecap: round;
|
|
165
|
-
|
|
166
|
-
&.bg-positive {
|
|
167
|
-
fill: var(--circular-progress-bar-positive-color);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
&.bg-negative {
|
|
171
|
-
fill: var(--circular-progress-bar-negative-color);
|
|
172
|
-
}
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
.iconWrapper {
|