@spaced-out/ui-design-system 0.1.124 → 0.1.126
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/CHANGELOG.md +14 -0
- package/lib/components/Chip/index.js.flow +1 -1
- package/lib/components/Rating/Rating.js +90 -0
- package/lib/components/Rating/Rating.js.flow +133 -0
- package/lib/components/Rating/Rating.module.css +41 -0
- package/lib/components/Rating/index.js +16 -0
- package/lib/components/Rating/index.js.flow +3 -0
- package/lib/components/Stepper/Step/Step.js +5 -9
- package/lib/components/Stepper/Step/Step.js.flow +6 -10
- package/lib/components/Stepper/Stepper.module.css +8 -23
- package/lib/utils/index.js +11 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/rating/index.js +16 -0
- package/lib/utils/rating/index.js.flow +3 -0
- package/lib/utils/rating/rating.js +30 -0
- package/lib/utils/rating/rating.js.flow +35 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.126](https://github.com/spaced-out/ui-design-system/compare/v0.1.125...v0.1.126) (2024-08-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* 🖼️ stepper component step color and custom icon changes ([#261](https://github.com/spaced-out/ui-design-system/issues/261)) ([038d129](https://github.com/spaced-out/ui-design-system/commit/038d12945065634f736b65a328f96c589f8307cf))
|
|
11
|
+
|
|
12
|
+
### [0.1.125](https://github.com/spaced-out/ui-design-system/compare/v0.1.124...v0.1.125) (2024-08-29)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* rating component ([#258](https://github.com/spaced-out/ui-design-system/issues/258)) ([450caa5](https://github.com/spaced-out/ui-design-system/commit/450caa523c55b5cf3e4635064f63b3e4eec19a8e))
|
|
18
|
+
|
|
5
19
|
### [0.1.124](https://github.com/spaced-out/ui-design-system/compare/v0.1.123...v0.1.124) (2024-08-27)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Rating = exports.RATING_SIZE = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
9
|
+
var _lodash = require("lodash");
|
|
10
|
+
var _classify = require("../../utils/classify");
|
|
11
|
+
var _rating = require("../../utils/rating");
|
|
12
|
+
var _Button = require("../Button");
|
|
13
|
+
var _Chip = require("../Chip");
|
|
14
|
+
var _ConditionalWrapper = require("../ConditionalWrapper");
|
|
15
|
+
var _Icon = require("../Icon");
|
|
16
|
+
var _Text = require("../Text");
|
|
17
|
+
var _RatingModule = _interopRequireDefault(require("./Rating.module.css"));
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
const RATING_SIZE = Object.freeze({
|
|
23
|
+
small: 'small',
|
|
24
|
+
medium: 'medium'
|
|
25
|
+
});
|
|
26
|
+
exports.RATING_SIZE = RATING_SIZE;
|
|
27
|
+
const Rating = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
28
|
+
let {
|
|
29
|
+
size = 'medium',
|
|
30
|
+
start = 0,
|
|
31
|
+
end = 5,
|
|
32
|
+
quiet,
|
|
33
|
+
rating = 0,
|
|
34
|
+
labels = _rating.RATINGS,
|
|
35
|
+
onChange,
|
|
36
|
+
readOnly,
|
|
37
|
+
hideLabel,
|
|
38
|
+
iconName = 'star',
|
|
39
|
+
iconColor = _Text.TEXT_COLORS.favorite,
|
|
40
|
+
chipSemantic = _Chip.CHIP_SEMANTIC.warning,
|
|
41
|
+
classNames
|
|
42
|
+
} = _ref;
|
|
43
|
+
const [hoverIcon, setHoverIcon] = React.useState(-1);
|
|
44
|
+
const chipText = (0, _rating.getRatingLabel)(rating - start, labels);
|
|
45
|
+
const totalIcons = end - start;
|
|
46
|
+
(0, _invariant.default)(totalIcons, JSON.stringify(_rating.RATING_ERRORS.INVALID_RANGE));
|
|
47
|
+
(0, _invariant.default)((0, _lodash.isUndefined)(labels) || (0, _lodash.isArray)(labels) && labels.length, JSON.stringify(_rating.RATING_ERRORS.INVALID_RATING_LABELS));
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
"data-testid": "Rating",
|
|
50
|
+
ref: ref,
|
|
51
|
+
className: (0, _classify.classify)(_RatingModule.default.ratingContainer, classNames?.wrapper)
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: _RatingModule.default.stars
|
|
54
|
+
}, Array.from({
|
|
55
|
+
length: totalIcons
|
|
56
|
+
}).map((_, index) => {
|
|
57
|
+
const isHovering = hoverIcon > -1;
|
|
58
|
+
const iconCount = index + 1;
|
|
59
|
+
const iconType = (isHovering ? iconCount <= hoverIcon : iconCount <= rating - start) ? 'solid' : 'regular';
|
|
60
|
+
return /*#__PURE__*/React.createElement(_ConditionalWrapper.ConditionalWrapper, {
|
|
61
|
+
key: iconCount,
|
|
62
|
+
condition: !readOnly,
|
|
63
|
+
wrapper: children => /*#__PURE__*/React.createElement(_Button.UnstyledButton, {
|
|
64
|
+
onKeyDown: e => {
|
|
65
|
+
if (e.key === 'Enter') {
|
|
66
|
+
onChange?.(start + iconCount, e);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onFocus: () => !quiet && setHoverIcon(iconCount),
|
|
70
|
+
className: (0, _classify.classify)(_RatingModule.default.button, classNames?.button),
|
|
71
|
+
onClick: e => onChange?.(start + iconCount, e),
|
|
72
|
+
onMouseEnter: () => !quiet && setHoverIcon(iconCount),
|
|
73
|
+
onMouseLeave: () => !quiet && setHoverIcon(-1)
|
|
74
|
+
}, children)
|
|
75
|
+
}, /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
76
|
+
size: size,
|
|
77
|
+
name: iconName,
|
|
78
|
+
type: iconType,
|
|
79
|
+
color: iconColor,
|
|
80
|
+
className: (0, _classify.classify)(_RatingModule.default.icon, classNames?.icon)
|
|
81
|
+
}));
|
|
82
|
+
})), !hideLabel &&
|
|
83
|
+
/*#__PURE__*/
|
|
84
|
+
// $FlowFixMe[incompatible-type]
|
|
85
|
+
React.createElement(_Chip.Chip, {
|
|
86
|
+
size: size,
|
|
87
|
+
semantic: chipSemantic
|
|
88
|
+
}, chipText));
|
|
89
|
+
});
|
|
90
|
+
exports.Rating = Rating;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import invariant from 'invariant';
|
|
5
|
+
import {isArray, isUndefined} from 'lodash';
|
|
6
|
+
|
|
7
|
+
import type {ColorTypes} from '../../types/typography';
|
|
8
|
+
import {classify} from '../../utils/classify';
|
|
9
|
+
import {getRatingLabel, RATING_ERRORS, RATINGS} from '../../utils/rating';
|
|
10
|
+
import {UnstyledButton} from '../Button';
|
|
11
|
+
import type {ChipSemanticType} from '../Chip';
|
|
12
|
+
import {Chip, CHIP_SEMANTIC} from '../Chip';
|
|
13
|
+
import {ConditionalWrapper} from '../ConditionalWrapper';
|
|
14
|
+
import {Icon} from '../Icon';
|
|
15
|
+
import {TEXT_COLORS} from '../Text';
|
|
16
|
+
|
|
17
|
+
import css from './Rating.module.css';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export const RATING_SIZE = Object.freeze({
|
|
21
|
+
small: 'small',
|
|
22
|
+
medium: 'medium',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
type ClassNames = $ReadOnly<{wrapper?: string, icon?: string, button?: string}>;
|
|
26
|
+
type RatingSize = $Values<typeof RATING_SIZE>;
|
|
27
|
+
|
|
28
|
+
export type RatingProps = {
|
|
29
|
+
size?: RatingSize,
|
|
30
|
+
start?: number,
|
|
31
|
+
end?: number,
|
|
32
|
+
quiet?: boolean,
|
|
33
|
+
rating?: number,
|
|
34
|
+
labels?: Array<string>,
|
|
35
|
+
iconColor?: ColorTypes,
|
|
36
|
+
onChange?: (rating: number, ?SyntheticEvent<HTMLElement>) => mixed,
|
|
37
|
+
readOnly?: boolean,
|
|
38
|
+
hideLabel?: boolean,
|
|
39
|
+
iconName?: string,
|
|
40
|
+
classNames?: ClassNames,
|
|
41
|
+
chipSemantic?: ChipSemanticType,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Rating: React$AbstractComponent<RatingProps, HTMLDivElement> =
|
|
45
|
+
React.forwardRef<RatingProps, HTMLDivElement>(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
size = 'medium',
|
|
49
|
+
start = 0,
|
|
50
|
+
end = 5,
|
|
51
|
+
quiet,
|
|
52
|
+
rating = 0,
|
|
53
|
+
labels = RATINGS,
|
|
54
|
+
onChange,
|
|
55
|
+
readOnly,
|
|
56
|
+
hideLabel,
|
|
57
|
+
iconName = 'star',
|
|
58
|
+
iconColor = TEXT_COLORS.favorite,
|
|
59
|
+
chipSemantic = CHIP_SEMANTIC.warning,
|
|
60
|
+
classNames,
|
|
61
|
+
}: RatingProps,
|
|
62
|
+
ref,
|
|
63
|
+
): React.Node => {
|
|
64
|
+
const [hoverIcon, setHoverIcon] = React.useState<number>(-1);
|
|
65
|
+
const chipText = getRatingLabel(rating - start, labels);
|
|
66
|
+
const totalIcons = end - start;
|
|
67
|
+
|
|
68
|
+
invariant(totalIcons, JSON.stringify(RATING_ERRORS.INVALID_RANGE));
|
|
69
|
+
invariant(
|
|
70
|
+
isUndefined(labels) || (isArray(labels) && labels.length),
|
|
71
|
+
JSON.stringify(RATING_ERRORS.INVALID_RATING_LABELS),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
data-testid="Rating"
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={classify(css.ratingContainer, classNames?.wrapper)}
|
|
79
|
+
>
|
|
80
|
+
<div className={css.stars}>
|
|
81
|
+
{Array.from({length: totalIcons}).map((_, index) => {
|
|
82
|
+
const isHovering = hoverIcon > -1;
|
|
83
|
+
const iconCount = index + 1;
|
|
84
|
+
const iconType = (
|
|
85
|
+
isHovering
|
|
86
|
+
? iconCount <= hoverIcon
|
|
87
|
+
: iconCount <= rating - start
|
|
88
|
+
)
|
|
89
|
+
? 'solid'
|
|
90
|
+
: 'regular';
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<ConditionalWrapper
|
|
94
|
+
key={iconCount}
|
|
95
|
+
condition={!readOnly}
|
|
96
|
+
wrapper={(children) => (
|
|
97
|
+
<UnstyledButton
|
|
98
|
+
onKeyDown={(e) => {
|
|
99
|
+
if (e.key === 'Enter') {
|
|
100
|
+
onChange?.(start + iconCount, e);
|
|
101
|
+
}
|
|
102
|
+
}}
|
|
103
|
+
onFocus={() => !quiet && setHoverIcon(iconCount)}
|
|
104
|
+
className={classify(css.button, classNames?.button)}
|
|
105
|
+
onClick={(e) => onChange?.(start + iconCount, e)}
|
|
106
|
+
onMouseEnter={() => !quiet && setHoverIcon(iconCount)}
|
|
107
|
+
onMouseLeave={() => !quiet && setHoverIcon(-1)}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</UnstyledButton>
|
|
111
|
+
)}
|
|
112
|
+
>
|
|
113
|
+
<Icon
|
|
114
|
+
size={size}
|
|
115
|
+
name={iconName}
|
|
116
|
+
type={iconType}
|
|
117
|
+
color={iconColor}
|
|
118
|
+
className={classify(css.icon, classNames?.icon)}
|
|
119
|
+
/>
|
|
120
|
+
</ConditionalWrapper>
|
|
121
|
+
);
|
|
122
|
+
})}
|
|
123
|
+
</div>
|
|
124
|
+
{!hideLabel && (
|
|
125
|
+
// $FlowFixMe[incompatible-type]
|
|
126
|
+
<Chip size={size} semantic={chipSemantic}>
|
|
127
|
+
{chipText}
|
|
128
|
+
</Chip>
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
spaceNone,
|
|
3
|
+
spaceXSmall,
|
|
4
|
+
spaceXXSmall
|
|
5
|
+
) from '../../styles/variables/_space.css';
|
|
6
|
+
@value (
|
|
7
|
+
colorFocusPrimary
|
|
8
|
+
) from '../../styles/variables/_color.css';
|
|
9
|
+
@value (
|
|
10
|
+
borderRadiusXSmall,
|
|
11
|
+
borderWidthNone,
|
|
12
|
+
borderWidthTertiary
|
|
13
|
+
) from '../../styles/variables/_border.css';
|
|
14
|
+
|
|
15
|
+
.ratingContainer {
|
|
16
|
+
width: fit-content;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: spaceXSmall;
|
|
20
|
+
margin: spaceXXSmall spaceXSmall;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.stars {
|
|
24
|
+
display: flex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.icon {
|
|
28
|
+
composes: motionEaseInEaseOut from '../../styles/animation.module.css';
|
|
29
|
+
margin: spaceNone spaceXXSmall;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.button {
|
|
33
|
+
border-radius: borderRadiusXSmall;
|
|
34
|
+
outline: none;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.button:focus {
|
|
39
|
+
box-shadow: borderWidthNone borderWidthNone borderWidthNone
|
|
40
|
+
borderWidthTertiary colorFocusPrimary;
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Rating = require("./Rating");
|
|
7
|
+
Object.keys(_Rating).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Rating[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Rating[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -57,17 +57,13 @@ const Step = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
57
57
|
}, classNames?.stepCounter)
|
|
58
58
|
}, completed && !active ? /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
59
59
|
name: "check",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
type: _Icon.ICON_TYPE.solid,
|
|
61
|
+
size: _Icon.ICON_SIZE.small,
|
|
62
|
+
className: _StepperModule.default.stepIcon
|
|
63
63
|
}) : /*#__PURE__*/React.createElement(React.Fragment, null, iconName ? /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
64
64
|
name: iconName,
|
|
65
|
-
className:
|
|
66
|
-
|
|
67
|
-
[_StepperModule.default.completed]: completed,
|
|
68
|
-
[_StepperModule.default.disabled]: disabled
|
|
69
|
-
}),
|
|
70
|
-
size: "medium",
|
|
65
|
+
className: _StepperModule.default.stepIcon,
|
|
66
|
+
size: _Icon.ICON_SIZE.small,
|
|
71
67
|
type: iconType
|
|
72
68
|
}) : (index + 1).toString())), /*#__PURE__*/React.createElement("div", {
|
|
73
69
|
className: (0, _classify.default)(_StepperModule.default.stepContent, classNames?.content)
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
|
|
5
5
|
import classify from '../../../utils/classify';
|
|
6
6
|
import type {IconType} from '../../Icon';
|
|
7
|
-
import {Icon} from '../../Icon';
|
|
7
|
+
import {Icon, ICON_SIZE, ICON_TYPE} from '../../Icon';
|
|
8
8
|
|
|
9
9
|
import css from '../Stepper.module.css';
|
|
10
10
|
|
|
@@ -95,21 +95,17 @@ export const Step: React$AbstractComponent<StepProps, HTMLDivElement> =
|
|
|
95
95
|
{completed && !active ? (
|
|
96
96
|
<Icon
|
|
97
97
|
name="check"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
type={ICON_TYPE.solid}
|
|
99
|
+
size={ICON_SIZE.small}
|
|
100
|
+
className={css.stepIcon}
|
|
101
101
|
/>
|
|
102
102
|
) : (
|
|
103
103
|
<React.Fragment>
|
|
104
104
|
{iconName ? (
|
|
105
105
|
<Icon
|
|
106
106
|
name={iconName}
|
|
107
|
-
className={
|
|
108
|
-
|
|
109
|
-
[css.completed]: completed,
|
|
110
|
-
[css.disabled]: disabled,
|
|
111
|
-
})}
|
|
112
|
-
size="medium"
|
|
107
|
+
className={css.stepIcon}
|
|
108
|
+
size={ICON_SIZE.small}
|
|
113
109
|
type={iconType}
|
|
114
110
|
/>
|
|
115
111
|
) : (
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
@value (
|
|
2
2
|
colorFillPrimary,
|
|
3
|
+
colorFillSecondary,
|
|
3
4
|
colorSuccessDark,
|
|
4
5
|
colorBackgroundTertiary,
|
|
5
6
|
colorFillDisabled,
|
|
6
7
|
colorTextSecondary,
|
|
7
8
|
colorTextPrimary,
|
|
9
|
+
colorTextClickable,
|
|
8
10
|
colorTextDisabled,
|
|
9
11
|
colorTextInversePrimary,
|
|
10
12
|
colorBorderSecondary
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
.stepWrapper {
|
|
40
42
|
position: relative;
|
|
41
43
|
display: flex;
|
|
42
|
-
align-items:
|
|
44
|
+
align-items: flex-start;
|
|
43
45
|
gap: spaceSmall;
|
|
44
46
|
width: sizeFluid;
|
|
45
47
|
}
|
|
@@ -60,16 +62,16 @@
|
|
|
60
62
|
color: colorTextSecondary;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
.stepWrapperCounter.
|
|
65
|
+
.stepWrapperCounter.completed {
|
|
64
66
|
background-color: colorFillPrimary;
|
|
65
67
|
border: borderWidthPrimary solid transparent;
|
|
66
68
|
color: colorTextInversePrimary;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
.stepWrapperCounter.
|
|
70
|
-
background-color:
|
|
71
|
+
.stepWrapperCounter.selected {
|
|
72
|
+
background-color: colorFillSecondary;
|
|
71
73
|
border: borderWidthPrimary solid transparent;
|
|
72
|
-
color:
|
|
74
|
+
color: colorTextClickable;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
.stepWrapperCounter.disabled {
|
|
@@ -78,32 +80,15 @@
|
|
|
78
80
|
color: colorTextDisabled;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
.stepWrapperCounter.withIcon {
|
|
82
|
-
border: initial;
|
|
83
|
-
border-radius: initial;
|
|
84
|
-
background-color: initial;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
83
|
.stepIcon {
|
|
88
84
|
color: inherit;
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
.stepIcon.selected {
|
|
92
|
-
color: colorFillPrimary;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.stepIcon.completed {
|
|
96
|
-
color: colorSuccessDark;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.stepIcon.disabled {
|
|
100
|
-
color: colorTextDisabled;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
87
|
.stepContent {
|
|
104
88
|
display: flex;
|
|
105
89
|
flex-flow: column;
|
|
106
90
|
gap: spaceXXSmall;
|
|
91
|
+
margin-top: spaceXXSmall;
|
|
107
92
|
}
|
|
108
93
|
|
|
109
94
|
.stepLabelWrapper {
|
package/lib/utils/index.js
CHANGED
|
@@ -113,6 +113,17 @@ Object.keys(_mergeRefs).forEach(function (key) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
+
var _rating = require("./rating");
|
|
117
|
+
Object.keys(_rating).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _rating[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _rating[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
116
127
|
var _string = require("./string");
|
|
117
128
|
Object.keys(_string).forEach(function (key) {
|
|
118
129
|
if (key === "default" || key === "__esModule") return;
|
package/lib/utils/index.js.flow
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _rating = require("./rating");
|
|
7
|
+
Object.keys(_rating).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _rating[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _rating[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRatingLabel = exports.RATING_ERRORS = exports.RATINGS = void 0;
|
|
7
|
+
|
|
8
|
+
const RATING_ERRORS = Object.freeze({
|
|
9
|
+
INVALID_RANGE: {
|
|
10
|
+
type: 'INVALID_RANGE',
|
|
11
|
+
description: 'Given rating\'s stop value cannot come before the start value.'
|
|
12
|
+
},
|
|
13
|
+
INVALID_RATING_LABELS: {
|
|
14
|
+
type: 'INVALID_RATING_LABELS',
|
|
15
|
+
description: 'Given rating labels are invalid.'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.RATING_ERRORS = RATING_ERRORS;
|
|
19
|
+
const RATINGS = ['Not-Qualified', 'Proficient', 'Silver', 'Gold', 'Platinum', 'Diamond'];
|
|
20
|
+
exports.RATINGS = RATINGS;
|
|
21
|
+
const getRatingLabel = (rating, labels) => {
|
|
22
|
+
if (rating <= 0) {
|
|
23
|
+
return labels[0];
|
|
24
|
+
} else if (rating >= labels.length) {
|
|
25
|
+
return labels.slice(-1)[0];
|
|
26
|
+
} else {
|
|
27
|
+
return labels[rating];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.getRatingLabel = getRatingLabel;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
export const RATING_ERRORS = Object.freeze({
|
|
4
|
+
INVALID_RANGE: {
|
|
5
|
+
type: 'INVALID_RANGE',
|
|
6
|
+
description:
|
|
7
|
+
'Given rating\'s stop value cannot come before the start value.',
|
|
8
|
+
},
|
|
9
|
+
INVALID_RATING_LABELS: {
|
|
10
|
+
type: 'INVALID_RATING_LABELS',
|
|
11
|
+
description: 'Given rating labels are invalid.',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const RATINGS: Array<string> = [
|
|
16
|
+
'Not-Qualified',
|
|
17
|
+
'Proficient',
|
|
18
|
+
'Silver',
|
|
19
|
+
'Gold',
|
|
20
|
+
'Platinum',
|
|
21
|
+
'Diamond',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export const getRatingLabel = (
|
|
25
|
+
rating: number,
|
|
26
|
+
labels: Array<string>,
|
|
27
|
+
): string => {
|
|
28
|
+
if (rating <= 0) {
|
|
29
|
+
return labels[0];
|
|
30
|
+
} else if (rating >= labels.length) {
|
|
31
|
+
return labels.slice(-1)[0];
|
|
32
|
+
} else {
|
|
33
|
+
return labels[rating];
|
|
34
|
+
}
|
|
35
|
+
};
|