tfrere commited on
Commit
83106dd
·
1 Parent(s): 8beb9ab

update darkmode | update wording

Browse files
frontend/src/components/BenchmarkCreateForm.jsx CHANGED
@@ -9,6 +9,7 @@ import {
9
  Alert,
10
  Grid,
11
  } from "@mui/material";
 
12
  import CloudUploadIcon from "@mui/icons-material/CloudUpload";
13
  import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
14
  import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
@@ -208,7 +209,7 @@ function BenchmarkCreateForm({ onStartGeneration }) {
208
  border:
209
  selectedDocument?.id === doc.id
210
  ? `2px solid ${theme.palette.primary.main}`
211
- : "2px solid rgba(0, 0, 0, 0.1)",
212
  "&:hover": {
213
  transform: "translateY(-2px)",
214
  boxShadow: 3,
@@ -253,8 +254,10 @@ function BenchmarkCreateForm({ onStartGeneration }) {
253
  ? `2px solid ${theme.palette.primary.main}`
254
  : isDragging
255
  ? `2px dashed ${theme.palette.primary.main}`
256
- : "2px dashed rgba(0, 0, 0, 0.16)",
257
- backgroundColor: isDragging ? "rgba(0, 0, 0, 0.05)" : "transparent",
 
 
258
  display: "flex",
259
  flexDirection: "column",
260
  alignItems: "center",
@@ -289,23 +292,23 @@ function BenchmarkCreateForm({ onStartGeneration }) {
289
  </>
290
  ) : (
291
  <>
292
- <CloudUploadIcon
293
- sx={{ fontSize: 50, color: "primary.main", mb: 1 }}
294
- />
 
 
 
 
295
  <Typography variant="h6" component="div" gutterBottom>
296
- Drag and drop your file here or click to browse
 
 
297
  </Typography>
298
  <Typography variant="body2" color="text.secondary">
299
  Accepted formats: PDF, TXT, HTML, MD
300
  </Typography>
301
  </>
302
  )}
303
-
304
- {isLoading && (
305
- <Box sx={{ mt: 2 }}>
306
- <CircularProgress size={30} />
307
- </Box>
308
- )}
309
  </Box>
310
 
311
  <Box sx={{ display: "flex", justifyContent: "center" }}>
 
9
  Alert,
10
  Grid,
11
  } from "@mui/material";
12
+ import { alpha } from "@mui/material/styles";
13
  import CloudUploadIcon from "@mui/icons-material/CloudUpload";
14
  import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
15
  import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
 
209
  border:
210
  selectedDocument?.id === doc.id
211
  ? `2px solid ${theme.palette.primary.main}`
212
+ : `2px solid ${theme.palette.divider}`,
213
  "&:hover": {
214
  transform: "translateY(-2px)",
215
  boxShadow: 3,
 
254
  ? `2px solid ${theme.palette.primary.main}`
255
  : isDragging
256
  ? `2px dashed ${theme.palette.primary.main}`
257
+ : `2px dashed ${theme.palette.divider}`,
258
+ backgroundColor: isDragging
259
+ ? alpha(theme.palette.action.hover, 0.5)
260
+ : "transparent",
261
  display: "flex",
262
  flexDirection: "column",
263
  alignItems: "center",
 
292
  </>
293
  ) : (
294
  <>
295
+ {isLoading ? (
296
+ <CircularProgress size={50} sx={{ mb: 1 }} />
297
+ ) : (
298
+ <CloudUploadIcon
299
+ sx={{ fontSize: 50, color: "primary.main", mb: 1 }}
300
+ />
301
+ )}
302
  <Typography variant="h6" component="div" gutterBottom>
303
+ {isLoading
304
+ ? "Uploading your file..."
305
+ : "Drag and drop your file here or click to browse"}
306
  </Typography>
307
  <Typography variant="body2" color="text.secondary">
308
  Accepted formats: PDF, TXT, HTML, MD
309
  </Typography>
310
  </>
311
  )}
 
 
 
 
 
 
312
  </Box>
