@magmamath/students-features 1.8.0 → 1.8.1-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 (113) hide show
  1. package/dist/commonjs/index.js +10 -22
  2. package/dist/commonjs/index.js.map +1 -1
  3. package/dist/module/index.js +0 -1
  4. package/dist/module/index.js.map +1 -1
  5. package/dist/typescript/commonjs/index.d.ts +0 -1
  6. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  7. package/dist/typescript/module/index.d.ts +0 -1
  8. package/dist/typescript/module/index.d.ts.map +1 -1
  9. package/package.json +1 -1
  10. package/src/i18n/.generated/schema.json +11 -13
  11. package/src/index.ts +0 -1
  12. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js +0 -29
  13. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js.map +0 -1
  14. package/dist/commonjs/features/exampleSolution/assets/grid.webp +0 -0
  15. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js +0 -97
  16. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +0 -1
  17. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js +0 -70
  18. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js.map +0 -1
  19. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js +0 -104
  20. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js.map +0 -1
  21. package/dist/commonjs/features/exampleSolution/constants.js +0 -13
  22. package/dist/commonjs/features/exampleSolution/constants.js.map +0 -1
  23. package/dist/commonjs/features/exampleSolution/hooks/useExampleSolution.js +0 -61
  24. package/dist/commonjs/features/exampleSolution/hooks/useExampleSolution.js.map +0 -1
  25. package/dist/commonjs/features/exampleSolution/index.js +0 -39
  26. package/dist/commonjs/features/exampleSolution/index.js.map +0 -1
  27. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js +0 -24
  28. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js.map +0 -1
  29. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionApi.js +0 -28
  30. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionApi.js.map +0 -1
  31. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionCache.js +0 -18
  32. package/dist/commonjs/features/exampleSolution/model/ExampleSolutionCache.js.map +0 -1
  33. package/dist/commonjs/features/exampleSolution/types.js +0 -6
  34. package/dist/commonjs/features/exampleSolution/types.js.map +0 -1
  35. package/dist/module/features/exampleSolution/ExampleSolutionModal.js +0 -23
  36. package/dist/module/features/exampleSolution/ExampleSolutionModal.js.map +0 -1
  37. package/dist/module/features/exampleSolution/assets/grid.webp +0 -0
  38. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js +0 -91
  39. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +0 -1
  40. package/dist/module/features/exampleSolution/components/QuestionSection.js +0 -62
  41. package/dist/module/features/exampleSolution/components/QuestionSection.js.map +0 -1
  42. package/dist/module/features/exampleSolution/components/SolutionSection.js +0 -96
  43. package/dist/module/features/exampleSolution/components/SolutionSection.js.map +0 -1
  44. package/dist/module/features/exampleSolution/constants.js +0 -9
  45. package/dist/module/features/exampleSolution/constants.js.map +0 -1
  46. package/dist/module/features/exampleSolution/hooks/useExampleSolution.js +0 -56
  47. package/dist/module/features/exampleSolution/hooks/useExampleSolution.js.map +0 -1
  48. package/dist/module/features/exampleSolution/index.js +0 -6
  49. package/dist/module/features/exampleSolution/index.js.map +0 -1
  50. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js +0 -19
  51. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js.map +0 -1
  52. package/dist/module/features/exampleSolution/model/ExampleSolutionApi.js +0 -23
  53. package/dist/module/features/exampleSolution/model/ExampleSolutionApi.js.map +0 -1
  54. package/dist/module/features/exampleSolution/model/ExampleSolutionCache.js +0 -13
  55. package/dist/module/features/exampleSolution/model/ExampleSolutionCache.js.map +0 -1
  56. package/dist/module/features/exampleSolution/types.js +0 -4
  57. package/dist/module/features/exampleSolution/types.js.map +0 -1
  58. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts +0 -11
  59. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts.map +0 -1
  60. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +0 -8
  61. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +0 -1
  62. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts +0 -10
  63. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts.map +0 -1
  64. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts +0 -9
  65. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts.map +0 -1
  66. package/dist/typescript/commonjs/features/exampleSolution/constants.d.ts +0 -6
  67. package/dist/typescript/commonjs/features/exampleSolution/constants.d.ts.map +0 -1
  68. package/dist/typescript/commonjs/features/exampleSolution/hooks/useExampleSolution.d.ts +0 -9
  69. package/dist/typescript/commonjs/features/exampleSolution/hooks/useExampleSolution.d.ts.map +0 -1
  70. package/dist/typescript/commonjs/features/exampleSolution/index.d.ts +0 -4
  71. package/dist/typescript/commonjs/features/exampleSolution/index.d.ts.map +0 -1
  72. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts +0 -10
  73. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts.map +0 -1
  74. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionApi.d.ts +0 -13
  75. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionApi.d.ts.map +0 -1
  76. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionCache.d.ts +0 -11
  77. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolutionCache.d.ts.map +0 -1
  78. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts +0 -27
  79. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts.map +0 -1
  80. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts +0 -11
  81. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts.map +0 -1
  82. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +0 -8
  83. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +0 -1
  84. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts +0 -10
  85. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts.map +0 -1
  86. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts +0 -9
  87. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts.map +0 -1
  88. package/dist/typescript/module/features/exampleSolution/constants.d.ts +0 -6
  89. package/dist/typescript/module/features/exampleSolution/constants.d.ts.map +0 -1
  90. package/dist/typescript/module/features/exampleSolution/hooks/useExampleSolution.d.ts +0 -9
  91. package/dist/typescript/module/features/exampleSolution/hooks/useExampleSolution.d.ts.map +0 -1
  92. package/dist/typescript/module/features/exampleSolution/index.d.ts +0 -4
  93. package/dist/typescript/module/features/exampleSolution/index.d.ts.map +0 -1
  94. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts +0 -10
  95. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map +0 -1
  96. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionApi.d.ts +0 -13
  97. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionApi.d.ts.map +0 -1
  98. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionCache.d.ts +0 -11
  99. package/dist/typescript/module/features/exampleSolution/model/ExampleSolutionCache.d.ts.map +0 -1
  100. package/dist/typescript/module/features/exampleSolution/types.d.ts +0 -27
  101. package/dist/typescript/module/features/exampleSolution/types.d.ts.map +0 -1
  102. package/src/features/exampleSolution/ExampleSolutionModal.tsx +0 -23
  103. package/src/features/exampleSolution/assets/grid.webp +0 -0
  104. package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +0 -80
  105. package/src/features/exampleSolution/components/QuestionSection.tsx +0 -61
  106. package/src/features/exampleSolution/components/SolutionSection.tsx +0 -117
  107. package/src/features/exampleSolution/constants.ts +0 -5
  108. package/src/features/exampleSolution/hooks/useExampleSolution.ts +0 -66
  109. package/src/features/exampleSolution/index.ts +0 -3
  110. package/src/features/exampleSolution/model/ExampleSolution.model.ts +0 -15
  111. package/src/features/exampleSolution/model/ExampleSolutionApi.ts +0 -29
  112. package/src/features/exampleSolution/model/ExampleSolutionCache.ts +0 -20
  113. package/src/features/exampleSolution/types.ts +0 -27
