@magmamath/students-features 0.6.12-rc.0 → 0.6.13

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 (185) hide show
  1. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js +31 -0
  2. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js.map +1 -0
  3. package/dist/commonjs/features/exampleSolution/assets/grid.png +0 -0
  4. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js +97 -0
  5. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -0
  6. package/dist/commonjs/features/exampleSolution/components/LavaIcon.js +44 -0
  7. package/dist/commonjs/features/exampleSolution/components/LavaIcon.js.map +1 -0
  8. package/dist/commonjs/features/exampleSolution/components/MessageBlock.js +61 -0
  9. package/dist/commonjs/features/exampleSolution/components/MessageBlock.js.map +1 -0
  10. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js +68 -0
  11. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js.map +1 -0
  12. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js +75 -0
  13. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js.map +1 -0
  14. package/dist/commonjs/features/exampleSolution/constants.js +13 -0
  15. package/dist/commonjs/features/exampleSolution/constants.js.map +1 -0
  16. package/dist/commonjs/features/exampleSolution/hooks/useExampleSolution.js +61 -0
  17. package/dist/commonjs/features/exampleSolution/hooks/useExampleSolution.js.map +1 -0
  18. package/dist/commonjs/features/exampleSolution/index.js +39 -0
  19. package/dist/commonjs/features/exampleSolution/index.js.map +1 -0
  20. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js +22 -0
  21. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js.map +1 -0
  22. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionApi.js +32 -0
  23. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionApi.js.map +1 -0
  24. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionCache.js +18 -0
  25. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionCache.js.map +1 -0
  26. package/dist/commonjs/features/exampleSolution/types.js +6 -0
  27. package/dist/commonjs/features/exampleSolution/types.js.map +1 -0
  28. package/dist/commonjs/features/problemSelector/components/ProblemSelectorButton.js +1 -1
  29. package/dist/commonjs/features/problemSelector/components/ProblemSelectorButton.js.map +1 -1
  30. package/dist/commonjs/index.js +24 -0
  31. package/dist/commonjs/index.js.map +1 -1
  32. package/dist/commonjs/shared/icons/ExcitedLavaIcon.js +681 -0
  33. package/dist/commonjs/shared/icons/ExcitedLavaIcon.js.map +1 -0
  34. package/dist/commonjs/shared/icons/LavaIconInGlasses.js +616 -0
  35. package/dist/commonjs/shared/icons/LavaIconInGlasses.js.map +1 -0
  36. package/dist/commonjs/shared/icons/index.js +204 -0
  37. package/dist/commonjs/shared/icons/index.js.map +1 -0
  38. package/dist/commonjs/shared/translation/localization/ca.json +6 -0
  39. package/dist/commonjs/shared/translation/localization/en.json +6 -0
  40. package/dist/commonjs/shared/translation/localization/gb.json +6 -0
  41. package/dist/commonjs/shared/translation/localization/sct.json +6 -0
  42. package/dist/commonjs/shared/translation/localization/sw.json +6 -0
  43. package/dist/module/features/exampleSolution/ExampleSolutionModal.js +25 -0
  44. package/dist/module/features/exampleSolution/ExampleSolutionModal.js.map +1 -0
  45. package/dist/module/features/exampleSolution/assets/grid.png +0 -0
  46. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js +91 -0
  47. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -0
  48. package/dist/module/features/exampleSolution/components/LavaIcon.js +36 -0
  49. package/dist/module/features/exampleSolution/components/LavaIcon.js.map +1 -0
  50. package/dist/module/features/exampleSolution/components/MessageBlock.js +53 -0
  51. package/dist/module/features/exampleSolution/components/MessageBlock.js.map +1 -0
  52. package/dist/module/features/exampleSolution/components/QuestionSection.js +60 -0
  53. package/dist/module/features/exampleSolution/components/QuestionSection.js.map +1 -0
  54. package/dist/module/features/exampleSolution/components/SolutionSection.js +67 -0
  55. package/dist/module/features/exampleSolution/components/SolutionSection.js.map +1 -0
  56. package/dist/module/features/exampleSolution/constants.js +9 -0
  57. package/dist/module/features/exampleSolution/constants.js.map +1 -0
  58. package/dist/module/features/exampleSolution/hooks/useExampleSolution.js +56 -0
  59. package/dist/module/features/exampleSolution/hooks/useExampleSolution.js.map +1 -0
  60. package/dist/module/features/exampleSolution/index.js +6 -0
  61. package/dist/module/features/exampleSolution/index.js.map +1 -0
  62. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js +17 -0
  63. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js.map +1 -0
  64. package/dist/module/features/exampleSolution/model/ExampleSolutionApi.js +27 -0
  65. package/dist/module/features/exampleSolution/model/ExampleSolutionApi.js.map +1 -0
  66. package/dist/module/features/exampleSolution/model/ExampleSolutionCache.js +13 -0
  67. package/dist/module/features/exampleSolution/model/ExampleSolutionCache.js.map +1 -0
  68. package/dist/module/features/exampleSolution/types.js +4 -0
  69. package/dist/module/features/exampleSolution/types.js.map +1 -0
  70. package/dist/module/features/problemSelector/components/ProblemSelectorButton.js +1 -1
  71. package/dist/module/features/problemSelector/components/ProblemSelectorButton.js.map +1 -1
  72. package/dist/module/index.js +2 -0
  73. package/dist/module/index.js.map +1 -1
  74. package/dist/module/shared/icons/ExcitedLavaIcon.js +673 -0
  75. package/dist/module/shared/icons/ExcitedLavaIcon.js.map +1 -0
  76. package/dist/module/shared/icons/LavaIconInGlasses.js +608 -0
  77. package/dist/module/shared/icons/LavaIconInGlasses.js.map +1 -0
  78. package/dist/module/shared/icons/index.js +21 -0
  79. package/dist/module/shared/icons/index.js.map +1 -0
  80. package/dist/module/shared/translation/localization/ca.json +6 -0
  81. package/dist/module/shared/translation/localization/en.json +6 -0
  82. package/dist/module/shared/translation/localization/gb.json +6 -0
  83. package/dist/module/shared/translation/localization/sct.json +6 -0
  84. package/dist/module/shared/translation/localization/sw.json +6 -0
  85. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts +11 -0
  86. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -0
  87. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +4 -0
  88. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -0
  89. package/dist/typescript/commonjs/features/exampleSolution/components/LavaIcon.d.ts +10 -0
  90. package/dist/typescript/commonjs/features/exampleSolution/components/LavaIcon.d.ts.map +1 -0
  91. package/dist/typescript/commonjs/features/exampleSolution/components/MessageBlock.d.ts +10 -0
  92. package/dist/typescript/commonjs/features/exampleSolution/components/MessageBlock.d.ts.map +1 -0
  93. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts +9 -0
  94. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts.map +1 -0
  95. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts +9 -0
  96. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts.map +1 -0
  97. package/dist/typescript/commonjs/features/exampleSolution/constants.d.ts +6 -0
  98. package/dist/typescript/commonjs/features/exampleSolution/constants.d.ts.map +1 -0
  99. package/dist/typescript/commonjs/features/exampleSolution/hooks/useExampleSolution.d.ts +9 -0
  100. package/dist/typescript/commonjs/features/exampleSolution/hooks/useExampleSolution.d.ts.map +1 -0
  101. package/dist/typescript/commonjs/features/exampleSolution/index.d.ts +4 -0
  102. package/dist/typescript/commonjs/features/exampleSolution/index.d.ts.map +1 -0
  103. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts +9 -0
  104. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -0
  105. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionApi.d.ts +13 -0
  106. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionApi.d.ts.map +1 -0
  107. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionCache.d.ts +11 -0
  108. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionCache.d.ts.map +1 -0
  109. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts +26 -0
  110. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts.map +1 -0
  111. package/dist/typescript/commonjs/index.d.ts +2 -0
  112. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  113. package/dist/typescript/commonjs/shared/icons/ExcitedLavaIcon.d.ts +4 -0
  114. package/dist/typescript/commonjs/shared/icons/ExcitedLavaIcon.d.ts.map +1 -0
  115. package/dist/typescript/commonjs/shared/icons/LavaIconInGlasses.d.ts +4 -0
  116. package/dist/typescript/commonjs/shared/icons/LavaIconInGlasses.d.ts.map +1 -0
  117. package/dist/typescript/commonjs/shared/icons/index.d.ts +19 -0
  118. package/dist/typescript/commonjs/shared/icons/index.d.ts.map +1 -0
  119. package/dist/typescript/commonjs/shared/translation/constants.d.ts +30 -0
  120. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  121. package/dist/typescript/commonjs/shared/translation/model.d.ts +12 -0
  122. package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
  123. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts +11 -0
  124. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -0
  125. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +4 -0
  126. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -0
  127. package/dist/typescript/module/features/exampleSolution/components/LavaIcon.d.ts +10 -0
  128. package/dist/typescript/module/features/exampleSolution/components/LavaIcon.d.ts.map +1 -0
  129. package/dist/typescript/module/features/exampleSolution/components/MessageBlock.d.ts +10 -0
  130. package/dist/typescript/module/features/exampleSolution/components/MessageBlock.d.ts.map +1 -0
  131. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts +9 -0
  132. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts.map +1 -0
  133. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts +9 -0
  134. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts.map +1 -0
  135. package/dist/typescript/module/features/exampleSolution/constants.d.ts +6 -0
  136. package/dist/typescript/module/features/exampleSolution/constants.d.ts.map +1 -0
  137. package/dist/typescript/module/features/exampleSolution/hooks/useExampleSolution.d.ts +9 -0
  138. package/dist/typescript/module/features/exampleSolution/hooks/useExampleSolution.d.ts.map +1 -0
  139. package/dist/typescript/module/features/exampleSolution/index.d.ts +4 -0
  140. package/dist/typescript/module/features/exampleSolution/index.d.ts.map +1 -0
  141. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts +9 -0
  142. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -0
  143. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionApi.d.ts +13 -0
  144. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionApi.d.ts.map +1 -0
  145. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionCache.d.ts +11 -0
  146. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionCache.d.ts.map +1 -0
  147. package/dist/typescript/module/features/exampleSolution/types.d.ts +26 -0
  148. package/dist/typescript/module/features/exampleSolution/types.d.ts.map +1 -0
  149. package/dist/typescript/module/index.d.ts +2 -0
  150. package/dist/typescript/module/index.d.ts.map +1 -1
  151. package/dist/typescript/module/shared/icons/ExcitedLavaIcon.d.ts +4 -0
  152. package/dist/typescript/module/shared/icons/ExcitedLavaIcon.d.ts.map +1 -0
  153. package/dist/typescript/module/shared/icons/LavaIconInGlasses.d.ts +4 -0
  154. package/dist/typescript/module/shared/icons/LavaIconInGlasses.d.ts.map +1 -0
  155. package/dist/typescript/module/shared/icons/index.d.ts +19 -0
  156. package/dist/typescript/module/shared/icons/index.d.ts.map +1 -0
  157. package/dist/typescript/module/shared/translation/constants.d.ts +30 -0
  158. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  159. package/dist/typescript/module/shared/translation/model.d.ts +12 -0
  160. package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
  161. package/package.json +7 -3
  162. package/src/features/exampleSolution/ExampleSolutionModal.tsx +29 -0
  163. package/src/features/exampleSolution/assets/grid.png +0 -0
  164. package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +71 -0
  165. package/src/features/exampleSolution/components/LavaIcon.tsx +35 -0
  166. package/src/features/exampleSolution/components/MessageBlock.tsx +67 -0
  167. package/src/features/exampleSolution/components/QuestionSection.tsx +56 -0
  168. package/src/features/exampleSolution/components/SolutionSection.tsx +69 -0
  169. package/src/features/exampleSolution/constants.ts +5 -0
  170. package/src/features/exampleSolution/hooks/useExampleSolution.ts +66 -0
  171. package/src/features/exampleSolution/index.ts +3 -0
  172. package/src/features/exampleSolution/model/ExampleSolution.model.ts +12 -0
  173. package/src/features/exampleSolution/model/ExampleSolutionApi.ts +33 -0
  174. package/src/features/exampleSolution/model/ExampleSolutionCache.ts +20 -0
  175. package/src/features/exampleSolution/types.ts +26 -0
  176. package/src/features/problemSelector/components/ProblemSelectorButton.tsx +1 -1
  177. package/src/index.ts +2 -0
  178. package/src/shared/icons/ExcitedLavaIcon.tsx +541 -0
  179. package/src/shared/icons/LavaIconInGlasses.tsx +489 -0
  180. package/src/shared/icons/index.ts +18 -0
  181. package/src/shared/translation/localization/ca.json +6 -0
  182. package/src/shared/translation/localization/en.json +6 -0
  183. package/src/shared/translation/localization/gb.json +6 -0
  184. package/src/shared/translation/localization/sct.json +6 -0
  185. package/src/shared/translation/localization/sw.json +6 -0