313
 
314
  <Box sx={{ display: "flex", justifyContent: "center" }}>
frontend/src/components/BenchmarkDisplay.jsx CHANGED
@@ -17,6 +17,8 @@ import LinkIcon from "@mui/icons-material/Link";
17
  import DownloadIcon from "@mui/icons-material/Download";
18
  import CheckCircleIcon from "@mui/icons-material/CheckCircle";
19
  import API_CONFIG from "../config/api";
 
 
20
 
21
  /**
22
  * Component to display benchmark information and evaluation button
@@ -35,6 +37,8 @@ const BenchmarkDisplay = ({
35
  datasetUrl,
36
  }) => {
37
  const [isDownloading, setIsDownloading] = useState(false);
 
 
38
 
39
  // Default questions if none provided
40
  const questions =
@@ -141,7 +145,8 @@ const BenchmarkDisplay = ({
141
  variant="outlined"
142
  sx={{
143
  mb: 2,
144
- backgroundColor: "#fafafa",
 
145
  }}
146
  >
147
  <CardContent>
 
17
  import DownloadIcon from "@mui/icons-material/Download";
18
  import CheckCircleIcon from "@mui/icons-material/CheckCircle";
19
  import API_CONFIG from "../config/api";
20
+ import { useThemeMode } from "../hooks/useThemeMode";
21
+ import getTheme from "../config/theme";
22
 
23
  /**
24
  * Component to display benchmark information and evaluation button
 
37
  datasetUrl,
38
  }) => {
39
  const [isDownloading, setIsDownloading] = useState(false);
40
+ const { mode } = useThemeMode();
41
+ const theme = getTheme(mode);
42
 
43
  // Default questions if none provided
44
  const questions =
 
145
  variant="outlined"
146
  sx={{
147
  mb: 2,
148
+ backgroundColor: theme.palette.background.subtle,
149
+ border: `1px solid ${theme.palette.divider}`,
150
  }}
151
  >
152
  <CardContent>
frontend/src/components/BenchmarkEvaluation.jsx CHANGED
@@ -14,10 +14,10 @@ const MESSAGE_CHANGE_INTERVAL = {
14
 
15
  // Starting messages with their timing
16
  const STARTING_MESSAGES = [
17
- { message: "Initializing evaluation environment...", progress: 0 },
18
- { message: "Starting evaluation process...", progress: 27 },
19
- { message: "Evaluating models...", progress: 54 },
20
- { message: "Storing evaluation results...", progress: 84 },
21
  ];
22
 
23
  const BenchmarkEvaluation = ({ sessionId, isDefaultDocument, onComplete }) => {
@@ -213,7 +213,7 @@ const BenchmarkEvaluation = ({ sessionId, isDefaultDocument, onComplete }) => {
213
 
214
  {/* Step progress indicator */}
215
  <Typography variant="body1" color="text.secondary">
216
- {`${STARTING_MESSAGES[startingMessageIndex].message} (${STARTING_MESSAGES[startingMessageIndex].progress}%)`}
217
  </Typography>
218
 
219
  {/* Timer display */}
 
14
 
15
  // Starting messages with their timing
16
  const STARTING_MESSAGES = [
17
+ { message: "Initializing evaluation environment...", step: 1, totalSteps: 4 },
18
+ { message: "Starting evaluation process...", step: 2, totalSteps: 4 },
19
+ { message: "Evaluating models...", step: 3, totalSteps: 4 },
20
+ { message: "Storing evaluation results...", step: 4, totalSteps: 4 },
21
  ];
22
 
