@magmamath/students-features 0.5.0-rc.5 → 0.5.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.
Files changed (61) hide show
  1. package/dist/commonjs/features/celebrations/components/Particle.js +3 -2
  2. package/dist/commonjs/features/celebrations/components/Particle.js.map +1 -1
  3. package/dist/commonjs/features/celebrations/components/ParticleBatch.js +4 -2
  4. package/dist/commonjs/features/celebrations/components/ParticleBatch.js.map +1 -1
  5. package/dist/commonjs/features/celebrations/config.js +40 -15
  6. package/dist/commonjs/features/celebrations/config.js.map +1 -1
  7. package/dist/commonjs/features/celebrations/helpers.js +8 -3
  8. package/dist/commonjs/features/celebrations/helpers.js.map +1 -1
  9. package/dist/commonjs/features/chatbot/model/ChatbotApi.js +0 -13
  10. package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +1 -1
  11. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +4 -2
  12. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
  13. package/dist/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
  14. package/dist/module/features/celebrations/components/Particle.js +3 -2
  15. package/dist/module/features/celebrations/components/Particle.js.map +1 -1
  16. package/dist/module/features/celebrations/components/ParticleBatch.js +4 -2
  17. package/dist/module/features/celebrations/components/ParticleBatch.js.map +1 -1
  18. package/dist/module/features/celebrations/config.js +40 -15
  19. package/dist/module/features/celebrations/config.js.map +1 -1
  20. package/dist/module/features/celebrations/helpers.js +8 -3
  21. package/dist/module/features/celebrations/helpers.js.map +1 -1
  22. package/dist/module/features/chatbot/model/ChatbotApi.js +0 -13
  23. package/dist/module/features/chatbot/model/ChatbotApi.js.map +1 -1
  24. package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +4 -2
  25. package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
  26. package/dist/module/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
  27. package/dist/typescript/commonjs/features/celebrations/components/Particle.d.ts +2 -1
  28. package/dist/typescript/commonjs/features/celebrations/components/Particle.d.ts.map +1 -1
  29. package/dist/typescript/commonjs/features/celebrations/components/ParticleBatch.d.ts.map +1 -1
  30. package/dist/typescript/commonjs/features/celebrations/config.d.ts +25 -0
  31. package/dist/typescript/commonjs/features/celebrations/config.d.ts.map +1 -1
  32. package/dist/typescript/commonjs/features/celebrations/helpers.d.ts.map +1 -1
  33. package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +1 -1
  34. package/dist/typescript/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
  35. package/dist/typescript/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
  36. package/dist/typescript/module/features/celebrations/components/Particle.d.ts +2 -1
  37. package/dist/typescript/module/features/celebrations/components/Particle.d.ts.map +1 -1
  38. package/dist/typescript/module/features/celebrations/components/ParticleBatch.d.ts.map +1 -1
  39. package/dist/typescript/module/features/celebrations/config.d.ts +25 -0
  40. package/dist/typescript/module/features/celebrations/config.d.ts.map +1 -1
  41. package/dist/typescript/module/features/celebrations/helpers.d.ts.map +1 -1
  42. package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +1 -1
  43. package/dist/typescript/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
  44. package/dist/typescript/module/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/features/celebrations/components/Particle.tsx +3 -1
  47. package/src/features/celebrations/components/ParticleBatch.tsx +2 -1
  48. package/src/features/celebrations/config.ts +44 -19
  49. package/src/features/celebrations/helpers.ts +10 -3
  50. package/src/features/chatbot/model/ChatbotApi.ts +0 -13
  51. package/src/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.tsx +3 -2
  52. package/src/features/endOfAssignment/ui/PracticeButtonGroup.tsx +0 -1
  53. package/dist/commonjs/lib/helpers/randomElements.js +0 -24
  54. package/dist/commonjs/lib/helpers/randomElements.js.map +0 -1
  55. package/dist/module/lib/helpers/randomElements.js +0 -20
  56. package/dist/module/lib/helpers/randomElements.js.map +0 -1
  57. package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts +0 -2
  58. package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts.map +0 -1
  59. package/dist/typescript/module/lib/helpers/randomElements.d.ts +0 -2
  60. package/dist/typescript/module/lib/helpers/randomElements.d.ts.map +0 -1
  61. package/src/lib/helpers/randomElements.ts +0 -22
