@magmamath/students-features 0.6.5 → 0.6.6-rc.1

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 (157) hide show
  1. package/dist/commonjs/features/feedback/model/comments.js +3 -5
  2. package/dist/commonjs/features/feedback/model/comments.js.map +1 -1
  3. package/dist/commonjs/features/feedback/model/model.js +9 -7
  4. package/dist/commonjs/features/feedback/model/model.js.map +1 -1
  5. package/dist/commonjs/features/gifCelebrations/GifCelebrations.js +65 -0
  6. package/dist/commonjs/features/gifCelebrations/GifCelebrations.js.map +1 -0
  7. package/dist/commonjs/features/gifCelebrations/assets/confetti.webp +0 -0
  8. package/dist/commonjs/features/gifCelebrations/components/Backdrop.js +44 -0
  9. package/dist/commonjs/features/gifCelebrations/components/Backdrop.js.map +1 -0
  10. package/dist/commonjs/features/gifCelebrations/components/ContentContainer.js +46 -0
  11. package/dist/commonjs/features/gifCelebrations/components/ContentContainer.js.map +1 -0
  12. package/dist/commonjs/features/gifCelebrations/components/Gif.js +80 -0
  13. package/dist/commonjs/features/gifCelebrations/components/Gif.js.map +1 -0
  14. package/dist/commonjs/features/gifCelebrations/components/Progress.js +106 -0
  15. package/dist/commonjs/features/gifCelebrations/components/Progress.js.map +1 -0
  16. package/dist/commonjs/features/gifCelebrations/constants.js +30 -0
  17. package/dist/commonjs/features/gifCelebrations/constants.js.map +1 -0
  18. package/dist/commonjs/features/gifCelebrations/helpers.js +71 -0
  19. package/dist/commonjs/features/gifCelebrations/helpers.js.map +1 -0
  20. package/dist/commonjs/features/gifCelebrations/index.js +20 -0
  21. package/dist/commonjs/features/gifCelebrations/index.js.map +1 -0
  22. package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js +32 -0
  23. package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.cache.js.map +1 -0
  24. package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js +125 -0
  25. package/dist/commonjs/features/gifCelebrations/model/GifCelebrations.model.js.map +1 -0
  26. package/dist/commonjs/features/gifCelebrations/model/GifCelebrationsApi.js +14 -0
  27. package/dist/commonjs/features/gifCelebrations/model/GifCelebrationsApi.js.map +1 -0
  28. package/dist/commonjs/features/gifCelebrations/types/model.types.js +6 -0
  29. package/dist/commonjs/features/gifCelebrations/types/model.types.js.map +1 -0
  30. package/dist/commonjs/index.js +12 -0
  31. package/dist/commonjs/index.js.map +1 -1
  32. package/dist/commonjs/lib/helpers/helpers.js.map +1 -1
  33. package/dist/commonjs/react-app-env.d.js +2 -0
  34. package/dist/commonjs/react-app-env.d.js.map +1 -0
  35. package/dist/commonjs/shared/translation/localization/en.json +5 -0
  36. package/dist/commonjs/shared/translation/localization/gb.json +5 -0
  37. package/dist/commonjs/shared/translation/localization/sw.json +5 -0
  38. package/dist/module/features/feedback/model/comments.js +3 -5
  39. package/dist/module/features/feedback/model/comments.js.map +1 -1
  40. package/dist/module/features/feedback/model/model.js +9 -7
  41. package/dist/module/features/feedback/model/model.js.map +1 -1
  42. package/dist/module/features/gifCelebrations/GifCelebrations.js +58 -0
  43. package/dist/module/features/gifCelebrations/GifCelebrations.js.map +1 -0
  44. package/dist/module/features/gifCelebrations/assets/confetti.webp +0 -0
  45. package/dist/module/features/gifCelebrations/components/Backdrop.js +36 -0
  46. package/dist/module/features/gifCelebrations/components/Backdrop.js.map +1 -0
  47. package/dist/module/features/gifCelebrations/components/ContentContainer.js +38 -0
  48. package/dist/module/features/gifCelebrations/components/ContentContainer.js.map +1 -0
  49. package/dist/module/features/gifCelebrations/components/Gif.js +73 -0
  50. package/dist/module/features/gifCelebrations/components/Gif.js.map +1 -0
  51. package/dist/module/features/gifCelebrations/components/Progress.js +98 -0
  52. package/dist/module/features/gifCelebrations/components/Progress.js.map +1 -0
  53. package/dist/module/features/gifCelebrations/constants.js +26 -0
  54. package/dist/module/features/gifCelebrations/constants.js.map +1 -0
  55. package/dist/module/features/gifCelebrations/helpers.js +64 -0
  56. package/dist/module/features/gifCelebrations/helpers.js.map +1 -0
  57. package/dist/module/features/gifCelebrations/index.js +5 -0
  58. package/dist/module/features/gifCelebrations/index.js.map +1 -0
  59. package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js +27 -0
  60. package/dist/module/features/gifCelebrations/model/GifCelebrations.cache.js.map +1 -0
  61. package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js +120 -0
  62. package/dist/module/features/gifCelebrations/model/GifCelebrations.model.js.map +1 -0
  63. package/dist/module/features/gifCelebrations/model/GifCelebrationsApi.js +9 -0
  64. package/dist/module/features/gifCelebrations/model/GifCelebrationsApi.js.map +1 -0
  65. package/dist/module/features/gifCelebrations/types/model.types.js +4 -0
  66. package/dist/module/features/gifCelebrations/types/model.types.js.map +1 -0
  67. package/dist/module/index.js +1 -0
  68. package/dist/module/index.js.map +1 -1
  69. package/dist/module/react-app-env.d.js +2 -0
  70. package/dist/module/react-app-env.d.js.map +1 -0
  71. package/dist/module/shared/translation/localization/en.json +5 -0
  72. package/dist/module/shared/translation/localization/gb.json +5 -0
  73. package/dist/module/shared/translation/localization/sw.json +5 -0
  74. package/dist/typescript/commonjs/features/gifCelebrations/GifCelebrations.d.ts +10 -0
  75. package/dist/typescript/commonjs/features/gifCelebrations/GifCelebrations.d.ts.map +1 -0
  76. package/dist/typescript/commonjs/features/gifCelebrations/components/Backdrop.d.ts +10 -0
  77. package/dist/typescript/commonjs/features/gifCelebrations/components/Backdrop.d.ts.map +1 -0
  78. package/dist/typescript/commonjs/features/gifCelebrations/components/ContentContainer.d.ts +10 -0
  79. package/dist/typescript/commonjs/features/gifCelebrations/components/ContentContainer.d.ts.map +1 -0
  80. package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts +10 -0
  81. package/dist/typescript/commonjs/features/gifCelebrations/components/Gif.d.ts.map +1 -0
  82. package/dist/typescript/commonjs/features/gifCelebrations/components/Progress.d.ts +10 -0
  83. package/dist/typescript/commonjs/features/gifCelebrations/components/Progress.d.ts.map +1 -0
  84. package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts +22 -0
  85. package/dist/typescript/commonjs/features/gifCelebrations/constants.d.ts.map +1 -0
  86. package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts +85 -0
  87. package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts.map +1 -0
  88. package/dist/typescript/commonjs/features/gifCelebrations/index.d.ts +3 -0
  89. package/dist/typescript/commonjs/features/gifCelebrations/index.d.ts.map +1 -0
  90. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts +18 -0
  91. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +1 -0
  92. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts +26 -0
  93. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +1 -0
  94. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrationsApi.d.ts +6 -0
  95. package/dist/typescript/commonjs/features/gifCelebrations/model/GifCelebrationsApi.d.ts.map +1 -0
  96. package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts +42 -0
  97. package/dist/typescript/commonjs/features/gifCelebrations/types/model.types.d.ts.map +1 -0
  98. package/dist/typescript/commonjs/index.d.ts +1 -0
  99. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  100. package/dist/typescript/commonjs/lib/helpers/helpers.d.ts.map +1 -1
  101. package/dist/typescript/commonjs/shared/translation/constants.d.ts +15 -0
  102. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  103. package/dist/typescript/commonjs/shared/translation/model.d.ts +10 -0
  104. package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
  105. package/dist/typescript/module/features/gifCelebrations/GifCelebrations.d.ts +10 -0
  106. package/dist/typescript/module/features/gifCelebrations/GifCelebrations.d.ts.map +1 -0
  107. package/dist/typescript/module/features/gifCelebrations/components/Backdrop.d.ts +10 -0
  108. package/dist/typescript/module/features/gifCelebrations/components/Backdrop.d.ts.map +1 -0
  109. package/dist/typescript/module/features/gifCelebrations/components/ContentContainer.d.ts +10 -0
  110. package/dist/typescript/module/features/gifCelebrations/components/ContentContainer.d.ts.map +1 -0
  111. package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts +10 -0
  112. package/dist/typescript/module/features/gifCelebrations/components/Gif.d.ts.map +1 -0
  113. package/dist/typescript/module/features/gifCelebrations/components/Progress.d.ts +10 -0
  114. package/dist/typescript/module/features/gifCelebrations/components/Progress.d.ts.map +1 -0
  115. package/dist/typescript/module/features/gifCelebrations/constants.d.ts +22 -0
  116. package/dist/typescript/module/features/gifCelebrations/constants.d.ts.map +1 -0
  117. package/dist/typescript/module/features/gifCelebrations/helpers.d.ts +85 -0
  118. package/dist/typescript/module/features/gifCelebrations/helpers.d.ts.map +1 -0
  119. package/dist/typescript/module/features/gifCelebrations/index.d.ts +3 -0
  120. package/dist/typescript/module/features/gifCelebrations/index.d.ts.map +1 -0
  121. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts +18 -0
  122. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.cache.d.ts.map +1 -0
  123. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts +26 -0
  124. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrations.model.d.ts.map +1 -0
  125. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrationsApi.d.ts +6 -0
  126. package/dist/typescript/module/features/gifCelebrations/model/GifCelebrationsApi.d.ts.map +1 -0
  127. package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts +42 -0
  128. package/dist/typescript/module/features/gifCelebrations/types/model.types.d.ts.map +1 -0
  129. package/dist/typescript/module/index.d.ts +1 -0
  130. package/dist/typescript/module/index.d.ts.map +1 -1
  131. package/dist/typescript/module/lib/helpers/helpers.d.ts.map +1 -1
  132. package/dist/typescript/module/shared/translation/constants.d.ts +15 -0
  133. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  134. package/dist/typescript/module/shared/translation/model.d.ts +10 -0
  135. package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
  136. package/package.json +1 -1
  137. package/src/features/feedback/model/comments.ts +7 -7
  138. package/src/features/feedback/model/model.ts +6 -6
  139. package/src/features/gifCelebrations/GifCelebrations.tsx +77 -0
  140. package/src/features/gifCelebrations/assets/confetti.webp +0 -0
  141. package/src/features/gifCelebrations/components/Backdrop.tsx +41 -0
  142. package/src/features/gifCelebrations/components/ContentContainer.tsx +44 -0
  143. package/src/features/gifCelebrations/components/Gif.tsx +86 -0
  144. package/src/features/gifCelebrations/components/Progress.tsx +116 -0
  145. package/src/features/gifCelebrations/constants.ts +25 -0
  146. package/src/features/gifCelebrations/helpers.ts +75 -0
  147. package/src/features/gifCelebrations/index.ts +2 -0
  148. package/src/features/gifCelebrations/model/GifCelebrations.cache.ts +43 -0
  149. package/src/features/gifCelebrations/model/GifCelebrations.model.ts +174 -0
  150. package/src/features/gifCelebrations/model/GifCelebrationsApi.ts +10 -0
  151. package/src/features/gifCelebrations/types/model.types.ts +50 -0
  152. package/src/index.ts +1 -0
  153. package/src/lib/helpers/helpers.ts +1 -1
  154. package/src/react-app-env.d.ts +5 -0
  155. package/src/shared/translation/localization/en.json +5 -0
  156. package/src/shared/translation/localization/gb.json +5 -0
  157. package/src/shared/translation/localization/sw.json +5 -0
