Spaces:
Running
Running
fix leaderboard card emoji
Browse files
client/package.json
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
"@mui/material": "^6.4.0",
|
17 |
"@tanstack/react-query": "^5.64.1",
|
18 |
"axios": "^1.7.9",
|
|
|
19 |
"react": "^18.3.1",
|
20 |
"react-dom": "^18.3.1",
|
21 |
"react-router-dom": "^7.1.2"
|
|
|
16 |
"@mui/material": "^6.4.0",
|
17 |
"@tanstack/react-query": "^5.64.1",
|
18 |
"axios": "^1.7.9",
|
19 |
+
"grapheme-splitter": "^1.0.4",
|
20 |
"react": "^18.3.1",
|
21 |
"react-dom": "^18.3.1",
|
22 |
"react-router-dom": "^7.1.2"
|
client/src/components/LeaderboardSection/components/LeaderboardCard.jsx
CHANGED
@@ -3,6 +3,7 @@ import { Card, CardContent, Typography, Box, Stack } from "@mui/material";
|
|
3 |
import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorder";
|
4 |
import { alpha } from "@mui/material/styles";
|
5 |
import { useLeaderboard } from "../../../context/LeaderboardContext";
|
|
|
6 |
|
7 |
const LeaderboardCard = ({ leaderboard }) => {
|
8 |
const {
|
@@ -49,8 +50,19 @@ const LeaderboardCard = ({ leaderboard }) => {
|
|
49 |
return `${diffDays} days ago`;
|
50 |
};
|
51 |
|
52 |
-
//
|
53 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
// Obtenir la description à afficher
|
56 |
const displayDescription =
|
@@ -245,11 +257,7 @@ const LeaderboardCard = ({ leaderboard }) => {
|
|
245 |
card_data.title || leaderboard.id
|
246 |
)}
|
247 |
</Typography>
|
248 |
-
<Box sx={{ fontSize: "1.5rem" }}>
|
249 |
-
{emojis.map((emoji, index) => (
|
250 |
-
<span key={index}>{emoji}</span>
|
251 |
-
))}
|
252 |
-
</Box>
|
253 |
</Box>
|
254 |
{displayDescription && (
|
255 |
<Typography
|
|
|
3 |
import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorder";
|
4 |
import { alpha } from "@mui/material/styles";
|
5 |
import { useLeaderboard } from "../../../context/LeaderboardContext";
|
6 |
+
import GraphemeSplitter from "grapheme-splitter";
|
7 |
|
8 |
const LeaderboardCard = ({ leaderboard }) => {
|
9 |
const {
|
|
|
50 |
return `${diffDays} days ago`;
|
51 |
};
|
52 |
|
53 |
+
// Récupérer uniquement le dernier emoji
|
54 |
+
const getLastEmoji = () => {
|
55 |
+
if (!card_data.emoji) return "🎯";
|
56 |
+
|
57 |
+
// Utiliser GraphemeSplitter pour diviser correctement les emojis
|
58 |
+
const splitter = new GraphemeSplitter();
|
59 |
+
const graphemes = splitter.splitGraphemes(card_data.emoji);
|
60 |
+
|
61 |
+
// Retourner le dernier graphème (emoji)
|
62 |
+
return graphemes.length > 0 ? graphemes[graphemes.length - 1] : "🎯";
|
63 |
+
};
|
64 |
+
|
65 |
+
const lastEmoji = getLastEmoji();
|
66 |
|
67 |
// Obtenir la description à afficher
|
68 |
const displayDescription =
|
|
|
257 |
card_data.title || leaderboard.id
|
258 |
)}
|
259 |
</Typography>
|
260 |
+
<Box sx={{ fontSize: "1.5rem" }}>{lastEmoji}</Box>
|
|
|
|
|
|
|
|
|
261 |
</Box>
|
262 |
{displayDescription && (
|
263 |
<Typography
|
client/yarn.lock
CHANGED
@@ -1633,6 +1633,11 @@ gopd@^1.0.1, gopd@^1.2.0:
|
|
1633 |
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1"
|
1634 |
integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==
|
1635 |
|
|
|
|
|
|
|
|
|
|
|
1636 |
has-bigints@^1.0.2:
|
1637 |
version "1.1.0"
|
1638 |
resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.1.0.tgz#28607e965ac967e03cd2a2c70a2636a1edad49fe"
|
|
|
1633 |
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1"
|
1634 |
integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==
|
1635 |
|
1636 |
+
grapheme-splitter@^1.0.4:
|
1637 |
+
version "1.0.4"
|
1638 |
+
resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e"
|
1639 |
+
integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==
|
1640 |
+
|
1641 |
has-bigints@^1.0.2:
|
1642 |
version "1.1.0"
|
1643 |
resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.1.0.tgz#28607e965ac967e03cd2a2c70a2636a1edad49fe"
|