@@ -1,10 +1,10 @@
1
- import StarIcon from '../../shared/icons/Star';
2
- import HalloweenIcon from '../../shared/icons/Halloween';
3
- import PiIcon from '../../shared/icons/Pi';
4
- import WinterIcon from '../../shared/icons/Winter';
5
- import ValentineIcon from '../../shared/icons/Valentine';
6
- import { COLORS } from '@magmamath/react-native-ui';
7
- import { CelebrationVariant } from './types';
1
+ import StarIcon from '../../shared/icons/Star'
2
+ import HalloweenIcon from '../../shared/icons/Halloween'
3
+ import PiIcon from '../../shared/icons/Pi'
4
+ import WinterIcon from '../../shared/icons/Winter'
5
+ import ValentineIcon from '../../shared/icons/Valentine'
6
+ import { COLORS } from '@magmamath/react-native-ui'
7
+ import { CelebrationVariant } from './types'
8
8
 
9
9
  export const CELEBRATION_ICON_CONFIG = [
10
10
  {
@@ -43,7 +43,7 @@ export const CELEBRATION_ICON_CONFIG = [
43
43
  end: '07-01',
44
44
  },
45
45
  },
46
- ];
46
+ ]
47
47
 
48
48
  export const CELEBRATION_VARIANTS = {
49
49
  [CelebrationVariant.FIRST_ATTEMPT]: {
@@ -74,7 +74,12 @@ export const CELEBRATION_VARIANTS = {
74
74
  from: -0.05,
75
75
  to: 0.05,
76
76
  },
77
+ speedRange: {
78
+ spark: [4, 18],
79
+ main: [4, 18],
80
+ },
77
81
  life: 65,
82
+ gravity: 0,
78
83
  },
79
84
  [CelebrationVariant.CORRECT]: {
80
85
  color: COLORS.PRIMARY_YELLOW,
@@ -104,7 +109,12 @@ export const CELEBRATION_VARIANTS = {
104
109
  from: -0.05,
105
110
  to: 0.05,
106
111
  },
112
+ speedRange: {
113
+ spark: [4, 18],
114
+ main: [4, 18],
115
+ },
107
116
  life: 65,
117
+ gravity: 0,
108
118
  },
109
119
  [CelebrationVariant.GBD]: {
110
120
  color: COLORS.PRIMARY_ORANGE,
@@ -134,7 +144,12 @@ export const CELEBRATION_VARIANTS = {
134
144
  from: -0.03,
135
145
  to: 0.03,
136
146
  },
147
+ speedRange: {
148
+ spark: [4, 18],
149
+ main: [4, 18],
150
+ },
137
151
  life: 120,
152
+ gravity: 0,
138
153
  },
139
154
  [CelebrationVariant.GBD_FINISH_ASSIGNMENT]: {
140
155
  color: COLORS.PRIMARY_ORANGE,
@@ -151,20 +166,25 @@ export const CELEBRATION_VARIANTS = {
151
166
  to: 32,
152
167
  },
153
168
  angle: {
154
- from: 180,
155
- to: 360,
169
+ from: 220,
170
+ to: 320,
156
171
  },
157
- velocityMultiplier: 1.8,
172
+ velocityMultiplier: 2,
158
173
  rotation: {
159
174
  from: 0,
160
175
  to: 10,
161
176
  },
162
177
  friction: 0.95,
163
178
  angularAcceleration: {
164
- from: -0.05,
165
- to: 0.05,
179
+ from: -0.02,
180
+ to: 0.02,
181
+ },
182
+ speedRange: {
183
+ spark: [14, 28],
184
+ main: [6, 18],
166
185
  },
167
186
  life: 100,
187
+ gravity: 0.1,
168
188
  },
169
189
  [CelebrationVariant.CORRECT_FINISH_ASSIGNMENT]: {
170
190
  color: COLORS.PRIMARY_GREEN,
@@ -181,19 +201,24 @@ export const CELEBRATION_VARIANTS = {
181
201
  to: 32,
182
202
  },
183
203
  angle: {
184
- from: 180,
185
- to: 360,
204
+ from: 220,
205
+ to: 320,
186
206
  },
187
- velocityMultiplier: 1.8,
207
+ velocityMultiplier: 2,
188
208
  rotation: {
189
209
  from: 0,
190
210
  to: 10,
191
211
  },
192
212
  friction: 0.95,
193
213
  angularAcceleration: {
194
- from: -0.05,
195
- to: 0.05,
214
+ from: -0.02,
215
+ to: 0.02,
216
+ },
217
+ speedRange: {
218
+ spark: [14, 28],
219
+ main: [6, 18],
196
220
  },
197
221
  life: 100,
222
+ gravity: 0.1,
198
223
  },
199
- };
224
+ }
@@ -32,7 +32,8 @@ export const getIconForCurrentDate = () => {
32
32
  };