23
  const BenchmarkEvaluation = ({ sessionId, isDefaultDocument, onComplete }) => {
 
213
 
214
  {/* Step progress indicator */}
215
  <Typography variant="body1" color="text.secondary">
216
+ {`${STARTING_MESSAGES[startingMessageIndex].message} (${STARTING_MESSAGES[startingMessageIndex].step}/${STARTING_MESSAGES[startingMessageIndex].totalSteps})`}
217
  </Typography>
218
 
219
  {/* Timer display */}
frontend/src/components/BenchmarkGenerator.jsx CHANGED
@@ -26,9 +26,9 @@ const STEP_LABELS = {
26
  upload_ingest_to_hub: "Upload to Hub",
27
  summarization: "Summarization",
28
  chunking: "Chunking",
29
- single_shot_question_generation: "Single-shot QG",
30
- multi_hop_question_generation: "Multi-hop QG",
31
- lighteval: "LightEval",
32
  };
33
 
34
  // Simulated log messages for pre-calculated documents
@@ -402,22 +402,19 @@ const BenchmarkGenerator = ({ sessionId, isDefaultDocument, onComplete }) => {
402
 
403
  // If there's no active step yet
404
  if (currentStepIndex === 0 && completedSteps.length === 0) {
405
- return `Starting... (0%)`;
406
  }
407
 
408
  // If all steps are completed
409
  if (currentStepIndex >= totalSteps) {
410
- return `Complete (100%)`;
411
  }
412
 
413
- // Calculate percentage
414
- const percentage = Math.round((currentStepIndex / totalSteps) * 100);
415
-
416
  // Get current step name
417
  const currentStepName =
418
  STEP_LABELS[BENCHMARK_STEPS[currentStepIndex]] || "Processing";
419
 
420
- return `${currentStepName} (${percentage}%)`;
421
  };
422
 
423
  // Format elapsed time in HH:MM:SS
 
26
  upload_ingest_to_hub: "Upload to Hub",
27
  summarization: "Summarization",
28
  chunking: "Chunking",
29
+ single_shot_question_generation: "Question generation",
30
+ multi_hop_question_generation: "Question generation",
31
+ lighteval: "Saving results",
32
  };
33
 
34
  // Simulated log messages for pre-calculated documents
 
402
 
403
  // If there's no active step yet
404
  if (currentStepIndex === 0 && completedSteps.length === 0) {
405
+ return `Starting (0/${totalSteps})`;
406
  }
407
 
408
  // If all steps are completed
409
  if (currentStepIndex >= totalSteps) {
410
+ return `Complete (${totalSteps}/${totalSteps})`;
411
  }
412
 
 
 
 
413
  // Get current step name
414
  const currentStepName =
415
  STEP_LABELS[BENCHMARK_STEPS[currentStepIndex]] || "Processing";
416
 
417
+ return `${currentStepName} (${currentStepIndex}/${totalSteps})`;
418
  };
419
 
420
  // Format elapsed time in HH:MM:SS
frontend/src/components/ExternalLinks.jsx CHANGED
@@ -2,8 +2,13 @@ import React from "react";
2
  import { Box, Typography, IconButton, Tooltip } from "@mui/material";
3
  import OpenInNewIcon from "@mui/icons-material/OpenInNew";
4
  import ShareIcon from "@mui/icons-material/Share";
 
 
 
5
 
