Skip to content

Commit 6b63156

Browse files
committed
add sidebar update. Todupdate(sidebar): Initial changes to sidebar
Todo: Address remaining bugs and refine functionality. o: still needs some work
1 parent b496fb0 commit 6b63156

File tree

7 files changed

+115
-38
lines changed

7 files changed

+115
-38
lines changed

app/src/components/left/ComponentDrag.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
2-
import Grid from '@mui/material/Grid';
31
import ComponentPanelItem from '../right/ComponentPanelItem';
2+
import Grid from '@mui/material/Grid';
3+
import React from 'react';
4+
import { RootState } from '../../redux/store';
45
import makeStyles from '@mui/styles/makeStyles';
56
import { useSelector } from 'react-redux';
6-
import { RootState } from '../../redux/store';
77
// The component panel section of the left panel displays all components and has the ability to add new components
88
const ComponentDrag = ({ isThemeLight }): JSX.Element => {
99
const classes = useStyles();
@@ -108,7 +108,7 @@ const useStyles = makeStyles({
108108
wordWrap: 'break-word'
109109
},
110110
lightThemeFontColor: {
111-
color: '#155084'
111+
color: '#fff'
112112
},
113113
darkThemeFontColor: {
114114
color: '#fff'
Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,82 @@
1+
import ComponentPanelItem from '../right/ComponentPanelItem';
2+
import Grid from '@mui/material/Grid';
13
import React from 'react';
4+
import { RootState } from '../../redux/store';
5+
import makeStyles from '@mui/styles/makeStyles';
6+
import { useSelector } from 'react-redux';
27

38
const ComponentsContainer = () => {
4-
return <div>ComponentsContainer</div>;
9+
const classes = useStyles();
10+
const state = useSelector((store: RootState) => store.appState);
11+
const isDarkMode = useSelector(
12+
(store: RootState) => store.darkMode.isDarkMode
13+
);
14+
const isFocus = (targetId: Number) => {
15+
return state.canvasFocus.componentId === targetId ? true : false;
16+
};
17+
return (
18+
<div>
19+
<div className={classes.panelWrapper}>
20+
<div className={classes.panelWrapperList}>
21+
<h4
22+
className={
23+
!isDarkMode
24+
? classes.lightThemeFontColor
25+
: classes.darkThemeFontColor
26+
}
27+
>
28+
Reusable Components
29+
</h4>
30+
<Grid
31+
container
32+
direction="row"
33+
justifyContent="center"
34+
alignItems="center"
35+
>
36+
{state.components
37+
.filter((comp) => !state.rootComponents.includes(comp.id))
38+
.map((comp) => {
39+
return (
40+
<ComponentPanelItem
41+
isFocus={isFocus(comp.id)}
42+
key={`comp-${comp.id}`}
43+
name={comp.name}
44+
id={comp.id}
45+
root={false}
46+
/>
47+
);
48+
})}
49+
</Grid>
50+
</div>
51+
</div>
52+
</div>
53+
);
554
};
655

56+
const useStyles = makeStyles({
57+
panelWrapper: {
58+
display: 'flex',
59+
flexDirection: 'column',
60+
alignItems: 'center',
61+
flexGrow: 1,
62+
overflow: 'auto'
63+
},
64+
panelWrapperList: {
65+
minHeight: '120px',
66+
marginLeft: '-15px',
67+
marginRight: '-15px',
68+
width: '100%',
69+
display: 'flex',
70+
flexDirection: 'column',
71+
alignItems: 'center',
72+
wordWrap: 'break-word'
73+
},
74+
lightThemeFontColor: {
75+
color: '#fff'
76+
},
77+
darkThemeFontColor: {
78+
color: '#fff'
79+
}
80+
});
81+
782
export default ComponentsContainer;

app/src/components/left/ContentArea.tsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,32 @@ import RoomsContainer from './RoomsContainer';
66
import TreeContainer from './TreeContainer';
77

88
interface TabPanelProps {
9-
value: number;
9+
activeTab: number;
1010
index: number;
1111
}
1212

13-
const TabPanel: React.FC<TabPanelProps> = ({ children, value, index }) => {
14-
return <Box hidden={value !== index}>{value === index && children}</Box>;
13+
const TabPanel: React.FC<TabPanelProps> = ({ children, activeTab, index }) => {
14+
return (
15+
<Box hidden={activeTab !== index}>{activeTab === index && children}</Box>
16+
);
1517
};
1618

17-
const ContentArea: React.FC<{ value: number | null }> = ({ value }) => {
18-
if (value === null) {
19-
return null;
20-
}
19+
const panels = [
20+
<ElementsContainer />,
21+
<ComponentsContainer />,
22+
<TreeContainer />,
23+
<RoomsContainer />
24+
];
2125

26+
const ContentArea: React.FC<{ activeTab: number | null }> = ({ activeTab }) => {
2227
return (
2328
<div className="left-container">
2429
<div className="column left">
25-
<TabPanel value={value} index={0}>
26-
<ElementsContainer />
27-
</TabPanel>
28-
<TabPanel value={value} index={1}>
29-
<ComponentsContainer />
30-
</TabPanel>
31-
<TabPanel value={value} index={2}>
32-
<TreeContainer />
33-
</TabPanel>
34-
<TabPanel value={value} index={3}>
35-
<RoomsContainer />
36-
</TabPanel>
30+
{panels.map((panel, idx) => (
31+
<TabPanel key={idx} activeTab={activeTab} index={idx}>
32+
{panel}
33+
</TabPanel>
34+
))}
3735
</div>
3836
</div>
3937
);

app/src/components/left/ElementsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const ElementsContainer = (props): JSX.Element => {
4848
textAlign: 'center'
4949
}}
5050
>
51-
<h4>Drag and Drop</h4>
51+
{' '}
5252
<DragDropPanel />
5353
<div id={'CompBottomHalf'}>
5454
<ComponentDrag isThemeLight={props.isThemeLight} />

app/src/components/left/Sidebar.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ import PeopleIcon from '@mui/icons-material/People';
77
import React from 'react';
88

99
interface SidebarProps {
10-
value: number | null;
11-
setValue: React.Dispatch<React.SetStateAction<number | null>>;
10+
activeTab: number | null;
11+
setActiveTab: (value: number | null) => void;
1212
}
13+
const Sidebar: React.FC<SidebarProps> = ({ activeTab, setActiveTab }) => {
14+
const handleTabChange = (event: React.ChangeEvent<{}>, newValue: number) => {
15+
if (activeTab === newValue) {
16+
setActiveTab(null);
17+
} else {
18+
setActiveTab(newValue);
19+
}
20+
};
1321

14-
const Sidebar: React.FC<SidebarProps> = ({ value, setValue }) => {
15-
console.log('sidebar value', value);
1622
return (
1723
<Tabs
1824
orientation="vertical"
1925
variant="scrollable"
20-
value={value}
21-
onChange={(_, newValue) => {
22-
setValue(value === newValue ? null : newValue);
23-
}}
26+
value={activeTab}
27+
onChange={handleTabChange}
2428
TabIndicatorProps={{
2529
style: {
2630
backgroundColor: '#4A4A4A'

app/src/components/top/NavBarButtons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ function navbarDropDown(props) {
344344
</svg>
345345
</button>
346346
)}
347-
<input
347+
{/* <input
348348
type="text"
349349
style={{
350350
margin: '3px 5%',
@@ -356,7 +356,7 @@ function navbarDropDown(props) {
356356
onChange={(e) => setRoomCode(e.target.value)}
357357
></input>
358358
<button onClick={() => joinRoom()}>Join Room</button>
359-
<p>In Room: {joinedRoom}</p>
359+
<p>In Room: {joinedRoom}</p> */}
360360
<MarketplaceButton />
361361
<LoginButton />
362362
<StyledMenu // Dropdown menu connected to Manage Project Button

app/src/containers/LeftContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { BrowserRouter as Router } from 'react-router-dom';
55
import Sidebar from '../components/left/Sidebar';
66

77
function App() {
8-
const [value, setValue] = useState<number | null>(5);
8+
const [activeTab, setActiveTab] = useState<number | null>(null);
99

1010
return (
1111
<div style={{ display: 'flex' }}>
12-
<Sidebar value={value} setValue={setValue} />
13-
<ContentArea value={value} />
12+
<Sidebar activeTab={activeTab} setActiveTab={setActiveTab} />
13+
<ContentArea activeTab={activeTab} />
1414
</div>
1515
);
1616
}

0 commit comments

Comments
 (0)