33
33
 
34
34
  const MainIcon = getIconForCurrentDate();
35
- export const generateParticle = (variant: CelebrationVariant) => {
35
+ export const generateParticle = (variant: CelebrationVariant
36
+ ) => {
36
37
  const {
37
38
  elementsCount,
38
39
  angle,
@@ -43,13 +44,19 @@ export const generateParticle = (variant: CelebrationVariant) => {
43
44
  friction,
44
45
  life,
45
46
  angularAcceleration,
47
+ speedRange
46
48
  } = CELEBRATION_VARIANTS[variant];
47
49
 
50
+ const sparkSpeedMin = speedRange?.spark?.[0]
51
+ const sparkSpeedMax = speedRange?.spark?.[1]
52
+ const mainSpeedMin = speedRange?.main?.[0]
53
+ const mainSpeedMax = speedRange?.main?.[1]
54
+
48
55
  const particles: ParticlesBatch[] = [];
49
56
 
50
57
  for (let i = 0; i < elementsCount.spark; i++) {
51
58
  const randomAngle = randomRange((angle.from * Math.PI) / 180, (angle.to * Math.PI) / 180);
52
- const randomSpeed = randomRange(4, 18);
59
+ const randomSpeed = randomRange(sparkSpeedMin, sparkSpeedMax);
53
60
  const randomAngularAcceleration = randomRange(angularAcceleration.from, angularAcceleration.to);
54
61
 
55
62
  particles.push({
@@ -71,7 +78,7 @@ export const generateParticle = (variant: CelebrationVariant) => {
71
78
  }
72
79
  for (let i = 0; i < elementsCount.star; i++) {
73
80
  const randomAngle = randomRange((angle.from * Math.PI) / 180, (angle.to * Math.PI) / 180);
74
- const randomSpeed = randomRange(4, 18);
81
+ const randomSpeed = randomRange(mainSpeedMin, mainSpeedMax);
75
82
  const randomAngularAcceleration = randomRange(angularAcceleration.from, angularAcceleration.to);
76
83
 
77
84
  particles.push({
@@ -13,19 +13,6 @@ export class ChatbotAPI {
13
13
  public readonly spotErrorFx
14
14
 
15
15
  constructor(api: ChatbotApiRequests) {
16
- // this.spotErrorFx = createControllerEffect(
17
- // (props: SpotErrorPayload): Promise<SpotErrorResponse> => {
18
- // return new Promise<SpotErrorResponse>((res) => {
19
- // if (props.strokes.length <= 3) return res({ strokesIds: [] })
20
- // setTimeout(() => {
21
- // const randomStrokes = getRandomElements(props.strokes, 4)
22
- // res({
23
- // strokesIds: randomStrokes.map((stroke) => stroke.id ?? ''),
24
- // })
25
- // }, 1000)
26
- // })
27
- // },
28
- // )
29
16
  this.spotErrorFx = createControllerEffect(api.spotError)
30
17
  this.postMessageFx = createControllerEffect(api.postMessage)
31
18
  this.getAlternativesFx = createEffect(api.getAlternatives)
@@ -64,6 +64,8 @@ export const AnimatedCard = memo(
64
64
  const statsOpacity = useSharedValue(OPACITY.initial)
65
65
  const delaySv = useSharedValue(0)
66
66
 
67
+ const starOffsetLeft = gbdAmount > 9 ? 70 : 55
68
+
67
69
  const animatedCardStyle = useAnimatedStyle(() => {
68
70
  const progress = interpolate(
69
71
  statsOpacity.value,
@@ -192,7 +194,7 @@ export const AnimatedCard = memo(
192
194
 
193
195
  <Animated.View style={[styles.statsWrapper, animatedStatsStyle]}>
194
196
  {variant === AnimatedCardVariant.GOOD_DRAWING && (
195
- <View style={styles.starContainer}>
197
+ <View style={[styles.starContainer, { left: starOffsetLeft }]}>
196
198
  <SparkIcon size={20} color={VARIANT_COLORS[variant].initial} />
197
199
  <View style={styles.starCircle} />
198
200
  <SparkIcon size={12} color={VARIANT_COLORS[variant].initial} />
@@ -281,7 +283,6 @@ const styles = StyleSheet.create({
281
283
  },
282
284
  starContainer: {
283
285
  position: 'absolute',
284
- left: 55,
285
286
  top: 10,
286
287
  },
287
288
  starCircle: {
@@ -1,6 +1,5 @@
1
1
  import React, { useEffect } from 'react'
2
2
  import { StyleSheet } from 'react-native'
3
-
4
3
  import Animated, {
5
4
  useSharedValue,
6
5
  withDelay,
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRandomElements = getRandomElements;
7
- function getRandomElements(array, limit = array.length) {
8
- if (array.length === 0) {
9
- return [];
10
- }
11
- const randomCount = Math.min(Math.floor(Math.random() * array.length) + 1, limit);
12
- const arrayCopy = [...array];
13
- const result = [];
14
- for (let i = 0; i < randomCount; i++) {
15
- if (arrayCopy.length === 0) {
16
- break;
17
- }
18
- const randomIndex = Math.floor(Math.random() * arrayCopy.length);
19
- result.push(arrayCopy[randomIndex]);
20
- arrayCopy.splice(randomIndex, 1);
21
- }
22
- return result;
23
- }
24
- //# sourceMappingURL=randomElements.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getRandomElements","array","limit","length","randomCount","Math","min","floor","random","arrayCopy","result","i","randomIndex","push","splice"],"sourceRoot":"../../../../src","sources":["lib/helpers/randomElements.ts"],"mappings":";;;;;;AAAO,SAASA,iBAAiBA,CAAIC,KAAU,EAAEC,KAAK,GAAGD,KAAK,CAACE,MAAM,EAAO;EAC1E,IAAIF,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;EAEA,MAAMC,WAAW,GAAGC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,KAAK,CAACF,IAAI,CAACG,MAAM,CAAC,CAAC,GAAGP,KAAK,CAACE,MAAM,CAAC,GAAG,CAAC,EAAED,KAAK,CAAC;EAEjF,MAAMO,SAAS,GAAG,CAAC,GAAGR,KAAK,CAAC;EAC5B,MAAMS,MAAW,GAAG,EAAE;EAEtB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,WAAW,EAAEO,CAAC,EAAE,EAAE;IACpC,IAAIF,SAAS,CAACN,MAAM,KAAK,CAAC,EAAE;MAC1B;IACF;IAEA,MAAMS,WAAW,GAAGP,IAAI,CAACE,KAAK,CAACF,IAAI,CAACG,MAAM,CAAC,CAAC,GAAGC,SAAS,CAACN,MAAM,CAAC;IAChEO,MAAM,CAACG,IAAI,CAACJ,SAAS,CAACG,WAAW,CAAC,CAAC;IACnCH,SAAS,CAACK,MAAM,CAACF,WAAW,EAAE,CAAC,CAAC;EAClC;EAEA,OAAOF,MAAM;AACf","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- export function getRandomElements(array, limit = array.length) {
4
- if (array.length === 0) {
5
- return [];
6
- }
7
- const randomCount = Math.min(Math.floor(Math.random() * array.length) + 1, limit);
8
- const arrayCopy = [...array];
9
- const result = [];
10
- for (let i = 0; i < randomCount; i++) {
11
- if (arrayCopy.length === 0) {
12
- break;
13
- }
14
- const randomIndex = Math.floor(Math.random() * arrayCopy.length);
15
- result.push(arrayCopy[randomIndex]);
16
- arrayCopy.splice(randomIndex, 1);
17
- }
18
- return result;
19
- }
20
- //# sourceMappingURL=randomElements.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getRandomElements","array","limit","length","randomCount","Math","min","floor","random","arrayCopy","result","i","randomIndex","push","splice"],"sourceRoot":"../../../../src","sources":["lib/helpers/randomElements.ts"],"mappings":";;AAAA,OAAO,SAASA,iBAAiBA,CAAIC,KAAU,EAAEC,KAAK,GAAGD,KAAK,CAACE,MAAM,EAAO;EAC1E,IAAIF,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;EAEA,MAAMC,WAAW,GAAGC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,KAAK,CAACF,IAAI,CAACG,MAAM,CAAC,CAAC,GAAGP,KAAK,CAACE,MAAM,CAAC,GAAG,CAAC,EAAED,KAAK,CAAC;EAEjF,MAAMO,SAAS,GAAG,CAAC,GAAGR,KAAK,CAAC;EAC5B,MAAMS,MAAW,GAAG,EAAE;EAEtB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGP,WAAW,EAAEO,CAAC,EAAE,EAAE;IACpC,IAAIF,SAAS,CAACN,MAAM,KAAK,CAAC,EAAE;MAC1B;IACF;IAEA,MAAMS,WAAW,GAAGP,IAAI,CAACE,KAAK,CAACF,IAAI,CAACG,MAAM,CAAC,CAAC,GAAGC,SAAS,CAACN,MAAM,CAAC;IAChEO,MAAM,CAACG,IAAI,CAACJ,SAAS,CAACG,WAAW,CAAC,CAAC;IACnCH,SAAS,CAACK,MAAM,CAACF,WAAW,EAAE,CAAC,CAAC;EAClC;EAEA,OAAOF,MAAM;AACf","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export declare function getRandomElements<T>(array: T[], limit?: number): T[];
2
- //# sourceMappingURL=randomElements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"randomElements.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/randomElements.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,SAAe,GAAG,CAAC,EAAE,CAqB1E"}
@@ -1,2 +0,0 @@
1
- export declare function getRandomElements<T>(array: T[], limit?: number): T[];
2
- //# sourceMappingURL=randomElements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"randomElements.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/randomElements.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,SAAe,GAAG,CAAC,EAAE,CAqB1E"}
@@ -1,22 +0,0 @@
1
- export function getRandomElements<T>(array: T[], limit = array.length): T[] {
2
- if (array.length === 0) {
3
- return []
4
- }
5
-
6
- const randomCount = Math.min(Math.floor(Math.random() * array.length) + 1, limit)
7
-
8
- const arrayCopy = [...array]
9
- const result: T[] = []
10
-
11
- for (let i = 0; i < randomCount; i++) {
12
- if (arrayCopy.length === 0) {
13
- break
14
- }
15
-
16
- const randomIndex = Math.floor(Math.random() * arrayCopy.length)
17
- result.push(arrayCopy[randomIndex])
18
- arrayCopy.splice(randomIndex, 1)
19
- }
20
-
21
- return result
22
- }