From 15065241a4052ff8d1f7067d3b8b2b449ff3bebe Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:25:59 +0800 Subject: [PATCH 1/8] right pane finlaised --- peerprep/frontend/package-lock.json | 10 + peerprep/frontend/package.json | 1 + peerprep/frontend/src/App.tsx | 4 - peerprep/frontend/src/styles/App.css | 915 +----------------- .../CollabServiceIntegratedView.tsx | 388 ++++---- .../CollabServiceMainView.tsx | 70 -- peerprep/frontend/yarn.lock | 7 +- 7 files changed, 244 insertions(+), 1151 deletions(-) delete mode 100644 peerprep/frontend/src/views/CollabServiceViews/CollabServiceMainView.tsx diff --git a/peerprep/frontend/package-lock.json b/peerprep/frontend/package-lock.json index 176b30cabb..d2b78d705e 100644 --- a/peerprep/frontend/package-lock.json +++ b/peerprep/frontend/package-lock.json @@ -12,6 +12,7 @@ "@types/testing-library__react": "^10.2.0", "axios": "^1.7.7", "codemirror": "^5.65.18", + "lucide-react": "^0.456.0", "openai": "^4.71.0", "react": "^18.3.1", "react-chatbotify": "^2.0.0-beta.22", @@ -5533,6 +5534,15 @@ "license": "MIT", "optional": true }, + "node_modules/lucide-react": { + "version": "0.456.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.456.0.tgz", + "integrity": "sha512-DIIGJqTT5X05sbAsQ+OhA8OtJYyD4NsEMCA/HQW/Y6ToPQ7gwbtujIoeAaup4HpHzV35SQOarKAWH8LYglB6eA==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" + } + }, "node_modules/lz-string": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", diff --git a/peerprep/frontend/package.json b/peerprep/frontend/package.json index ef047fd9dc..52fe89e7e6 100644 --- a/peerprep/frontend/package.json +++ b/peerprep/frontend/package.json @@ -15,6 +15,7 @@ "@types/testing-library__react": "^10.2.0", "axios": "^1.7.7", "codemirror": "^5.65.18", + "lucide-react": "^0.456.0", "openai": "^4.71.0", "react": "^18.3.1", "react-chatbotify": "^2.0.0-beta.22", diff --git a/peerprep/frontend/src/App.tsx b/peerprep/frontend/src/App.tsx index 1d55b1c669..462fd5581a 100644 --- a/peerprep/frontend/src/App.tsx +++ b/peerprep/frontend/src/App.tsx @@ -28,7 +28,6 @@ import SignUp from './views/UserServiceViews/SignUp'; // Import the new SignUp c import QuestionService from './views/QuestionServiceViews/QuestionManagement'; import MatchingService from './views/MatchingServiceViews/MatchingServiceMainView'; import SessionStubView from './views/MatchingServiceViews/SessionStubView'; -import CollaborationServiceView from './views/CollabServiceViews/CollabServiceMainView'; import CollaborationServiceIntegratedView from './views/CollabServiceViews/CollabServiceIntegratedView'; const App: React.FC = () => { @@ -47,9 +46,6 @@ const App: React.FC = () => { {/* Public Route for Session View (Stub for now) */} } /> - {/* Public Route for Collaboration Service View without sockets*/} - } /> - {/* Public Route for Collaboration Service Integrated View */} } /> diff --git a/peerprep/frontend/src/styles/App.css b/peerprep/frontend/src/styles/App.css index 7e5dda6b37..3efd0a382d 100644 --- a/peerprep/frontend/src/styles/App.css +++ b/peerprep/frontend/src/styles/App.css @@ -1,911 +1,10 @@ -#root { - margin: 0 auto; - padding: 5rem; - text-align: center; - background-color: white; - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - color-scheme: light dark; - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; +.react-codemirror2 { + overflow: auto; + height: 100%; + width: 100%; } -/* Global Styling */ -body { - background-color: white; - color: black; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - color: white; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} - -h1 { - font-size: 32px; - color: black; - line-height: 1.1; -} - -h2 { - font-size: 24px; - color: black; -} - -/* Container uses flexbox for split layout -.container { - display: flex; - justify-content: space-between; - gap: 20px; -} */ - -.question-container { - display: flex; - justify-content: space-between; - gap: 20px; -} - -.login-container { - display: flex; - justify-content: space-between; - gap: 20px; -} - -.signup-container { - display: flex; - justify-content: space-between; - gap: 20px; -} - -/* Left panel for form and question list, using grid */ -.left-panel { - display: grid; - grid-template-rows: auto 1fr; /* Independent sizing for form and list */ - gap: 20px; /* Add space between form and list */ - max-width: 65%; /* Custom max width for the left panel, 65% is around 2-thrids*/ - padding: 20px; -} - -/* Right panel for detailed view */ -.right-panel { - flex: 1; - max-width: 35%; - padding: 20px; - background-color: white; - border: 2px solid #ccc; /* light grey border */ - border-radius: 10px; /* Rounded corners */ - box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ - margin-left: 20px; /* Add some space between left and right panels */ -} - -.form-section { - max-width: 100%; /* Adjust width of the form, set smaller than 100 for aesthetics */ - text-align: center; /* Center the content inside */ - margin: 0 auto; /* Center the form horizontally */ - padding: 0; - border: none; - background-color: transparent; - box-shadow: none; -} - -/* List section can expand independently of the form-section */ -.list-section { - max-width: 100%; -} - - -/* Adjust questions table layout */ -.question-table { - width: 100%; - table-layout: fixed; - border-collapse: collapse; -} - -/* Ensure all table cells have consistent borders */ -.question-table th, .question-table td { - border: 1px solid #ccc; - padding: 8px; - vertical-align: top; - text-align: left; - box-sizing: border-box; -} - -.question-table tr:hover { - background-color: #f1f1f1; -} - -/* Limit the description cell height in the table */ -.description-cell { - min-height: 100%; - display: -webkit-box; - -webkit-line-clamp: 3; /* Limit to 3 lines, afterwhich text will truncate */ - line-clamp: 3; - -webkit-box-orient: vertical; - overflow: hidden; - text-overflow: ellipsis; - white-space: normal; - border: none; - box-sizing: border-box; - padding: 8px; -} - -/* General Form Styles */ -.question-form { - padding: 20px; - max-width: 100%; - margin: 0 auto; /* Center the form */ - border: 2px solid #ccc; /* form border */ - border-radius: 10px; /* Rounded corners for the form */ - background-color: white; - box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ -} - -/* Styles for inputs, textarea, and select within .question-form */ -.question-form input, -.question-form textarea, -.question-form select { - width: 100%; - padding: 10px; - margin-top: 5px; /* Space between input boxes */ - border: 1px solid #ccc; /* Border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f4f4f4; - color: #333; - font-size: 16px; - box-sizing: border-box; /* Ensures padding is included within the width */ -} - -/* Input Fields Focus State */ -.question-form input:focus, -.question-form textarea:focus, -.question-form select:focus { - outline: none; - border: 2px solid #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Custom styling for the difficulty select dropdown */ -.question-form select { - width: 100%; - padding: 10px; - margin-top: 5px; - border: 2px solid #ccc; /* border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f9f9f9; - color: #333; - font-size: 16px; - appearance: none; -} - -/* Focus state for select dropdown */ -.question-form select:focus { - outline: none; - border-color: #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Submit Button */ -.question-form button.submit-btn { - background-color: #4CAF50; - color: white; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - font-size: 16px; - margin-top: 10px; -} - -.question-form button.submit-btn:hover { - background-color: #45a049; -} - -/* Error Message styling, to be expanded later most likely split into diff types */ -.question-form .error-message { - color: red; - font-size: 14px; - margin-bottom: 15px; - text-align: center; -} - -/* Adjust spacing and alignment for category checkboxes */ -.category-group label { - display: inline-block; /* label and input stay on same line */ - margin-right: 15px; /* spacing between each checkbox and label */ - margin-bottom: 5px; /* Control vertical spacing */ - font-size: 16px; /* Adjust font size to match rest of the form */ -} - -.category-group input { - margin-right: 5px; - vertical-align: middle; /* Align checkbox vertically with the text */ -} - -/* Style the buttons inside table cells */ -.question-table .edit-btn { - display: block; - width: 100%; - box-sizing: border-box; - margin-bottom: 5px; - padding: 8px; - border-radius: 4px; - background-color: #007bff; /* Blue color for Edit button */ - color: white; - border: none; - cursor: pointer; -} - -/* Red color for Delete button */ -.question-table .delete-btn { - display: block; - width: 100%; - box-sizing: border-box; - margin-bottom: 5px; - padding: 8px; - border-radius: 4px; - background-color: #dc3545; /* Red color for Delete button */ - color: white; - border: none; - cursor: pointer; -} - -/* Hover effect for Edit button */ -.question-table .edit-btn:hover { - background-color: #0056b3; /* Darker blue on hover */ -} - -/* Hover effect for Delete button */ -.question-table .delete-btn:hover { - background-color: #c82333; /* Darker red on hover */ -} - - -/* MATCHING FORM VIEWS */ - -/* Container to center the form */ -.matching-container { - display: flex; - justify-content: center; - align-items: center; - - padding: 20px; -} - -.matching-form { - padding: 20px; - max-width: 100%; - margin: 0 auto; /* Center the form */ - border: 2px solid #ccc; /* form border */ - border-radius: 10px; /* Rounded corners for the form */ - background-color: white; - box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ -} - -/* Styles for inputs, textarea, and select within .question-form */ -.matching-form input, -.matching-form textarea, -.matching-form select { - width: 100%; - padding: 10px; - margin-top: 5px; /* Space between input boxes */ - border: 1px solid #ccc; /* Border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f4f4f4; - color: #333; - font-size: 16px; - box-sizing: border-box; /* Ensures padding is included within the width */ -} - -/* Input Fields Focus State */ -.matching-form input:focus, -.matching-form textarea:focus, -.matching-form select:focus { - outline: none; - border: 2px solid #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Custom styling for the difficulty select dropdown */ -.matching-form select { - width: 100%; - padding: 10px; - margin-top: 5px; - border: 2px solid #ccc; /* border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f9f9f9; - color: #333; - font-size: 16px; - appearance: none; -} - -/* Focus state for select dropdown */ -.matching-form select:focus { - outline: none; - border-color: #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Submit Button */ -.matching-form button.submit-btn { - background-color: #4CAF50; - color: white; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - font-size: 16px; - margin-top: 10px; -} - -.matching-form button.submit-btn:hover { - background-color: #45a049; -} - -/* Error Message styling, to be expanded later most likely split into diff types */ -.matching-form .error-message { - color: red; - font-size: 14px; - margin-bottom: 15px; - text-align: center; -} - -/* Position the link in the top right corner */ -.top-left-link { - position: absolute; - top: 20px; - left: 100px; - text-decoration: none; - color: #4CAF50; /* Green color */ - font-weight: bold; -} - -.top-left-link:hover { - color: #45a049; /* Slightly darker green on hover */ -} - -/* Position the link in the top right corner */ -.top-right-link { - position: absolute; - top: 20px; - right: 100px; - text-decoration: none; - color: #4CAF50; /* Green color */ - font-weight: bold; -} - -.top-right-link:hover { - color: #45a049; /* Slightly darker green on hover */ -} - -/* Position the link in the top right corner */ -.centers-link { - position: absolute; - top: 20px; - right: 100px; - text-decoration: none; - color: #4CAF50; /* Green color */ - font-weight: bold; -} - -.centers-link:hover { - color: #45a049; /* Slightly darker green on hover */ -} - -.center-link { - position: absolute; - top: 80%; - left: 50%; - transform: translate(-50%, -50%); - text-decoration: none; - color: #4CAF50; /* Green color */ - font-weight: bold; - font-size: 18px; - padding: 10px 20px; - border: 2px solid #4CAF50; - border-radius: 5px; - transition: background-color 0.3s, color 0.3s; - cursor: pointer; -} - -.center-link:hover { - background-color: #4CAF50; - color: white; -} - -/* LOGIN FORM STYLES */ - -.login-form { - width: 100%; - max-width: 400px; - min-width: 400px; - padding: 30px; - border: 2px solid #ccc; - border-radius: 12px; - background-color: white; - box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.1); - text-align: center; -} - -/* Input field styling */ -.login-form input { - width: 100%; - padding: 12px; - margin-top: 10px; - border: 1px solid #ccc; - border-radius: 6px; - background-color: #f4f4f4; - font-size: 16px; - color: black; - box-sizing: border-box; -} - -/* Focus state for input fields */ -.login-form input:focus { - outline: none; - border-color: #4CAF50; - color: black; - background-color: white; -} - -/* Primary button styling */ -.submit-btn { - width: 100%; - padding: 12px; - margin-top: 15px; - background-color: #4CAF50; - color: white; - border: none; - border-radius: 6px; - font-size: 18px; - cursor: pointer; -} - -.submit-btn:hover { - background-color: #45a049; -} - -/* Alternative button styling */ -.alt-btn { - width: 100%; - padding: 12px; - margin-top: 10px; - background-color: #333; - color: white; - border: none; - border-radius: 6px; - font-size: 18px; - cursor: pointer; -} - -.alt-btn:hover { - background-color: #444; -} - -/* Error message styling */ -.error-message { - color: red; - margin-top: 10px; -} - -/* Link styling */ -.link { - color: #4CAF50; - text-decoration: none; -} - -.link:hover { - text-decoration: underline; -} - -.progress-bar-container { - width: 100%; - height: 10px; - background-color: #f3f3f3; - border-radius: 5px; - margin-top: 10px; -} - -.progress-bar { - height: 100%; - background-color: #4caf50; - width: 0%; - border-radius: 5px; - transition: width 1s ease-in-out; -} - -.status-message { - margin-top: 10px; - font-size: 16px; - color: #333; - font-weight: bold; -} - -/* Ensure the container takes up the full page */ -.editor-container-parent { - display: flex; - flex-direction: column; - justify-content: space-between; /* Adjust layout */ - align-items: center; - - height: 85vh; /* Full height of the viewport */ - width: 80vw; /* Full width of the viewport */ - - overflow-y: scroll; - overflow-x: hidden; - background-color: white; - padding: 20px; - box-sizing: border-box; /* Include padding in width and height calculations */ - scrollbar-width: none; -} - -/* Hide scrollbar for Webkit browsers (Chrome, Safari) */ -.editor-container-parent::-webkit-scrollbar { - display: none; -} - -.CodeMirror { - min-height: 1000px; - width: 100%; -} - -.code-and-chat { - display: flex; - width: 100%; - height: 100%; - max-width: 900px; - max-height: 200px; - min-height: 200px; - flex-grow: 1; - position: relative; -} - -.editor-container { - width: 70%; - height: 100%; - max-width: 900px; - max-height: 200px; - min-height: 200px; - flex-grow: 1; - border: 2px solid #ccc; - border-radius: 10px; - box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); - background-color: white; - color: white; - - /* Add these properties */ - overflow-y: auto; - text-align: left; /* Ensure text aligns to the left */ - vertical-align: top; /* Ensures text starts from the top */ -} - -/* Hide scrollbar for Webkit browsers (Chrome, Safari) */ -.editor-container::-webkit-scrollbar { - display: none; -} - -/* Hide scrollbar for Firefox */ -.editor-container { - scrollbar-width: none; /* Firefox */ -} - -.chat-box { - width: 30%; - display: flex; - flex-direction: column; - height: 100%; - max-height: 200px; - min-height: 100px; - border: 2px solid #ccc; - border-radius: 10px; - box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); - background-color: white; - color: black; /* Changed to black for better readability */ -} - -.chat-heading{ - margin: 1px; -} - -.messages { - font-size: small; - flex-grow: 1; - overflow-y: auto; - padding: 5px; -} - -.message { - margin-bottom: 5px; - padding: 3px; - padding-left: 5px; - border-radius: 5px; - max-width: 60%; - overflow-x: scroll; - display: flex; -} - -.sent { - background-color: #dcf8c6; - align-self: flex-end; - margin-left: auto; -} - -.received { - background-color: #f1f0f0; - align-self: flex-start; - margin-right: auto; -} - -.input-container { - display: flex; - background-color: white; - padding-left: 2px; - padding-right: 2px; - padding-bottom: 2px; -} - -input { - flex-grow: 1; - padding: 5px; - border: 1px solid #ccc; - border-radius: 5px; - background-color: white; - margin-right: 2px; - color: black; - min-width: 0px; -} - -.sendBtn { - padding: 5px 10px; - border: none; - background-color: #007bff; - color: white; - border-radius: 5px; - cursor: pointer; - font-size: small; -} - -.sendBtn:hover { - background-color: #0056b3; -} - -/* Header section styling */ -.editor-header { - text-align: center; - margin-bottom: -10px; - margin-top: -45px; -} - -.leave-btn, -.run-btn { - margin-top: 10px; /* Additional spacing if needed for each button */ -} - -#language-select { - margin-bottom: 20px; -} - -/* Leave session button */ -.leave-btn { - background-color: #ff4d4d; - color: white; - border: none; - border-radius: 6px; - padding: 10px 20px; - cursor: pointer; - margin-top: 10px; -} - -.leave-btn:hover { - background-color: #ff1a1a; -} - -/* Styles for the collaborative cursor to look like a blinking bar */ -.CodeMirror-cursor { - position: absolute; - width: 2px; - background-color: blue; /* Adjust the color per user */ - opacity: 0.8; - animation: blink 1s step-end infinite; /* Blinking effect */ -} - -.CodeMirror-cursor { - border-left: 1px solid white; - border-right: 1px solid black; -} - -/* Styles for the label (optional) */ -.CodeMirror-cursor-label { - position: absolute; - background-color: orange; - color: white; - padding: 2px 5px; - border-radius: 3px; - font-size: 12px; - top: -20px; -} - -/* Blinking animation */ -@keyframes blink { - from, to { - opacity: 0; - } - 50% { - opacity: 1; - } -} - -.editor-header2 { - text-align: center; - margin-bottom: 20px; - margin-top: 10px; - display: flex; - flex-direction: row; /* Arrange items in a vertical stack */ - align-items: center; /* Align items to the left */ - gap: 60px; /* Add vertical spacing between items */ -} - -.matching-form2 { - padding: 0px; - max-width: 40%; - min-width: 18%; - margin: 0 auto; /* Center the form */ - border-radius: 10px; /* Rounded corners for the form */ - background-color: white; -} - -/* Styles for inputs, textarea, and select within .question-form */ -.matching-form2 input, -.matching-form2 textarea, -.matching-form2 select { - width: 100%; - padding: 10px; - margin-top: 5px; /* Space between input boxes */ - border: 1px solid #ccc; /* Border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f4f4f4; - color: #333; - font-size: 16px; - box-sizing: border-box; /* Ensures padding is included within the width */ -} - -/* Input Fields Focus State */ -.matching-form2 input:focus, -.matching-form2 textarea:focus, -.matching-form2 select:focus { - outline: none; - border: 2px solid #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Custom styling for the difficulty select dropdown */ -.matching-form2 select { - width: 100%; - padding: 10px; - margin-top: 5px; - border: 2px solid #ccc; /* border */ - border-radius: 4px; /* Rounded corners */ - background-color: #f9f9f9; - color: #333; - font-size: 16px; - appearance: none; -} - -/* Focus state for select dropdown */ -.matching-form2 select:focus { - outline: none; - border-color: #4CAF50; /* Green border on focus */ - background-color: #fff; /* White background on focus */ -} - -/* Submit Button */ -.matching-form2 button.submit-btn { - background-color: #4CAF50; - color: white; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - font-size: 16px; - margin-top: 10px; -} - -.matching-form2 button.submit-btn:hover { - background-color: #45a049; -} - -/* Error Message styling, to be expanded later most likely split into diff types */ -.matching-form2 .error-message { - color: red; - font-size: 14px; - margin-bottom: 15px; - text-align: center; -} - -.output-container{ - overflow-y: scroll; - min-height: 50px; - max-height: 100px; - max-width: 900px; -} - -/* Hide scrollbar for Webkit browsers (Chrome, Safari) */ -.output-container::-webkit-scrollbar { - display: none; -} - -/* Hide scrollbar for Firefox */ -.output-container { - scrollbar-width: none; /* Firefox */ -} - -.testcases-table { - margin: 20px auto; /* Center the table horizontally */ - max-width: 900px; /* Set max width */ - width: 100%; /* Allow the table to expand to max-width */ -} - -.testcases-table table { - border-collapse: collapse; - border: 2px solid #333 !important; /* Outer border around the table */ - text-align: center; - width: 100%; /* Ensure the table fills the container width */ -} - - -.testcases-table th, .testcases-table td { - border: 1px solid #333 !important; /* Border around each cell */ - padding: 8px; -} - -.testcases-table th { - background-color: #f2f2f2; - font-weight: bold; -} - -.testcases-table td { - background-color: #fff; +.CodeMirror{ + height: 100%; + width: 100%; } diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index b61129ff0e..1a4c1e3946 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -4,6 +4,7 @@ import { useParams, useNavigate } from 'react-router-dom'; import axios from 'axios'; import * as Y from 'yjs'; import Chat from './components/Chat.tsx'; +import { GripVertical, GripHorizontal, Code2 } from 'lucide-react'; import 'codemirror/lib/codemirror.css'; import 'codemirror/theme/material.css'; @@ -22,7 +23,7 @@ import { assessCode } from '../../api/assesscodeApi.ts'; import { CodemirrorBinding } from 'y-codemirror'; import { WebsocketProvider } from 'y-websocket'; -import { deleteMatchedSession} from "../../api/matchingApi.ts"; +import { deleteMatchedSession } from "../../api/matchingApi.ts"; import { getQuestionById } from '../../api/questionApi.ts'; const CollaborationServiceIntegratedView: React.FC = () => { @@ -34,14 +35,6 @@ const CollaborationServiceIntegratedView: React.FC = () => { const editorRef = useRef(null); const navigate = useNavigate(); const [yText, setYText] = useState(null); - - // const [commentoutput, setCommentOutput] = useState(null); - // console.log(commentoutput); - - //let topic = 'topic'; - //let difficulty = 'difficulty'; - // Declare question object - //extract questionID from session id (eg. 670d81daf90653ef4b9162b8-67094dcc6be97361a2e7cb1a-1730832550120-Q672890c43266d81a769bfaee) const [input1, setInput1] = useState('N/A'); const [output1, setOutput1] = useState('N/A'); const [input2, setInput2] = useState('N/A'); @@ -53,6 +46,58 @@ const CollaborationServiceIntegratedView: React.FC = () => { console.log("session id is " + sessionId); const questionId = sessionId ? sessionId.split('-Q')[1] : "N/A"; + const [leftPaneWidth, setLeftPaneWidth] = useState(35); + const [codeEditorHeight, setCodeEditorHeight] = useState(90); + + interface ResizeEvent extends MouseEvent { + clientX: number; + } + interface VerticalResizeEvent extends MouseEvent { + clientY: number; + } + interface ContainerRect { + left: number; + width: number; + top: number; + height: number; + } + + const handleHorizontalResize = (e: React.MouseEvent): void => { + const container = e.currentTarget.parentElement as HTMLDivElement; + const containerRect: ContainerRect = container.getBoundingClientRect(); + + const handleResize = (moveEvent: ResizeEvent): void => { + const newWidth = ((moveEvent.clientX - containerRect.left) / containerRect.width) * 100; + setLeftPaneWidth(Math.min(Math.max(20, newWidth), 80)); // Limit between 20% and 80% + }; + + const removeListeners = (): void => { + document.removeEventListener('mousemove', handleResize); + document.removeEventListener('mouseup', removeListeners); + }; + + document.addEventListener('mousemove', handleResize); + document.addEventListener('mouseup', removeListeners); + }; + + const handleVerticalResize = (e: React.MouseEvent): void => { + const container = e.currentTarget.parentElement as HTMLDivElement; + const containerRect: ContainerRect = container.getBoundingClientRect(); + + const handleResize = (moveEvent: VerticalResizeEvent): void => { + const newHeight = ((moveEvent.clientY - containerRect.top) / containerRect.height) * 100; + setCodeEditorHeight(Math.min(Math.max(30, newHeight), 90)); // Limit between 30% and 90% + }; + + const removeListeners = (): void => { + document.removeEventListener('mousemove', handleResize); + document.removeEventListener('mouseup', removeListeners); + }; + + document.addEventListener('mousemove', handleResize); + document.addEventListener('mouseup', removeListeners); + }; + //set topic, difficulty, questionId by calling the API useEffect(() => { const fetchData = async () => { @@ -85,13 +130,6 @@ const CollaborationServiceIntegratedView: React.FC = () => { console.log(`Session ID: ${sessionId}, Topics: ${topics}, Difficulty: ${difficulty}`); }, [sessionId, topics, difficulty, questionId]); - useEffect(() => { - document.body.style.overflow = 'hidden'; - return () => { - document.body.style.overflow = 'auto'; - }; - }, []); - useEffect(() => { const ydoc = new Y.Doc(); const provider = new WebsocketProvider('ws://localhost:1234/' + sessionId, 'collaborative-doc', ydoc); @@ -126,14 +164,14 @@ const CollaborationServiceIntegratedView: React.FC = () => { setSyntaxFullLang(e.target.textContent!); setSyntaxLang( e.target.value === '63' ? 'javascript' - : e.target.value === '54' ? 'text/x-c++src' - : e.target.value === '50' ? 'text/x-csrc' - : e.target.value === '71' ? 'python' - : e.target.value === '62' ? 'text/x-java' - : e.target.value === '72' ? 'ruby' - : e.target.value === '51' ? 'text/x-csharp' // New language - : e.target.value === '78' ? 'text/x-kotlin' // New language - : 'javascript' + : e.target.value === '54' ? 'text/x-c++src' + : e.target.value === '50' ? 'text/x-csrc' + : e.target.value === '71' ? 'python' + : e.target.value === '62' ? 'text/x-java' + : e.target.value === '72' ? 'ruby' + : e.target.value === '51' ? 'text/x-csharp' // New language + : e.target.value === '78' ? 'text/x-kotlin' // New language + : 'javascript' ); }; @@ -197,6 +235,7 @@ const CollaborationServiceIntegratedView: React.FC = () => { console.error('Error executing code:', error); setOutput('Error executing code'); } + setCodeEditorHeight(50); }; const handleAssessCode = async () => { @@ -221,164 +260,177 @@ const CollaborationServiceIntegratedView: React.FC = () => { console.error('Error executing OpenAI API call:', error); setOutput('Error executing code'); } + setCodeEditorHeight(50); }; return ( -
-
-