6
  const ExternalLinks = () => {
 
 
7
  const handleShare = async () => {
8
  try {
9
  await navigator.share({
@@ -72,22 +77,43 @@ const ExternalLinks = () => {
72
  <OpenInNewIcon sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }} />
73
  </a>
74
  </Typography>
75
- <Tooltip title="Share">
76
- <IconButton
77
- onClick={handleShare}
78
- size="small"
79
- sx={{
80
- ml: 1,
81
- color: "inherit",
82
- opacity: 0.7,
83
- "&:hover": {
84
- opacity: 1,
85
- },
86
- }}
87
- >
88
- <ShareIcon fontSize="small" />
89
- </IconButton>
90
- </Tooltip>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  </Box>
92
  );
93
  };
 
2
  import { Box, Typography, IconButton, Tooltip } from "@mui/material";
3
  import OpenInNewIcon from "@mui/icons-material/OpenInNew";
4
  import ShareIcon from "@mui/icons-material/Share";
5
+ import DarkModeOutlinedIcon from "@mui/icons-material/DarkModeOutlined";
6
+ import LightModeOutlinedIcon from "@mui/icons-material/LightModeOutlined";
7
+ import { useThemeMode } from "../hooks/useThemeMode";
8
 
9
  const ExternalLinks = () => {
10
+ const { mode, toggleTheme } = useThemeMode();
11
+
12
  const handleShare = async () => {
13
  try {
14
  await navigator.share({
 
77
  <OpenInNewIcon sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }} />
78
  </a>
79
  </Typography>
80
+ <Box sx={{ display: "flex", alignItems: "center" }}>
81
+ <Tooltip title="Share">
82
+ <IconButton
83
+ onClick={handleShare}
84
+ size="small"
85
+ sx={{
86
+ color: "inherit",
87
+ opacity: 0.7,
88
+ "&:hover": {
89
+ opacity: 1,
90
+ },
91
+ }}
92
+ >
93
+ <ShareIcon fontSize="small" />
94
+ </IconButton>
95
+ </Tooltip>
96
+ <Tooltip title={mode === "light" ? "Mode sombre" : "Mode clair"}>
97
+ <IconButton
98
+ onClick={toggleTheme}
99
+ size="small"
100
+ sx={{
101
+ ml: 1,
102
+ color: "inherit",
103
+ opacity: 0.7,
104
+ "&:hover": {
105
+ opacity: 1,
106
+ },
107
+ }}
108
+ >
109
+ {mode === "light" ? (
110
+ <DarkModeOutlinedIcon fontSize="small" />
111
+ ) : (
112
+ <LightModeOutlinedIcon fontSize="small" />
113
+ )}
114
+ </IconButton>
115
+ </Tooltip>
116
+ </Box>
117
  </Box>
118
  );
119
  };
frontend/src/hooks/useThemeMode.js CHANGED
@@ -1,28 +1,61 @@
1
- import { useState, useEffect } from 'react';
2
 
3
- export const useThemeMode = () => {
 
 
 
 
4
  // Get system preference
5
  const getSystemPreference = () => {
6
- return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
 
 
7
  };
8
 
9
- // Initialize theme mode from system preference
10
- const [mode, setMode] = useState(getSystemPreference);
 
 
 
11
 
12
- // Listen to system preference changes
 
 
 
13
  useEffect(() => {
14
- const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
15
  const handleChange = (e) => {
16
- setMode(e.matches ? 'dark' : 'light');
 
 
 
17
  };
18
-
19
- mediaQuery.addEventListener('change', handleChange);
20
- return () => mediaQuery.removeEventListener('change', handleChange);
21
  }, []);
22
 
 
 
 
 
 
23
  const toggleTheme = () => {
24
- setMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light'));
25
  };
26
 
27
- return { mode, toggleTheme };
28
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect, createContext, useContext } from "react";
2
 
3
+ // Créer un contexte pour le thème
4
+ const ThemeModeContext = createContext();
5
+
6
+ // Provider pour le contexte du thème
7
+ export const ThemeModeProvider = ({ children }) => {
8
  // Get system preference
9
  const getSystemPreference = () => {
10
+ return window.matchMedia("(prefers-color-scheme: dark)").matches
11
+ ? "dark"
12
+ : "light";
13
  };
14
 
15
+ // Essayer de récupérer le mode depuis localStorage ou utiliser la préférence système
16
+ const getSavedTheme = () => {
17
+ const savedTheme = localStorage.getItem("theme-mode");
18
+ return savedTheme || getSystemPreference();
19
+ };
20
 
21
+ // Initialize theme mode from saved or system preference
22
+ const [mode, setMode] = useState(getSavedTheme);
23
+
24
+ // Listen to system preference changes if no saved preference
25
  useEffect(() => {
26
+ const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
27
  const handleChange = (e) => {
28
+ // Only change if no user preference is saved
29
+ if (!localStorage.getItem("theme-mode")) {
30
+ setMode(e.matches ? "dark" : "light");
31
+ }
32
  };
33
+
34
+ mediaQuery.addEventListener("change", handleChange);
35
+ return () => mediaQuery.removeEventListener("change", handleChange);
36
  }, []);
37
 
38
+ // Save theme preference to localStorage when it changes
39
+ useEffect(() => {
40
+ localStorage.setItem("theme-mode", mode);
41
+ }, [mode]);
42
+
43
  const toggleTheme = () => {
44
+ setMode((prevMode) => (prevMode === "light" ? "dark" : "light"));
45
  };
46
 
47
+ return (
48
+ <ThemeModeContext.Provider value={{ mode, toggleTheme }}>
49
+ {children}
50
+ </ThemeModeContext.Provider>
51
+ );
52
+ };
53
+
54
+ // Hook pour utiliser le contexte du thème
55
+ export const useThemeMode = () => {
56
+ const context = useContext(ThemeModeContext);
57
+ if (context === undefined) {
58
+ throw new Error("useThemeMode must be used within a ThemeModeProvider");
59
+ }
60
+ return context;
61
+ };
frontend/src/index.js CHANGED
@@ -1,6 +1,11 @@
1
  import React from "react";
2
  import ReactDOM from "react-dom/client";
3
  import App from "./App";
 
4
 
5
  const root = ReactDOM.createRoot(document.getElementById("root"));
6
- root.render(<App />);
 
 
 
 
 
1
  import React from "react";
2
  import ReactDOM from "react-dom/client";
3
  import App from "./App";
4
+ import { ThemeModeProvider } from "./hooks/useThemeMode";
5
 
6
  const root = ReactDOM.createRoot(document.getElementById("root"));
7
+ root.render(
8
+ <ThemeModeProvider>
9
+ <App />
10
+ </ThemeModeProvider>
11
+ );
frontend/src/pages/BenchmarkDisplayPage.jsx CHANGED
@@ -4,6 +4,8 @@ import { useNavigate, useSearchParams, Navigate } from "react-router-dom";
4
  import Intro from "../components/Intro";
5
  import BenchmarkDisplay from "../components/BenchmarkDisplay";
6
  import API_CONFIG from "../config/api";
 
 
7
 
8
  function BenchmarkDisplayPage() {
9
  const navigate = useNavigate();
@@ -13,6 +15,8 @@ function BenchmarkDisplayPage() {
13
  const [datasetUrl, setDatasetUrl] = useState(null);
14
  const [isValidSession, setIsValidSession] = useState(true);
15
  const [isLoading, setIsLoading] = useState(true);
 
 
16
 
17
  useEffect(() => {
18
  console.log("BenchmarkDisplayPage useEffect - sessionId:", sessionId);
@@ -133,10 +137,10 @@ function BenchmarkDisplayPage() {
133
  ) : (
134
  <Box
135
  sx={{
136
- border: "1px solid rgba(0, 0, 0, 0.12)",
137
  borderRadius: 2,
138
  p: 4,
139
- bgcolor: "white",
140
  }}
141
  >
142
  <BenchmarkDisplay
 
4
  import Intro from "../components/Intro";
5
  import BenchmarkDisplay from "../components/BenchmarkDisplay";
6
  import API_CONFIG from "../config/api";
7
+ import { useThemeMode } from "../hooks/useThemeMode";
8
+ import getTheme from "../config/theme";
9
 
10
  function BenchmarkDisplayPage() {
11
  const navigate = useNavigate();
 
15
  const [datasetUrl, setDatasetUrl] = useState(null);
16
  const [isValidSession, setIsValidSession] = useState(true);
17
  const [isLoading, setIsLoading] = useState(true);
18
+ const { mode } = useThemeMode();
19
+ const theme = getTheme(mode);
20
 
21
  useEffect(() => {
22
  console.log("BenchmarkDisplayPage useEffect - sessionId:", sessionId);
 
137
  ) : (
138
  <Box
139
  sx={{
140
+ border: `1px solid ${theme.palette.divider}`,
141
  borderRadius: 2,
142
  p: 4,
143
+ bgcolor: "background.paper",
144
  }}
145
  >
146
  <BenchmarkDisplay
frontend/src/pages/EvaluationDisplayPage.jsx CHANGED
@@ -3,12 +3,16 @@ import { Box, CircularProgress } from "@mui/material";
3
  import { useSearchParams, Navigate } from "react-router-dom";
4
  import Intro from "../components/Intro";
5
  import EvaluationDisplay from "../components/EvaluationDisplay";
 
 
6
 
7
  function EvaluationDisplayPage() {
8
  const [searchParams] = useSearchParams();
9
  const sessionId = searchParams.get("session");
10
  const [isValidSession, setIsValidSession] = useState(true);
11
  const [isLoading, setIsLoading] = useState(true);
 
 
12
 
13
  useEffect(() => {
14
  if (!sessionId) {
@@ -64,10 +68,10 @@ function EvaluationDisplayPage() {
64
  ) : (
65
  <Box
66
  sx={{
67
- border: "1px solid rgba(0, 0, 0, 0.12)",
68
  borderRadius: 2,
69
  p: 4,
70
- bgcolor: "white",
71
  }}
72
  >
73
  <EvaluationDisplay sessionId={sessionId} />
 
3
  import { useSearchParams, Navigate } from "react-router-dom";
4
  import Intro from "../components/Intro";
5
  import EvaluationDisplay from "../components/EvaluationDisplay";
6
+ import { useThemeMode } from "../hooks/useThemeMode";
7
+ import getTheme from "../config/theme";
8
 
9
  function EvaluationDisplayPage() {
10
  const [searchParams] = useSearchParams();
11
  const sessionId = searchParams.get("session");
12
  const [isValidSession, setIsValidSession] = useState(true);
13
  const [isLoading, setIsLoading] = useState(true);
14
+ const { mode } = useThemeMode();
15
+ const theme = getTheme(mode);
16
 
17
  useEffect(() => {
18
  if (!sessionId) {
 
68
  ) : (
69
  <Box
70
  sx={{
71
+ border: `1px solid ${theme.palette.divider}`,
72
  borderRadius: 2,
73
  p: 4,
74
+ bgcolor: "background.paper",
75
  }}
76
  >
77
  <EvaluationDisplay sessionId={sessionId} />
frontend/src/pages/HomePage.jsx CHANGED
@@ -3,9 +3,13 @@ import { Box } from "@mui/material";
3
  import { useNavigate } from "react-router-dom";
4
  import Intro from "../components/Intro";
5
  import BenchmarkCreateForm from "../components/BenchmarkCreateForm";
 
 
6
 
7
  function HomePage() {
8
  const navigate = useNavigate();
 
 
9
 
10
  const handleStartGeneration = (sid, isDefaultDocument) => {
11
  navigate(
@@ -20,10 +24,10 @@ function HomePage() {
20
  <Intro />
21
  <Box
22
  sx={{
23
- border: "1px solid rgba(0, 0, 0, 0.12)",
24
  borderRadius: 2,
25
  p: 4,
26
- bgcolor: "white",
27
  }}
28
  >
29
  <BenchmarkCreateForm onStartGeneration={handleStartGeneration} />
 
3
  import { useNavigate } from "react-router-dom";
4
  import Intro from "../components/Intro";
5
  import BenchmarkCreateForm from "../components/BenchmarkCreateForm";
6
+ import { useThemeMode } from "../hooks/useThemeMode";
7
+ import getTheme from "../config/theme";
8
 
9
  function HomePage() {
10
  const navigate = useNavigate();
11
+ const { mode } = useThemeMode();
12
+ const theme = getTheme(mode);
13
 
14
  const handleStartGeneration = (sid, isDefaultDocument) => {
15
  navigate(
 
24
  <Intro />
25
  <Box
26
  sx={{
27
+ border: `1px solid ${theme.palette.divider}`,
28
  borderRadius: 2,
29
  p: 4,
30
+ bgcolor: "background.paper",
31
  }}
32
  >
33
  <BenchmarkCreateForm onStartGeneration={handleStartGeneration} />