@magmamath/students-features 0.9.113 → 0.9.114-rc.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.
- package/dist/commonjs/features/pmProgress/PracticeProgress.js +264 -0
- package/dist/commonjs/features/pmProgress/PracticeProgress.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/chart.helpers.js +24 -0
- package/dist/commonjs/features/pmProgress/chart/chart.helpers.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/chart.types.js +2 -0
- package/dist/commonjs/features/pmProgress/chart/chart.types.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/PracticeProgressPieChart.js +44 -0
- package/dist/commonjs/features/pmProgress/chart/components/PracticeProgressPieChart.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/SlicesClipPaths.js +38 -0
- package/dist/commonjs/features/pmProgress/chart/components/SlicesClipPaths.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/SlicesPaths.js +64 -0
- package/dist/commonjs/features/pmProgress/chart/components/SlicesPaths.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceArcPattern.js +38 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceArcPattern.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceBackgroundColor.js +21 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceBackgroundColor.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceFillColor.js +49 -0
- package/dist/commonjs/features/pmProgress/chart/components/layers/SliceFillColor.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/model/ArcPatternGenerator.js +49 -0
- package/dist/commonjs/features/pmProgress/chart/model/ArcPatternGenerator.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/model/PieChartManager.js +25 -0
- package/dist/commonjs/features/pmProgress/chart/model/PieChartManager.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/model/SliceHighlight.js +20 -0
- package/dist/commonjs/features/pmProgress/chart/model/SliceHighlight.js.map +1 -0
- package/dist/commonjs/features/pmProgress/chart/model/SliceShapeGenerator.js +67 -0
- package/dist/commonjs/features/pmProgress/chart/model/SliceShapeGenerator.js.map +1 -0
- package/dist/commonjs/features/pmProgress/header/PracticeProgressHeader.js +180 -0
- package/dist/commonjs/features/pmProgress/header/PracticeProgressHeader.js.map +1 -0
- package/dist/commonjs/features/pmProgress/index.js +13 -0
- package/dist/commonjs/features/pmProgress/index.js.map +1 -0
- package/dist/commonjs/features/pmProgress/list/ListCard.js +128 -0
- package/dist/commonjs/features/pmProgress/list/ListCard.js.map +1 -0
- package/dist/commonjs/features/pmProgress/list/ListItem.js +128 -0
- package/dist/commonjs/features/pmProgress/list/ListItem.js.map +1 -0
- package/dist/commonjs/features/pmProgress/recs/TeacherRecs.js +17 -0
- package/dist/commonjs/features/pmProgress/recs/TeacherRecs.js.map +1 -0
- package/dist/commonjs/features/pmProgress/stats/PracticeProgressStats.js +63 -0
- package/dist/commonjs/features/pmProgress/stats/PracticeProgressStats.js.map +1 -0
- package/dist/commonjs/features/pmProgress/stats/StatsCard.js +66 -0
- package/dist/commonjs/features/pmProgress/stats/StatsCard.js.map +1 -0
- package/dist/commonjs/features/pmProgress/temp.js +74 -0
- package/dist/commonjs/features/pmProgress/temp.js.map +1 -0
- package/dist/commonjs/index.js +14 -2
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/shared/icons/PentagonIcon.js +32 -0
- package/dist/commonjs/shared/icons/PentagonIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/SketchArrowRight.js +33 -0
- package/dist/commonjs/shared/icons/SketchArrowRight.js.map +1 -0
- package/dist/commonjs/shared/icons/SliceDiamondIcon.js +32 -0
- package/dist/commonjs/shared/icons/SliceDiamondIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/StarIcon.js +32 -0
- package/dist/commonjs/shared/icons/StarIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/TimerIcon.js +35 -0
- package/dist/commonjs/shared/icons/TimerIcon.js.map +1 -0
- package/dist/module/features/pmProgress/PracticeProgress.js +258 -0
- package/dist/module/features/pmProgress/PracticeProgress.js.map +1 -0
- package/dist/module/features/pmProgress/chart/chart.helpers.js +16 -0
- package/dist/module/features/pmProgress/chart/chart.helpers.js.map +1 -0
- package/dist/module/features/pmProgress/chart/chart.types.js +2 -0
- package/dist/module/features/pmProgress/chart/chart.types.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/PracticeProgressPieChart.js +38 -0
- package/dist/module/features/pmProgress/chart/components/PracticeProgressPieChart.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/SlicesClipPaths.js +32 -0
- package/dist/module/features/pmProgress/chart/components/SlicesClipPaths.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/SlicesPaths.js +58 -0
- package/dist/module/features/pmProgress/chart/components/SlicesPaths.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceArcPattern.js +32 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceArcPattern.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceBackgroundColor.js +15 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceBackgroundColor.js.map +1 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceFillColor.js +43 -0
- package/dist/module/features/pmProgress/chart/components/layers/SliceFillColor.js.map +1 -0
- package/dist/module/features/pmProgress/chart/model/ArcPatternGenerator.js +44 -0
- package/dist/module/features/pmProgress/chart/model/ArcPatternGenerator.js.map +1 -0
- package/dist/module/features/pmProgress/chart/model/PieChartManager.js +20 -0
- package/dist/module/features/pmProgress/chart/model/PieChartManager.js.map +1 -0
- package/dist/module/features/pmProgress/chart/model/SliceHighlight.js +15 -0
- package/dist/module/features/pmProgress/chart/model/SliceHighlight.js.map +1 -0
- package/dist/module/features/pmProgress/chart/model/SliceShapeGenerator.js +62 -0
- package/dist/module/features/pmProgress/chart/model/SliceShapeGenerator.js.map +1 -0
- package/dist/module/features/pmProgress/header/PracticeProgressHeader.js +174 -0
- package/dist/module/features/pmProgress/header/PracticeProgressHeader.js.map +1 -0
- package/dist/module/features/pmProgress/index.js +4 -0
- package/dist/module/features/pmProgress/index.js.map +1 -0
- package/dist/module/features/pmProgress/list/ListCard.js +121 -0
- package/dist/module/features/pmProgress/list/ListCard.js.map +1 -0
- package/dist/module/features/pmProgress/list/ListItem.js +122 -0
- package/dist/module/features/pmProgress/list/ListItem.js.map +1 -0
- package/dist/module/features/pmProgress/recs/TeacherRecs.js +11 -0
- package/dist/module/features/pmProgress/recs/TeacherRecs.js.map +1 -0
- package/dist/module/features/pmProgress/stats/PracticeProgressStats.js +56 -0
- package/dist/module/features/pmProgress/stats/PracticeProgressStats.js.map +1 -0
- package/dist/module/features/pmProgress/stats/StatsCard.js +60 -0
- package/dist/module/features/pmProgress/stats/StatsCard.js.map +1 -0
- package/dist/module/features/pmProgress/temp.js +70 -0
- package/dist/module/features/pmProgress/temp.js.map +1 -0
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/shared/icons/PentagonIcon.js +24 -0
- package/dist/module/shared/icons/PentagonIcon.js.map +1 -0
- package/dist/module/shared/icons/SketchArrowRight.js +25 -0
- package/dist/module/shared/icons/SketchArrowRight.js.map +1 -0
- package/dist/module/shared/icons/SliceDiamondIcon.js +24 -0
- package/dist/module/shared/icons/SliceDiamondIcon.js.map +1 -0
- package/dist/module/shared/icons/StarIcon.js +24 -0
- package/dist/module/shared/icons/StarIcon.js.map +1 -0
- package/dist/module/shared/icons/TimerIcon.js +27 -0
- package/dist/module/shared/icons/TimerIcon.js.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/PracticeProgress.d.ts +3 -0
- package/dist/typescript/commonjs/features/pmProgress/PracticeProgress.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/chart.helpers.d.ts +5 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/chart.helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/chart.types.d.ts +35 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/chart.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/PracticeProgressPieChart.d.ts +9 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/PracticeProgressPieChart.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/SlicesClipPaths.d.ts +10 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/SlicesClipPaths.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/SlicesPaths.d.ts +11 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/SlicesPaths.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceArcPattern.d.ts +12 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceArcPattern.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceBackgroundColor.d.ts +8 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceBackgroundColor.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceFillColor.d.ts +13 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/components/layers/SliceFillColor.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/ArcPatternGenerator.d.ts +12 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/ArcPatternGenerator.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/PieChartManager.d.ts +16 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/PieChartManager.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/SliceHighlight.d.ts +10 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/SliceHighlight.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/SliceShapeGenerator.d.ts +15 -0
- package/dist/typescript/commonjs/features/pmProgress/chart/model/SliceShapeGenerator.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/header/PracticeProgressHeader.d.ts +12 -0
- package/dist/typescript/commonjs/features/pmProgress/header/PracticeProgressHeader.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/index.d.ts +2 -0
- package/dist/typescript/commonjs/features/pmProgress/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/list/ListCard.d.ts +15 -0
- package/dist/typescript/commonjs/features/pmProgress/list/ListCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/list/ListItem.d.ts +11 -0
- package/dist/typescript/commonjs/features/pmProgress/list/ListItem.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/recs/TeacherRecs.d.ts +3 -0
- package/dist/typescript/commonjs/features/pmProgress/recs/TeacherRecs.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/stats/PracticeProgressStats.d.ts +3 -0
- package/dist/typescript/commonjs/features/pmProgress/stats/PracticeProgressStats.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/stats/StatsCard.d.ts +10 -0
- package/dist/typescript/commonjs/features/pmProgress/stats/StatsCard.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/pmProgress/temp.d.ts +4 -0
- package/dist/typescript/commonjs/features/pmProgress/temp.d.ts.map +1 -0
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/icons/PentagonIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/PentagonIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/SketchArrowRight.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/SketchArrowRight.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/SliceDiamondIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/SliceDiamondIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/StarIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/StarIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/TimerIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/TimerIcon.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/PracticeProgress.d.ts +3 -0
- package/dist/typescript/module/features/pmProgress/PracticeProgress.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/chart.helpers.d.ts +5 -0
- package/dist/typescript/module/features/pmProgress/chart/chart.helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/chart.types.d.ts +35 -0
- package/dist/typescript/module/features/pmProgress/chart/chart.types.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/PracticeProgressPieChart.d.ts +9 -0
- package/dist/typescript/module/features/pmProgress/chart/components/PracticeProgressPieChart.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/SlicesClipPaths.d.ts +10 -0
- package/dist/typescript/module/features/pmProgress/chart/components/SlicesClipPaths.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/SlicesPaths.d.ts +11 -0
- package/dist/typescript/module/features/pmProgress/chart/components/SlicesPaths.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceArcPattern.d.ts +12 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceArcPattern.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceBackgroundColor.d.ts +8 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceBackgroundColor.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceFillColor.d.ts +13 -0
- package/dist/typescript/module/features/pmProgress/chart/components/layers/SliceFillColor.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/model/ArcPatternGenerator.d.ts +12 -0
- package/dist/typescript/module/features/pmProgress/chart/model/ArcPatternGenerator.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/model/PieChartManager.d.ts +16 -0
- package/dist/typescript/module/features/pmProgress/chart/model/PieChartManager.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/model/SliceHighlight.d.ts +10 -0
- package/dist/typescript/module/features/pmProgress/chart/model/SliceHighlight.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/chart/model/SliceShapeGenerator.d.ts +15 -0
- package/dist/typescript/module/features/pmProgress/chart/model/SliceShapeGenerator.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/header/PracticeProgressHeader.d.ts +12 -0
- package/dist/typescript/module/features/pmProgress/header/PracticeProgressHeader.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/index.d.ts +2 -0
- package/dist/typescript/module/features/pmProgress/index.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/list/ListCard.d.ts +15 -0
- package/dist/typescript/module/features/pmProgress/list/ListCard.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/list/ListItem.d.ts +11 -0
- package/dist/typescript/module/features/pmProgress/list/ListItem.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/recs/TeacherRecs.d.ts +3 -0
- package/dist/typescript/module/features/pmProgress/recs/TeacherRecs.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/stats/PracticeProgressStats.d.ts +3 -0
- package/dist/typescript/module/features/pmProgress/stats/PracticeProgressStats.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/stats/StatsCard.d.ts +10 -0
- package/dist/typescript/module/features/pmProgress/stats/StatsCard.d.ts.map +1 -0
- package/dist/typescript/module/features/pmProgress/temp.d.ts +4 -0
- package/dist/typescript/module/features/pmProgress/temp.d.ts.map +1 -0
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/shared/icons/PentagonIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/PentagonIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/SketchArrowRight.d.ts +4 -0
- package/dist/typescript/module/shared/icons/SketchArrowRight.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/SliceDiamondIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/SliceDiamondIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/StarIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/StarIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/TimerIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/TimerIcon.d.ts.map +1 -0
- package/package.json +4 -2
- package/src/features/pmProgress/PracticeProgress.tsx +249 -0
- package/src/features/pmProgress/chart/chart.helpers.ts +15 -0
- package/src/features/pmProgress/chart/chart.types.ts +36 -0
- package/src/features/pmProgress/chart/components/PracticeProgressPieChart.tsx +32 -0
- package/src/features/pmProgress/chart/components/SlicesClipPaths.tsx +36 -0
- package/src/features/pmProgress/chart/components/SlicesPaths.tsx +67 -0
- package/src/features/pmProgress/chart/components/layers/SliceArcPattern.tsx +44 -0
- package/src/features/pmProgress/chart/components/layers/SliceBackgroundColor.tsx +11 -0
- package/src/features/pmProgress/chart/components/layers/SliceFillColor.tsx +55 -0
- package/src/features/pmProgress/chart/model/ArcPatternGenerator.ts +48 -0
- package/src/features/pmProgress/chart/model/PieChartManager.ts +20 -0
- package/src/features/pmProgress/chart/model/SliceHighlight.ts +17 -0
- package/src/features/pmProgress/chart/model/SliceShapeGenerator.ts +71 -0
- package/src/features/pmProgress/header/PracticeProgressHeader.tsx +178 -0
- package/src/features/pmProgress/index.ts +1 -0
- package/src/features/pmProgress/list/ListCard.tsx +133 -0
- package/src/features/pmProgress/list/ListItem.tsx +113 -0
- package/src/features/pmProgress/recs/TeacherRecs.tsx +10 -0
- package/src/features/pmProgress/stats/PracticeProgressStats.tsx +60 -0
- package/src/features/pmProgress/stats/StatsCard.tsx +58 -0
- package/src/features/pmProgress/temp.ts +67 -0
- package/src/index.ts +1 -0
- package/src/shared/icons/PentagonIcon.tsx +17 -0
- package/src/shared/icons/SketchArrowRight.tsx +18 -0
- package/src/shared/icons/SliceDiamondIcon.tsx +16 -0
- package/src/shared/icons/StarIcon.tsx +17 -0
- package/src/shared/icons/TimerIcon.tsx +21 -0
- package/dist/commonjs/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
- package/dist/module/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
- package/src/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, StyleSheet, Text, ListRenderItemInfo } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
BORDER_RADIUS,
|
|
5
|
+
COLORS,
|
|
6
|
+
SPACING,
|
|
7
|
+
ScrollableList,
|
|
8
|
+
Button,
|
|
9
|
+
ButtonSize,
|
|
10
|
+
ButtonVariant,
|
|
11
|
+
} from '@magmamath/react-native-ui'
|
|
12
|
+
import { PracticeProgressPieChart } from './chart/components/PracticeProgressPieChart'
|
|
13
|
+
import { DEFAULT_CONFIG, SAMPLE_DATA } from './temp'
|
|
14
|
+
import { PracticeProgressHeader } from './header/PracticeProgressHeader'
|
|
15
|
+
import { PracticeProgressStats } from './stats/PracticeProgressStats'
|
|
16
|
+
import { ListCard } from './list/ListCard'
|
|
17
|
+
import { ListItemData } from './list/ListItem'
|
|
18
|
+
import { SliceDiamondIcon } from '../../shared/icons/SliceDiamondIcon'
|
|
19
|
+
import { PentagonIcon } from '../../shared/icons/PentagonIcon'
|
|
20
|
+
|
|
21
|
+
type CardData = {
|
|
22
|
+
id: string
|
|
23
|
+
title: string
|
|
24
|
+
icon: JSX.Element
|
|
25
|
+
color: string
|
|
26
|
+
items: ListItemData[]
|
|
27
|
+
progress: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const SAMPLE_ITEMS: ListItemData[] = [
|
|
31
|
+
{ title: 'Solve real-world problems', subtitle: '4.NS.3B', skillsLeft: 3 },
|
|
32
|
+
{ title: 'Divide fractions', subtitle: '4.NS.3A', skillsLeft: 0, isFinished: true },
|
|
33
|
+
{ title: 'Add and subtract fractions', subtitle: '4.NS.2A', skillsLeft: 5 },
|
|
34
|
+
{ title: 'Multiply whole numbers', subtitle: '4.NS.1C', skillsLeft: 0, isFinished: true },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const LIST_DATA: CardData[] = [
|
|
38
|
+
...Array.from({ length: 11 }, (_, i) => ({
|
|
39
|
+
id: `algebra-${i}`,
|
|
40
|
+
title: 'Algebra and Functions',
|
|
41
|
+
color: COLORS.PRIMARY_INDIGO,
|
|
42
|
+
icon: <SliceDiamondIcon color={COLORS.PRIMARY_INDIGO} />,
|
|
43
|
+
items: SAMPLE_ITEMS,
|
|
44
|
+
progress: Math.round(10 + i * 8),
|
|
45
|
+
})),
|
|
46
|
+
{
|
|
47
|
+
id: 'data-analysis',
|
|
48
|
+
title: 'Data Analysis and Probability',
|
|
49
|
+
color: COLORS.PRIMARY_BLUE,
|
|
50
|
+
icon: <SliceDiamondIcon color={COLORS.PRIMARY_BLUE} />,
|
|
51
|
+
items: SAMPLE_ITEMS,
|
|
52
|
+
progress: 63,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'ratios',
|
|
56
|
+
title: 'Ratios and Proportionality',
|
|
57
|
+
color: COLORS.PRIMARY_RED,
|
|
58
|
+
icon: <SliceDiamondIcon color={COLORS.PRIMARY_RED} />,
|
|
59
|
+
items: SAMPLE_ITEMS,
|
|
60
|
+
progress: 27,
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
const FLUENCY_DATA: CardData = {
|
|
65
|
+
id: 'fluency',
|
|
66
|
+
title: 'Fluency',
|
|
67
|
+
color: COLORS.PRIMARY_ORANGE,
|
|
68
|
+
icon: <SliceDiamondIcon color={COLORS.PRIMARY_ORANGE} />,
|
|
69
|
+
items: SAMPLE_ITEMS,
|
|
70
|
+
progress: 85,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const SCROLLBAR_WIDTH = 8
|
|
74
|
+
const BADGE_SIZE = 20
|
|
75
|
+
const BADGE_OFFSET = -8
|
|
76
|
+
const BADGE_FONT_SIZE = 12
|
|
77
|
+
const CHART_SIZE = 432
|
|
78
|
+
const STATS_MAX_HEIGHT = 136
|
|
79
|
+
|
|
80
|
+
const ListFooter = () => (
|
|
81
|
+
<>
|
|
82
|
+
<View style={styles.separator} />
|
|
83
|
+
<ListCard
|
|
84
|
+
icon={FLUENCY_DATA.icon}
|
|
85
|
+
title={FLUENCY_DATA.title}
|
|
86
|
+
color={FLUENCY_DATA.color}
|
|
87
|
+
items={FLUENCY_DATA.items}
|
|
88
|
+
progress={FLUENCY_DATA.progress}
|
|
89
|
+
isFirst
|
|
90
|
+
isLast
|
|
91
|
+
/>
|
|
92
|
+
</>
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
export const PracticeProgress = () => (
|
|
96
|
+
<View style={styles.container}>
|
|
97
|
+
<PracticeProgressHeader
|
|
98
|
+
title="Practice & Progress"
|
|
99
|
+
buttonLabel="START"
|
|
100
|
+
grade="Grade 4"
|
|
101
|
+
nextUp="Next up!"
|
|
102
|
+
topic="Algebra and functions"
|
|
103
|
+
topicColor={COLORS.PRIMARY_RED}
|
|
104
|
+
/>
|
|
105
|
+
|
|
106
|
+
<View style={styles.content}>
|
|
107
|
+
<View style={styles.column}>
|
|
108
|
+
<View style={styles.recommendations}>
|
|
109
|
+
<View style={styles.badgeWrapper}>
|
|
110
|
+
<ListCard
|
|
111
|
+
icon={<PentagonIcon color={COLORS.PRIMARY_YELLOW} />}
|
|
112
|
+
title="Teacher Recommendations"
|
|
113
|
+
color={COLORS.PRIMARY_YELLOW}
|
|
114
|
+
items={SAMPLE_ITEMS}
|
|
115
|
+
progress={42}
|
|
116
|
+
isFirst
|
|
117
|
+
isLast
|
|
118
|
+
rightContent={
|
|
119
|
+
<Button size={ButtonSize.SMALL} variant={ButtonVariant.SECONDARY}>
|
|
120
|
+
PRACTICE
|
|
121
|
+
</Button>
|
|
122
|
+
}
|
|
123
|
+
/>
|
|
124
|
+
<View style={styles.badge}>
|
|
125
|
+
<Text style={styles.badgeText}>7</Text>
|
|
126
|
+
</View>
|
|
127
|
+
</View>
|
|
128
|
+
</View>
|
|
129
|
+
|
|
130
|
+
<View style={styles.cards}>
|
|
131
|
+
<ScrollableList<CardData>
|
|
132
|
+
style={styles.scroll}
|
|
133
|
+
scrollbarWidth={SCROLLBAR_WIDTH}
|
|
134
|
+
hideShadow
|
|
135
|
+
data={LIST_DATA}
|
|
136
|
+
renderItem={({ item, index }: ListRenderItemInfo<CardData>) => (
|
|
137
|
+
<ListCard
|
|
138
|
+
icon={item.icon}
|
|
139
|
+
title={item.title}
|
|
140
|
+
color={item.color}
|
|
141
|
+
items={item.items}
|
|
142
|
+
progress={item.progress}
|
|
143
|
+
isFirst={index === 0}
|
|
144
|
+
isLast={index === LIST_DATA.length - 1}
|
|
145
|
+
/>
|
|
146
|
+
)}
|
|
147
|
+
keyExtractor={(item) => item.id}
|
|
148
|
+
contentContainerStyle={styles.list}
|
|
149
|
+
ListFooterComponent={ListFooter}
|
|
150
|
+
/>
|
|
151
|
+
</View>
|
|
152
|
+
</View>
|
|
153
|
+
|
|
154
|
+
<View style={styles.metrics}>
|
|
155
|
+
<View style={styles.chart}>
|
|
156
|
+
<PracticeProgressPieChart data={SAMPLE_DATA} config={DEFAULT_CONFIG} />
|
|
157
|
+
</View>
|
|
158
|
+
<View style={styles.stats}>
|
|
159
|
+
<PracticeProgressStats />
|
|
160
|
+
</View>
|
|
161
|
+
</View>
|
|
162
|
+
</View>
|
|
163
|
+
</View>
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
const styles = StyleSheet.create({
|
|
167
|
+
container: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
},
|
|
170
|
+
content: {
|
|
171
|
+
flex: 1,
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
},
|
|
174
|
+
column: {
|
|
175
|
+
flex: 1,
|
|
176
|
+
gap: SPACING[200],
|
|
177
|
+
marginRight: SPACING[400] + SPACING[50],
|
|
178
|
+
},
|
|
179
|
+
recommendations: {
|
|
180
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
181
|
+
padding: SPACING[200],
|
|
182
|
+
borderRadius: BORDER_RADIUS[400],
|
|
183
|
+
overflow: 'visible',
|
|
184
|
+
},
|
|
185
|
+
badgeWrapper: {
|
|
186
|
+
position: 'relative',
|
|
187
|
+
},
|
|
188
|
+
badge: {
|
|
189
|
+
position: 'absolute',
|
|
190
|
+
top: BADGE_OFFSET,
|
|
191
|
+
right: BADGE_OFFSET,
|
|
192
|
+
width: BADGE_SIZE,
|
|
193
|
+
height: BADGE_SIZE,
|
|
194
|
+
backgroundColor: COLORS.PRIMARY_RED,
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
borderRadius: BADGE_SIZE / 2,
|
|
198
|
+
},
|
|
199
|
+
badgeText: {
|
|
200
|
+
fontSize: BADGE_FONT_SIZE,
|
|
201
|
+
fontWeight: '600',
|
|
202
|
+
color: COLORS.NEUTRAL_1,
|
|
203
|
+
textAlign: 'center',
|
|
204
|
+
},
|
|
205
|
+
cards: {
|
|
206
|
+
flex: 1,
|
|
207
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
208
|
+
padding: SPACING[200],
|
|
209
|
+
borderRadius: BORDER_RADIUS[400],
|
|
210
|
+
overflow: 'visible',
|
|
211
|
+
},
|
|
212
|
+
scroll: {
|
|
213
|
+
flex: 1,
|
|
214
|
+
},
|
|
215
|
+
list: {
|
|
216
|
+
marginRight: SPACING[400],
|
|
217
|
+
},
|
|
218
|
+
separator: {
|
|
219
|
+
height: 1,
|
|
220
|
+
backgroundColor: COLORS.NEUTRAL_4,
|
|
221
|
+
marginHorizontal: SPACING[100],
|
|
222
|
+
marginVertical: SPACING[200],
|
|
223
|
+
},
|
|
224
|
+
metrics: {
|
|
225
|
+
height: '100%',
|
|
226
|
+
},
|
|
227
|
+
chart: {
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
justifyContent: 'center',
|
|
230
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
231
|
+
borderRadius: BORDER_RADIUS[250],
|
|
232
|
+
width: CHART_SIZE,
|
|
233
|
+
height: CHART_SIZE,
|
|
234
|
+
marginBottom: SPACING[400],
|
|
235
|
+
marginTop: SPACING[400],
|
|
236
|
+
},
|
|
237
|
+
stats: {
|
|
238
|
+
maxHeight: STATS_MAX_HEIGHT,
|
|
239
|
+
height: '100%',
|
|
240
|
+
padding: SPACING[200],
|
|
241
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
242
|
+
borderRadius: BORDER_RADIUS[300],
|
|
243
|
+
shadowColor: COLORS.NEUTRAL_9,
|
|
244
|
+
shadowOffset: { width: 0, height: 1 },
|
|
245
|
+
shadowOpacity: 0.1,
|
|
246
|
+
shadowRadius: 3,
|
|
247
|
+
elevation: 2,
|
|
248
|
+
},
|
|
249
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getSliceClipId = (index: number | string) => `slice-clip-${index}`
|
|
2
|
+
export const getFillClipId = (index: number | string) => `fill-clip-${index}`
|
|
3
|
+
|
|
4
|
+
export const dynamicInnerRadius = (sliceCount: number): number => {
|
|
5
|
+
if (sliceCount > 5) return 16
|
|
6
|
+
if (sliceCount > 3) return 20
|
|
7
|
+
return 30
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const dynamicCornerRadius = (fillPercent: number): number => {
|
|
11
|
+
return 8
|
|
12
|
+
if (fillPercent >= 75) return 8
|
|
13
|
+
if (fillPercent >= 40) return 5
|
|
14
|
+
return 2
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type SliceInputData = {
|
|
2
|
+
value: number
|
|
3
|
+
fillPercent?: number
|
|
4
|
+
backgroundColor?: string
|
|
5
|
+
fillColor: string
|
|
6
|
+
borderColor: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type SliceShape = {
|
|
10
|
+
index: number
|
|
11
|
+
startAngle: number
|
|
12
|
+
endAngle: number
|
|
13
|
+
fillPercent: number
|
|
14
|
+
backgroundColor: string
|
|
15
|
+
fillColor: string
|
|
16
|
+
borderColor: string
|
|
17
|
+
data: SliceInputData
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type PieChartManagerConfig = {
|
|
21
|
+
size: number
|
|
22
|
+
outerRadius: number
|
|
23
|
+
innerRadius: number | ((sliceCount: number) => number)
|
|
24
|
+
cornerRadius: number | ((fillPercent: number) => number)
|
|
25
|
+
gapBetweenSlices: number
|
|
26
|
+
borderWidth: number
|
|
27
|
+
pressOffset: number
|
|
28
|
+
outerArc: {
|
|
29
|
+
color: string
|
|
30
|
+
strokeWidth: number
|
|
31
|
+
dashWidth: number
|
|
32
|
+
}
|
|
33
|
+
colors: {
|
|
34
|
+
background: string
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { memo, useMemo, useState } from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import Svg, { G } from 'react-native-svg'
|
|
4
|
+
import { PieChartManager } from '../model/PieChartManager'
|
|
5
|
+
import { SlicesClipPaths } from './SlicesClipPaths'
|
|
6
|
+
import { SlicesPaths } from './SlicesPaths'
|
|
7
|
+
import type { PieChartManagerConfig, SliceInputData } from '../chart.types'
|
|
8
|
+
|
|
9
|
+
type PracticeProgressPieChartProps = {
|
|
10
|
+
data: SliceInputData[]
|
|
11
|
+
config: PieChartManagerConfig
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PracticeProgressPieChart = memo(({ data, config }: PracticeProgressPieChartProps) => {
|
|
15
|
+
const [pieChartManager] = useState(() => new PieChartManager(config))
|
|
16
|
+
const center = pieChartManager.getCenter()
|
|
17
|
+
|
|
18
|
+
const slices = useMemo(() => {
|
|
19
|
+
return pieChartManager.shape.generateSlices(data)
|
|
20
|
+
}, [data])
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View>
|
|
24
|
+
<Svg width={config.size} height={config.size}>
|
|
25
|
+
<G x={center.x} y={center.y}>
|
|
26
|
+
<SlicesClipPaths slices={slices} pieChartManager={pieChartManager} />
|
|
27
|
+
<SlicesPaths slices={slices} pieChartManager={pieChartManager} config={config} />
|
|
28
|
+
</G>
|
|
29
|
+
</Svg>
|
|
30
|
+
</View>
|
|
31
|
+
)
|
|
32
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ClipPath, Defs, Path } from 'react-native-svg'
|
|
3
|
+
import { getSliceClipId, getFillClipId } from '../chart.helpers'
|
|
4
|
+
import type { SliceShape } from '../chart.types'
|
|
5
|
+
import type { PieChartManager } from '../model/PieChartManager'
|
|
6
|
+
|
|
7
|
+
type SlicesClipPathsProps = {
|
|
8
|
+
slices: SliceShape[]
|
|
9
|
+
pieChartManager: PieChartManager
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const SlicesClipPaths = ({ slices, pieChartManager }: SlicesClipPathsProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<Defs>
|
|
15
|
+
{slices.map((slice) => {
|
|
16
|
+
const isPartiallyFilled = slice.fillPercent > 0 && slice.fillPercent < 100
|
|
17
|
+
const shapeId = getSliceClipId(slice.index)
|
|
18
|
+
const fillId = getFillClipId(slice.index)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<React.Fragment key={slice.index}>
|
|
22
|
+
<ClipPath id={shapeId}>
|
|
23
|
+
<Path d={pieChartManager.shape.generateSlicePath(slice)} />
|
|
24
|
+
</ClipPath>
|
|
25
|
+
|
|
26
|
+
{isPartiallyFilled && (
|
|
27
|
+
<ClipPath id={fillId}>
|
|
28
|
+
<Path d={pieChartManager.shape.generateFillPath(slice)} />
|
|
29
|
+
</ClipPath>
|
|
30
|
+
)}
|
|
31
|
+
</React.Fragment>
|
|
32
|
+
)
|
|
33
|
+
})}
|
|
34
|
+
</Defs>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native'
|
|
3
|
+
import { G } from 'react-native-svg'
|
|
4
|
+
import { useUnit } from 'effector-react'
|
|
5
|
+
import { SliceBackgroundColor } from './layers/SliceBackgroundColor'
|
|
6
|
+
import { SliceFillColor } from './layers/SliceFillColor'
|
|
7
|
+
import { SliceArcPattern } from './layers/SliceArcPattern'
|
|
8
|
+
import type { PieChartManagerConfig, SliceShape } from '../chart.types'
|
|
9
|
+
import type { PieChartManager } from '../model/PieChartManager'
|
|
10
|
+
|
|
11
|
+
type SlicesPathsProps = {
|
|
12
|
+
slices: SliceShape[]
|
|
13
|
+
pieChartManager: PieChartManager
|
|
14
|
+
config: PieChartManagerConfig
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const SlicesPaths = ({ slices, pieChartManager, config }: SlicesPathsProps) => {
|
|
18
|
+
const highlightedIndex = useUnit(pieChartManager.highlight.$highlightedIndex)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
{slices.map((slice) => {
|
|
23
|
+
const id = `${slice.index}`
|
|
24
|
+
const shapeSvg = pieChartManager.shape.generateSlicePath(slice)
|
|
25
|
+
const fillSvg = pieChartManager.shape.generateFillPath(slice)
|
|
26
|
+
const isHighlighted = highlightedIndex === slice.index
|
|
27
|
+
const translateY = pieChartManager.highlight.getTranslateY(isHighlighted)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<G
|
|
31
|
+
key={id}
|
|
32
|
+
style={styles.container}
|
|
33
|
+
translateY={translateY}
|
|
34
|
+
onPressIn={() => pieChartManager.highlight.highlightSlice(slice.index)}
|
|
35
|
+
onPressOut={() => pieChartManager.highlight.resetHighlight()}
|
|
36
|
+
>
|
|
37
|
+
<SliceBackgroundColor path={shapeSvg} color={slice.backgroundColor} />
|
|
38
|
+
|
|
39
|
+
<SliceFillColor
|
|
40
|
+
clipPathId={id}
|
|
41
|
+
shapeSvg={shapeSvg}
|
|
42
|
+
fillSvg={fillSvg}
|
|
43
|
+
color={slice.fillColor}
|
|
44
|
+
percent={slice.fillPercent}
|
|
45
|
+
borderColor={isHighlighted ? slice.borderColor : undefined}
|
|
46
|
+
borderWidth={isHighlighted ? config.borderWidth : undefined}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<SliceArcPattern
|
|
50
|
+
clipPathId={id}
|
|
51
|
+
slice={slice}
|
|
52
|
+
config={config}
|
|
53
|
+
pieChartManager={pieChartManager}
|
|
54
|
+
/>
|
|
55
|
+
</G>
|
|
56
|
+
)
|
|
57
|
+
})}
|
|
58
|
+
</>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const styles = StyleSheet.create({
|
|
63
|
+
container: {
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
...(Platform.OS === 'web' ? { transition: 'transform 0.1s ease-in-out' } : {}),
|
|
66
|
+
},
|
|
67
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { G, Path } from 'react-native-svg'
|
|
3
|
+
import { getSliceClipId } from '../../chart.helpers'
|
|
4
|
+
import type { PieChartManagerConfig, SliceShape } from '../../chart.types'
|
|
5
|
+
import type { PieChartManager } from '../../model/PieChartManager'
|
|
6
|
+
|
|
7
|
+
type SliceArcPatternProps = {
|
|
8
|
+
clipPathId: string
|
|
9
|
+
slice: SliceShape
|
|
10
|
+
pieChartManager: PieChartManager
|
|
11
|
+
config: PieChartManagerConfig
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const SliceArcPattern = ({
|
|
15
|
+
clipPathId,
|
|
16
|
+
slice,
|
|
17
|
+
pieChartManager,
|
|
18
|
+
config,
|
|
19
|
+
}: SliceArcPatternProps) => {
|
|
20
|
+
const patternSizes = pieChartManager.pattern.getPatternTrackSizes()
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<G clipPath={`url(#${getSliceClipId(clipPathId)})`}>
|
|
24
|
+
{patternSizes.map((radius, rowIndex) => {
|
|
25
|
+
const arcPath = pieChartManager.pattern.generateArcPath(slice, radius)
|
|
26
|
+
const dashWidth = pieChartManager.pattern.getDashWidthForRadius(radius)
|
|
27
|
+
const dashOffset = pieChartManager.pattern.getDashOffset(rowIndex, radius)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Path
|
|
31
|
+
key={rowIndex}
|
|
32
|
+
d={arcPath}
|
|
33
|
+
fill="none"
|
|
34
|
+
stroke={config.outerArc.color}
|
|
35
|
+
strokeWidth={config.outerArc.strokeWidth}
|
|
36
|
+
strokeDasharray={[dashWidth, dashWidth]}
|
|
37
|
+
strokeDashoffset={dashOffset}
|
|
38
|
+
strokeLinecap="butt"
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
})}
|
|
42
|
+
</G>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Path } from 'react-native-svg'
|
|
3
|
+
|
|
4
|
+
type BackgroundLayerProps = {
|
|
5
|
+
path: string
|
|
6
|
+
color: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SliceBackgroundColor = ({ path, color }: BackgroundLayerProps) => {
|
|
10
|
+
return <Path d={path} fill={color} />
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { G, Path } from 'react-native-svg'
|
|
3
|
+
import { getSliceClipId, getFillClipId } from '../../chart.helpers'
|
|
4
|
+
|
|
5
|
+
type SliceFillColorProps = {
|
|
6
|
+
clipPathId: string
|
|
7
|
+
shapeSvg: string
|
|
8
|
+
fillSvg: string
|
|
9
|
+
color: string
|
|
10
|
+
percent: number
|
|
11
|
+
borderColor?: string
|
|
12
|
+
borderWidth?: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const SliceFillColor = ({
|
|
16
|
+
clipPathId,
|
|
17
|
+
shapeSvg,
|
|
18
|
+
fillSvg,
|
|
19
|
+
color,
|
|
20
|
+
percent,
|
|
21
|
+
borderColor,
|
|
22
|
+
borderWidth,
|
|
23
|
+
}: SliceFillColorProps) => {
|
|
24
|
+
const isFullyFilled = percent >= 100
|
|
25
|
+
const isPartiallyFilled = percent > 0
|
|
26
|
+
const hasBorder = borderColor != null && borderWidth != null && borderWidth > 0
|
|
27
|
+
|
|
28
|
+
if (isFullyFilled) {
|
|
29
|
+
return (
|
|
30
|
+
<G clipPath={`url(#${getSliceClipId(clipPathId)})`}>
|
|
31
|
+
<Path
|
|
32
|
+
d={shapeSvg}
|
|
33
|
+
fill={color}
|
|
34
|
+
stroke={hasBorder ? borderColor : undefined}
|
|
35
|
+
strokeWidth={hasBorder ? borderWidth * 2 : undefined}
|
|
36
|
+
/>
|
|
37
|
+
</G>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isPartiallyFilled) {
|
|
42
|
+
return (
|
|
43
|
+
<G clipPath={`url(#${getFillClipId(clipPathId)})`}>
|
|
44
|
+
<Path
|
|
45
|
+
d={fillSvg}
|
|
46
|
+
fill={color}
|
|
47
|
+
stroke={hasBorder ? borderColor : undefined}
|
|
48
|
+
strokeWidth={hasBorder ? borderWidth * 2 : undefined}
|
|
49
|
+
/>
|
|
50
|
+
</G>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PieChartManagerConfig, SliceShape } from '../chart.types'
|
|
2
|
+
|
|
3
|
+
export class OuterArcPatternGenerator {
|
|
4
|
+
constructor(private readonly config: PieChartManagerConfig) {}
|
|
5
|
+
|
|
6
|
+
public generateArcPath(slice: SliceShape, radius: number) {
|
|
7
|
+
const gapAngle = this.config.gapBetweenSlices / (2 * radius)
|
|
8
|
+
const startAngle = slice.startAngle + gapAngle
|
|
9
|
+
const endAngle = slice.endAngle - gapAngle
|
|
10
|
+
|
|
11
|
+
const startPoint = this.polarToCartesian(radius, startAngle)
|
|
12
|
+
const endPoint = this.polarToCartesian(radius, endAngle)
|
|
13
|
+
const largeArcFlag = endAngle - startAngle > Math.PI ? 1 : 0
|
|
14
|
+
|
|
15
|
+
return `M ${startPoint.x} ${startPoint.y} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endPoint.x} ${endPoint.y}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Returns the sizes of the two rings where the checkerboard dashes are drawn. */
|
|
19
|
+
public getPatternTrackSizes(): [number, number] {
|
|
20
|
+
const { outerRadius, outerArc } = this.config
|
|
21
|
+
return [
|
|
22
|
+
outerRadius - outerArc.strokeWidth / 2,
|
|
23
|
+
outerRadius - outerArc.strokeWidth * 1.5,
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public getDashWidthForRadius(radius: number) {
|
|
28
|
+
return this.config.outerArc.dashWidth * (radius / this.config.outerRadius)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public getDashOffset(rowIndex: number, radius: number) {
|
|
32
|
+
const dashAngle = this.config.outerArc.dashWidth / this.config.outerRadius
|
|
33
|
+
const dashWidthAtRadius = dashAngle * radius
|
|
34
|
+
const baseOffset = dashWidthAtRadius / 2
|
|
35
|
+
|
|
36
|
+
if (rowIndex === 1) {
|
|
37
|
+
return baseOffset - dashWidthAtRadius
|
|
38
|
+
}
|
|
39
|
+
return baseOffset
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private polarToCartesian(radius: number, angleInRadians: number) {
|
|
43
|
+
return {
|
|
44
|
+
x: radius * Math.sin(angleInRadians),
|
|
45
|
+
y: -radius * Math.cos(angleInRadians),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SliceShapeGenerator } from './SliceShapeGenerator'
|
|
2
|
+
import { OuterArcPatternGenerator } from './ArcPatternGenerator'
|
|
3
|
+
import { SliceHighlight } from './SliceHighlight'
|
|
4
|
+
import type { PieChartManagerConfig } from '../chart.types'
|
|
5
|
+
|
|
6
|
+
export class PieChartManager {
|
|
7
|
+
public readonly shape: SliceShapeGenerator
|
|
8
|
+
public readonly pattern: OuterArcPatternGenerator
|
|
9
|
+
public readonly highlight: SliceHighlight
|
|
10
|
+
|
|
11
|
+
constructor(public readonly config: PieChartManagerConfig) {
|
|
12
|
+
this.shape = new SliceShapeGenerator(config)
|
|
13
|
+
this.pattern = new OuterArcPatternGenerator(config)
|
|
14
|
+
this.highlight = new SliceHighlight(config)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public getCenter() {
|
|
18
|
+
return { x: this.config.size / 2, y: this.config.size / 2 }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createEvent, createStore } from 'effector'
|
|
2
|
+
import type { PieChartManagerConfig } from '../chart.types'
|
|
3
|
+
|
|
4
|
+
export class SliceHighlight {
|
|
5
|
+
public readonly highlightSlice = createEvent<number>()
|
|
6
|
+
public readonly resetHighlight = createEvent()
|
|
7
|
+
|
|
8
|
+
public readonly $highlightedIndex = createStore<number | null>(null)
|
|
9
|
+
.on(this.highlightSlice, (_, index) => index)
|
|
10
|
+
.reset(this.resetHighlight)
|
|
11
|
+
|
|
12
|
+
constructor(private readonly config: PieChartManagerConfig) {}
|
|
13
|
+
|
|
14
|
+
public getTranslateY(isHighlighted: boolean): number {
|
|
15
|
+
return isHighlighted ? -this.config.pressOffset : 0
|
|
16
|
+
}
|
|
17
|
+
}
|