Collaboration Session

-

Topics: {topics} | Difficulty: {difficulty} | Question: {questionTitle}

-

Description: {questionDescription}

-
+
+
+
+
+

Q. {questionTitle}

+ +
+ {topics && ( + + {topics} + + )} + {difficulty && ( + + {difficulty} + + )} +
+ +

{questionDescription}

+
-
- - -
-
- +
+

Test Cases

+
+ + + + + + + + + + + + + + + + + +
Input 1Output 1Input 2Output 2
{input1}{output1}{input2}{output2}
+
-
- - -
-
-
- { - editor.on('keyup', (cm: any, event: any) => { - // Only trigger autocomplete on specific characters - const triggerKeys = /^[a-zA-Z0-9_]$/; // Allow letters, numbers, and underscore - if ( - triggerKeys.test(event.key) && - !cm.state.completionActive // Ensure that completion is not already active - ) { - cm.showHint({ completeSingle: false }); - } - }); - }} - onChange={() => { - // Let Yjs handle all updates; do not use setCode here - }} - /> + {sessionId && }
- {sessionId && } -
-

Output

-
- -
{output}
+
+
- {/*
-
{commentoutput}
-
*/} - -
-

Test Cases

- - - - - - - - - - - - - - - - - -
Input 1Output 1Input 2Output 2
{input1}{output1}{input2}{output2}
-
-
- ); -}; -export default CollaborationServiceIntegratedView; - -/** Sample code snippets in different languages for testing */ -/** TO BE USED FOR INTERNAL TESTING WHERE REQUIRED */ -/* -KOTLIN -fun greet(name: String) { - println("Hello, $name!") -} - -fun main() { - greet("World") -} +
+
+
+
+ +

Code

+
+ +
+
+
+ +
+ ⌄ +
+
+ + +
+ + +
-C# -using System; +
-class Program { - static void Greet(string name) { - Console.WriteLine("Hello, " + name + "!"); - } +
+ { + editor.on('keyup', (cm: any, event: any) => { + // Only trigger autocomplete on specific characters + const triggerKeys = /^[a-zA-Z0-9_]$/; // Allow letters, numbers, and underscore + if ( + triggerKeys.test(event.key) && + !cm.state.completionActive // Ensure that completion is not already active + ) { + cm.showHint({ completeSingle: false }); + } + }); + }} + onChange={() => { + // Let Yjs handle all updates; do not use setCode here + }} + /> +
+
- static void Main() { - Greet("World"); - } -} +
+ +
-RUBY -def greet(name) - puts "Hello, #{name}!" -end +
+
+

Output

+
{output}
+
+
+
+
+ ); +}; -greet("World") -*/ +export default CollaborationServiceIntegratedView; \ No newline at end of file diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceMainView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceMainView.tsx deleted file mode 100644 index e25177c102..0000000000 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceMainView.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import { Controlled as CodeMirror } from 'react-codemirror2'; // CodeMirror component -import { useParams, useNavigate } from 'react-router-dom'; // For routing and session handling -import 'codemirror/lib/codemirror.css'; // Default CodeMirror styles -import 'codemirror/theme/material.css'; // CodeMirror theme -import 'codemirror/mode/javascript/javascript'; // Support for JavaScript mode - -interface CollaborationServiceViewProps { - topic: string; - difficulty: string; - sessionId: string; -} - -const CollaborationServiceView: React.FC = ({ topic, difficulty, sessionId }) => { - const [code, setCode] = useState('// Start coding here...\n'); - const [users, setUsers] = useState([]); // Placeholder for active users - const navigate = useNavigate(); // For navigation - - useEffect(() => { - // Assume we later use WebSocket or Socket.io to sync code - console.log(`Session ID: ${sessionId}, Topic: ${topic}, Difficulty: ${difficulty}`); - }, [sessionId, topic, difficulty]); - - - useEffect(() => { - // Lock scroll when this component mounts - document.body.style.overflow = 'hidden'; - - // Cleanup function to unlock scroll when component unmounts - return () => { - document.body.style.overflow = 'auto'; - }; - }, []); - - const handleCodeChange = (editor: any, data: any, value: string) => { - setCode(value); // Update local code state - // TODO: Later sync this code change with the backend using WebSocket/Socket.io - }; - - const handleLeaveSession = () => { - navigate('/matching'); // Navigate back to home on session exit - }; - - return ( -
-
-

Collaboration Session

-

Topic: {topic} | Difficulty: {difficulty}

-

Session ID: {sessionId}

- -
- -
- -
-
- ); -}; - -export default CollaborationServiceView; \ No newline at end of file diff --git a/peerprep/frontend/yarn.lock b/peerprep/frontend/yarn.lock index f34c413100..5546981db3 100644 --- a/peerprep/frontend/yarn.lock +++ b/peerprep/frontend/yarn.lock @@ -2904,6 +2904,11 @@ ltgt@^2.1.2: resolved "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz" integrity sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA== +lucide-react@^0.456.0: + version "0.456.0" + resolved "https://registry.npmjs.org/lucide-react/-/lucide-react-0.456.0.tgz" + integrity sha512-DIIGJqTT5X05sbAsQ+OhA8OtJYyD4NsEMCA/HQW/Y6ToPQ7gwbtujIoeAaup4HpHzV35SQOarKAWH8LYglB6eA== + lz-string@^1.5.0: version "1.5.0" resolved "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz" @@ -3383,7 +3388,7 @@ react-router@6.26.2: dependencies: "@remix-run/router" "1.19.2" -react@^18.0.0, react@^18.3.1, "react@>=15.5 <=18.x", "react@>=16.14.0 <20.0.0 || ^19.0.0-0", react@>=16.8: +"react@^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc", react@^18.0.0, react@^18.3.1, "react@>=15.5 <=18.x", "react@>=16.14.0 <20.0.0 || ^19.0.0-0", react@>=16.8: version "18.3.1" resolved "https://registry.npmjs.org/react/-/react-18.3.1.tgz" integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ== From ec1a209c0c1f42a74355e146fd6f41bc8cfbd22e Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:06:52 +0800 Subject: [PATCH 2/8] left pane fixed --- .../CollabServiceIntegratedView.tsx | 136 +++++++++++------- 1 file changed, 84 insertions(+), 52 deletions(-) diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index 1a4c1e3946..c08d6f67c2 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -48,6 +48,8 @@ const CollaborationServiceIntegratedView: React.FC = () => { const [leftPaneWidth, setLeftPaneWidth] = useState(35); const [codeEditorHeight, setCodeEditorHeight] = useState(90); + const [chatHeight, setChatHeight] = useState(80); + interface ResizeEvent extends MouseEvent { clientX: number; @@ -55,6 +57,10 @@ const CollaborationServiceIntegratedView: React.FC = () => { interface VerticalResizeEvent extends MouseEvent { clientY: number; } + + interface ChatResizeEvent extends MouseEvent { + clientY: number; + } interface ContainerRect { left: number; width: number; @@ -98,6 +104,24 @@ const CollaborationServiceIntegratedView: React.FC = () => { document.addEventListener('mouseup', removeListeners); }; + const handleChatResize = (e: React.MouseEvent): void => { + const container = e.currentTarget.parentElement as HTMLDivElement; + const containerRect: ContainerRect = container.getBoundingClientRect(); + + const handleResize = (moveEvent: ChatResizeEvent): void => { + const newHeight = ((moveEvent.clientY - containerRect.top) / containerRect.height) * 100; + setChatHeight(Math.min(Math.max(40, newHeight), 90)); + }; + + const removeListeners = (): void => { + document.removeEventListener('mousemove', handleResize); + document.removeEventListener('mouseup', removeListeners); + }; + + document.addEventListener('mousemove', handleResize); + document.addEventListener('mouseup', removeListeners); + }; + //set topic, difficulty, questionId by calling the API useEffect(() => { const fetchData = async () => { @@ -265,66 +289,74 @@ const CollaborationServiceIntegratedView: React.FC = () => { return (
-
-
-
-

Q. {questionTitle}

- -
- {topics && ( - - {topics} - - )} - {difficulty && ( - - {difficulty} - - )} -
- -

{questionDescription}

+
+
+

Q. {questionTitle}

+ +
+ {topics && ( + + {topics} + + )} + {difficulty && ( + + {difficulty} + + )}
+

{questionDescription}

+
-

Test Cases

-
- - - - - - - - - - - - - - - - - -
Input 1Output 1Input 2Output 2
{input1}{output1}{input2}{output2}
+

Test Cases

+ +
+

Test Case 1:

+

+ Input: {input1} +

+

+ Output: {output1} +

-
- {sessionId && } +
+

Test Case 2:

+

+ Input: {input2} +

+

+ Output: {output2} +

+
+
+ + {/* Chat section fixed at the bottom */} + {sessionId && (<> +
+ +
+
+ +
+ + )}
-
+ +
-
+
-
+

Code

@@ -356,7 +388,7 @@ const CollaborationServiceIntegratedView: React.FC = () => {
- ⌄ + ⌄
@@ -414,14 +446,14 @@ const CollaborationServiceIntegratedView: React.FC = () => {
-
-

Output

From 35beaec1cdb9365de2fef543c8095232d86d7019 Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:29:51 +0800 Subject: [PATCH 3/8] fixed Chat component styling --- .../CollabServiceIntegratedView.tsx | 4 +- .../CollabServiceViews/components/Chat.tsx | 63 ++++++++++++++----- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index c08d6f67c2..fe383d180d 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -48,7 +48,7 @@ const CollaborationServiceIntegratedView: React.FC = () => { const [leftPaneWidth, setLeftPaneWidth] = useState(35); const [codeEditorHeight, setCodeEditorHeight] = useState(90); - const [chatHeight, setChatHeight] = useState(80); + const [chatHeight, setChatHeight] = useState(70); interface ResizeEvent extends MouseEvent { @@ -341,7 +341,7 @@ const CollaborationServiceIntegratedView: React.FC = () => { >
-
+
diff --git a/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx b/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx index 28452bd9ba..3b567ddbd5 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import io from 'socket.io-client'; const socket = io('http://localhost:1234', { @@ -15,6 +15,7 @@ const Chat: React.FC = ({ sessionId }) => { const [message, setMessage] = useState(''); const [messages, setMessages] = useState<{ text: string; sender: boolean }[]>([]); const [connectionError, setConnectionError] = useState(null); + const messagesEndRef = useRef(null); const joinRoom = () => { if (room !== '') { @@ -24,12 +25,12 @@ const Chat: React.FC = ({ sessionId }) => { const sendMessage = () => { if (!message) return; // Checking if there's a message to send - + const messageData = { message, room, senderId: socket.id }; - + setMessages((prevMessages) => [...prevMessages, { text: message, sender: true }]); setMessage(''); - + socket.emit('send_message', messageData, (ackError: string | null) => { if (ackError) { setConnectionError("Failed to send message. Please try again."); @@ -37,7 +38,13 @@ const Chat: React.FC = ({ sessionId }) => { } }); }; - + + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + e.preventDefault(); + sendMessage(); + } + }; useEffect(() => { joinRoom(); // Automatically join the room based on sessionId @@ -68,28 +75,52 @@ const Chat: React.FC = ({ sessionId }) => { }; }, [room]); + useEffect(() => { + if (messagesEndRef.current) { + messagesEndRef.current.scrollIntoView({ behavior: 'smooth' }); + } + }, [messages]); + return ( -
-

Chat

- {connectionError &&
{connectionError}
} -
- {messages.map((msg, index) => ( -
+
+

Chat

+ + {connectionError && ( +
{connectionError}
+ )} + +
+ {messages.map((msg, index) => (<> +
{msg.text}
+
+ ))}
-
+ +
{ - setMessage(event.target.value); - }} + onChange={(e) => setMessage(e.target.value)} + onKeyDown={handleKeyDown} + className="flex-grow border border-gray-300 text-sm rounded-md bg-white text-black focus:outline-none focus:border-green-500 min-w-0 px-1 py-px" /> - +
+ ); }; From 308e40617267841e3ae15fe46ba3d5511854e392 Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:39:08 +0800 Subject: [PATCH 4/8] bug fixes --- peerprep/frontend/src/styles/App.css | 658 +++++++++++++++++- .../CollabServiceIntegratedView.tsx | 10 +- 2 files changed, 659 insertions(+), 9 deletions(-) diff --git a/peerprep/frontend/src/styles/App.css b/peerprep/frontend/src/styles/App.css index 3efd0a382d..e6496cf787 100644 --- a/peerprep/frontend/src/styles/App.css +++ b/peerprep/frontend/src/styles/App.css @@ -1,10 +1,658 @@ +#root { + margin: 0 auto; + background-color: white; + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + color-scheme: light dark; + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* Global Styling */ +body { + background-color: white; + color: black; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + color: white; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} + +h1 { + font-size: 32px; + color: black; + line-height: 1.1; +} + +h2 { + font-size: 24px; + color: black; +} + +/* Container uses flexbox for split layout +.container { + display: flex; + justify-content: space-between; + gap: 20px; +} */ + +.question-container { + display: flex; + justify-content: space-between; + gap: 20px; + margin-top: 5rem; +} + +.login-container { + display: flex; + justify-content: space-between; + gap: 20px; +} + +.signup-container { + display: flex; + justify-content: space-between; + gap: 20px; +} + +/* Left panel for form and question list, using grid */ +.left-panel { + display: grid; + grid-template-rows: auto 1fr; /* Independent sizing for form and list */ + gap: 20px; /* Add space between form and list */ + max-width: 65%; /* Custom max width for the left panel, 65% is around 2-thrids*/ + padding: 20px; +} + +/* Right panel for detailed view */ +.right-panel { + margin-right: 20px; + flex: 1; + max-width: 35%; + padding: 20px; + background-color: white; + border: 2px solid #ccc; /* light grey border */ + border-radius: 10px; /* Rounded corners */ + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ + margin-left: 20px; /* Add some space between left and right panels */ +} + +.form-section { + max-width: 100%; /* Adjust width of the form, set smaller than 100 for aesthetics */ + text-align: center; /* Center the content inside */ + margin: 0 auto; /* Center the form horizontally */ + padding: 0; + border: none; + background-color: transparent; + box-shadow: none; +} + +/* List section can expand independently of the form-section */ +.list-section { + max-width: 100%; +} + + +/* Adjust questions table layout */ +.question-table { + width: 100%; + table-layout: fixed; + border-collapse: collapse; +} + +/* Ensure all table cells have consistent borders */ +.question-table th, .question-table td { + border: 1px solid #ccc; + padding: 8px; + vertical-align: top; + text-align: left; + box-sizing: border-box; +} + +.question-table tr:hover { + background-color: #f1f1f1; +} + +/* Limit the description cell height in the table */ +.description-cell { + min-height: 100%; + display: -webkit-box; + -webkit-line-clamp: 3; /* Limit to 3 lines, afterwhich text will truncate */ + line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + white-space: normal; + border: none; + box-sizing: border-box; + padding: 8px; +} + +/* General Form Styles */ +.question-form { + padding: 20px; + max-width: 100%; + margin: 0 auto; /* Center the form */ + border: 2px solid #ccc; /* form border */ + border-radius: 10px; /* Rounded corners for the form */ + background-color: white; + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ +} + +/* Styles for inputs, textarea, and select within .question-form */ +.question-form input, +.question-form textarea, +.question-form select { + width: 100%; + padding: 10px; + margin-top: 5px; /* Space between input boxes */ + border: 1px solid #ccc; /* Border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f4f4f4; + color: #333; + font-size: 16px; + box-sizing: border-box; /* Ensures padding is included within the width */ +} + +/* Input Fields Focus State */ +.question-form input:focus, +.question-form textarea:focus, +.question-form select:focus { + outline: none; + border: 2px solid #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Custom styling for the difficulty select dropdown */ +.question-form select { + width: 100%; + padding: 10px; + margin-top: 5px; + border: 2px solid #ccc; /* border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f9f9f9; + color: #333; + font-size: 16px; + appearance: none; +} + +/* Focus state for select dropdown */ +.question-form select:focus { + outline: none; + border-color: #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Submit Button */ +.question-form button.submit-btn { + background-color: #4CAF50; + color: white; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 16px; + margin-top: 10px; +} + +.question-form button.submit-btn:hover { + background-color: #45a049; +} + +/* Error Message styling, to be expanded later most likely split into diff types */ +.question-form .error-message { + color: red; + font-size: 14px; + margin-bottom: 15px; + text-align: center; +} + +/* Adjust spacing and alignment for category checkboxes */ +.category-group label { + display: inline-block; /* label and input stay on same line */ + margin-right: 15px; /* spacing between each checkbox and label */ + margin-bottom: 5px; /* Control vertical spacing */ + font-size: 16px; /* Adjust font size to match rest of the form */ +} + +.category-group input { + margin-right: 5px; + vertical-align: middle; /* Align checkbox vertically with the text */ +} + +/* Style the buttons inside table cells */ +.question-table .edit-btn { + display: block; + width: 100%; + box-sizing: border-box; + margin-bottom: 5px; + padding: 8px; + border-radius: 4px; + background-color: #007bff; /* Blue color for Edit button */ + color: white; + border: none; + cursor: pointer; +} + +/* Red color for Delete button */ +.question-table .delete-btn { + display: block; + width: 100%; + box-sizing: border-box; + margin-bottom: 5px; + padding: 8px; + border-radius: 4px; + background-color: #dc3545; /* Red color for Delete button */ + color: white; + border: none; + cursor: pointer; +} + +/* Hover effect for Edit button */ +.question-table .edit-btn:hover { + background-color: #0056b3; /* Darker blue on hover */ +} + +/* Hover effect for Delete button */ +.question-table .delete-btn:hover { + background-color: #c82333; /* Darker red on hover */ +} + + +/* MATCHING FORM VIEWS */ + +/* Container to center the form */ +.matching-container { + display: flex; + justify-content: center; + align-items: center; + + padding: 20px; +} + +.matching-form { + padding: 20px; + max-width: 100%; + margin: 0 auto; /* Center the form */ + border: 2px solid #ccc; /* form border */ + border-radius: 10px; /* Rounded corners for the form */ + background-color: white; + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* shadow */ +} + +/* Styles for inputs, textarea, and select within .question-form */ +.matching-form input, +.matching-form textarea, +.matching-form select { + width: 100%; + padding: 10px; + margin-top: 5px; /* Space between input boxes */ + border: 1px solid #ccc; /* Border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f4f4f4; + color: #333; + font-size: 16px; + box-sizing: border-box; /* Ensures padding is included within the width */ +} + +/* Input Fields Focus State */ +.matching-form input:focus, +.matching-form textarea:focus, +.matching-form select:focus { + outline: none; + border: 2px solid #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Custom styling for the difficulty select dropdown */ +.matching-form select { + width: 100%; + padding: 10px; + margin-top: 5px; + border: 2px solid #ccc; /* border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f9f9f9; + color: #333; + font-size: 16px; + appearance: none; +} + +/* Focus state for select dropdown */ +.matching-form select:focus { + outline: none; + border-color: #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Submit Button */ +.matching-form button.submit-btn { + background-color: #4CAF50; + color: white; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 16px; + margin-top: 10px; +} + +.matching-form button.submit-btn:hover { + background-color: #45a049; +} + +/* Error Message styling, to be expanded later most likely split into diff types */ +.matching-form .error-message { + color: red; + font-size: 14px; + margin-bottom: 15px; + text-align: center; +} + +/* Position the link in the top right corner */ +.top-left-link { + position: absolute; + top: 20px; + left: 100px; + text-decoration: none; + color: #4CAF50; /* Green color */ + font-weight: bold; +} + +.top-left-link:hover { + color: #45a049; /* Slightly darker green on hover */ +} + +/* Position the link in the top right corner */ +.top-right-link { + position: absolute; + top: 20px; + right: 100px; + text-decoration: none; + color: #4CAF50; /* Green color */ + font-weight: bold; +} + +.top-right-link:hover { + color: #45a049; /* Slightly darker green on hover */ +} + +/* Position the link in the top right corner */ +.centers-link { + position: absolute; + top: 20px; + right: 100px; + text-decoration: none; + color: #4CAF50; /* Green color */ + font-weight: bold; +} + +.centers-link:hover { + color: #45a049; /* Slightly darker green on hover */ +} + +.center-link { + position: absolute; + top: 80%; + left: 50%; + transform: translate(-50%, -50%); + text-decoration: none; + color: #4CAF50; /* Green color */ + font-weight: bold; + font-size: 18px; + padding: 10px 20px; + border: 2px solid #4CAF50; + border-radius: 5px; + transition: background-color 0.3s, color 0.3s; + cursor: pointer; +} + +.center-link:hover { + background-color: #4CAF50; + color: white; +} + +/* LOGIN FORM STYLES */ + +.login-form { + width: 100%; + max-width: 400px; + min-width: 400px; + padding: 30px; + border: 2px solid #ccc; + border-radius: 12px; + background-color: white; + box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.1); + text-align: center; +} + +/* Input field styling */ +.login-form input { + width: 100%; + padding: 12px; + margin-top: 10px; + border: 1px solid #ccc; + border-radius: 6px; + background-color: #f4f4f4; + font-size: 16px; + color: black; + box-sizing: border-box; +} + +/* Focus state for input fields */ +.login-form input:focus { + outline: none; + border-color: #4CAF50; + color: black; + background-color: white; +} + +/* Primary button styling */ +.submit-btn { + width: 100%; + padding: 12px; + margin-top: 15px; + background-color: #4CAF50; + color: white; + border: none; + border-radius: 6px; + font-size: 18px; + cursor: pointer; +} + +.submit-btn:hover { + background-color: #45a049; +} + +/* Alternative button styling */ +.alt-btn { + width: 100%; + padding: 12px; + margin-top: 10px; + background-color: #333; + color: white; + border: none; + border-radius: 6px; + font-size: 18px; + cursor: pointer; +} + +.alt-btn:hover { + background-color: #444; +} + +/* Error message styling */ +.error-message { + color: red; + margin-top: 10px; +} + +/* Link styling */ +.link { + color: #4CAF50; + text-decoration: none; +} + +.link:hover { + text-decoration: underline; +} + +.progress-bar-container { + width: 100%; + height: 10px; + background-color: #f3f3f3; + border-radius: 5px; + margin-top: 10px; +} + +.progress-bar { + height: 100%; + background-color: #4caf50; + width: 0%; + border-radius: 5px; + transition: width 1s ease-in-out; +} + +input { + flex-grow: 1; + padding: 5px; + border: 1px solid #ccc; + border-radius: 5px; + background-color: white; + margin-right: 2px; + color: black; + min-width: 0px; +} + +.matching-form2 { + padding: 0px; + max-width: 40%; + min-width: 18%; + margin: 0 auto; /* Center the form */ + border-radius: 10px; /* Rounded corners for the form */ + background-color: white; +} + +/* Styles for inputs, textarea, and select within .question-form */ +.matching-form2 input, +.matching-form2 textarea, +.matching-form2 select { + width: 100%; + padding: 10px; + margin-top: 5px; /* Space between input boxes */ + border: 1px solid #ccc; /* Border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f4f4f4; + color: #333; + font-size: 16px; + box-sizing: border-box; /* Ensures padding is included within the width */ +} + +/* Input Fields Focus State */ +.matching-form2 input:focus, +.matching-form2 textarea:focus, +.matching-form2 select:focus { + outline: none; + border: 2px solid #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Custom styling for the difficulty select dropdown */ +.matching-form2 select { + width: 100%; + padding: 10px; + margin-top: 5px; + border: 2px solid #ccc; /* border */ + border-radius: 4px; /* Rounded corners */ + background-color: #f9f9f9; + color: #333; + font-size: 16px; + appearance: none; +} + +/* Focus state for select dropdown */ +.matching-form2 select:focus { + outline: none; + border-color: #4CAF50; /* Green border on focus */ + background-color: #fff; /* White background on focus */ +} + +/* Submit Button */ +.matching-form2 button.submit-btn { + background-color: #4CAF50; + color: white; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 16px; + margin-top: 10px; +} + +.matching-form2 button.submit-btn:hover { + background-color: #45a049; +} + +/* Error Message styling, to be expanded later most likely split into diff types */ +.matching-form2 .error-message { + color: red; + font-size: 14px; + margin-bottom: 15px; + text-align: center; +} + + +/* STYLES FOR CODEMIRROR */ .react-codemirror2 { - overflow: auto; - height: 100%; - width: 100%; + height: 100%; + width: 100%; } .CodeMirror{ - height: 100%; - width: 100%; + height: 100%; + width: 100%; } diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index fe383d180d..e90a75b3b6 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -207,6 +207,8 @@ const CollaborationServiceIntegratedView: React.FC = () => { return; } + setOutput('Executing code...'); + const currentCode = yText.toString(); console.log('Submitting code for execution:', currentCode); @@ -289,9 +291,9 @@ const CollaborationServiceIntegratedView: React.FC = () => { return (
-
+
-

Q. {questionTitle}

+

Q. {questionTitle}

{topics && ( @@ -354,12 +356,12 @@ const CollaborationServiceIntegratedView: React.FC = () => {
-
+
-

Code

+

Code

From 95d706e022207a52a35e5b3b8676213a705b3db3 Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:51:14 +0800 Subject: [PATCH 6/8] minor fix --- .../views/CollabServiceViews/CollabServiceIntegratedView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index 99b43d04d6..dc098353d0 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -297,12 +297,12 @@ const CollaborationServiceIntegratedView: React.FC = () => {
{topics && ( - + {topics} )} {difficulty && ( - + {difficulty} )} From c718349a028cef19fd092a6901cee6cf3df38aff Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:07:23 +0800 Subject: [PATCH 7/8] bug fixes --- peerprep/frontend/src/styles/App.css | 4 ++++ .../CollabServiceViews/CollabServiceIntegratedView.tsx | 6 +++--- .../src/views/CollabServiceViews/components/Chat.tsx | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/peerprep/frontend/src/styles/App.css b/peerprep/frontend/src/styles/App.css index e6496cf787..194fa0fb89 100644 --- a/peerprep/frontend/src/styles/App.css +++ b/peerprep/frontend/src/styles/App.css @@ -656,3 +656,7 @@ input { height: 100%; width: 100%; } + +.CodeMirror-cursor{ + height: 19px !important; +} \ No newline at end of file diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index dc098353d0..cedaa33a7e 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -356,7 +356,7 @@ const CollaborationServiceIntegratedView: React.FC = () => {
-
+
@@ -455,11 +455,11 @@ const CollaborationServiceIntegratedView: React.FC = () => {

Output

-
{output}
+
{output}
diff --git a/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx b/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx index 3b567ddbd5..6d63cf11d2 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/components/Chat.tsx @@ -93,8 +93,13 @@ const Chat: React.FC = ({ sessionId }) => { {messages.map((msg, index) => (<>
{msg.text}
From d53e9e75ed2b46db56b7ed799851825777f6876b Mon Sep 17 00:00:00 2001 From: Suryansh Kushwaha <112935210+suryanshkushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:13:26 +0800 Subject: [PATCH 8/8] minor spelling error --- .../views/CollabServiceViews/CollabServiceIntegratedView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx index cedaa33a7e..02c390bc36 100644 --- a/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx +++ b/peerprep/frontend/src/views/CollabServiceViews/CollabServiceIntegratedView.tsx @@ -406,7 +406,7 @@ const CollaborationServiceIntegratedView: React.FC = () => { onClick={handleAssessCode} className="px-4 py-2 bg-blue-500 text-white rounded text-sm hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2" > - Access + Assess