Skip to content

Commit a9bf652

Browse files
authored
Merge pull request #21 from oslabs-beta/sean
Toggle Switch
2 parents 4ec06ce + ab67893 commit a9bf652

File tree

5 files changed

+84
-55
lines changed

5 files changed

+84
-55
lines changed

app/src/components/left/RoomsContainer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
getSocket,
3939
disconnectSocket
4040
} from '../../helperFunctions/socket';
41+
import Canvas from '../components/main/Canvas';
4142

4243
// // for websockets
4344
// // Part - join room and room code functionality
@@ -180,6 +181,7 @@ const RoomsContainer = () => {
180181
return userName.length === 0 || roomCode.length === 0;
181182
}
182183

184+
// Turning off the cursor live tracking on canvas with the press of a button.
183185
const handleKeyDown = (e) => {
184186
if (e.key === 'Enter' && e.target.id === 'filled-hidden-label-small') {
185187
e.preventDefault();

app/src/components/left/Sidebar.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@ const Sidebar: React.FC<SidebarProps> = ({
2020
}) => {
2121
const handleTabChange = (event: React.ChangeEvent<{}>, newValue: number) => {
2222
setActiveTab(newValue);
23-
toggleVisibility(true);// Show the left-container when a different tab is clicked
24-
oldValue = newValue;//setting the oldvalue to match the new tab
23+
toggleVisibility(true); // Show the left-container when a different tab is clicked
24+
oldValue = newValue; //setting the oldvalue to match the new tab
2525
};
2626

2727
const handleTabClick = (event: React.MouseEvent, oldValue: number) => {
28-
if (activeTab === oldValue) { //if the person is clicking the same tab, oldValue should match activeTab since it did not trigger an onChange
28+
if (activeTab === oldValue) {
29+
//if the person is clicking the same tab, oldValue should match activeTab since it did not trigger an onChange
2930
setActiveTab(null);
3031
toggleVisibility(false); // Hide the left-container when the same tab is clicked again
3132
}
32-
}
33+
};
3334

3435
return (
3536
<Tabs
3637
key={activeTab}
3738
orientation="vertical"
3839
variant="scrollable"
3940
value={activeTab}
40-
onChange = {handleTabChange}
41-
onClick = {(e: React.MouseEvent) => handleTabClick(e, oldValue)}
41+
onChange={handleTabChange}
42+
onClick={(e: React.MouseEvent) => handleTabClick(e, oldValue)}
4243
TabIndicatorProps={{
4344
style: {
4445
backgroundColor: '#4A4A4A'
@@ -53,10 +54,10 @@ const Sidebar: React.FC<SidebarProps> = ({
5354
gap: '50px',
5455
width: 67,
5556
background: '#151515',
56-
height: '100vh',
57+
height: '100vh'
5758
}}
5859
>
59-
<Tab sx={{position: 'absolute', visibility: "hidden"}} value={null}/>
60+
<Tab sx={{ position: 'absolute', visibility: 'hidden' }} value={null} />
6061
<Tab
6162
sx={{
6263
color: activeTab === 0 ? '#a5ead6' : '#4A4A4A',

app/src/components/main/Canvas.tsx

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { combineStyles } from '../../helperFunctions/combineStyles';
1616
import renderChildren from '../../helperFunctions/renderChildren';
1717
import { emitEvent, getSocket } from '../../helperFunctions/socket';
1818
import { GiBoba } from 'react-icons/gi';
19+
import { Console } from 'console';
1920

2021
function Canvas(props: {}): JSX.Element {
2122
const state = useSelector((store: RootState) => store.appState);
@@ -27,9 +28,20 @@ function Canvas(props: {}): JSX.Element {
2728
//-------cursors tracking-------
2829
console.log('canvas is rendered');
2930

31+
//remote cursor data
32+
3033
const [remoteCursors, setRemoteCursors] = useState([]);
34+
35+
//toggle switch
3136
const [toggleSwitch, setToggleSwitch] = useState(true);
3237

38+
// toggle text
39+
const [toggleText, setToggleText] = useState('off');
40+
41+
const toggleButton = () => {
42+
setToggleText(toggleText === 'on' ? 'off' : 'on');
43+
};
44+
3345
const debounceSetPosition = debounce((newX, newY) => {
3446
//emit socket event every 300ms when cursor moves
3547
if (userList.length > 1)
@@ -111,6 +123,12 @@ function Canvas(props: {}): JSX.Element {
111123

112124
console.log('Toggle Switch:', toggleSwitch);
113125

126+
//Function to handle the click events.
127+
const multipleClicks = () => {
128+
handleToggleSwitch();
129+
toggleButton();
130+
};
131+
114132
const socket = getSocket();
115133
//wrap the socket event listener in useEffect with dependency array as [socket], so the the effect will run only when: 1. After the initial rendering of the component 2. Every time the socket instance changes(connect, disconnect)
116134
useEffect(() => {
@@ -328,19 +346,29 @@ function Canvas(props: {}): JSX.Element {
328346
</div>
329347
)
330348
)}
331-
332-
<label
333-
className="switch"
334-
style={{
335-
position: 'relative',
336-
display: 'inline-block',
337-
width: '60px',
338-
height: '34px'
339-
}}
340-
>
341-
<button className="btn-toggle" onClick={handleToggleSwitch}>
342-
On/Off
343-
</button>
349+
<label className="switch">
350+
{userList.length > 1 && (
351+
<button
352+
className="btn-toggle"
353+
onClick={multipleClicks}
354+
style={{
355+
position: 'fixed',
356+
width: 'max-content',
357+
height: 'max-content',
358+
bottom: '100px',
359+
left: '51vw',
360+
textAlign: 'center',
361+
color: '#ffffff',
362+
backgroundColor: '#151515',
363+
zIndex: 0,
364+
padding: '5px',
365+
borderColor: '#46C0A5',
366+
borderRadius: '5px'
367+
}}
368+
>
369+
{toggleText === 'on' ? 'View Cursors' : 'Hide Cursors'}
370+
</button>
371+
)}
344372
</label>
345373
</div>
346374
);

app/src/public/styles/style.css

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
99
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
1010
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0');
11-
@import url("https: //fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap");
11+
@import url('https: //fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');
1212

1313
html {
1414
box-sizing: border-box;
@@ -143,14 +143,13 @@ span.material-symbols-outlined {
143143
border: solid gray 1px;
144144
}
145145

146-
147146
.column.left::-webkit-scrollbar {
148-
width: .5rem;
149-
height: .5rem;
147+
width: 0.5rem;
148+
height: 0.5rem;
150149
}
151150

152151
.column.left::-webkit-scrollbar-thumb {
153-
transition: .3s ease all;
152+
transition: 0.3s ease all;
154153
border-color: transparent;
155154
background-color: #1e83714b;
156155
z-index: 40;
@@ -177,7 +176,7 @@ span.material-symbols-outlined {
177176
flex-wrap: wrap;
178177
width: 100%;
179178
flex-grow: 1;
180-
border: 1px solid #C6C6C6;
179+
border: 1px solid #c6c6c6;
181180
/* border-radius: 10px; */
182181
}
183182

@@ -202,7 +201,7 @@ span.material-symbols-outlined {
202201
border: 3px solid white;
203202
}
204203

205-
#HTMLItemsTopHalf {
204+
#Half {
206205
display: flex;
207206
flex-direction: column;
208207
justify-content: top;
@@ -213,12 +212,12 @@ span.material-symbols-outlined {
213212
}
214213

215214
#HTMLItemsTopHalf::-webkit-scrollbar {
216-
width: .8rem;
217-
height: .5rem;
215+
width: 0.8rem;
216+
height: 0.5rem;
218217
}
219218

220219
#HTMLItemsTopHalf::-webkit-scrollbar-thumb {
221-
transition: .3s ease all;
220+
transition: 0.3s ease all;
222221
border-color: transparent;
223222
background-color: #1e83714b;
224223
border-radius: 8px;
@@ -390,11 +389,11 @@ h1 {
390389
}
391390

392391
.export-preference div span {
393-
transition: .5s
392+
transition: 0.5s;
394393
}
395394

396395
#export-modal {
397-
transition: .5s
396+
transition: 0.5s;
398397
}
399398

400399
#export-modal:hover {
@@ -403,7 +402,7 @@ h1 {
403402
}
404403

405404
#export-modal:hover span {
406-
color: white
405+
color: white;
407406
}
408407

409408
.info {
@@ -457,7 +456,7 @@ RIGHT COLUMN
457456
}
458457

459458
#addComponentButton {
460-
border: 2px solid #46C0A5;
459+
border: 2px solid #46c0a5;
461460
border-radius: 4px;
462461
}
463462

@@ -485,7 +484,7 @@ RIGHT COLUMN
485484
display: flex;
486485
justify-content: center;
487486
align-content: center;
488-
border-color: #46C0A5;
487+
border-color: #46c0a5;
489488
}
490489

491490
.compPanelItem h3 {
@@ -533,18 +532,16 @@ BOTTOM PANEL
533532
background-color: #191919;
534533
}
535534

536-
.MuiDataGrid-menuList, .MuiDataGrid-columnsPanel, .MuiDataGrid-filterForm {
537-
538-
background-color: #333333
535+
.MuiDataGrid-menuList,
536+
.MuiDataGrid-columnsPanel,
537+
.MuiDataGrid-filterForm {
538+
background-color: #333333;
539539
}
540-
.MuiDataGrid-panelHeader, .MuiDataGrid-panelFooter {
541-
542-
background-color: #252525
543-
540+
.MuiDataGrid-panelHeader,
541+
.MuiDataGrid-panelFooter {
542+
background-color: #252525;
544543
}
545544

546-
547-
548545
#resize-drag {
549546
cursor: row-resize;
550547
height: 25px;
@@ -568,7 +565,6 @@ BOTTOM PANEL
568565
height: 100%;
569566
display: flex;
570567
flex-direction: column;
571-
572568
}
573569

574570
.htmlattr {
@@ -652,7 +648,6 @@ NAVBAR
652648
cursor: pointer;
653649
}
654650

655-
656651
.navDropDown {
657652
position: absolute;
658653
border: 1px solid #555;
@@ -685,12 +680,12 @@ NAVBAR
685680

686681
.navDropDown p {
687682
margin: 3px 5%;
688-
color: whitesmoke
683+
color: whitesmoke;
689684
}
690685

691686
.navDropDown button:hover {
692687
cursor: pointer;
693-
background-color: #555
688+
background-color: #555;
694689
}
695690

696691
.navDropDown button svg {
@@ -709,8 +704,6 @@ NAVBAR
709704
width: 16%;
710705
}
711706

712-
713-
714707
/*
715708
/////////////////////////////////////////////////
716709
CANVAS WINDOW
@@ -724,7 +717,8 @@ CANVAS WINDOW
724717
border: none;
725718
font-size: 15px;
726719
color: white;
727-
box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%)
720+
box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%),
721+
0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
728722
}
729723

730724
.delete-button-empty:hover {
@@ -757,7 +751,7 @@ div.rst__rowContents {
757751
.rst__rowContentsDragDisabled {
758752
background-color: #333333;
759753
background-color: rgba(37, 37, 38, 0.4);
760-
}
754+
}
761755

762756
.rst__moveHandle,
763757
.rst__loadingHandle {
@@ -816,7 +810,7 @@ a.nav_link:hover {
816810
.useState-btn {
817811
color: rgb(241, 240, 240);
818812
background-color: rgba(0, 0, 0, 0.54);
819-
border: 1px solid #46C0A5;
813+
border: 1px solid #46c0a5;
820814
border-radius: 3px;
821815
box-shadow: '2px 2px 2px #1a1a1a';
822816
font-family: Arial, Helvetica, sans-serif;
@@ -868,4 +862,4 @@ a.nav_link:hover {
868862

869863
li {
870864
color: black;
871-
}
865+
}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@
5353
"Katrina Henderson",
5454
"Kevin Park",
5555
"Khuong Nguyen",
56+
"Laura Forden",
57+
"Lauren Leer",
5658
"Linh Tran",
5759
"Luke Madden",
5860
"Michael Ng",
5961
"Mitchel Severe",
6062
"Natalie Vick",
6163
"Ron Fu",
64+
"Rose Jiang",
65+
"Sean Kil",
6266
"Sean Sadykoff",
6367
"Shana Hoehn",
6468
"Shlomo Porges",

0 commit comments

Comments
 (0)