Skip to content

Commit 2768316

Browse files
authored
Merge pull request #7 from oslabs-beta/feature/MUItab
Jesse 4/25, MUI Props Tab added in file BottomTabs.tsx,re-adjust the …
2 parents aaf7b18 + 1da9056 commit 2768316

File tree

3 files changed

+85
-36
lines changed

3 files changed

+85
-36
lines changed

app/src/components/bottom/BottomPanel.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ const BottomPanel = (props): JSX.Element => {
3333
if (!props.bottomShow) return; // prevent drag calculation to occur when bottom menu is not showing
3434

3535
const dy = y - e.clientY;
36+
const newHeight = h + dy;
3637

37-
const newVal = h + dy;
38-
const styles = window.getComputedStyle(node.current);
39-
const min = parseInt(styles.minHeight, 10);
40-
node.current.style.height = newVal > min ? `${h + dy}px` : `${min}px`;
38+
const styles = window.getComputedStyle(node.current);
39+
const minHeight = parseInt(styles.minHeight, 10);
40+
const maxHeight = window.innerHeight * 0.8; // Set a maximum height, e.g., 90% of window height
41+
42+
node.current.style.height = `${Math.max(minHeight, Math.min(maxHeight, newHeight))}px`;
4143
};
4244

4345
const mouseUpHandler = function () {
@@ -49,13 +51,18 @@ const BottomPanel = (props): JSX.Element => {
4951
};
5052

5153
useEffect(() => {
52-
node.current.style.height = '50vh';
53-
node.current.style.minHeight = '50vh';
54-
}, []);
54+
if (props.bottomShow) {
55+
node.current.style.height = '50vh'; // Initial height when bottom panel is open
56+
node.current.style.minHeight = '20vh'; // Minimum height when bottom panel is open
57+
} else {
58+
node.current.style.height = '0.1'; // Initial height when bottom panel is closed
59+
node.current.style.minHeight = '0.1'; // Minimum height when bottom panel is closed
60+
}
61+
}, [props.bottomShow]);
5562

