@alfalab/core-components-circular-progress-bar 2.4.2 → 2.4.3

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.
@@ -2,46 +2,99 @@ import cn from 'classnames';
2
2
  import React, { useMemo } from 'react';
3
3
  import { Typography } from '@alfalab/core-components-typography/modern';
4
4
 
5
- var styles = {"component":"circular-progress-bar__component_mot4l","svg":"circular-progress-bar__svg_mot4l","title":"circular-progress-bar__title_mot4l","subtitle":"circular-progress-bar__subtitle_mot4l","l":"circular-progress-bar__l_mot4l","label":"circular-progress-bar__label_mot4l","m":"circular-progress-bar__m_mot4l","s":"circular-progress-bar__s_mot4l","backgroundCircle":"circular-progress-bar__backgroundCircle_mot4l","progressCircle":"circular-progress-bar__progressCircle_mot4l","positive":"circular-progress-bar__positive_mot4l","negative":"circular-progress-bar__negative_mot4l"};
5
+ var styles = {"component":"circular-progress-bar__component_1piud","svg":"circular-progress-bar__svg_1piud","title":"circular-progress-bar__title_1piud","subtitle":"circular-progress-bar__subtitle_1piud","labelWrapper":"circular-progress-bar__labelWrapper_1piud","label":"circular-progress-bar__label_1piud","typography":"circular-progress-bar__typography_1piud","xxl":"circular-progress-bar__xxl_1piud","xl":"circular-progress-bar__xl_1piud","l":"circular-progress-bar__l_1piud","m":"circular-progress-bar__m_1piud","s":"circular-progress-bar__s_1piud","xs":"circular-progress-bar__xs_1piud","backgroundCircle":"circular-progress-bar__backgroundCircle_1piud","progressCircle":"circular-progress-bar__progressCircle_1piud","positive":"circular-progress-bar__positive_1piud","negative":"circular-progress-bar__negative_1piud","stroke":"circular-progress-bar__stroke_1piud","bg-positive":"circular-progress-bar__bg-positive_1piud","bg-negative":"circular-progress-bar__bg-negative_1piud","iconWrapper":"circular-progress-bar__iconWrapper_1piud","icon-tertiary":"circular-progress-bar__icon-tertiary_1piud","icon-positive":"circular-progress-bar__icon-positive_1piud","icon-negative":"circular-progress-bar__icon-negative_1piud","icon-primary-inverted":"circular-progress-bar__icon-primary-inverted_1piud","icon-primary":"circular-progress-bar__icon-primary_1piud","icon-secondary":"circular-progress-bar__icon-secondary_1piud","icon":"circular-progress-bar__icon_1piud"};
6
6
  require('./index.css')
7
7
 
8
8
  const SIZES = {
9
- s: 96,
10
- m: 120,
11
- l: 144,
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',
12
39
  };
13
40
  /**
14
41
  * Компонент круглого прогресс бара.
15
42
  */