@@ -0,0 +1,42 @@
1
+ import { Store } from 'effector';
2
+ export type CustomPrefetchMethod = (gifs: string[] | string) => Promise<unknown>;
3
+ export type CustomGetCachePathMethod = (uri: string) => Promise<string | null>;
4
+ export type GroupNumber = number;
5
+ export type GifCelebrationApiRequests = {
6
+ getGifs: () => Promise<GifResponse>;
7
+ };
8
+ export type GifCelebrationCache = {
9
+ prefetchMethod?: CustomPrefetchMethod;
10
+ };
11
+ export type GifCelebrationsModelProps = {
12
+ api: GifCelebrationApiRequests;
13
+ totalProblems: Store<number>;
14
+ resolvedProblems: Store<number>;
15
+ customPrefetchMethod?: CustomPrefetchMethod;
16
+ customGetCachePathMethod?: CustomGetCachePathMethod;
17
+ };
18
+ export type GifsGroup = string[];
19
+ export type GifsGroups = Record<`group${GroupNumber}`, GifsGroup>;
20
+ export type GifObject = {
21
+ url: string;
22
+ isShown: boolean;
23
+ group: `group${GroupNumber}`;
24
+ };
25
+ export type GifsStructure = Record<`group${GroupNumber}`, GifObject[]>;
26
+ /**
27
+ * Usually, the response contains 3 groups of gifs:
28
+ * - group1: early celebrations
29
+ * - group2: mid celebrations
30
+ * - group3: party
31
+ */
32
+ export type GifResponse = {
33
+ data: GifsGroups;
34
+ ok: boolean;
35
+ };
36
+ export type GifsPayload = {
37
+ group: number;
38
+ };
39
+ export type ProblemsPercentageTable = Record<number, number>;
40
+ export type ProgressValue = 0 | 1 | 2;
41
+ export type TextComponentType = (text: string) => React.ReactNode;
42
+ //# sourceMappingURL=model.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/gifCelebrations/types/model.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAChF,MAAM,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AAE9E,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;CACpC,CAAA;AACD,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,oBAAoB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,yBAAyB,CAAA;IAC9B,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IAC3C,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAChC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,WAAW,EAAE,EAAE,SAAS,CAAC,CAAA;AAEjE,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,QAAQ,WAAW,EAAE,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;AACtE;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,EAAE,EAAE,OAAO,CAAA;CACZ,CAAA;AACD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAErC,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAA"}
@@ -6,4 +6,5 @@ export * from './features/celebrations';
6
6
  export * from './features/endOfAssignment';
