Skip to content

Commit 760f507

Browse files
committed
Set up basic frontend
Split the collaboration space into 4 components, navigation bar, chat, code space
1 parent 4cfa15d commit 760f507

File tree

6 files changed

+106
-27
lines changed

6 files changed

+106
-27
lines changed

Frontend/src/components/NavigationBar.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import Container from 'react-bootstrap/Container';
22
import Navbar from 'react-bootstrap/Navbar';
3-
import { useNavigate } from 'react-router-dom';
43
import UserAvatarBox from "./user/userAvatarBox";
54

65
function NavigationBar() {
7-
const navigate = useNavigate();
8-
9-
// Add log out functionality
10-
const handleLogout = () => {
11-
sessionStorage.removeItem("jwt_token");
12-
navigate("/login");
13-
}
146

157
return (
168
<Navbar className='bg-light' sticky="top">
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react'
2+
import { Card, ListGroup, ListGroupItem } from 'react-bootstrap'
3+
4+
const Chat = () => {
5+
6+
const messages = ["Hello!", "Nice to meet you!"]
7+
return (
8+
<Card>
9+
<Card.Header>Chat</Card.Header>
10+
<Card.Body>
11+
<ListGroup>
12+
{messages.map((msg, idx) => (
13+
<ListGroupItem key={idx}>{msg}</ListGroupItem>
14+
))}
15+
</ListGroup>
16+
</Card.Body>
17+
</Card>
18+
)
19+
}
20+
21+
export default Chat
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react'
2+
import { Editor } from '@monaco-editor/react'
3+
import { Container, Stack } from 'react-bootstrap'
4+
5+
const CodeSpace = ({ handleEditorChange, code }) => {
6+
return (
7+
8+
<Stack gap={3} className='h-100'>
9+
<Editor
10+
height='400px'
11+
defaultLanguage='javascript'
12+
value={code}
13+
onChange={handleEditorChange}
14+
theme='vs-dark'
15+
/>
16+
<Container style={{ height: '200px', border: '1px solid #ccc', borderRadius: '0.5rem', padding: '1rem', backgroundColor: '#f8f9fa'}}>
17+
<h5>Output</h5>
18+
</Container>
19+
</Stack>
20+
21+
)
22+
}
23+
24+
export default CodeSpace
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { Button, Container, Navbar, Nav } from 'react-bootstrap';
3+
4+
const CollabNavigationBar = ({ handleExit, users }) => {
5+
return (
6+
<Navbar className='bg-light' sticky='top'>
7+
<Container className='d-flex justify-content-between'>
8+
{/* Run Code and Exit Buttons in Center */}
9+
<Nav className='mx-auto'>
10+
<Button>Run Code</Button>
11+
<Button variant="danger" className="ms-2" onClick={handleExit}>Exit</Button>
12+
</Nav>
13+
14+
<Nav>
15+
{users.map(user => {
16+
return <div
17+
className='border rounded p-2 bg-secondary text-center mx-2'
18+
style={{ minWidth: '100px'}}>
19+
{user}
20+
</div>
21+
})}
22+
</Nav>
23+
</Container>
24+
</Navbar>
25+
)
26+
}
27+
28+
export default CollabNavigationBar

Frontend/src/components/collab/CollaborationSpace.jsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import React, { useEffect, useState } from 'react';
22
import { useParams, useNavigate } from 'react-router-dom';
3-
import { Editor } from '@monaco-editor/react';
43
import * as Y from 'yjs';
54
import { WebsocketProvider } from 'y-websocket';
6-
import Button from 'react-bootstrap/Button';
75
import { getUserFromToken } from '../user/userAvatarBox';
6+
import QuestionDisplay from './QuestionDisplay';
7+
import Chat from './Chat';
8+
import CollabNavigationBar from './CollabNavigationBar';
9+
import CodingSpace from './CodeSpace';
10+
import { Container, Row, Col } from 'react-bootstrap';
811

912
const CollaborationSpace = () => {
1013
const navigate = useNavigate();
@@ -102,23 +105,19 @@ const CollaborationSpace = () => {
102105
}
103106

104107
return (
105-
<div style={{ textAlign: 'center', marginTop: '50px' }}>
106-
<h1>Welcome to Collaboration Space</h1>
107-
<p>You are in room: {roomId}</p>
108-
<h3>Connected Users:</h3>
109-
<ul>
110-
{users.map(user => {
111-
return <li key={user}>{user}</li>
112-
})}
113-
</ul>
114-
<Editor
115-
height="800px"
116-
language="javascript" // change this later to get from params too
117-
value={code}
118-
theme="vs-dark"
119-
onChange={handleEditorChange}
120-
/>
121-
<Button variant="danger" onClick={() => handleExit()}>Exit</Button>{' '}
108+
<div>
109+
<CollabNavigationBar handleExit={handleExit} users={users}/>
110+
<Container fluid style={{ marginTop: '20px' }}>
111+
<Row>
112+
<Col md={8}>
113+
<CodingSpace handleEditorChange={handleEditorChange} code={code}/>
114+
</Col>
115+
<Col md={4}>
116+
<QuestionDisplay/>
117+
<Chat/>
118+
</Col>
119+
</Row>
120+
</Container>
122121
</div>
123122
);
124123
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
import { Card } from 'react-bootstrap'
3+
4+
const QuestionDisplay = () => {
5+
return (
6+
<Card>
7+
<Card.Header>Question Title</Card.Header>
8+
<Card.Body>
9+
<p>Question Description Placeholder</p>
10+
</Card.Body>
11+
</Card>
12+
)
13+
}
14+
15+
export default QuestionDisplay

0 commit comments

Comments
 (0)