react-achievements 2.2.2 → 3.0.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.
- package/README.md +377 -401
- package/dist/index.d.ts +222 -8
- package/dist/index.js +631 -0
- package/dist/index.js.map +1 -0
- package/dist/stories/Button.d.ts +28 -0
- package/dist/stories/Button.stories.d.ts +23 -0
- package/dist/stories/Header.d.ts +13 -0
- package/dist/stories/Header.stories.d.ts +18 -0
- package/dist/stories/Page.d.ts +3 -0
- package/dist/stories/Page.stories.d.ts +12 -0
- package/dist/types/__mocks__/confetti-wrapper.d.ts +5 -0
- package/dist/types/__mocks__/react-confetti.d.ts +3 -0
- package/dist/types/__mocks__/react-toastify.d.ts +13 -0
- package/dist/types/core/components/BadgesButton.d.ts +10 -0
- package/dist/types/core/components/BadgesModal.d.ts +11 -0
- package/dist/types/core/components/ConfettiWrapper.d.ts +6 -0
- package/dist/types/core/context/AchievementContext.d.ts +5 -0
- package/dist/types/core/icons/defaultIcons.d.ts +81 -0
- package/dist/types/core/storage/LocalStorage.d.ts +16 -0
- package/dist/types/core/storage/MemoryStorage.d.ts +11 -0
- package/dist/types/core/styles/defaultStyles.d.ts +2 -0
- package/dist/types/core/types.d.ts +74 -0
- package/dist/types/hooks/useAchievements.d.ts +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/providers/AchievementProvider.d.ts +24 -0
- package/dist/types/setupTests.d.ts +1 -0
- package/dist/types/stories/Button.d.ts +16 -0
- package/dist/types/stories/Button.stories.d.ts +23 -0
- package/dist/types/stories/Header.d.ts +13 -0
- package/dist/types/stories/Header.stories.d.ts +18 -0
- package/dist/types/stories/Page.d.ts +3 -0
- package/dist/types/stories/Page.stories.d.ts +12 -0
- package/package.json +73 -54
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/react-achievements.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/coverage/clover.xml +0 -131
- package/coverage/coverage-final.json +0 -9
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/components/AchievementModal.tsx.html +0 -229
- package/coverage/lcov-report/src/components/BadgesButton.tsx.html +0 -169
- package/coverage/lcov-report/src/components/BadgesModal.tsx.html +0 -253
- package/coverage/lcov-report/src/components/ConfettiWrapper.tsx.html +0 -157
- package/coverage/lcov-report/src/components/index.html +0 -161
- package/coverage/lcov-report/src/context/AchievementContext.tsx.html +0 -505
- package/coverage/lcov-report/src/context/index.html +0 -116
- package/coverage/lcov-report/src/index.html +0 -146
- package/coverage/lcov-report/src/index.ts.html +0 -121
- package/coverage/lcov-report/src/react-confetti.d.ts.html +0 -139
- package/coverage/lcov-report/src/react-use.d.ts.html +0 -94
- package/coverage/lcov.info +0 -240
- package/demo/src/AchievementConfig.ts +0 -0
- package/public/badges/icon1.svg +0 -1
- package/rollup.config.mjs +0 -34
- package/src/assets/defaultIcons.ts +0 -100
- package/src/components/BadgesButton.tsx +0 -49
- package/src/components/BadgesModal.tsx +0 -47
- package/src/components/ConfettiWrapper.tsx +0 -17
- package/src/defaultStyles.ts +0 -86
- package/src/hooks/useAchievement.ts +0 -17
- package/src/index.ts +0 -25
- package/src/providers/AchievementProvider.tsx +0 -202
- package/src/react-confetti.d.ts +0 -19
- package/src/react-use.d.ts +0 -4
- package/src/redux/achievementSlice.ts +0 -116
- package/src/redux/notificationSlice.ts +0 -26
- package/src/redux/store.ts +0 -16
- package/src/types.ts +0 -39
- package/tsconfig.json +0 -113
package/coverage/lcov.info
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
TN:
|
|
2
|
-
SF:src/index.ts
|
|
3
|
-
FN:6,(anonymous_1)
|
|
4
|
-
FN:7,(anonymous_2)
|
|
5
|
-
FNF:2
|
|
6
|
-
FNH:0
|
|
7
|
-
FNDA:0,(anonymous_1)
|
|
8
|
-
FNDA:0,(anonymous_2)
|
|
9
|
-
DA:1,0
|
|
10
|
-
DA:3,0
|
|
11
|
-
DA:6,0
|
|
12
|
-
DA:7,0
|
|
13
|
-
DA:12,0
|
|
14
|
-
LF:5
|
|
15
|
-
LH:0
|
|
16
|
-
BRF:0
|
|
17
|
-
BRH:0
|
|
18
|
-
end_of_record
|
|
19
|
-
TN:
|
|
20
|
-
SF:src/react-confetti.d.ts
|
|
21
|
-
FNF:0
|
|
22
|
-
FNH:0
|
|
23
|
-
LF:0
|
|
24
|
-
LH:0
|
|
25
|
-
BRF:0
|
|
26
|
-
BRH:0
|
|
27
|
-
end_of_record
|
|
28
|
-
TN:
|
|
29
|
-
SF:src/react-use.d.ts
|
|
30
|
-
FNF:0
|
|
31
|
-
FNH:0
|
|
32
|
-
LF:0
|
|
33
|
-
LH:0
|
|
34
|
-
BRF:0
|
|
35
|
-
BRH:0
|
|
36
|
-
end_of_record
|
|
37
|
-
TN:
|
|
38
|
-
SF:src/components/AchievementModal.tsx
|
|
39
|
-
FN:10,(anonymous_1)
|
|
40
|
-
FNF:1
|
|
41
|
-
FNH:0
|
|
42
|
-
FNDA:0,(anonymous_1)
|
|
43
|
-
DA:1,0
|
|
44
|
-
DA:10,0
|
|
45
|
-
DA:11,0
|
|
46
|
-
DA:13,0
|
|
47
|
-
DA:25,0
|
|
48
|
-
DA:35,0
|
|
49
|
-
DA:49,0
|
|
50
|
-
LF:7
|
|
51
|
-
LH:0
|
|
52
|
-
BRDA:11,0,0,0
|
|
53
|
-
BRDA:11,1,0,0
|
|
54
|
-
BRDA:11,1,1,0
|
|
55
|
-
BRF:3
|
|
56
|
-
BRH:0
|
|
57
|
-
end_of_record
|
|
58
|
-
TN:
|
|
59
|
-
SF:src/components/BadgesButton.tsx
|
|
60
|
-
FN:8,(anonymous_1)
|
|
61
|
-
FNF:1
|
|
62
|
-
FNH:0
|
|
63
|
-
FNDA:0,(anonymous_1)
|
|
64
|
-
DA:1,0
|
|
65
|
-
DA:8,0
|
|
66
|
-
DA:9,0
|
|
67
|
-
DA:22,0
|
|
68
|
-
DA:29,0
|
|
69
|
-
LF:5
|
|
70
|
-
LH:0
|
|
71
|
-
BRF:0
|
|
72
|
-
BRH:0
|
|
73
|
-
end_of_record
|
|
74
|
-
TN:
|
|
75
|
-
SF:src/components/BadgesModal.tsx
|
|
76
|
-
FN:10,(anonymous_1)
|
|
77
|
-
FN:44,(anonymous_2)
|
|
78
|
-
FNF:2
|
|
79
|
-
FNH:0
|
|
80
|
-
FNDA:0,(anonymous_1)
|
|
81
|
-
FNDA:0,(anonymous_2)
|
|
82
|
-
DA:1,0
|
|
83
|
-
DA:10,0
|
|
84
|
-
DA:11,0
|
|
85
|
-
DA:13,0
|
|
86
|
-
DA:28,0
|
|
87
|
-
DA:38,0
|
|
88
|
-
DA:45,0
|
|
89
|
-
DA:57,0
|
|
90
|
-
LF:8
|
|
91
|
-
LH:0
|
|
92
|
-
BRDA:11,0,0,0
|
|
93
|
-
BRF:1
|
|
94
|
-
BRH:0
|
|
95
|
-
end_of_record
|
|
96
|
-
TN:
|
|
97
|
-
SF:src/components/ConfettiWrapper.tsx
|
|
98
|
-
FN:11,(anonymous_1)
|
|
99
|
-
FNF:1
|
|
100
|
-
FNH:0
|
|
101
|
-
FNDA:0,(anonymous_1)
|
|
102
|
-
DA:1,0
|
|
103
|
-
DA:2,0
|
|
104
|
-
DA:3,0
|
|
105
|
-
DA:11,0
|
|
106
|
-
DA:12,0
|
|
107
|
-
DA:14,0
|
|
108
|
-
DA:16,0
|
|
109
|
-
DA:25,0
|
|
110
|
-
LF:8
|
|
111
|
-
LH:0
|
|
112
|
-
BRDA:14,0,0,0
|
|
113
|
-
BRF:1
|
|
114
|
-
BRH:0
|
|
115
|
-
end_of_record
|
|
116
|
-
TN:
|
|
117
|
-
SF:src/context/AchievementProvider.tsx
|
|
118
|
-
FN:26,(anonymous_7)
|
|
119
|
-
FN:33,(anonymous_8)
|
|
120
|
-
FN:34,(anonymous_9)
|
|
121
|
-
FN:44,(anonymous_10)
|
|
122
|
-
FN:45,(anonymous_11)
|
|
123
|
-
FN:46,(anonymous_12)
|
|
124
|
-
FN:46,(anonymous_13)
|
|
125
|
-
FN:50,(anonymous_14)
|
|
126
|
-
FN:58,(anonymous_15)
|
|
127
|
-
FN:67,(anonymous_16)
|
|
128
|
-
FN:71,(anonymous_17)
|
|
129
|
-
FN:74,(anonymous_18)
|
|
130
|
-
FN:76,(anonymous_19)
|
|
131
|
-
FN:84,(anonymous_20)
|
|
132
|
-
FN:92,(anonymous_21)
|
|
133
|
-
FN:96,(anonymous_22)
|
|
134
|
-
FN:102,(anonymous_23)
|
|
135
|
-
FN:103,(anonymous_24)
|
|
136
|
-
FN:119,(anonymous_25)
|
|
137
|
-
FN:127,(anonymous_26)
|
|
138
|
-
FN:135,(anonymous_27)
|
|
139
|
-
FNF:21
|
|
140
|
-
FNH:0
|
|
141
|
-
FNDA:0,(anonymous_7)
|
|
142
|
-
FNDA:0,(anonymous_8)
|
|
143
|
-
FNDA:0,(anonymous_9)
|
|
144
|
-
FNDA:0,(anonymous_10)
|
|
145
|
-
FNDA:0,(anonymous_11)
|
|
146
|
-
FNDA:0,(anonymous_12)
|
|
147
|
-
FNDA:0,(anonymous_13)
|
|
148
|
-
FNDA:0,(anonymous_14)
|
|
149
|
-
FNDA:0,(anonymous_15)
|
|
150
|
-
FNDA:0,(anonymous_16)
|
|
151
|
-
FNDA:0,(anonymous_17)
|
|
152
|
-
FNDA:0,(anonymous_18)
|
|
153
|
-
FNDA:0,(anonymous_19)
|
|
154
|
-
FNDA:0,(anonymous_20)
|
|
155
|
-
FNDA:0,(anonymous_21)
|
|
156
|
-
FNDA:0,(anonymous_22)
|
|
157
|
-
FNDA:0,(anonymous_23)
|
|
158
|
-
FNDA:0,(anonymous_24)
|
|
159
|
-
FNDA:0,(anonymous_25)
|
|
160
|
-
FNDA:0,(anonymous_26)
|
|
161
|
-
FNDA:0,(anonymous_27)
|
|
162
|
-
DA:1,0
|
|
163
|
-
DA:3,0
|
|
164
|
-
DA:4,0
|
|
165
|
-
DA:5,0
|
|
166
|
-
DA:6,0
|
|
167
|
-
DA:24,0
|
|
168
|
-
DA:26,0
|
|
169
|
-
DA:33,0
|
|
170
|
-
DA:34,0
|
|
171
|
-
DA:35,0
|
|
172
|
-
DA:36,0
|
|
173
|
-
DA:38,0
|
|
174
|
-
DA:40,0
|
|
175
|
-
DA:44,0
|
|
176
|
-
DA:45,0
|
|
177
|
-
DA:46,0
|
|
178
|
-
DA:50,0
|
|
179
|
-
DA:51,0
|
|
180
|
-
DA:52,0
|
|
181
|
-
DA:53,0
|
|
182
|
-
DA:55,0
|
|
183
|
-
DA:58,0
|
|
184
|
-
DA:59,0
|
|
185
|
-
DA:60,0
|
|
186
|
-
DA:63,0
|
|
187
|
-
DA:64,0
|
|
188
|
-
DA:65,0
|
|
189
|
-
DA:67,0
|
|
190
|
-
DA:68,0
|
|
191
|
-
DA:71,0
|
|
192
|
-
DA:72,0
|
|
193
|
-
DA:74,0
|
|
194
|
-
DA:75,0
|
|
195
|
-
DA:76,0
|
|
196
|
-
DA:77,0
|
|
197
|
-
DA:78,0
|
|
198
|
-
DA:83,0
|
|
199
|
-
DA:84,0
|
|
200
|
-
DA:85,0
|
|
201
|
-
DA:86,0
|
|
202
|
-
DA:87,0
|
|
203
|
-
DA:88,0
|
|
204
|
-
DA:92,0
|
|
205
|
-
DA:93,0
|
|
206
|
-
DA:96,0
|
|
207
|
-
DA:97,0
|
|
208
|
-
DA:100,0
|
|
209
|
-
DA:103,0
|
|
210
|
-
DA:104,0
|
|
211
|
-
DA:105,0
|
|
212
|
-
DA:113,0
|
|
213
|
-
DA:120,0
|
|
214
|
-
DA:121,0
|
|
215
|
-
DA:127,0
|
|
216
|
-
DA:135,0
|
|
217
|
-
DA:136,0
|
|
218
|
-
DA:137,0
|
|
219
|
-
DA:138,0
|
|
220
|
-
DA:140,0
|
|
221
|
-
LF:59
|
|
222
|
-
LH:0
|
|
223
|
-
BRDA:29,0,0,0
|
|
224
|
-
BRDA:30,1,0,0
|
|
225
|
-
BRDA:31,2,0,0
|
|
226
|
-
BRDA:35,3,0,0
|
|
227
|
-
BRDA:35,3,1,0
|
|
228
|
-
BRDA:52,4,0,0
|
|
229
|
-
BRDA:60,5,0,0
|
|
230
|
-
BRDA:60,5,1,0
|
|
231
|
-
BRDA:77,6,0,0
|
|
232
|
-
BRDA:77,7,0,0
|
|
233
|
-
BRDA:77,7,1,0
|
|
234
|
-
BRDA:83,8,0,0
|
|
235
|
-
BRDA:104,9,0,0
|
|
236
|
-
BRDA:104,9,1,0
|
|
237
|
-
BRDA:137,10,0,0
|
|
238
|
-
BRF:15
|
|
239
|
-
BRH:0
|
|
240
|
-
end_of_record
|
|
File without changes
|
package/public/badges/icon1.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M560-440q-50 0-85-35t-35-85q0-50 35-85t85-35q50 0 85 35t35 85q0 50-35 85t-85 35ZM280-320q-33 0-56.5-23.5T200-400v-320q0-33 23.5-56.5T280-800h560q33 0 56.5 23.5T920-720v320q0 33-23.5 56.5T840-320H280Zm80-80h400q0-33 23.5-56.5T840-480v-160q-33 0-56.5-23.5T760-720H360q0 33-23.5 56.5T280-640v160q33 0 56.5 23.5T360-400Zm440 240H120q-33 0-56.5-23.5T40-240v-440h80v440h680v80ZM280-400v-320 320Z"/></svg>
|
package/rollup.config.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
4
|
-
import replace from '@rollup/plugin-replace';
|
|
5
|
-
import postcss from 'rollup-plugin-postcss';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
input: 'src/index.ts',
|
|
9
|
-
output: [
|
|
10
|
-
{
|
|
11
|
-
file: 'dist/index.cjs.js',
|
|
12
|
-
format: 'cjs',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
file: 'dist/index.esm.js',
|
|
16
|
-
format: 'esm',
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
plugins: [
|
|
20
|
-
replace({
|
|
21
|
-
preventAssignment: true,
|
|
22
|
-
'this': 'undefined',
|
|
23
|
-
}),
|
|
24
|
-
postcss({
|
|
25
|
-
extract: false,
|
|
26
|
-
inject: true,
|
|
27
|
-
modules: false
|
|
28
|
-
}),
|
|
29
|
-
resolve(),
|
|
30
|
-
commonjs(),
|
|
31
|
-
typescript({ tsconfig: './tsconfig.json' })
|
|
32
|
-
],
|
|
33
|
-
external: ['react', 'react-dom']
|
|
34
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// src/defaultIcons.ts
|
|
2
|
-
|
|
3
|
-
export const defaultAchievementIcons = {
|
|
4
|
-
// General Progress & Milestones
|
|
5
|
-
levelUp: '🏆',
|
|
6
|
-
questComplete: '📜',
|
|
7
|
-
monsterDefeated: '⚔️',
|
|
8
|
-
itemCollected: '📦',
|
|
9
|
-
challengeCompleted: '🏁',
|
|
10
|
-
milestoneReached: '🏅',
|
|
11
|
-
firstStep: '👣',
|
|
12
|
-
newBeginnings: '🌱',
|
|
13
|
-
breakthrough: '💡',
|
|
14
|
-
growth: '📈',
|
|
15
|
-
|
|
16
|
-
// Social & Engagement
|
|
17
|
-
shared: '🔗',
|
|
18
|
-
liked: '❤️',
|
|
19
|
-
commented: '💬',
|
|
20
|
-
followed: '👥',
|
|
21
|
-
invited: '🤝',
|
|
22
|
-
communityMember: '🏘️',
|
|
23
|
-
supporter: '🌟',
|
|
24
|
-
connected: '🌐',
|
|
25
|
-
participant: '🙋',
|
|
26
|
-
influencer: '📣',
|
|
27
|
-
|
|
28
|
-
// Time & Activity
|
|
29
|
-
activeDay: '☀️',
|
|
30
|
-
activeWeek: '📅',
|
|
31
|
-
activeMonth: '🗓️',
|
|
32
|
-
earlyBird: '⏰',
|
|
33
|
-
nightOwl: '🌙',
|
|
34
|
-
streak: '🔥',
|
|
35
|
-
dedicated: '⏳',
|
|
36
|
-
punctual: '⏱️',
|
|
37
|
-
consistent: '🔄',
|
|
38
|
-
marathon: '🏃',
|
|
39
|
-
|
|
40
|
-
// Creativity & Skill
|
|
41
|
-
artist: '🎨',
|
|
42
|
-
writer: '✍️',
|
|
43
|
-
innovator: '🔬',
|
|
44
|
-
creator: '🛠️',
|
|
45
|
-
expert: '🎓',
|
|
46
|
-
master: '👑',
|
|
47
|
-
pioneer: '🚀',
|
|
48
|
-
performer: '🎭',
|
|
49
|
-
thinker: '🧠',
|
|
50
|
-
explorer: '🗺️',
|
|
51
|
-
|
|
52
|
-
// Achievement Types
|
|
53
|
-
bronze: '🥉',
|
|
54
|
-
silver: '🥈',
|
|
55
|
-
gold: '🥇',
|
|
56
|
-
diamond: '💎',
|
|
57
|
-
legendary: '✨',
|
|
58
|
-
epic: '💥',
|
|
59
|
-
rare: '🔮',
|
|
60
|
-
common: '🔘',
|
|
61
|
-
special: '🎁',
|
|
62
|
-
hidden: '❓',
|
|
63
|
-
|
|
64
|
-
// Numbers & Counters
|
|
65
|
-
one: '1️⃣',
|
|
66
|
-
ten: '🔟',
|
|
67
|
-
hundred: '💯',
|
|
68
|
-
thousand: '🔢',
|
|
69
|
-
|
|
70
|
-
// Actions & Interactions
|
|
71
|
-
clicked: '🖱️',
|
|
72
|
-
used: '🔑',
|
|
73
|
-
found: '🔍',
|
|
74
|
-
built: '🧱',
|
|
75
|
-
solved: '🧩',
|
|
76
|
-
discovered: '🔭',
|
|
77
|
-
unlocked: '🔓',
|
|
78
|
-
upgraded: '⬆️',
|
|
79
|
-
repaired: '🔧',
|
|
80
|
-
defended: '🛡️',
|
|
81
|
-
|
|
82
|
-
// Placeholders
|
|
83
|
-
default: '⭐', // A fallback icon
|
|
84
|
-
loading: '⏳',
|
|
85
|
-
error: '⚠️',
|
|
86
|
-
success: '✅',
|
|
87
|
-
failure: '❌',
|
|
88
|
-
|
|
89
|
-
// Miscellaneous
|
|
90
|
-
trophy: '🏆',
|
|
91
|
-
star: '⭐',
|
|
92
|
-
flag: '🚩',
|
|
93
|
-
puzzle: '🧩',
|
|
94
|
-
gem: '💎',
|
|
95
|
-
crown: '👑',
|
|
96
|
-
medal: '🏅',
|
|
97
|
-
ribbon: '🎗️',
|
|
98
|
-
badge: '🎖️',
|
|
99
|
-
shield: '🛡️',
|
|
100
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Styles } from '../defaultStyles';
|
|
3
|
-
import { AchievementDetails } from '../types';
|
|
4
|
-
|
|
5
|
-
interface BadgesButtonProps {
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
8
|
-
styles: Styles['badgesButton'];
|
|
9
|
-
unlockedAchievements: AchievementDetails[];
|
|
10
|
-
icon?: React.ReactNode; // Allow custom icons
|
|
11
|
-
drawer?: boolean; // Indicate if it triggers a drawer
|
|
12
|
-
customStyles?: React.CSSProperties; // Allow custom styles
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const BadgesButton: React.FC<BadgesButtonProps> = ({
|
|
16
|
-
onClick,
|
|
17
|
-
position,
|
|
18
|
-
styles,
|
|
19
|
-
unlockedAchievements,
|
|
20
|
-
icon,
|
|
21
|
-
drawer = false,
|
|
22
|
-
customStyles,
|
|
23
|
-
}) => {
|
|
24
|
-
const positionStyle = position
|
|
25
|
-
? {
|
|
26
|
-
[position.split('-')[0]]: '20px',
|
|
27
|
-
[position.split('-')[1]]: '20px',
|
|
28
|
-
}
|
|
29
|
-
: {};
|
|
30
|
-
|
|
31
|
-
const handleButtonClick = () => {
|
|
32
|
-
onClick();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const achievementsText = 'View Achievements';
|
|
36
|
-
|
|
37
|
-
const buttonContent = icon ? icon : achievementsText;
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<button
|
|
41
|
-
onClick={handleButtonClick}
|
|
42
|
-
style={{ ...styles, ...positionStyle, ...customStyles }}
|
|
43
|
-
>
|
|
44
|
-
{buttonContent}
|
|
45
|
-
</button>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default React.memo(BadgesButton);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {AchievementDetails, AchievementIconRecord} from '../types';
|
|
3
|
-
import { Styles } from '../defaultStyles';
|
|
4
|
-
import { defaultAchievementIcons } from '../assets/defaultIcons'; // Import default icons
|
|
5
|
-
|
|
6
|
-
interface BadgesModalProps {
|
|
7
|
-
isOpen: boolean;
|
|
8
|
-
achievements: AchievementDetails[];
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
styles: Styles['badgesModal'];
|
|
11
|
-
icons?: Record<string, string>; // Optional user-specified icons
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const BadgesModal: React.FC<BadgesModalProps> = ({ isOpen, achievements, onClose, styles, icons = {} }) => {
|
|
15
|
-
if (!isOpen) return null;
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<div style={styles.overlay as React.CSSProperties}>
|
|
19
|
-
<div style={styles.content}>
|
|
20
|
-
<h2 style={styles.title}>Your Achievements</h2>
|
|
21
|
-
<div style={styles.badgeContainer}>
|
|
22
|
-
{achievements.map((achievement) => {
|
|
23
|
-
const mergedIcons: AchievementIconRecord = { ...defaultAchievementIcons, ...icons };
|
|
24
|
-
let iconToDisplay: string | undefined = mergedIcons.default;
|
|
25
|
-
if (achievement.achievementIconKey && mergedIcons[achievement.achievementIconKey]) {
|
|
26
|
-
iconToDisplay = mergedIcons[achievement.achievementIconKey];
|
|
27
|
-
}
|
|
28
|
-
return (
|
|
29
|
-
<div key={achievement.achievementId} style={styles.badge}>
|
|
30
|
-
{/* Render icon based on type (Unicode or image path) */}
|
|
31
|
-
{iconToDisplay.startsWith('http') || iconToDisplay.startsWith('data:image') ? (
|
|
32
|
-
<img src={iconToDisplay} alt={achievement.achievementTitle} style={styles.badgeIcon} />
|
|
33
|
-
) : (
|
|
34
|
-
<p style={{ fontSize: '2em' }}>{iconToDisplay}</p> // Render Unicode as large text
|
|
35
|
-
)}
|
|
36
|
-
<span style={styles.badgeTitle}>{achievement.achievementTitle}</span>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
})}
|
|
40
|
-
</div>
|
|
41
|
-
<button onClick={onClose} style={styles.button}>Close</button>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default React.memo(BadgesModal);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Confetti from 'react-confetti';
|
|
3
|
-
import { useWindowSize } from 'react-use';
|
|
4
|
-
|
|
5
|
-
interface ConfettiWrapperProps {
|
|
6
|
-
show: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const ConfettiWrapper: React.FC<ConfettiWrapperProps> = ({ show }) => {
|
|
10
|
-
const { width, height } = useWindowSize();
|
|
11
|
-
|
|
12
|
-
if (!show) return null;
|
|
13
|
-
|
|
14
|
-
return <Confetti width={width} height={height} recycle={false} />;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default ConfettiWrapper;
|
package/src/defaultStyles.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
type StyleObject = { [key: string]: string | number };
|
|
2
|
-
|
|
3
|
-
interface BadgesModalStyles {
|
|
4
|
-
overlay: StyleObject;
|
|
5
|
-
content: StyleObject;
|
|
6
|
-
title: StyleObject;
|
|
7
|
-
badgeContainer: StyleObject;
|
|
8
|
-
badge: StyleObject;
|
|
9
|
-
badgeIcon: StyleObject;
|
|
10
|
-
badgeTitle: StyleObject;
|
|
11
|
-
button: StyleObject;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface Styles {
|
|
15
|
-
badgesModal: BadgesModalStyles;
|
|
16
|
-
badgesButton: StyleObject;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const defaultStyles: Styles = {
|
|
20
|
-
badgesModal: {
|
|
21
|
-
overlay: {
|
|
22
|
-
position: 'fixed',
|
|
23
|
-
top: 0,
|
|
24
|
-
left: 0,
|
|
25
|
-
right: 0,
|
|
26
|
-
bottom: 0,
|
|
27
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
28
|
-
display: 'flex',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
justifyContent: 'center',
|
|
31
|
-
},
|
|
32
|
-
content: {
|
|
33
|
-
backgroundColor: '#ffffff',
|
|
34
|
-
borderRadius: '8px',
|
|
35
|
-
padding: '20px',
|
|
36
|
-
maxWidth: '600px',
|
|
37
|
-
width: '100%',
|
|
38
|
-
maxHeight: '80vh',
|
|
39
|
-
overflowY: 'auto',
|
|
40
|
-
},
|
|
41
|
-
title: {
|
|
42
|
-
fontSize: '24px',
|
|
43
|
-
fontWeight: 'bold',
|
|
44
|
-
marginBottom: '20px',
|
|
45
|
-
},
|
|
46
|
-
badgeContainer: {
|
|
47
|
-
display: 'flex',
|
|
48
|
-
flexWrap: 'wrap',
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
},
|
|
51
|
-
badge: {
|
|
52
|
-
display: 'flex',
|
|
53
|
-
flexDirection: 'column',
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
margin: '10px',
|
|
56
|
-
},
|
|
57
|
-
badgeIcon: {
|
|
58
|
-
width: '50px',
|
|
59
|
-
height: '50px',
|
|
60
|
-
marginBottom: '5px',
|
|
61
|
-
},
|
|
62
|
-
badgeTitle: {
|
|
63
|
-
fontSize: '14px',
|
|
64
|
-
textAlign: 'center',
|
|
65
|
-
},
|
|
66
|
-
button: {
|
|
67
|
-
backgroundColor: '#007bff',
|
|
68
|
-
color: '#ffffff',
|
|
69
|
-
padding: '10px 20px',
|
|
70
|
-
borderRadius: '4px',
|
|
71
|
-
border: 'none',
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
marginTop: '20px',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
badgesButton: {
|
|
77
|
-
position: 'fixed',
|
|
78
|
-
padding: '10px 20px',
|
|
79
|
-
backgroundColor: '#007bff',
|
|
80
|
-
color: '#ffffff',
|
|
81
|
-
border: 'none',
|
|
82
|
-
borderRadius: '4px',
|
|
83
|
-
cursor: 'pointer',
|
|
84
|
-
zIndex: 1000,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useSelector } from 'react-redux';
|
|
2
|
-
import { RootState } from '../redux/store';
|
|
3
|
-
import { useAchievementContext } from '../providers/AchievementProvider';
|
|
4
|
-
|
|
5
|
-
export const useAchievement = () => {
|
|
6
|
-
const { updateMetrics, unlockedAchievements, resetStorage } = useAchievementContext();
|
|
7
|
-
const metrics = useSelector((state: RootState) => state.achievements.metrics);
|
|
8
|
-
const config = useSelector((state: RootState) => state.achievements.config);
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
metrics,
|
|
12
|
-
unlockedAchievements,
|
|
13
|
-
config,
|
|
14
|
-
updateMetrics,
|
|
15
|
-
resetStorage,
|
|
16
|
-
};
|
|
17
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AchievementProvider, useAchievementContext as useAchievement } from './providers/AchievementProvider';
|
|
2
|
-
import type {
|
|
3
|
-
AchievementMetrics,
|
|
4
|
-
AchievementConfiguration,
|
|
5
|
-
AchievementDetails,
|
|
6
|
-
AchievementUnlockCondition,
|
|
7
|
-
AchievementMetricValue,
|
|
8
|
-
InitialAchievementMetrics
|
|
9
|
-
} from './types';
|
|
10
|
-
import achievementReducer from './redux/achievementSlice';
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
AchievementProvider,
|
|
14
|
-
useAchievement,
|
|
15
|
-
achievementReducer,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
AchievementMetrics,
|
|
20
|
-
AchievementConfiguration,
|
|
21
|
-
AchievementDetails,
|
|
22
|
-
AchievementUnlockCondition,
|
|
23
|
-
AchievementMetricValue,
|
|
24
|
-
InitialAchievementMetrics,
|
|
25
|
-
};
|