@spaced-out/ui-design-system 0.3.8 → 0.3.10
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/.cspell/custom-words.txt +1 -0
- package/CHANGELOG.md +18 -0
- package/design-tokens/color/app-color.json +6 -6
- package/lib/components/Banner/Banner.js +1 -0
- package/lib/components/Banner/Banner.js.flow +1 -0
- package/lib/components/ChatBubble/ChatBubble.js +152 -0
- package/lib/components/ChatBubble/ChatBubble.js.flow +218 -0
- package/lib/components/ChatBubble/ChatBubble.module.css +132 -0
- package/lib/components/ChatBubble/index.js +16 -0
- package/lib/components/ChatBubble/index.js.flow +3 -0
- package/lib/components/Disclaimer/Disclaimer.js +36 -0
- package/lib/components/Disclaimer/Disclaimer.js.flow +44 -0
- package/lib/components/Disclaimer/Disclaimer.module.css +14 -0
- package/lib/components/Disclaimer/index.js +16 -0
- package/lib/components/Disclaimer/index.js.flow +3 -0
- package/lib/components/InContextAlert/InContextAlert.js +17 -8
- package/lib/components/InContextAlert/InContextAlert.js.flow +11 -0
- package/lib/components/KPIBox/KPIBox.js.flow +1 -1
- package/lib/components/PromptChip/PromptChip.js +88 -0
- package/lib/components/PromptChip/PromptChip.js.flow +161 -0
- package/lib/components/PromptChip/PromptChip.module.css +82 -0
- package/lib/components/PromptChip/index.js +16 -0
- package/lib/components/PromptChip/index.js.flow +3 -0
- package/lib/components/PromptInput/PromptInput.js +119 -0
- package/lib/components/PromptInput/PromptInput.js.flow +190 -0
- package/lib/components/PromptInput/PromptInput.module.css +56 -0
- package/lib/components/PromptInput/index.js +16 -0
- package/lib/components/PromptInput/index.js.flow +3 -0
- package/lib/components/RadioTile/RadioTile.js +77 -0
- package/lib/components/RadioTile/RadioTile.js.flow +110 -0
- package/lib/components/RadioTile/RadioTile.module.css +41 -0
- package/lib/components/RadioTile/index.js +16 -0
- package/lib/components/RadioTile/index.js.flow +3 -0
- package/lib/components/ScoreBar/ScoreBar.js +11 -3
- package/lib/components/ScoreBar/ScoreBar.js.flow +25 -7
- package/lib/components/ScoreBar/ScoreBar.module.css +19 -13
- package/lib/components/Separator/Separator.js +41 -0
- package/lib/components/Separator/Separator.js.flow +62 -0
- package/lib/components/Separator/Separator.module.css +10 -0
- package/lib/components/Separator/index.js +16 -0
- package/lib/components/Separator/index.js.flow +3 -0
- package/lib/components/TextTile/TextTile.js +36 -0
- package/lib/components/TextTile/TextTile.js.flow +44 -0
- package/lib/components/TextTile/TextTile.module.css +27 -0
- package/lib/components/TextTile/index.js +16 -0
- package/lib/components/TextTile/index.js.flow +3 -0
- package/lib/components/Textarea/Textarea.js +2 -1
- package/lib/components/Textarea/Textarea.js.flow +2 -1
- package/lib/components/index.js +99 -0
- package/lib/components/index.js.flow +9 -0
- package/lib/styles/index.css +6 -6
- package/lib/styles/index.js +6 -6
- package/lib/styles/index.js.flow +6 -6
- package/lib/styles/variables/_color.css +6 -6
- package/lib/styles/variables/_color.js +6 -6
- package/lib/styles/variables/_color.js.flow +6 -6
- package/lib/utils/score-bar/score-bar.js +22 -8
- package/lib/utils/score-bar/score-bar.js.flow +35 -10
- package/package.json +1 -1
|
@@ -3,21 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getColorByScorePercentage = exports.SCORE_BAR_ERRORS = void 0;
|
|
6
|
+
exports.getLabelByScorePercentage = exports.getColorByScorePercentage = exports.SCORE_BAR_ERRORS = void 0;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
if (score <= 0) {
|
|
10
|
-
return colorMap.inactive;
|
|
11
|
-
}
|
|
8
|
+
const getValidRange = (score, totalBars, keys) => {
|
|
12
9
|
const scorePercentage = 100 * score / totalBars;
|
|
13
|
-
const
|
|
14
|
-
|
|
10
|
+
for (const key of keys) {
|
|
11
|
+
if (scorePercentage <= Number(key)) {
|
|
12
|
+
return key;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return [...keys].pop() || '';
|
|
15
16
|
};
|
|
16
17
|
const getColorByScorePercentage = (totalBars, score, currentBarNumber, colorMap) => {
|
|
17
|
-
|
|
18
|
+
if (score <= 0) {
|
|
19
|
+
return colorMap.inactive;
|
|
20
|
+
}
|
|
21
|
+
const validRange = getValidRange(score, totalBars, Object.keys(colorMap));
|
|
22
|
+
const validColor = colorMap[validRange];
|
|
18
23
|
return currentBarNumber < score ? validColor : colorMap.inactive;
|
|
19
24
|
};
|
|
20
25
|
exports.getColorByScorePercentage = getColorByScorePercentage;
|
|
26
|
+
const getLabelByScorePercentage = (score, totalBars, labelMap) => {
|
|
27
|
+
if (!labelMap) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
const validRange = getValidRange(score, totalBars, Object.keys(labelMap));
|
|
31
|
+
const validLabel = labelMap[validRange];
|
|
32
|
+
return validLabel || '';
|
|
33
|
+
};
|
|
34
|
+
exports.getLabelByScorePercentage = getLabelByScorePercentage;
|
|
21
35
|
const SCORE_BAR_ERRORS = Object.freeze({
|
|
22
36
|
INVALID_BAR_COUNT: {
|
|
23
37
|
type: 'INVALID_BAR_COUNT',
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
-
import type {ScoreBarColorMap} from '../../components/ScoreBar';
|
|
3
2
|
|
|
3
|
+
import type {
|
|
4
|
+
ScoreBarColorMap,
|
|
5
|
+
ScoreBarLabelMap,
|
|
6
|
+
} from '../../components/ScoreBar';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
const getValidRange = (
|
|
7
10
|
score: number,
|
|
8
|
-
|
|
11
|
+
totalBars: number,
|
|
12
|
+
keys: Array<string>,
|
|
9
13
|
): string => {
|
|
10
|
-
if (score <= 0) {
|
|
11
|
-
return colorMap.inactive;
|
|
12
|
-
}
|
|
13
14
|
const scorePercentage = (100 * score) / totalBars;
|
|
14
|
-
const
|
|
15
|
-
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
if (scorePercentage <= Number(key)) {
|
|
17
|
+
return key;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [...keys].pop() || '';
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
export const getColorByScorePercentage = (
|
|
@@ -21,10 +27,29 @@ export const getColorByScorePercentage = (
|
|
|
21
27
|
currentBarNumber: number,
|
|
22
28
|
colorMap: ScoreBarColorMap,
|
|
23
29
|
): string => {
|
|
24
|
-
|
|
30
|
+
if (score <= 0) {
|
|
31
|
+
return colorMap.inactive;
|
|
32
|
+
}
|
|
33
|
+
const validRange = getValidRange(score, totalBars, Object.keys(colorMap));
|
|
34
|
+
const validColor = colorMap[validRange];
|
|
35
|
+
|
|
25
36
|
return currentBarNumber < score ? validColor : colorMap.inactive;
|
|
26
37
|
};
|
|
27
38
|
|
|
39
|
+
export const getLabelByScorePercentage = (
|
|
40
|
+
score: number,
|
|
41
|
+
totalBars: number,
|
|
42
|
+
labelMap?: ScoreBarLabelMap,
|
|
43
|
+
): string => {
|
|
44
|
+
if (!labelMap) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
const validRange = getValidRange(score, totalBars, Object.keys(labelMap));
|
|
48
|
+
const validLabel = labelMap[validRange];
|
|
49
|
+
|
|
50
|
+
return validLabel || '';
|
|
51
|
+
};
|
|
52
|
+
|
|
28
53
|
export const SCORE_BAR_ERRORS = Object.freeze({
|
|
29
54
|
INVALID_BAR_COUNT: {
|
|
30
55
|
type: 'INVALID_BAR_COUNT',
|