16
- const CircularProgressBar = ({ value, view = 'positive', size = 'm', className, dataTestId, title = value.toString(), subtitle, children, }) => {
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, }) => {
17
44
  const memorized = useMemo(() => {
18
- const strokeWidth = 8;
45
+ const strokeWidth = STROKE[size];
19
46
  const maxProgress = 100;
20
47
  const minProgress = 0;
21
- const width = SIZES[size];
22
- const height = SIZES[size];
23
- const center = width / 2;
48
+ const widthSVG = SIZES[size];
49
+ const heightSVG = SIZES[size];
50
+ const center = widthSVG / 2;
24
51
  const radius = center - strokeWidth / 2;
25
52
  const circumference = Math.PI * radius * 2;
26
53
  const progress = Math.min(Math.max(value, minProgress), maxProgress);
27
54
  const strokeDasharray = circumference.toFixed(3);
28
55
  const strokeDashoffset = (((100 - progress) / 100) * circumference).toFixed(3);
29
56
  return {
30
- width,
31
- height,
57
+ widthSVG,
58
+ heightSVG,
32
59
  center,
33
60
  radius,
34
61
  strokeDasharray,
35
62
  strokeDashoffset,
36
63
  };
37
64
  }, [value, size]);
38
- return (React.createElement("div", { className: cn(styles.component, styles[size], className), "data-test-id": dataTestId },
39
- React.createElement("svg", { viewBox: `0 0 ${memorized.width} ${memorized.height}`, className: styles.svg, xmlns: 'http://www.w3.org/2000/svg' },
40
- React.createElement("circle", { className: styles.backgroundCircle, cx: memorized.center, cy: memorized.center, r: memorized.radius }),
41
- React.createElement("circle", { className: cn(styles.progressCircle, styles[view]), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeDasharray: memorized.strokeDasharray, strokeDashoffset: memorized.strokeDashoffset, transform: `rotate(${-90} ${memorized.center} ${memorized.center})` })),
42
- React.createElement("div", { className: styles.label }, children || (React.createElement(React.Fragment, null,
43
- typeof title === 'string' ? (React.createElement(Typography.Title, { className: styles.title, color: 'secondary', tag: 'div', view: size === 'l' ? 'small' : 'xsmall' }, title)) : (title),
44
- typeof subtitle === 'string' ? (React.createElement(Typography.Text, { tag: 'div', className: styles.subtitle, color: 'primary', view: 'primary-small' }, subtitle)) : (subtitle))))));
65
+ const isComplete = value === 100;
66
+ const isCompleteTextColor = isComplete && completeTextColor;
67
+ const titleContent = titleComplete && isComplete ? titleComplete : title;
68
+ const subtitleContent = subtitleComplete && isComplete ? subtitleComplete : subtitle;
69
+ const IconComponent = IconComplete && isComplete ? IconComplete : Icon;
70
+ const renderTitleString = () => {
71
+ return (React.createElement(React.Fragment, null, 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))));
72
+ };
73
+ const renderTitle = () => (typeof title === 'string' ? renderTitleString() : titleContent);
74
+ const renderSubTitle = () => typeof subtitle === 'string' ? (React.createElement(Typography.Text, { tag: 'div', className: styles.subtitle, color: isCompleteTextColor ? completeTextColor : contentColor, view: 'primary-small' }, subtitleContent)) : (subtitleContent);
75
+ const renderIcon = () => {
76
+ return (React.createElement("span", { className: cn(styles.iconWrapper, styles[size], styles.tertiary, styles[`icon-${contentColor}`], {
77
+ [styles[`icon-${completeIconColor}`]]: completeIconColor,
78
+ }) }, IconComponent && React.createElement(IconComponent, { className: styles.icon })));
79
+ };
80
+ const renderContent = () => Icon || (IconComplete && isComplete) ? (renderIcon()) : (React.createElement(React.Fragment, null,
81
+ SIZES[size] > 24 && renderTitle(),
82
+ SIZES[size] > 64 && renderSubTitle()));
83
+ return (React.createElement("div", { className: cn(styles.component, styles[size], className), style: {
84
+ ...(height && { height, width: height }),
85
+ }, "data-test-id": dataTestId },
86
+ React.createElement("svg", { viewBox: `0 0 ${memorized.widthSVG} ${memorized.heightSVG}`, className: styles.svg, xmlns: 'http://www.w3.org/2000/svg' },
87
+ React.createElement("circle", { className: cn(styles.backgroundCircle, styles[size], {
88
+ [styles.stroke]: !stroke,
89
+ }), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size] }),
90
+ React.createElement("circle", { className: cn(styles.progressCircle, styles[view], styles[size], {
91
+ [styles[`bg-${view}`]]: fillComplete && isComplete,
92
+ }), cx: memorized.center, cy: memorized.center, r: memorized.radius, strokeWidth: STROKE[size], strokeDasharray: memorized.strokeDasharray, strokeDashoffset: direction === 'counter-clockwise'
93
+ ? -memorized.strokeDashoffset
94
+ : memorized.strokeDashoffset, transform: `rotate(${-90} ${memorized.center} ${memorized.center})` })),
95
+ React.createElement("div", { className: cn(styles.labelWrapper, {
96
+ [styles.label]: Icon || IconComplete,
97
+ }) }, children || renderContent())));
45
98
  };
46
99
 
47
100
  export { CircularProgressBar };
package/modern/index.css CHANGED
@@ -1,10 +1,25 @@
1
- /* hash: sgitj */
1
+ /* hash: ws88i */
2
2
  :root {
3
3
  --color-light-bg-tertiary: #e7e9eb;
4
4
  --color-light-graphic-negative: #f15045;
5
5
  --color-light-graphic-positive: #2fc26e;
6
+ --color-light-graphic-primary: #0b1f35;
7
+ --color-light-graphic-primary-inverted: #fff;
8
+ --color-light-graphic-secondary: #6d7986;
9
+ --color-light-graphic-tertiary: #b6bcc3;
6
10
  }
11
+ :root {
12
+
13
+ /* Hard */
14
+
15
+ /* Up */
7
16
 
17
+ /* Hard up */
18
+ }
19
+ :root {
20
+ --font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
21
+ sans-serif;
22
+ }
8
23
  :root {
9
24
  /* bg */
10
25
  --circular-progress-bar-bg-color: var(--color-light-bg-tertiary);
@@ -14,94 +29,184 @@
14
29
 
15
30
  /* negative */
16
31
  --circular-progress-bar-negative-color: var(--color-light-graphic-negative);
17
- }
18
32
 