7
7
  export * from './features/formulaSheet';
8
8
  export * from './features/problemSelector';
9
+ export * from './features/gifCelebrations';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/helpers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAW,CAAC;AAE7B,eAAO,MAAM,gBAAgB,cACsC,CAAA;AASnE,eAAO,MAAM,mBAAmB,SAAU,IAAI,WAuB7C,CAAA"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/lib/helpers/helpers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAW,CAAA;AAE5B,eAAO,MAAM,gBAAgB,cACsC,CAAA;AASnE,eAAO,MAAM,mBAAmB,SAAU,IAAI,WAuB7C,CAAA"}
@@ -20,6 +20,11 @@ export declare const LOCALIZATION_CONFIGS: {
20
20
  howCanIHelp: string;
21
21
  showError: string;
22
22
  };
23
+ gifCelebrations: {
24
+ greatStart: string;
25
+ onTheWay: string;
26
+ almostThere: string;
27
+ };
23
28
  };
24
29
  "en-GB": {
25
30
  "teacherFeedback.noComments": string;
@@ -42,6 +47,11 @@ export declare const LOCALIZATION_CONFIGS: {
42
47
  howCanIHelp: string;
43
48
  showError: string;
44
49
  };
50
+ gifCelebrations: {
51
+ greatStart: string;
52
+ onTheWay: string;
53
+ almostThere: string;
54
+ };
45
55
  };