5663
return (
5764
<>
58-
<div className="bottom-panel" id="resize" ref={node}>
65+
<div className="bottom-panel" id="resize" ref={node} >
5966
<div
6067
id="resize-drag"
6168
onMouseDown={mouseDownHandler}

app/src/components/bottom/BottomTabs.tsx

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import React, { useState } from 'react';
2-
import makeStyles from '@mui/styles/makeStyles';
3-
import Tabs from '@mui/material/Tabs';
4-
import Tab from '@mui/material/Tab';
5-
import StylesEditor from './StylesEditor';
6-
import CustomizationPanel from '../../containers/CustomizationPanel';
2+
import { useDispatch, useSelector } from 'react-redux';
3+
import { changeProjectType } from '../../redux/reducers/slice/appStateSlice';
4+
import { RootState } from '../../redux/store';
5+
import { MeetingProvider } from '@videosdk.live/react-sdk';
6+
const videoSDKToken = `${import.meta.env.VITE_VIDEOSDK_TOKEN}`;
7+
import Chatroom from './ChatRoom';
78
import CreationPanel from './CreationPanel';
9+
import CustomizationPanel from '../../containers/CustomizationPanel';
10+
import StylesEditor from './StylesEditor';
11+
import Tree from '../../tree/TreeChart';
812
import ContextManager from '../ContextAPIManager/ContextManager';
913
import StateManager from '../StateManagement/StateManagement';
10-
import Chatroom from './ChatRoom';
14+
import MUIProps from './MUIProps';
15+
import makeStyles from '@mui/styles/makeStyles';
16+
import Tabs from '@mui/material/Tabs';
17+
import Tab from '@mui/material/Tab';
1118
import Box from '@mui/material/Box';
12-
import Tree from '../../tree/TreeChart';
1319
import FormControl from '@mui/material/FormControl';
1420
import MenuItem from '@mui/material/MenuItem';
1521
import Select from '@mui/material/Select';
1622
import arrow from '../main/Arrow';
17-
import { useDispatch, useSelector } from 'react-redux';
18-
import { changeProjectType } from '../../redux/reducers/slice/appStateSlice';
19-
import { RootState } from '../../redux/store';
20-
import { MeetingProvider } from '@videosdk.live/react-sdk';
21-
const videoSDKToken = `${import.meta.env.VITE_VIDEOSDK_TOKEN}`;
23+
2224

2325
const BottomTabs = (props): JSX.Element => {
2426
const { setBottomShow, isThemeLight } = props;
@@ -73,54 +75,52 @@ const BottomTabs = (props): JSX.Element => {
7375
indicator: classes.tabsIndicator
7476
}}
7577
variant="scrollable"
76-
scrollButtons="auto"
78+
scrollButtons="auto"
7779
>
78-
<Tab
79-
disableRipple
80+
<Tab
8081
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
8182
label="Live Chat"
8283
onClick={showBottomPanel}
8384
sx={{ borderTop: '2px solid #191919' }}
8485
/>
8586
<Tab
86-
disableRipple
8787
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
8888
label="Creation Panel"
8989
onClick={showBottomPanel}
9090
sx={{ borderTop: '2px solid #191919' }}
9191
/>
9292
<Tab
93-
disableRipple
9493
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
9594
label="Customization"
9695
onClick={showBottomPanel}
9796
sx={{ borderTop: '2px solid #191919' }}
9897
/>
9998
<Tab
100-
disableRipple
10199
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
102100
label="CSS Editor"
103101
onClick={showBottomPanel}
104102
sx={{ borderTop: '2px solid #191919' }}
105103
/>
106104
<Tab
107-
disableRipple
108105
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
109106
label="Component Tree"
110107
onClick={showBottomPanel}
111108
/>
112109
<Tab
113-
disableRipple
114110
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
115111
label="Context Manager"
116112
onClick={showBottomPanel}
117113
/>
118114
<Tab
119-
disableRipple
120115
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
121116
label="State Manager"
122117
onClick={showBottomPanel}
123118
/>
119+
<Tab
120+
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
121+
label="MUI Props"
122+
onClick={showBottomPanel}
123+
/>
124124
</Tabs>
125125

126126
<div className={classes.projectTypeWrapper}>
@@ -161,13 +161,8 @@ const BottomTabs = (props): JSX.Element => {
161161
{tab === 3 && <StylesEditor theme={theme} setTheme={setTheme} />}
162162
{tab === 4 && <Tree data={components} />}
163163
{tab === 5 && <ContextManager theme={theme} setTheme={setTheme} />}
164-
{tab === 6 && (
165-
<StateManager
166-
theme={theme}
167-
setTheme={setTheme}
168-
isThemeLight={isThemeLight}
169-
/>
170-
)}
164+
{tab === 6 && (<StateManager theme={theme} setTheme={setTheme} isThemeLight={isThemeLight} />)}
165+
{tab === 7 && <MUIProps theme={theme} setTheme={setTheme} />}
171166
</div>
172167
</div>
173168
</MeetingProvider>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, { useState } from 'react';
2+
import { Button, TextField } from "@mui/material";
3+
import { Send } from "@mui/icons-material";
4+
import MUITypes from "../../redux/MUITypes";
5+
import { MUIType } from '../../interfaces/Interfaces';
6+
import { emitEvent } from '../../helperFunctions/socket';
7+
8+
const MUIProps = (props): JSX.Element => {
9+
const [selectedComponent, setSelectedComponent] = useState<MUIType | null>(null);
10+
11+
const handleComponentSelect = (component: MUIType) => {
12+
setSelectedComponent(component);
13+
};
14+
15+
const handleSend = () => {
16+
if (selectedComponent) {
17+
emitEvent("add-component", selectedComponent, {placeholder: "Placeholder"});
18+
}
19+
};
20+
21+
return (
22+
<div>
23+
<div style={{ display: "flex", flexDirection: "column" }}>
24+
{MUITypes.map((component) => (
25+
<Button
26+
key={component.id}
27+
onClick={() => handleComponentSelect(component)}
28+
sx={{ marginBottom: "0.5rem" }}
29+
>
30+
{component.name}
31+
</Button>
32+
))}
33+
</div>
34+
<Button
35+
onClick={handleSend}
36+
variant="contained"
37+
endIcon={<Send />}
38+
sx={{ marginTop: "1rem" }}
39+
>
40+
Save
41+
</Button>
42+
</div>
43+
);
44+
};
45+
46+
export default MUIProps;
47+

0 commit comments

Comments
 (0)