@magmamath/students-features 0.6.14-rc.20 → 0.6.14-rc.21

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 (63) hide show
  1. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js +1 -3
  2. package/dist/commonjs/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
  3. package/dist/commonjs/features/exampleSolution/assets/grid.webp +0 -0
  4. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js +18 -11
  5. package/dist/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
  6. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js +7 -7
  7. package/dist/commonjs/features/exampleSolution/components/QuestionSection.js.map +1 -1
  8. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js +55 -29
  9. package/dist/commonjs/features/exampleSolution/components/SolutionSection.js.map +1 -1
  10. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js +3 -1
  11. package/dist/commonjs/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
  12. package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js +5 -4
  13. package/dist/commonjs/features/formulaSheet/components/FormulaSheet.js.map +1 -1
  14. package/dist/commonjs/shared/translation/localization/sw.json +1 -1
  15. package/dist/module/features/exampleSolution/ExampleSolutionModal.js +1 -3
  16. package/dist/module/features/exampleSolution/ExampleSolutionModal.js.map +1 -1
  17. package/dist/module/features/exampleSolution/assets/grid.webp +0 -0
  18. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js +19 -12
  19. package/dist/module/features/exampleSolution/components/ExampleSolutionModalContent.js.map +1 -1
  20. package/dist/module/features/exampleSolution/components/QuestionSection.js +9 -9
  21. package/dist/module/features/exampleSolution/components/QuestionSection.js.map +1 -1
  22. package/dist/module/features/exampleSolution/components/SolutionSection.js +57 -31
  23. package/dist/module/features/exampleSolution/components/SolutionSection.js.map +1 -1
  24. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js +3 -1
  25. package/dist/module/features/exampleSolution/model/ExampleSolution.model.js.map +1 -1
  26. package/dist/module/features/formulaSheet/components/FormulaSheet.js +5 -4
  27. package/dist/module/features/formulaSheet/components/FormulaSheet.js.map +1 -1
  28. package/dist/module/shared/translation/localization/sw.json +1 -1
  29. package/dist/typescript/commonjs/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
  30. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
  31. package/dist/typescript/commonjs/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
  32. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts +2 -1
  33. package/dist/typescript/commonjs/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
  34. package/dist/typescript/commonjs/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
  35. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
  36. package/dist/typescript/commonjs/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
  37. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts +2 -1
  38. package/dist/typescript/commonjs/features/exampleSolution/types.d.ts.map +1 -1
  39. package/dist/typescript/commonjs/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
  40. package/dist/typescript/module/features/exampleSolution/ExampleSolutionModal.d.ts.map +1 -1
  41. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts +5 -1
  42. package/dist/typescript/module/features/exampleSolution/components/ExampleSolutionModalContent.d.ts.map +1 -1
  43. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts +2 -1
  44. package/dist/typescript/module/features/exampleSolution/components/QuestionSection.d.ts.map +1 -1
  45. package/dist/typescript/module/features/exampleSolution/components/SolutionSection.d.ts.map +1 -1
  46. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts +3 -2
  47. package/dist/typescript/module/features/exampleSolution/model/ExampleSolution.model.d.ts.map +1 -1
  48. package/dist/typescript/module/features/exampleSolution/types.d.ts +2 -1
  49. package/dist/typescript/module/features/exampleSolution/types.d.ts.map +1 -1
  50. package/dist/typescript/module/features/formulaSheet/components/FormulaSheet.d.ts.map +1 -1
  51. package/package.json +2 -2
  52. package/src/features/exampleSolution/ExampleSolutionModal.tsx +1 -7
  53. package/src/features/exampleSolution/assets/grid.webp +0 -0
  54. package/src/features/exampleSolution/components/ExampleSolutionModalContent.tsx +24 -12
  55. package/src/features/exampleSolution/components/QuestionSection.tsx +11 -7
  56. package/src/features/exampleSolution/components/SolutionSection.tsx +72 -29
  57. package/src/features/exampleSolution/model/ExampleSolution.model.ts +5 -2
  58. package/src/features/exampleSolution/types.ts +2 -1
  59. package/src/features/formulaSheet/components/FormulaSheet.tsx +6 -4
  60. package/src/shared/translation/localization/sw.json +1 -1
  61. package/dist/commonjs/features/exampleSolution/assets/grid.png +0 -0
  62. package/dist/module/features/exampleSolution/assets/grid.png +0 -0
  63. package/src/features/exampleSolution/assets/grid.png +0 -0