@@ -1,117 +0,0 @@
1
- import {
2
- StyleSheet,
3
- View,
4
- Image,
5
- ImageBackground,
6
- ScrollView,
7
- useWindowDimensions,
8
- } from 'react-native'
9
- import React from 'react'
10
- import { COLORS, IS_WEB, SPACING } from '@magmamath/react-native-ui'
11
- import Animated, { FadeIn } from 'react-native-reanimated'
12
- import { ExampleSolutionStatuses } from '../constants'
13
- import gridImage from '../assets/grid.webp'
14
- import { TEST_IDS } from '@magmamath/students-qa'
15
-
16
- type SolutionSectionProps = {
17
- answer?: string
18
- status: ExampleSolutionStatuses
19
- }
20
-
21
- const CONTAINER_SIZES = {
22
- width: 489,
23
- height: 543,
24
- }
25
- const BORDER_WIDTH = 1
26
- const CONTAINER_HEIGHT_OFFSET = 160
27
-
28
- const gridImagePath = !IS_WEB ? Image.resolveAssetSource(gridImage).uri : gridImage
29
-
30
- export const SolutionSection = ({ answer, status }: SolutionSectionProps) => {
31
- const { height } = useWindowDimensions()
32
-
33
- const shouldShowAnswer =
34
- answer &&
35
- (status === ExampleSolutionStatuses.DONE_DATA || status === ExampleSolutionStatuses.CACHE)
36
-
37
- return (
38
- <View
39
- style={[styles.container, IS_WEB && { maxHeight: height - CONTAINER_HEIGHT_OFFSET }]}
40
- testID={TEST_IDS.EXAMPLE_SOLUTION_SOLUTION_SECTION}
41
- >
42
- <ScrollView
43
- style={styles.solutionScroll}
44
- contentContainerStyle={styles.solutionScrollContent}
45
- bounces
46
- >
47
- {IS_WEB ? (
48
- <ImageBackground
49
- resizeMode="repeat"
50
- style={[styles.gridImageWeb]}
51
- source={{ uri: gridImagePath }}
52
- >
53
- {shouldShowAnswer && (
54
- <Animated.Text
55
- entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
56
- style={styles.solutionText}
57
- >
58
- {answer}
59
- </Animated.Text>
60
- )}
61
- </ImageBackground>
62
- ) : (
63
- <>
64
- <ImageBackground
65
- resizeMode="repeat"
66
- style={styles.gridImageRn}
67
- source={{ uri: gridImagePath }}
68
- />
69
- {shouldShowAnswer && (
70
- <Animated.Text
71
- entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
72
- style={styles.solutionText}
73
- >
74
- {answer}
75
- </Animated.Text>
76
- )}
77
- </>
78
- )}
79
- </ScrollView>
80
- </View>
81
- )
82
- }
83
-
84
- const styles = StyleSheet.create({
85
- container: {
86
- width: CONTAINER_SIZES.width,
87
- height: CONTAINER_SIZES.height,
88
- overflow: 'hidden',
89
- borderRadius: 8,
90
- borderWidth: BORDER_WIDTH,
91
- borderColor: COLORS.NEUTRAL_5,
92
- },
93
- gridImageRn: {
94
- top: -327,
95
- width: '100%',
96
- height: '150%',
97
- position: 'absolute',
98
- },
99
- gridImageWeb: {
100
- width: '100%',
101
- height: '100%',
102
- },
103
- solutionScroll: {
104
- flex: 1,
105
- },
106
- solutionScrollContent: {
107
- minHeight: CONTAINER_SIZES.height - BORDER_WIDTH * 2,
108
- width: '100%',
109
- },
110
- solutionText: {
111
- fontFamily: 'PlaypenSans-Light',
112
- fontSize: 28,
113
- marginHorizontal: SPACING[800],
114
- marginVertical: SPACING[400],
115
- lineHeight: 36,
116
- },
117
- })
@@ -1,5 +0,0 @@
1
- export const enum ExampleSolutionStatuses {
2
- LOADING = 'loading',
3
- DONE_DATA = 'doneData',
4
- CACHE = 'cache',
5
- }
@@ -1,66 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export * from './ExampleSolutionModal'
2
- export * from './model/ExampleSolution.model'
3
- export * from './types'
@@ -1,15 +0,0 @@
1
- import { ExampleSolutionModelProps } 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
- public readonly renderKatexComponent: (katexString: string) => React.ReactNode
10
-
11
- constructor({ api, errorHandler, renderKatexComponent }: ExampleSolutionModelProps) {
12
- this.api = new ExampleSolutionsApi({ api, errorHandler })
13
- this.renderKatexComponent = renderKatexComponent
14
- }
15
- }
@@ -1,29 +0,0 @@
1
- import { createControllerEffect } from './../../../lib/effector/createControllerEffect'
2
- import { ExampleSolutionApiRequests, ExampleSolutionErrorHandler } from '../types'
3
- import { createEffect, sample } from 'effector'
4
- import { getText } from '../../../i18n/i18n'
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 = createEffect(() => {
16
- if (!this.errorHandlerFx) return
17
- this.errorHandlerFx(getText('exampleSolution.errorMessage'))
18
- })
19
-
20
- constructor({ api, errorHandler }: ExampleSolutionApiProps) {
21
- this.generateExampleSolutionFx = createControllerEffect(api.generateExampleSolution)
22
- this.errorHandlerFx = errorHandler
23
-
24
- sample({
25
- clock: this.generateExampleSolutionFx.fail,
26
- target: this.errorHandlingFx,
27
- })
28
- }
29
- }
@@ -1,20 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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 ExampleSolutionModelProps = {
19
- api: ExampleSolutionApiRequests
20
- errorHandler?: ExampleSolutionErrorHandler
21
- renderKatexComponent: (katexString: string) => React.ReactNode
22
- }
23
- export type ExampleSolutionModalParams = {
24
- cacheKey: string
25
- payload: ExampleSolutionPayload
26
- model: ExampleSolutionModel
27
- }