@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.
@@ -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-bar__component_xzi53","svg":"circular-progress-bar__svg_xzi53","title":"circular-progress-bar__title_xzi53","subtitle":"circular-progress-bar__subtitle_xzi53","labelWrapper":"circular-progress-bar__labelWrapper_xzi53","label":"circular-progress-bar__label_xzi53","typography":"circular-progress-bar__typography_xzi53","xxl":"circular-progress-bar__xxl_xzi53","xl":"circular-progress-bar__xl_xzi53","l":"circular-progress-bar__l_xzi53","m":"circular-progress-bar__m_xzi53","s":"circular-progress-bar__s_xzi53","xs":"circular-progress-bar__xs_xzi53","backgroundCircle":"circular-progress-bar__backgroundCircle_xzi53","progressCircle":"circular-progress-bar__progressCircle_xzi53","positive":"circular-progress-bar__positive_xzi53","negative":"circular-progress-bar__negative_xzi53","stroke":"circular-progress-bar__stroke_xzi53","bg-positive":"circular-progress-bar__bg-positive_xzi53","bg-negative":"circular-progress-bar__bg-negative_xzi53","iconWrapper":"circular-progress-bar__iconWrapper_xzi53","icon-tertiary":"circular-progress-bar__icon-tertiary_xzi53","icon-positive":"circular-progress-bar__icon-positive_xzi53","icon-negative":"circular-progress-bar__icon-negative_xzi53","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_xzi53","icon-primary":"circular-progress-bar__icon-primary_xzi53","icon-secondary":"circular-progress-bar__icon-secondary_xzi53","icon":"circular-progress-bar__icon_xzi53"};
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 renderTitleString = () => SIZES[size] > 64 ? (React.createElement(Typography.TitleMobile, { className: cn(styles.typography, styles.title), color: isCompleteTextColor ? completeTextColor : contentColor, tag: 'div', font: 'system', view: VIEW_TITLE[size] }, titleContent)) : (React.createElement(Typography.Text, { className: styles.title, color: isCompleteTextColor ? completeTextColor : contentColor, tag: 'div', weight: 'bold', view: VIEW_TEXT[size] }, titleContent));
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 : contentColor, view: 'primary-small' }, subtitleContent)) : (subtitleContent);
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), style: {
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
- [styles[`bg-${view}`]]: fillComplete && isComplete,
88
- }), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
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 };
@@ -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: n376a */
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-bar__component_xzi53 {
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
- } .circular-progress-bar__svg_xzi53 {
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-bar__title_xzi53,
48
- .circular-progress-bar__subtitle_xzi53 {
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-bar__subtitle_xzi53 {
60
+ } .circular-progress-bar__subtitle_kekau {
55
61
  max-height: 40px;
56
- } .circular-progress-bar__labelWrapper_xzi53 {
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-bar__labelWrapper_xzi53.circular-progress-bar__label_xzi53 {
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-bar__typography_xzi53 {
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-bar__xxl_xzi53 {
77
+ } .circular-progress-bar__xxl_kekau {
72
78
  width: 144px;
73
79
  height: 144px
74
- } .circular-progress-bar__xxl_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
80
+ } .circular-progress-bar__xxl_kekau .circular-progress-bar__labelWrapper_kekau {
75
81
  max-width: 128px;
76
- } .circular-progress-bar__xxl_xzi53 .circular-progress-bar__title_xzi53 {
82
+ } .circular-progress-bar__xxl_kekau .circular-progress-bar__title_kekau {
77
83
  max-height: 32px;
78
- } .circular-progress-bar__xl_xzi53 {
84
+ } .circular-progress-bar__xl_kekau {
79
85
  width: 128px;
80
86
  height: 128px
81
- } .circular-progress-bar__xl_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
87
+ } .circular-progress-bar__xl_kekau .circular-progress-bar__labelWrapper_kekau {
82
88
  max-width: 108px;
83
- } .circular-progress-bar__xl_xzi53 .circular-progress-bar__title_xzi53 {
89
+ } .circular-progress-bar__xl_kekau .circular-progress-bar__title_kekau {
84
90
  max-height: 32px;
85
- } .circular-progress-bar__l_xzi53 {
91
+ } .circular-progress-bar__l_kekau {
86
92
  width: 80px;
87
93
  height: 80px
88
- } .circular-progress-bar__l_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
94
+ } .circular-progress-bar__l_kekau .circular-progress-bar__labelWrapper_kekau {
89
95
  max-width: 64px;
90
- } .circular-progress-bar__l_xzi53 .circular-progress-bar__title_xzi53 {
96
+ } .circular-progress-bar__l_kekau .circular-progress-bar__title_kekau {
91
97
  max-height: 24px;
92
- } .circular-progress-bar__m_xzi53 {
98
+ } .circular-progress-bar__m_kekau {
93
99
  width: 64px;
94
100
  height: 64px
95
- } .circular-progress-bar__m_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
101
+ } .circular-progress-bar__m_kekau .circular-progress-bar__labelWrapper_kekau {
96
102
  max-width: 48px;
97
- } .circular-progress-bar__m_xzi53 .circular-progress-bar__title_xzi53 {
103
+ } .circular-progress-bar__m_kekau .circular-progress-bar__title_kekau {
98
104
  max-height: 16px;
99
105
  margin: 0;
100
- } .circular-progress-bar__s_xzi53 {
106
+ } .circular-progress-bar__s_kekau {
101
107
  width: 48px;
102
108
  height: 48px
103
- } .circular-progress-bar__s_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
109
+ } .circular-progress-bar__s_kekau .circular-progress-bar__labelWrapper_kekau {
104
110
  max-width: 40px;
105
- } .circular-progress-bar__s_xzi53 .circular-progress-bar__title_xzi53 {
111
+ } .circular-progress-bar__s_kekau .circular-progress-bar__title_kekau {
106
112
  max-height: 16px;
107
113
  margin: 0;
108
- } .circular-progress-bar__xs_xzi53 {
114
+ } .circular-progress-bar__xs_kekau {
109
115
  width: 24px;
110
116
  height: 24px
111
- } .circular-progress-bar__xs_xzi53 .circular-progress-bar__labelWrapper_xzi53 {
117
+ } .circular-progress-bar__xs_kekau .circular-progress-bar__labelWrapper_kekau {
112
118
  max-width: 24px;
113
- } .circular-progress-bar__backgroundCircle_xzi53,
114
- .circular-progress-bar__progressCircle_xzi53 {
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-bar__positive_xzi53 {
124
+ } .circular-progress-bar__positive_kekau {
119
125
  stroke: var(--circular-progress-bar-positive-color);
120
- } .circular-progress-bar__negative_xzi53 {
126
+ } .circular-progress-bar__negative_kekau {
121
127
  stroke: var(--circular-progress-bar-negative-color);
122
- } .circular-progress-bar__backgroundCircle_xzi53 {
128
+ } .circular-progress-bar__backgroundCircle_kekau {
123
129
  stroke: var(--circular-progress-bar-stroke-color)
124
- } .circular-progress-bar__backgroundCircle_xzi53.circular-progress-bar__stroke_xzi53 {
130
+ } .circular-progress-bar__backgroundCircle_kekau.circular-progress-bar__stroke_kekau {
125
131
  stroke: transparent;
126
- } .circular-progress-bar__progressCircle_xzi53 {
127
- stroke-linecap: round
128
- } .circular-progress-bar__progressCircle_xzi53.circular-progress-bar__bg-positive_xzi53 {
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-bar__iconWrapper_xzi53.circular-progress-bar__xxl_xzi53 {
138
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xxl_kekau {
137
139
  max-width: 64px;
138
140
  max-height: 64px;
139
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__xl_xzi53 {
141
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xl_kekau {
140
142
  max-width: 64px;
141
143
  max-height: 64px;
142
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__l_xzi53 {
144
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__l_kekau {
143
145
  max-width: 48px;
144
146
  max-height: 48px;
145
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__m_xzi53 {
147
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__m_kekau {
146
148
  max-width: 36px;
147
149
  max-height: 36px;
148
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__s_xzi53 {
150
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__s_kekau {
149
151
  max-width: 24px;
150
152
  max-height: 24px;
151
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__xs_xzi53 {
153
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__xs_kekau {
152
154
  max-width: 16px;
153
155
  max-height: 16px;
154
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__icon-tertiary_xzi53 {
156
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-tertiary_kekau {
155
157
  color: var(--color-light-graphic-tertiary);
156
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__icon-positive_xzi53 {
158
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-positive_kekau {
157
159
  color: var(--color-light-graphic-positive);
158
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__icon-negative_xzi53 {
160
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-negative_kekau {
159
161
  color: var(--color-light-graphic-negative);
160
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__icon-primary-inverted_xzi53 {
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-bar__iconWrapper_xzi53.circular-progress-bar__icon-primary_xzi53 {
164
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-primary_kekau {
163
165
  color: var(--color-light-graphic-primary);
164
- } .circular-progress-bar__iconWrapper_xzi53.circular-progress-bar__icon-secondary_xzi53 {
166
+ } .circular-progress-bar__iconWrapper_kekau.circular-progress-bar__icon-secondary_kekau {
165
167
  color: var(--color-light-graphic-secondary);
166
- } .circular-progress-bar__icon_xzi53 {
168
+ } .circular-progress-bar__icon_kekau {
167
169
  width: 100%;
168
170
  height: 100%;
169
171
  }
package/modern/index.js CHANGED
@@ -2,3 +2,4 @@ export { CircularProgressBar } from './Component.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
4
  import '@alfalab/core-components-typography/modern';
5
+ import './consts.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-circular-progress-bar",
3
- "version": "3.1.0",
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.0.0",
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 styles from './index.module.css';
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
- const STROKE = {
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
- const VIEW_TITLE = {
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?: 'primary' | 'secondary' | 'tertiary' | 'positive' | 'negative';
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 : contentColor}
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 : contentColor}
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 : contentColor}
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
- [styles[`bg-${view}`]]: fillComplete && isComplete,
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'];
@@ -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 {