46
56
  "sv-SE": {
47
57
  "teacherFeedback.noComments": string;
@@ -64,6 +74,11 @@ export declare const LOCALIZATION_CONFIGS: {
64
74
  howCanIHelp: string;
65
75
  showError: string;
66
76
  };
77
+ gifCelebrations: {
78
+ greatStart: string;
79
+ onTheWay: string;
80
+ almostThere: string;
81
+ };
67
82
  };
68
83
  };
69
84
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhC,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhC,CAAA"}
@@ -21,6 +21,11 @@ export declare const setLocalization: import("effector").EventCallable<{
21
21
  howCanIHelp: string;
22
22
  showError: string;
23
23
  };
24
+ gifCelebrations: {
25
+ greatStart: string;
26
+ onTheWay: string;
27
+ almostThere: string;
28
+ };
24
29
  } | ((config: typeof LOCALIZATION_CONFIGS) => Translations)>;
25
30
  export declare const $localization: import("effector").StoreWritable<{
26
31
  "teacherFeedback.noComments": string;
@@ -43,5 +48,10 @@ export declare const $localization: import("effector").StoreWritable<{
43
48
  howCanIHelp: string;
44
49
  showError: string;
45
50
  };
51
+ gifCelebrations: {
52
+ greatStart: string;
53
+ onTheWay: string;
54
+ almostThere: string;
55
+ };
46
56
  }>;
47
57
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;cACD,OAAO,oBAAoB,KAAK,YAAY,EACpE,CAAA;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAA"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;cACD,OAAO,oBAAoB,KAAK,YAAY,EACpE,CAAA;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.6.5",
3
+ "version": "0.6.6-rc.1",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "src/index.ts",
@@ -23,18 +23,18 @@ export class TeacherCommentsModel {
23
23
  state,
24
24
  assignmentId,
25
25
  problemId,
26
- fn: (data) => ({
27
- comments: data.comments.map((comment) => ({ ...comment, isRead: true })),
26
+ fn: data => ({
27
+ comments: data.comments.map(comment => ({ ...comment, isRead: true })),
28
28
  unreadMessagesCount: 0,
29
29
  }),
30
30
  }),
31
31
  )
