@alfalab/core-components-circular-progress-bar 2.3.4 → 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.
@@ -1,47 +0,0 @@
1
- import cn from 'classnames';
2
- import React, { useMemo } from 'react';
3
- import { Typography } from '@alfalab/core-components-typography/dist/modern';
4
-
5
- var styles = {"component":"circular-progress-bar__component_17pfh","svg":"circular-progress-bar__svg_17pfh","title":"circular-progress-bar__title_17pfh","subtitle":"circular-progress-bar__subtitle_17pfh","l":"circular-progress-bar__l_17pfh","label":"circular-progress-bar__label_17pfh","m":"circular-progress-bar__m_17pfh","s":"circular-progress-bar__s_17pfh","backgroundCircle":"circular-progress-bar__backgroundCircle_17pfh","progressCircle":"circular-progress-bar__progressCircle_17pfh","positive":"circular-progress-bar__positive_17pfh","negative":"circular-progress-bar__negative_17pfh"};
6
- require('./index.css')
7
-
8
- const SIZES = {
9
- s: 96,
10
- m: 120,
11
- l: 144,
12
- };
13
- /**
14
- * Компонент круглого прогресс бара.
15
- */
16
- const CircularProgressBar = ({ value, view = 'positive', size = 'm', className, dataTestId, title = value.toString(), subtitle, children, }) => {
17
- const memorized = useMemo(() => {
18
- const strokeWidth = 8;
19
- const maxProgress = 100;
20
- const minProgress = 0;
21
- const width = SIZES[size];
22
- const height = SIZES[size];
23
- const center = width / 2;
24
- const radius = center - strokeWidth / 2;
25
- const circumference = Math.PI * radius * 2;
26
- const progress = Math.min(Math.max(value, minProgress), maxProgress);
27
- const strokeDasharray = circumference.toFixed(3);
28
- const strokeDashoffset = (((100 - progress) / 100) * circumference).toFixed(3);
29
- return {
30
- width,
31
- height,
32
- center,
33
- radius,
34
- strokeDasharray,
35
- strokeDashoffset,
36
- };
37
- }, [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))))));
45
- };
46
-
47
- export { CircularProgressBar };
@@ -1,107 +0,0 @@
1
- /* hash: 1jvf0 */
2
- :root {
3
- --color-light-bg-tertiary: #e7e9eb;
4
- --color-light-graphic-negative: #f15045;
5
- --color-light-graphic-positive: #2fc26e;
6
- }
7
-
8
- :root {
9
- /* bg */
10
- --circular-progress-bar-bg-color: var(--color-light-bg-tertiary);
11
-
12
- /* positive */
13
- --circular-progress-bar-positive-color: var(--color-light-graphic-positive);
14
-
15
- /* negative */
16
- --circular-progress-bar-negative-color: var(--color-light-graphic-negative);
17
- }
18
-
19
- .circular-progress-bar__component_17pfh {
20
- position: relative;
21
- display: flex;
22
- justify-content: center;
23
- align-items: center;
24
- }
25
-
26
- .circular-progress-bar__svg_17pfh {
27
- display: block;
28
- width: 100%;
29
- }
30
-
31
- .circular-progress-bar__title_17pfh,
32
- .circular-progress-bar__subtitle_17pfh {
33
- overflow: hidden;
34
- word-break: break-word;
35
- }
36
-
37
- .circular-progress-bar__subtitle_17pfh {
38
- max-height: 40px;
39
- }
40
-
41
- .circular-progress-bar__l_17pfh {
42
- width: 144px;
43
- height: 144px
44
- }
45
-
46
- .circular-progress-bar__l_17pfh .circular-progress-bar__label_17pfh {
47
- max-width: 120px;
48
- }
49
-
50
- .circular-progress-bar__l_17pfh .circular-progress-bar__title_17pfh {
51
- max-height: 32px;
52
- }
53
-
54
- .circular-progress-bar__m_17pfh {
55
- width: 120px;
56
- height: 120px
57
- }
58
-
59
- .circular-progress-bar__m_17pfh .circular-progress-bar__label_17pfh {
60
- max-width: 96px;
61
- }
62
-
63
- .circular-progress-bar__m_17pfh .circular-progress-bar__title_17pfh {
64
- max-height: 24px;
65
- }
66
-
67
- .circular-progress-bar__s_17pfh {
68
- width: 96px;
69
- height: 96px
70
- }
71
-
72
- .circular-progress-bar__s_17pfh .circular-progress-bar__label_17pfh {
73
- max-width: 72px;
74
- }
75
-
76
- .circular-progress-bar__s_17pfh .circular-progress-bar__title_17pfh {
77
- max-height: 24px;
78
- }
79
-
80
- .circular-progress-bar__label_17pfh {
81
- text-align: center;
82
- position: absolute;
83
- top: 50%;
84
- left: 50%;
85
- width: 100%;
86
- transform: translate(-50%, -50%);
87
- }
88
-
89
- .circular-progress-bar__backgroundCircle_17pfh,
90
- .circular-progress-bar__progressCircle_17pfh {
91
- width: 100%;
92
- height: 100%;
93
- fill: transparent;
94
- stroke-width: 8;
95
- }
96
-
97
- .circular-progress-bar__positive_17pfh {
98
- stroke: var(--circular-progress-bar-positive-color);
99
- }
100
-
101
- .circular-progress-bar__negative_17pfh {
102
- stroke: var(--circular-progress-bar-negative-color);
103
- }
104
-
105
- .circular-progress-bar__backgroundCircle_17pfh {
106
- stroke: var(--circular-progress-bar-bg-color);
107
- }