From e37812e644716efb695deac5f15393a9d400bd8e Mon Sep 17 00:00:00 2001 From: Singa-pirate Date: Wed, 13 Nov 2024 20:46:49 +0800 Subject: [PATCH] Fix conflict due to refactor --- .../CodeContainer/CodeContainer.scss | 28 +++++++++++++++++++ .../CodeContainer/CodeContainer.tsx | 25 ++++++++++++++++- frontend/src/pages/CodeEditor/CodeEditor.scss | 27 ------------------ frontend/src/pages/CodeEditor/CodeEditor.tsx | 22 --------------- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/frontend/src/components/CodeContainer/CodeContainer.scss b/frontend/src/components/CodeContainer/CodeContainer.scss index d79486e9dd..8fc1bf73ce 100644 --- a/frontend/src/components/CodeContainer/CodeContainer.scss +++ b/frontend/src/components/CodeContainer/CodeContainer.scss @@ -59,4 +59,32 @@ overflow: hidden; } } + + .ai-hint-button { + position: fixed; + top: 20px; + left: 20px; + background-color: #2e2e2e; + border-radius: 20px; + padding: 10px 20px; + cursor: pointer; + display: flex; + align-items: center; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); + transition: + background-color 0.2s ease, + transform 0.2s ease; + z-index: 1000; + } + + .ai-hint-button:hover { + background-color: #373737; + transform: scale(1.05); + } + + .ai-hint-button .MuiTypography-root { + color: #fff; + font-size: 1rem; + margin-left: 8px; + } } diff --git a/frontend/src/components/CodeContainer/CodeContainer.tsx b/frontend/src/components/CodeContainer/CodeContainer.tsx index 153b0028ea..69c7ebf15a 100644 --- a/frontend/src/components/CodeContainer/CodeContainer.tsx +++ b/frontend/src/components/CodeContainer/CodeContainer.tsx @@ -17,9 +17,11 @@ import { useMainDialog } from "../../contexts/MainDialogContext"; import QuestionService from "../../services/question.service"; import { SessionContext } from "../../contexts/SessionContext"; import { UserContext } from "../../contexts/UserContext"; -import { Button } from "@mui/material"; +import { Button, Typography } from "@mui/material"; import { useNavigate } from "react-router-dom"; import "./CodeContainer.scss"; +import HintBox from "../HintBox/HintBox"; +import LightbulbIcon from "@mui/icons-material/Lightbulb"; const COLLABORATION_WEBSOCKET_URL = process.env.REACT_APP_COLLABORATION_SERVICE_URL as string; @@ -127,6 +129,8 @@ const CodeContainer: React.FC = ({ const codeRef = useRef(code); const languageRef = useRef(language); + const [isHintBoxExpanded, setIsHintBoxExpanded] = useState(false); + const [joinedRoom, setJoinedRoom] = useState(false); const [isExecuting, setIsExecuting] = useState(false); @@ -447,6 +451,25 @@ const CodeContainer: React.FC = ({ theme={okaidia} /> + + {/* Floating AI Hint Button */} + {!isHintBoxExpanded && ( +
setIsHintBoxExpanded(true)}> + + + AI Hint + +
+ )} + + {isHintBoxExpanded && questionData && ( + setIsHintBoxExpanded(false)} + code={code} // Pass the current code + language={language} // Pass the current language + /> + )} ); }; diff --git a/frontend/src/pages/CodeEditor/CodeEditor.scss b/frontend/src/pages/CodeEditor/CodeEditor.scss index 3314302dc0..39c86e7152 100644 --- a/frontend/src/pages/CodeEditor/CodeEditor.scss +++ b/frontend/src/pages/CodeEditor/CodeEditor.scss @@ -14,33 +14,6 @@ background: var(--Grey-10, #1a1a1a); } -.ai-hint-button { - position: fixed; - top: 20px; - left: 20px; - background-color: #2e2e2e; - border-radius: 20px; - padding: 10px 20px; - cursor: pointer; - display: flex; - align-items: center; - box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); - transition: - background-color 0.2s ease, - transform 0.2s ease; - z-index: 1000; -} - -.ai-hint-button:hover { - background-color: #373737; - transform: scale(1.05); -} - -.ai-hint-button .MuiTypography-root { - color: #fff; - font-size: 1rem; - margin-left: 8px; -} .buttons { margin: 10px; } diff --git a/frontend/src/pages/CodeEditor/CodeEditor.tsx b/frontend/src/pages/CodeEditor/CodeEditor.tsx index 548283cb1a..e733b4d708 100644 --- a/frontend/src/pages/CodeEditor/CodeEditor.tsx +++ b/frontend/src/pages/CodeEditor/CodeEditor.tsx @@ -2,9 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from "react"; import { Button, Typography } from "@mui/material"; import Chatbox from "../../components/Chatbox/Chatbox"; import VideoCall from "../../components/VideoCall/VideoCall"; -import HintBox from "../../components/HintBox/HintBox"; import VideoCallIcon from "@mui/icons-material/VideoCall"; -import LightbulbIcon from "@mui/icons-material/Lightbulb"; import ChatIcon from "@mui/icons-material/Chat"; import io, { Socket } from "socket.io-client"; import "./CodeEditor.scss"; @@ -39,7 +37,6 @@ const CodeEditor: React.FC = () => { const [customTestCases, setCustomTestCases] = useState([]); // States for UI display - const [isHintBoxExpanded, setIsHintBoxExpanded] = useState(false); const [isChatboxExpanded, setIsChatboxExpanded] = useState(false); const [isVideoCallExpanded, setIsVideoCallExpanded] = useState(false); const [hasNewChatMessage, setHasNewChatMessage] = useState(false); @@ -398,25 +395,6 @@ const CodeEditor: React.FC = () => { isAudioEnabled={isAudioEnabled} /> - - {/* Floating AI Hint Button */} - {!isHintBoxExpanded && ( -
setIsHintBoxExpanded(true)}> - - - AI Hint - -
- )} - - {isHintBoxExpanded && questionData && ( - setIsHintBoxExpanded(false)} - code={code} // Pass the current code - language={language} // Pass the current language - /> - )} ); };