@redocly/theme 0.26.1 → 0.27.0

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.
@@ -68,7 +68,7 @@ const Mood = ({ settings, onSubmit, className }) => {
68
68
  const displaySubmitBnt = !!score && (displayReasons || displayComment);
69
69
  const onSubmitMoodForm = () => {
70
70
  onSubmit({
71
- score,
71
+ score: remapScore(score),
72
72
  comment,
73
73
  reasons,
74
74
  });
@@ -114,6 +114,18 @@ const Mood = ({ settings, onSubmit, className }) => {
114
114
  React.createElement(SubmitButton, { onClick: onSubmitMoodForm }, "Submit"))))));
115
115
  };
116
116
  exports.Mood = Mood;
117
+ const remapScore = (score) => {
118
+ switch (score) {
119
+ case MOOD_STATES.SATISFIED:
120
+ return 1;
121
+ case MOOD_STATES.NEUTRAL:
122
+ return 0;
123
+ case MOOD_STATES.DISSATISFIED:
124
+ return -1;
125
+ default:
126
+ return 0;
127
+ }
128
+ };
117
129
  const Wrapper = styled_components_1.default.div `
118
130
  font-family: var(--font-family-base);
119
131
  display: flex;
@@ -49,7 +49,7 @@ export type ScaleProps = {
49
49
  };
50
50
  export type MoodProps = {
51
51
  onSubmit: (value: {
52
- score: string;
52
+ score: number;
53
53
  comment?: string;
54
54
  reasons?: string[];
55
55
  }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -54,7 +54,7 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
54
54
 
55
55
  const onSubmitMoodForm = () => {
56
56
  onSubmit({
57
- score,
57
+ score: remapScore(score),
58
58
  comment,
59
59
  reasons,
60
60
  });
@@ -148,6 +148,19 @@ export const Mood = ({ settings, onSubmit, className }: MoodProps): JSX.Element
148
148
  );
149
149
  };
150
150
 
151
+ const remapScore = (score: string): number => {
152
+ switch (score) {
153
+ case MOOD_STATES.SATISFIED:
154
+ return 1;
155
+ case MOOD_STATES.NEUTRAL:
156
+ return 0;
157
+ case MOOD_STATES.DISSATISFIED:
158
+ return -1;
159
+ default:
160
+ return 0;
161
+ }
162
+ };
163
+
151
164
  const Wrapper = styled.div`
152
165
  font-family: var(--font-family-base);
153
166
  display: flex;
@@ -41,7 +41,7 @@ export type ScaleProps = {
41
41
  };
42
42
 
43
43
  export type MoodProps = {
44
- onSubmit: (value: { score: string; comment?: string; reasons?: string[] }) => void;
44
+ onSubmit: (value: { score: number; comment?: string; reasons?: string[] }) => void;
45
45
  settings?: {
46
46
  label?: string;
47
47
  submitText?: string;