@wasto/cms-components 1.5.10 → 1.5.12
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/README.md +47 -47
- package/dist/index.d.mts +181 -51
- package/dist/index.d.ts +181 -51
- package/dist/index.js +3614 -3015
- package/dist/index.mjs +3021 -2418
- package/package.json +12 -2
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
- package/src/components/article/Article.tsx +21 -21
- package/src/components/article/ArticleCard.tsx +81 -81
- package/src/components/article/ArticleExcerpts.tsx +80 -80
- package/src/components/article/ArticleList.tsx +114 -114
- package/src/components/article/ArticleMarkdown.tsx +170 -170
- package/src/components/article/ArticleReaderModal.tsx +93 -93
- package/src/components/article/ArticleSingle.tsx +57 -57
- package/src/components/bottom-tab/BottomTab.tsx +392 -392
- package/src/components/button/Button.tsx +154 -154
- package/src/components/challenge/Badges.tsx +84 -84
- package/src/components/challenge/BadgesModal.tsx +166 -166
- package/src/components/challenge/Challenge.tsx +380 -380
- package/src/components/challenge/ChallengeModal.tsx +231 -231
- package/src/components/challenge/ChallengeVignette.tsx +249 -249
- package/src/components/challenge/ChallengesModal.tsx +243 -243
- package/src/components/challenge/QuizModal.tsx +381 -381
- package/src/components/challenge/ResultModal.tsx +144 -144
- package/src/components/chat/Chat.tsx +928 -928
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
- package/src/components/columns/Columns.tsx +33 -33
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
- package/src/components/content-inset/ContentInset.tsx +33 -33
- package/src/components/header/Header.tsx +415 -391
- package/src/components/image/Image.tsx +15 -15
- package/src/components/image/ImageFrame.tsx +102 -102
- package/src/components/image/ImageMedia.tsx +31 -31
- package/src/components/image/ImageUrl.tsx +30 -30
- package/src/components/locations-map/LocationSheet.tsx +417 -417
- package/src/components/locations-map/LocationsMap.native.tsx +260 -260
- package/src/components/locations-map/LocationsMap.tsx +13 -13
- package/src/components/locations-map/LocationsMap.web.tsx +10 -10
- package/src/components/locations-map/LocationsMapShell.tsx +546 -527
- package/src/components/locations-map/LocationsMapView.tsx +108 -108
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
- package/src/components/nav-button/NavButton.tsx +59 -59
- package/src/components/next-collection/NextCollection.tsx +636 -621
- package/src/components/notifications/NotificationsScreen.tsx +247 -247
- package/src/components/page/Page.tsx +102 -64
- package/src/components/parapraph/Paragraph.tsx +67 -67
- package/src/components/profile/ProfileScreen.tsx +236 -236
- package/src/components/push/PushTokenRegistrar.tsx +47 -0
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
- package/src/components/search/Search.tsx +320 -320
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
- package/src/components/title/Title.tsx +100 -100
- package/src/components/vision/Vision.tsx +447 -447
- package/src/components/vision/VisionActionCard.tsx +117 -117
- package/src/components/vision/VisionCapture.tsx +30 -30
- package/src/components/vision/VisionTapOverlay.tsx +122 -122
- package/src/contexts/AnnouncementsContext.tsx +171 -171
- package/src/contexts/AppDataContext.tsx +458 -0
- package/src/contexts/ChallengesContext.tsx +182 -182
- package/src/contexts/HeaderConfigContext.tsx +29 -0
- package/src/contexts/LocalContext.tsx +227 -227
- package/src/contexts/ThemeContext.tsx +37 -37
- package/src/contexts/WastoContext.tsx +132 -127
- package/src/helpers/blogPost.ts +72 -72
- package/src/helpers/generateQuizQuestions.ts +247 -247
- package/src/helpers/getContrastColor.ts +18 -18
- package/src/helpers/haptics.ts +20 -20
- package/src/helpers/hoursSchedule.ts +230 -230
- package/src/helpers/htmlContentToMarkdown.ts +114 -114
- package/src/helpers/layout.ts +54 -54
- package/src/helpers/loadLinearGradient.ts +22 -22
- package/src/helpers/mapLocations.ts +170 -0
- package/src/helpers/maquetteTheme.ts +76 -76
- package/src/helpers/markdownUnderlinePlugin.ts +32 -32
- package/src/helpers/nextCollection.ts +122 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
- package/src/helpers/publicMediaUrl.ts +8 -8
- package/src/helpers/resolveApiAssetUrl.ts +21 -21
- package/src/helpers/systemRoutes.ts +7 -7
- package/src/helpers/themeStyles.ts +114 -114
- package/src/helpers/ttlCache.ts +41 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -14
- package/src/hooks/useBadges.ts +100 -100
- package/src/hooks/useBlogPosts.ts +109 -105
- package/src/hooks/useChallenges.ts +110 -110
- package/src/hooks/useCities.ts +56 -56
- package/src/hooks/useCityAnnouncements.ts +118 -118
- package/src/hooks/useCollectionCalendar.ts +421 -421
- package/src/hooks/useColumns.ts +19 -19
- package/src/hooks/useConsignes.ts +62 -62
- package/src/hooks/useLocations.ts +120 -248
- package/src/hooks/useNextCollection.ts +163 -238
- package/src/hooks/useRecyclingInfo.ts +90 -90
- package/src/hooks/useWastoClient.ts +16 -16
- package/src/index.ts +161 -142
- package/src/navigation/NavigationContext.tsx +56 -56
- package/src/push/registerExpoPushToken.ts +133 -0
- package/src/sentry/initSentry.ts +120 -120
- package/src/types/Theme.ts +72 -72
- package/src/types/css-modules.d.ts +1 -1
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { Modal, StyleSheet, Text, View } from "react-native";
|
|
3
|
-
import { Star } from "lucide-react-native";
|
|
4
|
-
import { useTheme } from "../../contexts/ThemeContext";
|
|
5
|
-
import { Theme } from "../../types/Theme";
|
|
6
|
-
import { Title } from "../title/Title";
|
|
7
|
-
import { Button } from "../button/Button";
|
|
8
|
-
import { quizResultMessage, quizStarCount } from "../../helpers/generateQuizQuestions";
|
|
9
|
-
|
|
10
|
-
export type ResultModalProps = {
|
|
11
|
-
visible: boolean;
|
|
12
|
-
correct: number;
|
|
13
|
-
incorrect: number;
|
|
14
|
-
total: number;
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function ResultModal({
|
|
19
|
-
visible,
|
|
20
|
-
correct,
|
|
21
|
-
incorrect,
|
|
22
|
-
total,
|
|
23
|
-
onClose,
|
|
24
|
-
}: ResultModalProps): ReactNode {
|
|
25
|
-
const { theme } = useTheme();
|
|
26
|
-
const themedStyles = createThemedStyles(theme);
|
|
27
|
-
const stars = quizStarCount(correct, total);
|
|
28
|
-
const percentage = total > 0 ? Math.round((correct / total) * 100) : 0;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Modal visible={visible} animationType="fade" transparent onRequestClose={onClose}>
|
|
32
|
-
<View style={styles.overlay}>
|
|
33
|
-
<View style={[styles.card, themedStyles.card]}>
|
|
34
|
-
<Title text="Ton score" level="2" />
|
|
35
|
-
<Text style={[styles.percentage, themedStyles.percentage]}>{percentage}%</Text>
|
|
36
|
-
|
|
37
|
-
<View style={styles.scores}>
|
|
38
|
-
<View style={styles.scoreItem}>
|
|
39
|
-
<Text style={[styles.scoreMark, { color: theme.colors.success }]}>✓</Text>
|
|
40
|
-
<Text style={[styles.scoreNumber, themedStyles.text]}>{correct}</Text>
|
|
41
|
-
</View>
|
|
42
|
-
<View style={styles.scoreItem}>
|
|
43
|
-
<Text style={[styles.scoreMark, { color: theme.colors.error }]}>×</Text>
|
|
44
|
-
<Text style={[styles.scoreNumber, themedStyles.text]}>{incorrect}</Text>
|
|
45
|
-
</View>
|
|
46
|
-
</View>
|
|
47
|
-
|
|
48
|
-
<View style={[styles.feedback, themedStyles.feedback]}>
|
|
49
|
-
<Text style={styles.emoji}>
|
|
50
|
-
{percentage >= 80 ? "🎉" : percentage >= 50 ? "😊" : "🐸"}
|
|
51
|
-
</Text>
|
|
52
|
-
<Text style={[styles.feedbackText, themedStyles.text]}>
|
|
53
|
-
{quizResultMessage(correct, total)}
|
|
54
|
-
</Text>
|
|
55
|
-
</View>
|
|
56
|
-
|
|
57
|
-
<View style={styles.stars}>
|
|
58
|
-
{[1, 2, 3, 4, 5].map((star) => (
|
|
59
|
-
<Star
|
|
60
|
-
key={star}
|
|
61
|
-
size={28}
|
|
62
|
-
fill={star <= stars ? theme.colors.primary : "none"}
|
|
63
|
-
color={star <= stars ? theme.colors.primary : theme.colors.border}
|
|
64
|
-
strokeWidth={star <= stars ? 0 : 2}
|
|
65
|
-
/>
|
|
66
|
-
))}
|
|
67
|
-
</View>
|
|
68
|
-
|
|
69
|
-
<Button onPress={onClose}>Terminer</Button>
|
|
70
|
-
</View>
|
|
71
|
-
</View>
|
|
72
|
-
</Modal>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const createThemedStyles = (theme: Theme) =>
|
|
77
|
-
StyleSheet.create({
|
|
78
|
-
card: {
|
|
79
|
-
backgroundColor: theme.colors.surface,
|
|
80
|
-
borderRadius: Math.max(theme.radius, 20),
|
|
81
|
-
},
|
|
82
|
-
percentage: {
|
|
83
|
-
color: theme.colors.primary,
|
|
84
|
-
},
|
|
85
|
-
text: {
|
|
86
|
-
color: theme.colors.onSurface,
|
|
87
|
-
},
|
|
88
|
-
feedback: {
|
|
89
|
-
backgroundColor: `${theme.colors.border}66`,
|
|
90
|
-
borderRadius: theme.radius,
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const styles = StyleSheet.create({
|
|
95
|
-
overlay: {
|
|
96
|
-
flex: 1,
|
|
97
|
-
backgroundColor: "rgba(15, 23, 42, 0.45)",
|
|
98
|
-
justifyContent: "center",
|
|
99
|
-
padding: 24,
|
|
100
|
-
},
|
|
101
|
-
card: {
|
|
102
|
-
padding: 24,
|
|
103
|
-
gap: 16,
|
|
104
|
-
alignItems: "center",
|
|
105
|
-
},
|
|
106
|
-
percentage: {
|
|
107
|
-
fontSize: 42,
|
|
108
|
-
fontWeight: "700",
|
|
109
|
-
},
|
|
110
|
-
scores: {
|
|
111
|
-
flexDirection: "row",
|
|
112
|
-
gap: 32,
|
|
113
|
-
},
|
|
114
|
-
scoreItem: {
|
|
115
|
-
alignItems: "center",
|
|
116
|
-
gap: 4,
|
|
117
|
-
},
|
|
118
|
-
scoreMark: {
|
|
119
|
-
fontSize: 22,
|
|
120
|
-
fontWeight: "700",
|
|
121
|
-
},
|
|
122
|
-
scoreNumber: {
|
|
123
|
-
fontSize: 22,
|
|
124
|
-
fontWeight: "700",
|
|
125
|
-
},
|
|
126
|
-
feedback: {
|
|
127
|
-
width: "100%",
|
|
128
|
-
padding: 16,
|
|
129
|
-
alignItems: "center",
|
|
130
|
-
gap: 8,
|
|
131
|
-
},
|
|
132
|
-
emoji: {
|
|
133
|
-
fontSize: 32,
|
|
134
|
-
},
|
|
135
|
-
feedbackText: {
|
|
136
|
-
textAlign: "center",
|
|
137
|
-
fontSize: 16,
|
|
138
|
-
lineHeight: 22,
|
|
139
|
-
},
|
|
140
|
-
stars: {
|
|
141
|
-
flexDirection: "row",
|
|
142
|
-
gap: 6,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Modal, StyleSheet, Text, View } from "react-native";
|
|
3
|
+
import { Star } from "lucide-react-native";
|
|
4
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
5
|
+
import { Theme } from "../../types/Theme";
|
|
6
|
+
import { Title } from "../title/Title";
|
|
7
|
+
import { Button } from "../button/Button";
|
|
8
|
+
import { quizResultMessage, quizStarCount } from "../../helpers/generateQuizQuestions";
|
|
9
|
+
|
|
10
|
+
export type ResultModalProps = {
|
|
11
|
+
visible: boolean;
|
|
12
|
+
correct: number;
|
|
13
|
+
incorrect: number;
|
|
14
|
+
total: number;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function ResultModal({
|
|
19
|
+
visible,
|
|
20
|
+
correct,
|
|
21
|
+
incorrect,
|
|
22
|
+
total,
|
|
23
|
+
onClose,
|
|
24
|
+
}: ResultModalProps): ReactNode {
|
|
25
|
+
const { theme } = useTheme();
|
|
26
|
+
const themedStyles = createThemedStyles(theme);
|
|
27
|
+
const stars = quizStarCount(correct, total);
|
|
28
|
+
const percentage = total > 0 ? Math.round((correct / total) * 100) : 0;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Modal visible={visible} animationType="fade" transparent onRequestClose={onClose}>
|
|
32
|
+
<View style={styles.overlay}>
|
|
33
|
+
<View style={[styles.card, themedStyles.card]}>
|
|
34
|
+
<Title text="Ton score" level="2" />
|
|
35
|
+
<Text style={[styles.percentage, themedStyles.percentage]}>{percentage}%</Text>
|
|
36
|
+
|
|
37
|
+
<View style={styles.scores}>
|
|
38
|
+
<View style={styles.scoreItem}>
|
|
39
|
+
<Text style={[styles.scoreMark, { color: theme.colors.success }]}>✓</Text>
|
|
40
|
+
<Text style={[styles.scoreNumber, themedStyles.text]}>{correct}</Text>
|
|
41
|
+
</View>
|
|
42
|
+
<View style={styles.scoreItem}>
|
|
43
|
+
<Text style={[styles.scoreMark, { color: theme.colors.error }]}>×</Text>
|
|
44
|
+
<Text style={[styles.scoreNumber, themedStyles.text]}>{incorrect}</Text>
|
|
45
|
+
</View>
|
|
46
|
+
</View>
|
|
47
|
+
|
|
48
|
+
<View style={[styles.feedback, themedStyles.feedback]}>
|
|
49
|
+
<Text style={styles.emoji}>
|
|
50
|
+
{percentage >= 80 ? "🎉" : percentage >= 50 ? "😊" : "🐸"}
|
|
51
|
+
</Text>
|
|
52
|
+
<Text style={[styles.feedbackText, themedStyles.text]}>
|
|
53
|
+
{quizResultMessage(correct, total)}
|
|
54
|
+
</Text>
|
|
55
|
+
</View>
|
|
56
|
+
|
|
57
|
+
<View style={styles.stars}>
|
|
58
|
+
{[1, 2, 3, 4, 5].map((star) => (
|
|
59
|
+
<Star
|
|
60
|
+
key={star}
|
|
61
|
+
size={28}
|
|
62
|
+
fill={star <= stars ? theme.colors.primary : "none"}
|
|
63
|
+
color={star <= stars ? theme.colors.primary : theme.colors.border}
|
|
64
|
+
strokeWidth={star <= stars ? 0 : 2}
|
|
65
|
+
/>
|
|
66
|
+
))}
|
|
67
|
+
</View>
|
|
68
|
+
|
|
69
|
+
<Button onPress={onClose}>Terminer</Button>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
</Modal>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const createThemedStyles = (theme: Theme) =>
|
|
77
|
+
StyleSheet.create({
|
|
78
|
+
card: {
|
|
79
|
+
backgroundColor: theme.colors.surface,
|
|
80
|
+
borderRadius: Math.max(theme.radius, 20),
|
|
81
|
+
},
|
|
82
|
+
percentage: {
|
|
83
|
+
color: theme.colors.primary,
|
|
84
|
+
},
|
|
85
|
+
text: {
|
|
86
|
+
color: theme.colors.onSurface,
|
|
87
|
+
},
|
|
88
|
+
feedback: {
|
|
89
|
+
backgroundColor: `${theme.colors.border}66`,
|
|
90
|
+
borderRadius: theme.radius,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const styles = StyleSheet.create({
|
|
95
|
+
overlay: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
backgroundColor: "rgba(15, 23, 42, 0.45)",
|
|
98
|
+
justifyContent: "center",
|
|
99
|
+
padding: 24,
|
|
100
|
+
},
|
|
101
|
+
card: {
|
|
102
|
+
padding: 24,
|
|
103
|
+
gap: 16,
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
},
|
|
106
|
+
percentage: {
|
|
107
|
+
fontSize: 42,
|
|
108
|
+
fontWeight: "700",
|
|
109
|
+
},
|
|
110
|
+
scores: {
|
|
111
|
+
flexDirection: "row",
|
|
112
|
+
gap: 32,
|
|
113
|
+
},
|
|
114
|
+
scoreItem: {
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
gap: 4,
|
|
117
|
+
},
|
|
118
|
+
scoreMark: {
|
|
119
|
+
fontSize: 22,
|
|
120
|
+
fontWeight: "700",
|
|
121
|
+
},
|
|
122
|
+
scoreNumber: {
|
|
123
|
+
fontSize: 22,
|
|
124
|
+
fontWeight: "700",
|
|
125
|
+
},
|
|
126
|
+
feedback: {
|
|
127
|
+
width: "100%",
|
|
128
|
+
padding: 16,
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
gap: 8,
|
|
131
|
+
},
|
|
132
|
+
emoji: {
|
|
133
|
+
fontSize: 32,
|
|
134
|
+
},
|
|
135
|
+
feedbackText: {
|
|
136
|
+
textAlign: "center",
|
|
137
|
+
fontSize: 16,
|
|
138
|
+
lineHeight: 22,
|
|
139
|
+
},
|
|
140
|
+
stars: {
|
|
141
|
+
flexDirection: "row",
|
|
142
|
+
gap: 6,
|
|
143
|
+
},
|
|
144
|
+
});
|