19
- .circular-progress-bar__component_mot4l {
33
+ /* theme */
34
+ --circular-progress-bar-font-family: var(--font-family-system);
35
+ --circular-progress-bar-font-weight: 600;
36
+ }
37
+ .circular-progress-bar__component_1piud {
20
38
  position: relative;
21
39
  display: flex;
22
40
  justify-content: center;
23
41
  align-items: center;
24
42
  }
25
-
26
- .circular-progress-bar__svg_mot4l {
43
+ .circular-progress-bar__svg_1piud {
27
44
  display: block;
28
45
  width: 100%;
29
46
  }
30
-
31
- .circular-progress-bar__title_mot4l,
32
- .circular-progress-bar__subtitle_mot4l {
47
+ .circular-progress-bar__title_1piud,
48
+ .circular-progress-bar__subtitle_1piud {
33
49
  overflow: hidden;
34
50
  word-break: break-word;
51
+ white-space: nowrap;
52
+ text-overflow: ellipsis;
53
+ margin: 0 6px;
35
54
  }
36
-
37
- .circular-progress-bar__subtitle_mot4l {
55
+ .circular-progress-bar__subtitle_1piud {
38
56
  max-height: 40px;
39
57
  }
40
-
41
- .circular-progress-bar__l_mot4l {
58
+ .circular-progress-bar__labelWrapper_1piud {
59
+ text-align: center;
60
+ position: absolute;
61
+ top: 50%;
62
+ left: 50%;
63
+ width: 100%;
64
+ transform: translate(-50%, -50%)
65
+ }
66
+ .circular-progress-bar__labelWrapper_1piud.circular-progress-bar__label_1piud {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ }
71
+ .circular-progress-bar__typography_1piud {
72
+ font-feature-settings: 'ss01';
73
+ font-weight: var(--circular-progress-bar-font-weight);
74
+ font-family: var(--circular-progress-bar-font-family);
75
+ }
76
+ .circular-progress-bar__xxl_1piud {
42
77
  width: 144px;
43
78
  height: 144px
44
79
  }
45
-
46
- .circular-progress-bar__l_mot4l .circular-progress-bar__label_mot4l {
47
- max-width: 120px;
80
+ .circular-progress-bar__xxl_1piud .circular-progress-bar__labelWrapper_1piud {
81
+ max-width: 128px;
48
82
  }
49
-
50
- .circular-progress-bar__l_mot4l .circular-progress-bar__title_mot4l {
83
+ .circular-progress-bar__xxl_1piud .circular-progress-bar__title_1piud {
51
84
  max-height: 32px;
52
85
  }
53
-
54
- .circular-progress-bar__m_mot4l {
55
- width: 120px;
56
- height: 120px
86
+ .circular-progress-bar__xl_1piud {
87
+ width: 128px;
88
+ height: 128px
57
89
  }
58
-
59
- .circular-progress-bar__m_mot4l .circular-progress-bar__label_mot4l {
60
- max-width: 96px;
90
+ .circular-progress-bar__xl_1piud .circular-progress-bar__labelWrapper_1piud {
91
+ max-width: 108px;
61
92
  }
62
-
63
- .circular-progress-bar__m_mot4l .circular-progress-bar__title_mot4l {
64
- max-height: 24px;
93
+ .circular-progress-bar__xl_1piud .circular-progress-bar__title_1piud {
94
+ max-height: 32px;
65
95
  }
66
-
67
- .circular-progress-bar__s_mot4l {
68
- width: 96px;
69
- height: 96px
96
+ .circular-progress-bar__l_1piud {
97
+ width: 80px;
98
+ height: 80px
70
99
  }
71
-
72
- .circular-progress-bar__s_mot4l .circular-progress-bar__label_mot4l {
73
- max-width: 72px;
100
+ .circular-progress-bar__l_1piud .circular-progress-bar__labelWrapper_1piud {
101
+ max-width: 64px;
74
102
  }
75
-
76
- .circular-progress-bar__s_mot4l .circular-progress-bar__title_mot4l {
103
+ .circular-progress-bar__l_1piud .circular-progress-bar__title_1piud {
77
104
  max-height: 24px;
78
105
  }
79
-
80
- .circular-progress-bar__label_mot4l {
81
- text-align: center;
82
- position: absolute;
83
- top: 50%;
84
- left: 50%;
85
- width: 100%;
86
- transform: translate(-50%, -50%);
106
+ .circular-progress-bar__m_1piud {
107
+ width: 64px;
108
+ height: 64px
87
109
  }
88
-
89
- .circular-progress-bar__backgroundCircle_mot4l,
90
- .circular-progress-bar__progressCircle_mot4l {
110
+ .circular-progress-bar__m_1piud .circular-progress-bar__labelWrapper_1piud {
111
+ max-width: 48px;
112
+ }
113
+ .circular-progress-bar__m_1piud .circular-progress-bar__title_1piud {
114
+ max-height: 16px;
115
+ margin: 0;
116
+ }
117
+ .circular-progress-bar__s_1piud {
118
+ width: 48px;
119
+ height: 48px
120
+ }
121
+ .circular-progress-bar__s_1piud .circular-progress-bar__labelWrapper_1piud {
122
+ max-width: 40px;
123
+ }
124
+ .circular-progress-bar__s_1piud .circular-progress-bar__title_1piud {
125
+ max-height: 16px;
126
+ margin: 0;
127
+ }
128
+ .circular-progress-bar__xs_1piud {
129
+ width: 24px;
130
+ height: 24px
131
+ }
132
+ .circular-progress-bar__xs_1piud .circular-progress-bar__labelWrapper_1piud {
133
+ max-width: 24px;
134
+ }
135
+ .circular-progress-bar__backgroundCircle_1piud,
136
+ .circular-progress-bar__progressCircle_1piud {
91
137
  width: 100%;
92
138
  height: 100%;
93
139
  fill: transparent;
94
- stroke-width: 8;
95
140
  }
96
-
97
- .circular-progress-bar__positive_mot4l {
141
+ .circular-progress-bar__positive_1piud {
98
142
  stroke: var(--circular-progress-bar-positive-color);
99
143
  }
100
-
101
- .circular-progress-bar__negative_mot4l {
144
+ .circular-progress-bar__negative_1piud {
102
145
  stroke: var(--circular-progress-bar-negative-color);
103
146
  }
104
-
105
- .circular-progress-bar__backgroundCircle_mot4l {
106
- stroke: var(--circular-progress-bar-bg-color);
147
+ .circular-progress-bar__backgroundCircle_1piud {
148
+ stroke: var(--circular-progress-bar-bg-color)
149
+ }
150
+ .circular-progress-bar__backgroundCircle_1piud.circular-progress-bar__stroke_1piud {
151
+ stroke: transparent;
152
+ }
153
+ .circular-progress-bar__progressCircle_1piud {
154
+ stroke-linecap: round
155
+ }
156
+ .circular-progress-bar__progressCircle_1piud.circular-progress-bar__bg-positive_1piud {
157
+ fill: var(--circular-progress-bar-positive-color);
158
+ }
159
+ .circular-progress-bar__progressCircle_1piud.circular-progress-bar__bg-negative_1piud {
160
+ fill: var(--circular-progress-bar-negative-color);
161
+ }
162
+ .circular-progress-bar__iconWrapper_1piud {
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center
166
+ }
167
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__xxl_1piud {
168
+ max-width: 64px;
169
+ max-height: 64px;
170
+ }
171
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__xl_1piud {
172
+ max-width: 64px;
173
+ max-height: 64px;
174
+ }
175
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__l_1piud {
176
+ max-width: 48px;
177
+ max-height: 48px;
178
+ }
179
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__m_1piud {
180
+ max-width: 36px;
181
+ max-height: 36px;
182
+ }
183
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__s_1piud {
184
+ max-width: 24px;
185
+ max-height: 24px;
186
+ }
187
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__xs_1piud {
188
+ max-width: 16px;
189
+ max-height: 16px;
190
+ }
191
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-tertiary_1piud {
192
+ color: var(--color-light-graphic-tertiary);
193
+ }
194
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-positive_1piud {
195
+ color: var(--color-light-graphic-positive);
196
+ }
197
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-negative_1piud {
198
+ color: var(--color-light-graphic-negative);
199
+ }
200
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-primary-inverted_1piud {
201
+ color: var(--color-light-graphic-primary-inverted);
202
+ }
203
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-primary_1piud {
204
+ color: var(--color-light-graphic-primary);
205
+ }
206
+ .circular-progress-bar__iconWrapper_1piud.circular-progress-bar__icon-secondary_1piud {
207
+ color: var(--color-light-graphic-secondary);
208
+ }
209
+ .circular-progress-bar__icon_1piud {
210
+ width: 100%;
211
+ height: 100%;
107
212
  }
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-circular-progress-bar",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
8
  "module": "./esm/index.js",
9
9
  "scripts": {
10
- "postinstall": "node ./send-stats.js > /dev/null 2>&1 || exit 0"
10
+ "postinstall": "node -e \"if (require('fs').existsSync('./send-stats.js')){require('./send-stats.js')} \""
11
11
  },
12
12
  "publishConfig": {
13
13
  "access": "public",
14
14
  "directory": "dist"
15
15
  },
16
16
  "dependencies": {
17
- "@alfalab/core-components-typography": "^2.6.2",
17
+ "@alfalab/core-components-typography": "^2.6.3",
18
18
  "classnames": "^2.2.6"
19
19
  },
20
20
  "peerDependencies": {