@wasto/cms-components 1.5.10

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 (94) hide show
  1. package/README.md +47 -0
  2. package/dist/index.d.mts +465 -0
  3. package/dist/index.d.ts +465 -0
  4. package/dist/index.js +10445 -0
  5. package/dist/index.mjs +10553 -0
  6. package/package.json +90 -0
  7. package/src/components/announcement-modal/AnnouncementModal.tsx +183 -0
  8. package/src/components/article/Article.tsx +22 -0
  9. package/src/components/article/ArticleCard.tsx +81 -0
  10. package/src/components/article/ArticleExcerpts.tsx +80 -0
  11. package/src/components/article/ArticleList.tsx +114 -0
  12. package/src/components/article/ArticleMarkdown.tsx +170 -0
  13. package/src/components/article/ArticleReaderModal.tsx +93 -0
  14. package/src/components/article/ArticleSingle.tsx +57 -0
  15. package/src/components/bottom-tab/BottomTab.tsx +392 -0
  16. package/src/components/button/Button.tsx +154 -0
  17. package/src/components/challenge/Badges.tsx +84 -0
  18. package/src/components/challenge/BadgesModal.tsx +166 -0
  19. package/src/components/challenge/Challenge.tsx +380 -0
  20. package/src/components/challenge/ChallengeModal.tsx +231 -0
  21. package/src/components/challenge/ChallengeVignette.tsx +249 -0
  22. package/src/components/challenge/ChallengesModal.tsx +243 -0
  23. package/src/components/challenge/QuizModal.tsx +381 -0
  24. package/src/components/challenge/ResultModal.tsx +144 -0
  25. package/src/components/chat/Chat.tsx +928 -0
  26. package/src/components/collection-calendar/CollectionCalendar.tsx +274 -0
  27. package/src/components/columns/Columns.tsx +34 -0
  28. package/src/components/consignes-modal/ConsignesModal.tsx +267 -0
  29. package/src/components/content-inset/ContentInset.tsx +33 -0
  30. package/src/components/header/Header.tsx +391 -0
  31. package/src/components/image/Image.tsx +16 -0
  32. package/src/components/image/ImageFrame.tsx +102 -0
  33. package/src/components/image/ImageMedia.tsx +31 -0
  34. package/src/components/image/ImageUrl.tsx +30 -0
  35. package/src/components/locations-map/LocationSheet.tsx +417 -0
  36. package/src/components/locations-map/LocationsMap.native.tsx +260 -0
  37. package/src/components/locations-map/LocationsMap.tsx +13 -0
  38. package/src/components/locations-map/LocationsMap.web.tsx +10 -0
  39. package/src/components/locations-map/LocationsMapShell.tsx +527 -0
  40. package/src/components/locations-map/LocationsMapView.tsx +108 -0
  41. package/src/components/locations-map/LocationsMapView.web.tsx +331 -0
  42. package/src/components/nav-button/NavButton.tsx +59 -0
  43. package/src/components/next-collection/NextCollection.tsx +621 -0
  44. package/src/components/notifications/NotificationsScreen.tsx +247 -0
  45. package/src/components/page/Page.tsx +64 -0
  46. package/src/components/parapraph/Paragraph.tsx +67 -0
  47. package/src/components/profile/ProfileScreen.tsx +236 -0
  48. package/src/components/recycling-info/RecyclingInfo.tsx +189 -0
  49. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -0
  50. package/src/components/search/Search.tsx +320 -0
  51. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -0
  52. package/src/components/title/Title.tsx +100 -0
  53. package/src/components/vision/Vision.tsx +447 -0
  54. package/src/components/vision/VisionActionCard.tsx +117 -0
  55. package/src/components/vision/VisionCapture.tsx +30 -0
  56. package/src/components/vision/VisionTapOverlay.tsx +122 -0
  57. package/src/contexts/AnnouncementsContext.tsx +171 -0
  58. package/src/contexts/ChallengesContext.tsx +182 -0
  59. package/src/contexts/LocalContext.tsx +227 -0
  60. package/src/contexts/ThemeContext.tsx +37 -0
  61. package/src/contexts/WastoContext.tsx +127 -0
  62. package/src/helpers/blogPost.ts +72 -0
  63. package/src/helpers/generateQuizQuestions.ts +247 -0
  64. package/src/helpers/getContrastColor.ts +19 -0
  65. package/src/helpers/haptics.ts +20 -0
  66. package/src/helpers/hoursSchedule.ts +230 -0
  67. package/src/helpers/htmlContentToMarkdown.ts +114 -0
  68. package/src/helpers/layout.ts +54 -0
  69. package/src/helpers/loadLinearGradient.ts +22 -0
  70. package/src/helpers/maquetteTheme.ts +76 -0
  71. package/src/helpers/markdownUnderlinePlugin.ts +32 -0
  72. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -0
  73. package/src/helpers/publicMediaUrl.ts +8 -0
  74. package/src/helpers/resolveApiAssetUrl.ts +21 -0
  75. package/src/helpers/systemRoutes.ts +7 -0
  76. package/src/helpers/themeStyles.ts +114 -0
  77. package/src/helpers/useSafeAreaPadding.ts +14 -0
  78. package/src/hooks/useBadges.ts +100 -0
  79. package/src/hooks/useBlogPosts.ts +105 -0
  80. package/src/hooks/useChallenges.ts +110 -0
  81. package/src/hooks/useCities.ts +56 -0
  82. package/src/hooks/useCityAnnouncements.ts +118 -0
  83. package/src/hooks/useCollectionCalendar.ts +421 -0
  84. package/src/hooks/useColumns.ts +20 -0
  85. package/src/hooks/useConsignes.ts +62 -0
  86. package/src/hooks/useLocations.ts +248 -0
  87. package/src/hooks/useNextCollection.ts +238 -0
  88. package/src/hooks/useRecyclingInfo.ts +90 -0
  89. package/src/hooks/useWastoClient.ts +16 -0
  90. package/src/index.ts +142 -0
  91. package/src/navigation/NavigationContext.tsx +56 -0
  92. package/src/sentry/initSentry.ts +120 -0
  93. package/src/types/Theme.ts +72 -0
  94. package/src/types/css-modules.d.ts +1 -0
@@ -0,0 +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
+ });