@@ -1,69 +1,112 @@
1
- import { StyleSheet, View, Image, Text } from 'react-native'
1
+ import {
2
+ StyleSheet,
3
+ View,
4
+ Image,
5
+ ImageBackground,
6
+ ScrollView,
7
+ useWindowDimensions,
8
+ } from 'react-native'
2
9
  import React from 'react'
3
10
  import { COLORS, IS_WEB, SPACING } from '@magmamath/react-native-ui'
4
11
  import Animated, { FadeIn } from 'react-native-reanimated'
5
12
  import { ExampleSolutionStatuses } from '../constants'
6
- import gridImage from '../assets/grid.png'
13
+ import gridImage from '../assets/grid.webp'
7
14
 
8
15
  type SolutionSectionProps = {
9
16
  answer?: string
10
17
  status: ExampleSolutionStatuses
11
18
  }
12
19
 
20
+ const CONTAINER_SIZES = {
21
+ width: 489,
22
+ height: 543,
23
+ }
24
+ const BORDER_WIDTH = 1
25
+ const CONTAINER_HEIGHT_OFFSET = 160
26
+
13
27
  const gridImagePath = !IS_WEB ? Image.resolveAssetSource(gridImage).uri : gridImage
14
28
 
15
29
  export const SolutionSection = ({ answer, status }: SolutionSectionProps) => {
30
+ const { height } = useWindowDimensions()
31
+
16
32
  const shouldShowAnswer =
17
33
  answer &&
18
34
  (status === ExampleSolutionStatuses.DONE_DATA || status === ExampleSolutionStatuses.CACHE)
19
35
 
20
36
  return (
21
- <View style={styles.container}>
22
- <Image
23
- source={{ uri: gridImagePath }}
24
- style={[styles.gridImage, IS_WEB && styles.gridImageWeb]}
25
- />
26
- {shouldShowAnswer && (
27
- <Animated.ScrollView
28
- style={styles.solutionScroll}
29
- contentContainerStyle={styles.solutionScrollContent}
30
- entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
31
- >
32
- <Text style={styles.solutionText}>{answer}</Text>
33
- </Animated.ScrollView>
34
- )}
37
+ <View style={[styles.container, IS_WEB && { maxHeight: height - CONTAINER_HEIGHT_OFFSET }]}>
38
+ <ScrollView
39
+ style={styles.solutionScroll}
40
+ contentContainerStyle={styles.solutionScrollContent}
41
+ bounces
42
+ >
43
+ {IS_WEB ? (
44
+ <ImageBackground
45
+ resizeMode="repeat"
46
+ style={[styles.gridImageWeb]}
47
+ source={{ uri: gridImagePath }}
48
+ >
49
+ {shouldShowAnswer && (
50
+ <Animated.Text
51
+ entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
52
+ style={styles.solutionText}
53
+ >
54
+ {answer}
55
+ </Animated.Text>
56
+ )}
57
+ </ImageBackground>
58
+ ) : (
59
+ <>
60
+ <ImageBackground
61
+ resizeMode="repeat"
62
+ style={styles.gridImageRn}
63
+ source={{ uri: gridImagePath }}
64
+ />
65
+ {shouldShowAnswer && (
66
+ <Animated.Text
67
+ entering={status === 'cache' ? undefined : FadeIn.delay(1000).duration(500)}
68
+ style={styles.solutionText}
69
+ >
70
+ {answer}
71
+ </Animated.Text>
72
+ )}
73
+ </>
74
+ )}
75
+ </ScrollView>
35
76
  </View>
36
77
  )
37
78
  }
38
79
 