32
- .on(this.add, (state, { assignmentId, comment, isRead }) =>
32
+ .on(this.add, (state, { assignmentId, problemId, comment, isRead }) =>
33
33
  updateCommentsState({
34
34
  state,
35
35
  assignmentId,
36
- problemId: comment.problemId,
37
- fn: (data) => ({
36
+ problemId,
37
+ fn: data => ({
38
38
  comments: [...data.comments, comment],
39
39
  unreadMessagesCount: isRead ? data.unreadMessagesCount : data.unreadMessagesCount + 1,
40
40
  }),
@@ -45,7 +45,7 @@ export class TeacherCommentsModel {
45
45
  state,
46
46
  assignmentId,
47
47
  problemId,
48
- fn: (data) => {
48
+ fn: data => {
49
49
  const commentToDelete = data.comments.find(({ _id }) => _id === commentId)
50
50
  if (!commentToDelete) return data
51
51
 
@@ -77,7 +77,7 @@ export class TeacherCommentsModel {
77
77
  sample({
78
78
  clock: this.add,
79
79
  source: { isOpen: $isOpen },
80
- filter: ({ isOpen }, { problemId, comment }) => isOpen && comment.problemId === problemId,
80
+ filter: ({ isOpen }) => isOpen,
81
81
  fn: (_, { comment }) => ({
82
82
  ids: [comment._id],
83
83
  }),
@@ -56,7 +56,7 @@ export class TeacherFeedbackModel {
56
56
  comments?.length === 1 && comments[0]._id === EMPTY_COMMENT_ID
57
57
  return !isOpen && isOnlyNoCommentsMessage
58
58
  },
59
- fn: ({ assignmentId, problemId }) => ({
59
+ fn: ({ assignmentId, problemId }, comment) => ({
60
60
  assignmentId,
61
61
  problemId,
62
62
  commentId: EMPTY_COMMENT_ID,
@@ -76,7 +76,7 @@ export class TeacherFeedbackModel {
76
76
  const hasUnreadComments = comments.some(({ isRead }) => !isRead)
77
77
  return isOpen && hasUnreadComments
78
78
  },
79
- fn: (source) => {
79
+ fn: source => {
80
80
  const comments = findCommentsByCredits(source)
81
81
  return { ids: comments.map(({ _id }) => _id) }
82
82
  },
@@ -97,8 +97,9 @@ export class TeacherFeedbackModel {
97
97
 
98
98
  sample({
99
99
  clock: this.sockets.commentDeleted,
100
- fn: (comment) => ({
101
- assignmentId: comment.exerciseId,
100
+ source: { assignmentId: credits.$assignmentId },
101
+ fn: ({ assignmentId }, comment) => ({
102
+ assignmentId,
102
103
  problemId: comment.problemId,
103
104
  commentId: comment._id,
104
105
  }),
@@ -112,11 +113,10 @@ export class TeacherFeedbackModel {
112
113
  problemId: credits.$problemId,
113
114
  isOpen: this.$isOpen,
114
115
  },
115
- filter: ({ assignmentId }, comment) => assignmentId === comment.exerciseId,
116
116
  fn: ({ assignmentId, problemId, isOpen }, comment) => ({
117
117
  comment,
118
118
  assignmentId,
119
- problemId,
119
+ problemId: comment.problemId,
120
120
  isRead: isOpen && comment.problemId === problemId,
121
121
  }),
122
122
  target: this.comments.add,
@@ -0,0 +1,77 @@
1
+ import React, { useEffect } from 'react'
2
+ import { Gif } from './components/Gif'
3
+ import { Progress } from './components/Progress'
4
+ import { ContentContainer } from './components/ContentContainer'
5
+ import { Backdrop } from './components/Backdrop'
6
+ import { Easing, runOnJS, useSharedValue, withSequence, withTiming } from 'react-native-reanimated'
7
+ import { useUnit } from 'effector-react'
8
+ import { ANIMATION_DURATION } from './constants'
9
+ import { GifCelebrationsModel } from './model/GifCelebrations.model'
10
+ import { ProgressValue, TextComponentType } from './types/model.types'
11
+
12
+ type GifCelebrationsProps = {
13
+ model: GifCelebrationsModel
14
+ TextComponent: TextComponentType
15
+ }
16
+
17
+ export const GifCelebrations = ({ model, TextComponent }: GifCelebrationsProps) => {
18
+ const [totalProblems, resolvedProblems, activeGif] = useUnit([
19
+ model.$totalProblems,
20
+ model.$resolvedProblems,
21
+ model.$activeGif,
22
+ ])
23
+
24
+ const completedPercent =
25
+ resolvedProblems && totalProblems && Math.round((resolvedProblems / totalProblems) * 100)
26
+
27
+ const progress = useSharedValue<ProgressValue>(0)
28
+
29
+ const stopAnimation = () => {
30
+ model.stop()
31
+ progress.value = 0
32
+ }
33
+
34
+ const playAnimation = () => {
35
+ progress.value = withSequence(
36
+ withTiming(1, {
37
+ duration: ANIMATION_DURATION,
38
+ easing: Easing.bezier(0.52, 0.16, 0.26, 0.77),
39
+ }),
40
+ withTiming(
41
+ 2,
42
+ {
43
+ duration: ANIMATION_DURATION,
44
+ easing: Easing.bezier(0.71, 0.09, 0.49, 0.89),
45
+ },
46
+ () => runOnJS(stopAnimation)(),
47
+ ),
48
+ )
49
+ }
50
+
51
+ useEffect(() => {
52
+ model.initialize()
53
+ }, [])
54
+
55
+ useEffect(() => {
56
+ if (activeGif) {
57
+ playAnimation()
58
+ }
59
+ }, [activeGif])
60
+
61
+ if (!activeGif) {
62
+ return null
63
+ }
64
+
65
+ return (
66
+ <Backdrop progress={progress}>
67
+ <ContentContainer progress={progress}>
68
+ <Gif
69
+ gifObject={activeGif}
70
+ getCachePathMethod={model.cache.getCachePathMethod}
71
+ TextComponent={TextComponent}
72
+ />
73
+ <Progress progress={progress} completedPercent={completedPercent} />
74
+ </ContentContainer>
75
+ </Backdrop>
76
+ )
77
+ }
@@ -0,0 +1,41 @@
1
+ import { StyleSheet, useWindowDimensions } from 'react-native'
2
+ import React from 'react'
3
+ import Animated, { useAnimatedStyle, interpolateColor, SharedValue } from 'react-native-reanimated'
4
+ import { BACKDROP_COLOR } from '../constants'
5
+ import { ProgressValue } from '../types/model.types'
6
+
7
+ type BackdropProps = {
8
+ children: React.ReactNode
9
+ progress: SharedValue<ProgressValue>
10
+ }
11
+
12
+ export const Backdrop = ({ children, progress }: BackdropProps) => {
13
+ const { width, height } = useWindowDimensions()
14
+
15
+ const backdropAnimatedStyle = useAnimatedStyle(
16
+ () => ({
17
+ backgroundColor: interpolateColor(
18
+ progress.value,
19
+ [0, 1, 2],
20
+ [BACKDROP_COLOR.INITIAL, BACKDROP_COLOR.FINAL, BACKDROP_COLOR.INITIAL],
21
+ ),
22
+ }),
23
+ [progress],
24
+ )
25
+
26
+ return (
27
+ <Animated.View style={[styles.backdrop, { width, height }, backdropAnimatedStyle]}>
28
+ {children}
29
+ </Animated.View>
30
+ )
31
+ }
32
+
33
+ const styles = StyleSheet.create({
34
+ backdrop: {
35
+ position: 'absolute',
36
+ zIndex: 10100,
37
+ justifyContent: 'center',
38
+ alignItems: 'center',
39
+ backgroundColor: 'rgba(51, 51, 51, 0.33);',
40
+ },
41
+ })
@@ -0,0 +1,44 @@
1
+ import { StyleSheet, useWindowDimensions } from 'react-native'
2
+ import React from 'react'
3
+ import { SPACING } from '@magmamath/react-native-ui'
4
+ import Animated, { useAnimatedStyle, interpolate, SharedValue } from 'react-native-reanimated'
5
+ import { CONTENT_CONTAINER } from '../constants'
6
+ import { ProgressValue } from '../types/model.types'
7
+
8
+ type ContentContainerProps = {
9
+ children: React.ReactNode
10
+ progress: SharedValue<ProgressValue>
11
+ }
12
+
13
+ export const ContentContainer = ({ children, progress }: ContentContainerProps) => {
14
+ const { width } = useWindowDimensions()
15
+
16
+ const RIGHT_POSITION =
17
+ width / 2 + CONTENT_CONTAINER.CONTAINER_WIDTH / 2 + CONTENT_CONTAINER.SAFE_AREA
18
+ const LEFT_POSITION = -RIGHT_POSITION - CONTENT_CONTAINER.SAFE_AREA
19
+
20
+ const animatedStyles = useAnimatedStyle(
21
+ () => ({
22
+ transform: [
23
+ {
24
+ translateX: interpolate(progress.value, [0, 1, 2], [LEFT_POSITION, 0, RIGHT_POSITION]),
25
+ },
26
+ {
27
+ rotate: `${interpolate(progress.value, [0, 1, 2], [-CONTENT_CONTAINER.ANGLE, 0, CONTENT_CONTAINER.ANGLE])}deg`,
28
+ },
29
+ ],
30
+ }),
31
+ [progress, RIGHT_POSITION, LEFT_POSITION],
32
+ )
33
+
34
+ return <Animated.View style={[styles.container, animatedStyles]}>{children}</Animated.View>
35
+ }
36
+
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ width: CONTENT_CONTAINER.CONTAINER_WIDTH,
40
+ alignItems: 'center',
41
+ gap: SPACING[800],
42
+ position: 'absolute',
43
+ },
44
+ })
@@ -0,0 +1,86 @@
1
+ import { StyleSheet, View, Image } from 'react-native'
2
+ import React, { useLayoutEffect, useState } from 'react'
3
+ import { BORDER_RADIUS, COLORS, SPACING } from '@magmamath/react-native-ui'
4
+ import { CustomGetCachePathMethod, GifObject, TextComponentType } from '../types/model.types'
5
+ import { MAX_GIF_SIZE, MIN_GIF_SIZE } from '../constants'
6
+ import { useText } from '../../../shared/translation'
7
+ import { getGifLabel } from '../helpers'
8
+
9
+ type GifProps = {
10
+ gifObject: GifObject
11
+ getCachePathMethod?: CustomGetCachePathMethod
12
+ TextComponent: TextComponentType
13
+ }
14
+
15
+ type Size = {
16
+ width: number
17
+ height: number
18
+ }
19
+
20
+ export const Gif = ({ gifObject, getCachePathMethod, TextComponent }: GifProps) => {
21
+ const [size, setSize] = useState<Size | null>(null)
22
+ const [pathOrUri, setPathOrUri] = useState<string>('')
23
+
24
+ const t = useText()
25
+
26
+ useLayoutEffect(() => {
27
+ const loadImageSize = async () => {
28
+ const path = getCachePathMethod
29
+ ? (await getCachePathMethod(gifObject.url)) || gifObject.url
30
+ : gifObject.url
31
+
32
+ Image.getSize(path, (width, height) => {
33
+ setSize({
34
+ width: Math.max(MIN_GIF_SIZE, Math.min(MAX_GIF_SIZE.WIDTH, width)),
35
+ height: Math.max(MIN_GIF_SIZE, Math.min(MAX_GIF_SIZE.HEIGHT, height)),
36
+ })
37
+
38
+ setPathOrUri(path)
39
+ })
40
+ }
41
+
42
+ loadImageSize()
43
+ }, [gifObject.url])
44
+
45
+ return (
46
+ <View style={styles.backgroundContainer}>
47
+ <View style={styles.container}>
48
+ {size && pathOrUri && (
49
+ <Image
50
+ alt="Funny celebration animated image"
51
+ source={{
52
+ uri: pathOrUri,
53
+ }}
54
+ width={size.width}
55
+ height={size.height}
56
+ style={[styles.image, { width: size.width, height: size.height }]} //this sizes duplication is needed for compatibility with web and rn
57
+ />
58
+ )}
59
+ <View style={styles.textContainer}>
60
+ {TextComponent(t(getGifLabel(Number(gifObject.group.replace('group', '')))))}
61
+ </View>
62
+ </View>
63
+ </View>
64
+ )
65
+ }
66
+
67
+ const styles = StyleSheet.create({
68
+ backgroundContainer: {
69
+ backgroundColor: 'rgba(255, 255, 255, 0.6)',
70
+ borderRadius: 23,
71
+ padding: SPACING[200],
72
+ },
73
+ container: {
74
+ padding: SPACING[1600],
75
+ borderRadius: BORDER_RADIUS[400],
76
+ backgroundColor: COLORS.NEUTRAL_1,
77
+ },
78
+ image: {
79
+ borderRadius: BORDER_RADIUS[100],
80
+ },
81
+ textContainer: {
82
+ position: 'absolute',
83
+ bottom: 74,
84
+ alignSelf: 'center',
85
+ },
86
+ })
@@ -0,0 +1,116 @@
1
+ import { StyleSheet, View, Image, Platform } from 'react-native'
2
+ import React from 'react'
3
+ import {
4
+ BORDER_RADIUS,
5
+ COLORS,
6
+ HeadingVariants,
7
+ SPACING,
8
+ Typography,
9
+ } from '@magmamath/react-native-ui'
10
+ import Animated, { useAnimatedStyle, SharedValue, interpolate } from 'react-native-reanimated'
11
+ import confettiImage from '../assets/confetti.webp'
12
+ import { ProgressValue } from '../types/model.types'
13
+
14
+ const MIN_WIDTH_FOR_ONE_DIGIT = 12
15
+ const MIN_WIDTH_FOR_TWO_DIGITS = 15
16
+ const IS_WEB = Platform.OS === 'web'
17
+
18
+ type ProgressProps = {
19
+ progress: SharedValue<ProgressValue>
20
+ completedPercent: number
21
+ }
22
+
23
+ export const Progress = ({ progress, completedPercent }: ProgressProps) => {
24
+ const progressLineWidth = (() => {
25
+ if (completedPercent <= 9) {
26
+ return MIN_WIDTH_FOR_ONE_DIGIT
27
+ }
28
+ if (completedPercent <= 15) {
29
+ return MIN_WIDTH_FOR_TWO_DIGITS
30
+ }
31
+ return completedPercent
32
+ })()
33
+
34
+ const animatedStyles = useAnimatedStyle(
35
+ () => ({
36
+ width: `${interpolate(
37
+ progress.value,
38
+ [0, 1, 2],
39
+ [0, progressLineWidth, progressLineWidth],
40
+ )}%`,
41
+ }),
42
+ [progress, progressLineWidth],
43
+ )
44
+
45
+ return (
46
+ <View style={styles.backgroundContainer}>
47
+ <View style={styles.container}>
48
+ <View style={styles.progressContainer}>
49
+ <Animated.View style={[styles.progress, animatedStyles]}>
50
+ <Typography variant={HeadingVariants.H1} style={styles.percent}>
51
+ {`${completedPercent}%`}
52
+ </Typography>
53
+ </Animated.View>
54
+ </View>
55
+ <Image
56
+ source={
57
+ IS_WEB
58
+ ? {
59
+ uri: confettiImage,
60
+ }
61
+ : require('../assets/confetti.webp')
62
+ }
63
+ style={styles.confetti}
64
+ />
65
+ </View>
66
+ </View>
67
+ )
68
+ }
69
+
70
+ const styles = StyleSheet.create({
71
+ backgroundContainer: {
72
+ backgroundColor: 'rgba(255, 255, 255, 0.6)',
73
+ borderRadius: 23,
74
+ padding: SPACING[200],
75
+ width: '100%',
76
+ },
77
+ container: {
78
+ width: '100%',
79
+ height: 116,
80
+ flexDirection: 'row',
81
+ alignItems: 'center',
82
+ borderRadius: BORDER_RADIUS[400],
83
+ backgroundColor: COLORS.NEUTRAL_1,
84
+ paddingLeft: SPACING[400],
85
+ paddingRight: SPACING[200],
86
+ gap: SPACING[100],
87
+ },
88
+ progressContainer: {
89
+ height: 50,
90
+ flexGrow: 1,
91
+ backgroundColor: COLORS.NEUTRAL_5,
92
+ borderRadius: 90,
93
+ overflow: 'hidden',
94
+ },
95
+ progress: {
96
+ position: 'absolute',
97
+ height: '100%',
98
+ backgroundColor: COLORS.PRIMARY_BLUE,
99
+ borderRadius: BORDER_RADIUS[200],
100
+ justifyContent: 'center',
101
+ alignItems: 'flex-end',
102
+ paddingRight: 10.6,
103
+ overflow: 'hidden',
104
+ },
105
+ confetti: {
106
+ width: 75,
107
+ height: 70,
108
+ marginHorizontal: SPACING[200],
109
+ },
110
+ percent: {
111
+ position: 'absolute',
112
+ paddingRight: 10,
113
+ color: COLORS.NEUTRAL_1,
114
+ fontWeight: '700',
115
+ },
116
+ })
@@ -0,0 +1,25 @@
1
+ export const BACKDROP_COLOR = {
2
+ INITIAL: 'rgba(51, 51, 51, 0)',
3
+ FINAL: 'rgba(51, 51, 51, 0.66)',
4
+ }
5
+
6
+ export const CONTENT_CONTAINER = {
7
+ ANGLE: 5,
8
+ CONTAINER_WIDTH: 769,
9
+ SAFE_AREA: 44, // to be sure that the content is not cut off on the edges because of rotate transform
10
+ }
11
+
12
+ export const ANIMATION_DURATION = 1750
13
+ export const MIN_PROBLEMS_TO_SHOW_GIF = 6
14
+
15
+ export const MAX_GIF_SIZE = {
16
+ WIDTH: 480,
17
+ HEIGHT: 300,
18
+ }
19
+ export const MIN_GIF_SIZE = 300
20
+
21
+ export const GROUPS_PERCENTAGES = {
22
+ group1: [15, 20, 25, 30], // Early celebrations
23
+ group2: [33, 40, 45, 50], // Mid celebrations
24
+ group3: [60, 66, 75, 80], // Party
25
+ }