@@ -0,0 +1,66 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { useUnit } from 'effector-react'
3
+ import { ExampleSolutionModalParams, ExampleSolutionResponse } from '../types'
4
+ import { ExampleSolutionStatuses } from '../constants'
5
+
6
+ const ANIMATION_DELAY = 600
7
+
8
+ type UseExampleSolutionReturn = {
9
+ result: ExampleSolutionResponse | null
10
+ status: ExampleSolutionStatuses
11
+ }
12
+
13
+ export const useExampleSolution = ({
14
+ model,
15
+ payload,
16
+ cacheKey,
17
+ }: ExampleSolutionModalParams): UseExampleSolutionReturn => {
18
+ const exampleSolutionsCache = useUnit(model.cache.$state)
19
+ const [result, setResult] = useState<ExampleSolutionResponse | null>(null)
20
+ const [status, setStatus] = useState<ExampleSolutionStatuses>(ExampleSolutionStatuses.LOADING)
21
+
22
+ useEffect(() => {
23
+ let timer: NodeJS.Timeout | null = null
24
+
25
+ const fetchExampleSolution = async () => {
26
+ try {
27
+ if (exampleSolutionsCache[cacheKey]) {
28
+ setResult(exampleSolutionsCache[cacheKey])
29
+ setStatus(ExampleSolutionStatuses.CACHE)
30
+ return
31
+ }
32
+
33
+ const startTime = Date.now()
34
+ const response = await model.api.generateExampleSolutionFx(payload)
35
+
36
+ setResult(response)
37
+ model.cache.addExampleSolution({ cacheKey, response })
38
+
39
+ const elapsedTime = Date.now() - startTime
40
+ if (elapsedTime >= ANIMATION_DELAY) {
41
+ setStatus(ExampleSolutionStatuses.DONE_DATA)
42
+ } else {
43
+ timer = setTimeout(() => {
44
+ setStatus(ExampleSolutionStatuses.DONE_DATA)
45
+ }, ANIMATION_DELAY - elapsedTime)
46
+ }
47
+ } catch (error) {
48
+ console.error('Failed to fetch example solution:', error)
49
+ setStatus(ExampleSolutionStatuses.DONE_DATA)
50
+ }
51
+ }
52
+
53
+ fetchExampleSolution()
54
+
55
+ return () => {
56
+ if (timer) {
57
+ clearTimeout(timer)
58
+ }
59
+ }
60
+ }, [])
61
+
62
+ return {
63
+ result,
64
+ status,
65
+ }
66
+ }
@@ -0,0 +1,3 @@
1
+ export * from './ExampleSolutionModal'
2
+ export * from './model/ExampleSolution.model'
3
+ export * from './types'
@@ -0,0 +1,12 @@
1
+ import { GifCelebrationsModelProps } from '../types'
2
+ import { ExampleSolutionsApi } from './ExampleSolutionApi'
3
+ import { ExampleSolutionCache } from './ExampleSolutionCache'
4
+
5
+ export class ExampleSolutionModel {
6
+ public readonly api
7
+ public readonly cache = new ExampleSolutionCache()
8
+
9
+ constructor({ api, errorHandler }: GifCelebrationsModelProps) {
10
+ this.api = new ExampleSolutionsApi({ api, errorHandler })
11
+ }
12
+ }
@@ -0,0 +1,33 @@
1
+ import { createControllerEffect } from './../../../lib/effector/createControllerEffect'
2
+ import { ExampleSolutionApiRequests, ExampleSolutionErrorHandler } from '../types'
3
+ import { $localization } from '../../../shared/translation'
4
+ import { createEffect, sample, attach, StoreValue } from 'effector'
5
+
6
+ type ExampleSolutionApiProps = {
7
+ api: ExampleSolutionApiRequests
8
+ errorHandler?: ExampleSolutionErrorHandler
9
+ }
10
+
11
+ export class ExampleSolutionsApi {
12
+ public readonly generateExampleSolutionFx
13
+ public readonly errorHandlerFx?: ExampleSolutionErrorHandler
14
+
15
+ public readonly errorHandlingFx = attach({
16
+ source: $localization,
17
+ effect: createEffect((localization: StoreValue<typeof $localization>) => {
18
+ if (!this.errorHandlerFx) return
19
+ const errorMessage = localization.exampleSolution.errorMessage
20
+ this.errorHandlerFx(errorMessage)
21
+ }),
22
+ })
23
+
24
+ constructor({ api, errorHandler }: ExampleSolutionApiProps) {
25
+ this.generateExampleSolutionFx = createControllerEffect(api.generateExampleSolution)
26
+ this.errorHandlerFx = errorHandler
27
+
28
+ sample({
29
+ clock: this.generateExampleSolutionFx.fail,
30
+ target: this.errorHandlingFx,
31
+ })
32
+ }
33
+ }
@@ -0,0 +1,20 @@
1
+ import { createEvent, createStore } from 'effector'
2
+ import { ExampleSolutionResponse } from '../types'
3
+
4
+ type AddExampleSolution = {
5
+ cacheKey: string
6
+ response: ExampleSolutionResponse
7
+ }
8
+
9
+ export class ExampleSolutionCache {
10
+ public readonly addExampleSolution = createEvent<AddExampleSolution>()
11
+ public readonly $state = createStore<Record<string, ExampleSolutionResponse>>({}).on(
12
+ this.addExampleSolution,
13
+ (state, exampleSolution) => {
14
+ return {
15
+ ...state,
16
+ [exampleSolution.cacheKey]: exampleSolution.response,
17
+ }
18
+ },
19
+ )
20
+ }
@@ -0,0 +1,26 @@
1
+ import { ExampleSolutionModel } from './model/ExampleSolution.model'
2
+
3
+ export type ExampleSolutionPayload = {
4
+ question: string
5
+ answer: string
6
+ language: string
7
+ altText?: string
8
+ imageCdnId?: string
9
+ }
10
+ export type ExampleSolutionResponse = {
11
+ question: string
12
+ answer: string
13
+ }
14
+ export type ExampleSolutionApiRequests = {
15
+ generateExampleSolution: (body: ExampleSolutionPayload) => Promise<ExampleSolutionResponse>
16
+ }
17
+ export type ExampleSolutionErrorHandler = (errorMessage: string) => void
18
+ export type GifCelebrationsModelProps = {
19
+ api: ExampleSolutionApiRequests
20
+ errorHandler?: ExampleSolutionErrorHandler
21
+ }
22
+ export type ExampleSolutionModalParams = {
23
+ cacheKey: string
24
+ payload: ExampleSolutionPayload
25
+ model: ExampleSolutionModel
26
+ }
@@ -38,7 +38,7 @@ export const ProblemSelectorButton = ({
38
38
  disabled={locked}
39
39
  icon={
40
40
  locked ? (
41
- <LockIcon color={customColorScheme[ButtonStates.DISABLED]?.color} size={25} />
41
+ <LockIcon color={customColorScheme[ButtonStates.DISABLED]?.color} size="large" />
42
42
  ) : (
43
43
  <Typography
44
44
  variant="h3"
package/src/index.ts CHANGED
@@ -7,3 +7,5 @@ export * from './features/endOfAssignment'
7
7
  export * from './features/formulaSheet'
8
8
  export * from './features/problemSelector'
9
9
  export * from './features/gifCelebrations'
10
+ export * from './features/exampleSolution'
11
+ export * from './shared/icons'