39
80
  const styles = StyleSheet.create({
40
81
  container: {
41
- width: 500,
82
+ width: CONTAINER_SIZES.width,
83
+ height: CONTAINER_SIZES.height,
42
84
  overflow: 'hidden',
43
85
  borderRadius: 8,
44
- borderWidth: 1,
86
+ borderWidth: BORDER_WIDTH,
45
87
  borderColor: COLORS.NEUTRAL_5,
46
88
  },
47
- gridImage: {
89
+ gridImageRn: {
90
+ top: -327,
48
91
  width: '100%',
49
- height: '100%',
50
- resizeMode: 'cover',
51
- aspectRatio: 28 / 8,
92
+ height: '150%',
93
+ position: 'absolute',
52
94
  },
53
95
  gridImageWeb: {
54
- transform: [{ scale: 3.5 }],
55
- },
56
- solutionScroll: {
57
- position: 'absolute',
58
96
  width: '100%',
59
97
  height: '100%',
60
98
  },
99
+ solutionScroll: {
100
+ flex: 1,
101
+ },
61
102
  solutionScrollContent: {
62
- paddingHorizontal: SPACING[800],
63
- paddingVertical: SPACING[400],
103
+ minHeight: CONTAINER_SIZES.height - BORDER_WIDTH * 2,
104
+ width: '100%',
64
105
  },
65
106
  solutionText: {
66
107
  fontFamily: 'PlaypenSans-Light',
67
- fontSize: 22,
108
+ fontSize: 28,
109
+ marginHorizontal: SPACING[800],
110
+ marginVertical: SPACING[400],
68
111
  },
69
112
  })
@@ -1,4 +1,4 @@
1
- import { GifCelebrationsModelProps } from '../types'
1
+ import { ExampleSolutionModelProps } from '../types'
2
2
  import { ExampleSolutionsApi } from './ExampleSolutionApi'
3
3
  import { ExampleSolutionCache } from './ExampleSolutionCache'
4
4
 
@@ -6,7 +6,10 @@ export class ExampleSolutionModel {
6
6
  public readonly api
7
7
  public readonly cache = new ExampleSolutionCache()
8
8
 
9
- constructor({ api, errorHandler }: GifCelebrationsModelProps) {
9
+ public readonly renderKatexComponent: (katexString: string) => React.ReactNode
10
+
11
+ constructor({ api, errorHandler, renderKatexComponent }: ExampleSolutionModelProps) {
10
12
  this.api = new ExampleSolutionsApi({ api, errorHandler })
13
+ this.renderKatexComponent = renderKatexComponent
11
14
  }
12
15
  }
@@ -15,9 +15,10 @@ export type ExampleSolutionApiRequests = {
15
15
  generateExampleSolution: (body: ExampleSolutionPayload) => Promise<ExampleSolutionResponse>
16
16
  }
17
17
  export type ExampleSolutionErrorHandler = (errorMessage: string) => void
18
- export type GifCelebrationsModelProps = {
18
+ export type ExampleSolutionModelProps = {
19
19
  api: ExampleSolutionApiRequests
20
20
  errorHandler?: ExampleSolutionErrorHandler
21
+ renderKatexComponent: (katexString: string) => React.ReactNode
21
22
  }
22
23
  export type ExampleSolutionModalParams = {
23
24
  cacheKey: string
@@ -43,6 +43,11 @@ export const FormulaSheet = forwardRef<ButtonRef | null, FormulaSheetProps>(
43
43
  const sheetFileBlob = useUnit(model.file.$blob)
44
44
  const isRequestPending = useUnit(model.api.getPDFFileBlobFx.pending)
45
45
 
46
+ const onPressHandler = () => {
47
+ model.modal.toggle()
48
+ onPress?.()
49
+ }
50
+
46
51
  useEffect(() => {
47
52
  model.file.setId(fileId ?? null)
48
53
  }, [fileId])
@@ -55,10 +60,7 @@ export const FormulaSheet = forwardRef<ButtonRef | null, FormulaSheetProps>(
55
60
  variant={ButtonVariant.SECONDARY}
56
61
  colorScheme={buttonColor}
57
62
  isActive={isOpen}
58
- onPress={() => {
59
- model.modal.toggle()
60
- onPress?.()
61
- }}
63
+ onPress={() => onPressHandler()}
62
64
  icon={<TheoryIcon color={isOpen ? COLORS.NEUTRAL_1 : undefined} size={20} />}
63
65
  style={style}
64
66
  />
@@ -26,7 +26,7 @@
26
26
  "almostThere": "Nästan där"
27
27
  },
28
28
  "exampleSolution": {
29
- "exampleSolution": "Lösnings exempel",
29
+ "exampleSolution": "Lösningsexempel",
30
30
  "letMeThink": "Låt mig tänka...",
31
31
  "aha": "Aha!",
32
32
  "errorMessage": "Något gick snett med att generera en exempellösning"