@spaced-out/ui-design-system 0.1.112 → 0.1.113

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.
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Check Permissions
23
23
  id: check-permissions
24
24
  env:
25
- ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah
25
+ ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah, Swatantramishra1
26
26
  if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
27
27
  run: |
28
28
  echo "You don't have correct permissions to do this release"
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.113](https://github.com/spaced-out/ui-design-system/compare/v0.1.112...v0.1.113) (2024-07-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * donut progress bar ([#243](https://github.com/spaced-out/ui-design-system/issues/243)) ([5510117](https://github.com/spaced-out/ui-design-system/commit/5510117890fb1dd5a8ba7537cb0079885bcc6a8c))
11
+
5
12
  ### [0.1.112](https://github.com/spaced-out/ui-design-system/compare/v0.1.111...v0.1.112) (2024-07-15)
6
13
 
7
14
 
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProgressDonut = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
9
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
10
+ var _Text = require("../Text");
11
+ var _ProgressDonutModule = _interopRequireDefault(require("./ProgressDonut.module.css"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ const STROKE_WIDTH = 8;
17
+ const MIN_PERCENTAGE = 0;
18
+ const DIVISOR_TWO = 2;
19
+ const MAX_PERCENTAGE = 100;
20
+ const SUCCESS_THRESHOLD = 80;
21
+ const LARGE_DONUT_SIZE = 72;
22
+ const INFO_THRESHOLD = 50;
23
+ const WARNING_THRESHOLD = 30;
24
+ const getProgressDonutColor = percentage => {
25
+ if (percentage >= SUCCESS_THRESHOLD) {
26
+ return COLORS.colorSuccess;
27
+ } else if (percentage >= INFO_THRESHOLD && percentage < SUCCESS_THRESHOLD) {
28
+ return COLORS.colorInformation;
29
+ } else if (percentage >= WARNING_THRESHOLD && percentage < INFO_THRESHOLD) {
30
+ return COLORS.colorWarning;
31
+ } else {
32
+ return COLORS.colorDanger;
33
+ }
34
+ };
35
+ const ProgressDonut = /*#__PURE__*/React.forwardRef((_ref, ref) => {
36
+ let {
37
+ classNames,
38
+ percentage = 0,
39
+ color = ''
40
+ } = _ref;
41
+ const donutPercentage = React.useMemo(() => Math.min(Math.max(percentage, MIN_PERCENTAGE), MAX_PERCENTAGE), [percentage]);
42
+ const donutColor = React.useMemo(() => getProgressDonutColor(donutPercentage), [donutPercentage]);
43
+ const radius = React.useMemo(() => (LARGE_DONUT_SIZE - STROKE_WIDTH) / DIVISOR_TWO, [LARGE_DONUT_SIZE]);
44
+ const circumference = React.useMemo(() => DIVISOR_TWO * Math.PI * radius, [radius]);
45
+ const offset = React.useMemo(() => circumference - donutPercentage / MAX_PERCENTAGE * circumference, [circumference, donutPercentage]);
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ ref: ref,
48
+ "data-testid": "ProgressDonut",
49
+ className: (0, _classify.default)(_ProgressDonutModule.default.wrapper, classNames?.wrapper)
50
+ }, /*#__PURE__*/React.createElement("div", {
51
+ className: _ProgressDonutModule.default.donutChart
52
+ }, /*#__PURE__*/React.createElement("svg", {
53
+ width: LARGE_DONUT_SIZE,
54
+ height: LARGE_DONUT_SIZE,
55
+ viewBox: `0 0 ${LARGE_DONUT_SIZE} ${LARGE_DONUT_SIZE}`,
56
+ className: _ProgressDonutModule.default.donutChartSvg
57
+ }, /*#__PURE__*/React.createElement("circle", {
58
+ className: _ProgressDonutModule.default.donutChartBackground,
59
+ cx: LARGE_DONUT_SIZE / DIVISOR_TWO,
60
+ cy: LARGE_DONUT_SIZE / DIVISOR_TWO,
61
+ r: radius,
62
+ strokeWidth: STROKE_WIDTH
63
+ }), /*#__PURE__*/React.createElement("circle", {
64
+ className: _ProgressDonutModule.default.donutChartForeground,
65
+ cx: LARGE_DONUT_SIZE / DIVISOR_TWO,
66
+ cy: LARGE_DONUT_SIZE / DIVISOR_TWO,
67
+ r: radius,
68
+ strokeWidth: STROKE_WIDTH,
69
+ strokeDasharray: circumference,
70
+ strokeDashoffset: donutPercentage === MIN_PERCENTAGE ? circumference : offset,
71
+ stroke: COLORS[color] || donutColor,
72
+ strokeLinecap: "round"
73
+ })), /*#__PURE__*/React.createElement(_Text.BodyLargeBold, {
74
+ className: _ProgressDonutModule.default.donutChartPercentage
75
+ }, `${donutPercentage}%`)));
76
+ });
77
+ exports.ProgressDonut = ProgressDonut;
@@ -0,0 +1,111 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import * as COLORS from '../../styles/variables/_color';
6
+ import classify from '../../utils/classify';
7
+ import {BodyLargeBold} from '../Text';
8
+
9
+ import css from './ProgressDonut.module.css';
10
+
11
+
12
+ const STROKE_WIDTH = 8;
13
+ const MIN_PERCENTAGE = 0;
14
+ const DIVISOR_TWO = 2;
15
+ const MAX_PERCENTAGE = 100;
16
+ const SUCCESS_THRESHOLD = 80;
17
+ const LARGE_DONUT_SIZE = 72;
18
+ const INFO_THRESHOLD = 50;
19
+ const WARNING_THRESHOLD = 30;
20
+
21
+ type ClassNames = $ReadOnly<{
22
+ wrapper?: string,
23
+ }>;
24
+
25
+ export type ProgressDonutProps = {
26
+ classNames?: ClassNames,
27
+ color?: $Keys<typeof COLORS>,
28
+ percentage: number,
29
+ };
30
+
31
+ const getProgressDonutColor = (percentage: number): string => {
32
+ if (percentage >= SUCCESS_THRESHOLD) {
33
+ return COLORS.colorSuccess;
34
+ } else if (percentage >= INFO_THRESHOLD && percentage < SUCCESS_THRESHOLD) {
35
+ return COLORS.colorInformation;
36
+ } else if (percentage >= WARNING_THRESHOLD && percentage < INFO_THRESHOLD) {
37
+ return COLORS.colorWarning;
38
+ } else {
39
+ return COLORS.colorDanger;
40
+ }
41
+ };
42
+
43
+ export const ProgressDonut: React$AbstractComponent<
44
+ ProgressDonutProps,
45
+ HTMLDivElement,
46
+ > = React.forwardRef<ProgressDonutProps, HTMLDivElement>(
47
+ ({classNames, percentage = 0, color = ''}: ProgressDonutProps, ref) => {
48
+ const donutPercentage = React.useMemo(
49
+ () => Math.min(Math.max(percentage, MIN_PERCENTAGE), MAX_PERCENTAGE),
50
+ [percentage],
51
+ );
52
+ const donutColor = React.useMemo(
53
+ () => getProgressDonutColor(donutPercentage),
54
+ [donutPercentage],
55
+ );
56
+
57
+ const radius = React.useMemo(
58
+ () => (LARGE_DONUT_SIZE - STROKE_WIDTH) / DIVISOR_TWO,
59
+ [LARGE_DONUT_SIZE],
60
+ );
61
+ const circumference = React.useMemo(
62
+ () => DIVISOR_TWO * Math.PI * radius,
63
+ [radius],
64
+ );
65
+ const offset = React.useMemo(
66
+ () => circumference - (donutPercentage / MAX_PERCENTAGE) * circumference,
67
+ [circumference, donutPercentage],
68
+ );
69
+
70
+ return (
71
+ <div
72
+ ref={ref}
73
+ data-testid="ProgressDonut"
74
+ className={classify(css.wrapper, classNames?.wrapper)}
75
+ >
76
+ <div className={css.donutChart}>
77
+ <svg
78
+ width={LARGE_DONUT_SIZE}
79
+ height={LARGE_DONUT_SIZE}
80
+ viewBox={`0 0 ${LARGE_DONUT_SIZE} ${LARGE_DONUT_SIZE}`}
81
+ className={css.donutChartSvg}
82
+ >
83
+ <circle
84
+ className={css.donutChartBackground}
85
+ cx={LARGE_DONUT_SIZE / DIVISOR_TWO}
86
+ cy={LARGE_DONUT_SIZE / DIVISOR_TWO}
87
+ r={radius}
88
+ strokeWidth={STROKE_WIDTH}
89
+ />
90
+ <circle
91
+ className={css.donutChartForeground}
92
+ cx={LARGE_DONUT_SIZE / DIVISOR_TWO}
93
+ cy={LARGE_DONUT_SIZE / DIVISOR_TWO}
94
+ r={radius}
95
+ strokeWidth={STROKE_WIDTH}
96
+ strokeDasharray={circumference}
97
+ strokeDashoffset={
98
+ donutPercentage === MIN_PERCENTAGE ? circumference : offset
99
+ }
100
+ stroke={COLORS[color] || donutColor}
101
+ strokeLinecap="round"
102
+ />
103
+ </svg>
104
+ <BodyLargeBold className={css.donutChartPercentage}>
105
+ {`${donutPercentage}%`}
106
+ </BodyLargeBold>
107
+ </div>
108
+ </div>
109
+ );
110
+ },
111
+ );
@@ -0,0 +1,45 @@
1
+ @value (
2
+ borderRadiusSmall
3
+ ) from '../../styles/variables/_border.css';
4
+ @value (spaceHalfFluid, spaceNegHalfFluid) from '../../styles/variables/_space.css';
5
+ @value (size10, size20, sizeFluid) from
6
+ '../../styles/variables/_size.css';
7
+ @value (
8
+ colorBorderPrimary,
9
+ colorBackgroundSecondary,
10
+ colorBackgroundPrimary
11
+ ) from '../../styles/variables/_color.css';
12
+ @value (motionDurationSlower) from
13
+ '../../styles/variables/_motion.css';
14
+
15
+ .donutChart {
16
+ position: relative;
17
+ display: inline-block;
18
+ width: fit-content;
19
+ height: fit-content;
20
+ background-color: colorBackgroundPrimary;
21
+ }
22
+
23
+ .donutChartSvg {
24
+ transform: rotate(-90deg);
25
+ }
26
+
27
+ .donutChartBackground,
28
+ .donutChartForeground {
29
+ fill: none;
30
+ }
31
+
32
+ .donutChartBackground {
33
+ stroke: colorBackgroundSecondary;
34
+ }
35
+
36
+ .donutChartForeground {
37
+ transition: stroke-dashoffset motionDurationSlower;
38
+ }
39
+
40
+ .donutChartPercentage {
41
+ position: absolute;
42
+ top: spaceHalfFluid;
43
+ left: spaceHalfFluid;
44
+ transform: translate(spaceNegHalfFluid, spaceNegHalfFluid);
45
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ProgressDonut = require("./ProgressDonut");
7
+ Object.keys(_ProgressDonut).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ProgressDonut[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _ProgressDonut[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './ProgressDonut';
@@ -432,6 +432,17 @@ Object.keys(_Panel).forEach(function (key) {
432
432
  }
433
433
  });
434
434
  });
435
+ var _ProgressDonut = require("./ProgressDonut");
436
+ Object.keys(_ProgressDonut).forEach(function (key) {
437
+ if (key === "default" || key === "__esModule") return;
438
+ if (key in exports && exports[key] === _ProgressDonut[key]) return;
439
+ Object.defineProperty(exports, key, {
440
+ enumerable: true,
441
+ get: function () {
442
+ return _ProgressDonut[key];
443
+ }
444
+ });
445
+ });
435
446
  var _RadioButton = require("./RadioButton");
436
447
  Object.keys(_RadioButton).forEach(function (key) {
437
448
  if (key === "default" || key === "__esModule") return;
@@ -39,6 +39,7 @@ export * from './OptionButton';
39
39
  export * from './PageTitle';
40
40
  export * from './Pagination';
41
41
  export * from './Panel';
42
+ export * from './ProgressDonut';
42
43
  export * from './RadioButton';
43
44
  export * from './SearchInput';
44
45
  export * from './Shimmer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.112",
3
+ "version": "0.1.113",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {