Skip to content

Commit 7e054d7

Browse files
committed
changed styling of form group for textfields for module panel, turned header buttons into separate modules
1 parent eca4bc6 commit 7e054d7

File tree

7 files changed

+269
-295
lines changed

7 files changed

+269
-295
lines changed

app/src/components/left/HTMLPanel.tsx

Lines changed: 63 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,15 @@ const HTMLPanel = (props): JSX.Element => {
113113

114114
const handleSubmit = (e) => {
115115
e.preventDefault();
116-
116+
console.log('did submit');
117117
if (tag.trim() === '' || name.trim() === '') return triggerError('empty');
118118
if (!tag.charAt(0).match(/[a-zA-Z]/) || !name.charAt(0).match(/[a-zA-Z]/))
119119
return triggerError('letters');
120120
if (!alphanumeric(tag) || !alphanumeric(name))
121121
return triggerError('symbolsDetected');
122122
if (checkNameDupe(tag) || checkNameDupe(name)) return triggerError('dupe');
123123
if (name.length > 10) return triggerError('length');
124+
setAlertOpen(true);
124125
createOption(tag, name);
125126
resetError();
126127
};
@@ -143,8 +144,6 @@ const HTMLPanel = (props): JSX.Element => {
143144
};
144145
}, []);
145146

146-
const handleAlertOpen = () => setAlertOpen(true);
147-
148147
const handleAlertClose = (
149148
event: React.SyntheticEvent | Event,
150149
reason?: string
@@ -162,126 +161,84 @@ const HTMLPanel = (props): JSX.Element => {
162161

163162
return (
164163
<>
165-
<div className="HTMLItemCreate">
166-
<div className={`${classes.addComponentWrapper}`}>
167-
<div className={classes.inputWrapper}>
168-
<form onSubmit={handleSubmit} className="customForm">
169-
<TextField
170-
id="outlined-basic"
171-
label="Element Name"
172-
variant="outlined"
173-
size="small"
174-
value={name}
175-
autoComplete="off"
176-
placeholder="Element Name"
177-
sx={{ width: '80%' }}
178-
onChange={handleNameChange}
179-
helperText={errorMsg}
180-
/>
181-
<div
182-
style={{ display: 'flex', alignItems: 'center', width: '100%' }}
183-
>
184-
<TextField
185-
id="outlined-basic"
186-
label="HTML Tag"
187-
variant="outlined"
188-
size="small"
189-
value={tag}
190-
autoComplete="off"
191-
placeholder="HTML Tag"
192-
sx={{ width: '80%' }}
193-
onChange={handleTagChange}
194-
helperText={errorMsg}
195-
/>
196-
<Fab
197-
id="submitButton"
198-
type="submit"
199-
color="primary"
200-
aria-label="add"
201-
size="small"
202-
value="Add Element"
203-
sx={{ width: '15%', height: 40, borderRadius: 1 }}
204-
onClick={handleAlertOpen}
205-
>
206-
<AddIcon />
207-
</Fab>
208-
</div>
209-
</form>
210-
</div>
164+
<form onSubmit={handleSubmit} className={classes.customForm}>
165+
<div className={classes.inputWrapper}>
166+
<TextField
167+
id="outlined-basic"
168+
label="Element Name"
169+
variant="outlined"
170+
size="small"
171+
value={name}
172+
autoComplete="off"
173+
sx={{ width: '80%' }}
174+
onChange={handleNameChange}
175+
helperText={errorMsg}
176+
/>
211177
</div>
212-
</div>
213-
<>
214-
<Snackbar
215-
open={alertOpen}
216-
autoHideDuration={3000}
217-
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
178+
<div className={classes.inputWrapper}>
179+
<TextField
180+
id="outlined-basic"
181+
label="HTML Tag"
182+
variant="outlined"
183+
size="small"
184+
value={tag}
185+
autoComplete="off"
186+
sx={{ width: '80%' }}
187+
onChange={handleTagChange}
188+
helperText={errorMsg}
189+
/>
190+
<Fab
191+
id="submitButton"
192+
type="submit"
193+
color="primary"
194+
aria-label="add"
195+
size="small"
196+
value="Add Element"
197+
sx={{ width: '15%', height: 40, borderRadius: 1 }}
198+
onClick={handleSubmit}
199+
>
200+
<AddIcon />
201+
</Fab>
202+
</div>
203+
</form>
204+
205+
<Snackbar
206+
open={alertOpen}
207+
autoHideDuration={3000}
208+
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
209+
onClose={handleAlertClose}
210+
>
211+
<Alert
218212
onClose={handleAlertClose}
213+
severity="success"
214+
sx={{ width: '100%', color: 'white', backgroundColor: '#f88e16' }}
219215
>
220-
<Alert
221-
onClose={handleAlertClose}
222-
severity="success"
223-
sx={{ width: '100%', color: 'white', backgroundColor: '#f88e16' }}
224-
>
225-
HTML Tag Created!
226-
</Alert>
227-
</Snackbar>
228-
</>
216+
HTML Tag Created!
217+
</Alert>
218+
</Snackbar>
229219
</>
230220
);
231221
};
232222

233223
const useStyles = makeStyles({
234-
inputField: {
235-
marginTop: '10px',
236-
borderRadius: '5px',
237-
whiteSpace: 'nowrap',
238-
overflowX: 'hidden',
239-
textOverflow: 'ellipsis',
240-
backgroundColor: 'rgba(255,255,255,0.15)',
241-
margin: '0px 0px 0px 10px',
242-
width: '100%',
243-
height: '30px'
224+
customForm: {
225+
display: 'flex',
226+
flexDirection: 'column',
227+
alignItems: 'start'
244228
},
245229
inputWrapper: {
230+
display: 'flex',
246231
width: '100%',
247232
marginBottom: '10px', // was originally 10px, decreased to 0 to decrease overall menu height
248-
alignItems: 'center'
249-
},
250-
addComponentWrapper: {
251-
width: '100%'
252-
},
253-
input: {
254-
width: '500px',
255-
whiteSpace: 'nowrap',
256-
overflowX: 'hidden',
257-
textOverflow: 'ellipsis',
258-
margin: '0px 0px 0px 0px',
259-
alignSelf: 'center'
260-
},
261-
lightThemeFontColor: {
262-
color: 'white',
263-
'& .MuiInputBase-root': {
264-
color: 'rgba (0, 0, 0, 0.54)'
265-
}
266-
},
267-
darkThemeFontColor: {
268-
color: '#ffffff',
269-
'& .MuiInputBase-root': {
270-
color: '#fff'
271-
}
233+
justifyContent: 'start'
272234
},
273235
errorMessage: {
274236
display: 'flex',
275-
alignSelf: 'center',
237+
alignSelf: 'start',
276238
fontSize: '11px',
277239
marginTop: '10px',
278-
width: '150px'
279-
},
280-
errorMessageLight: {
281-
color: '#6B6B6B'
282-
},
283-
errorMessageDark: {
284-
color: 'white'
240+
width: '150px',
241+
borderRadius: '5px'
285242
}
286243
});
287244

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import Popover, { PopoverProps } from '@mui/material/Popover';
4+
import Typography from '@mui/material/Typography';
5+
import makeStyles from '@mui/styles/makeStyles';
6+
import Button from '@mui/material/Button';
7+
import HelpIcon from '@mui/icons-material/Help';
8+
9+
const HeaderButton = (props) => {
10+
const [anchorEl, setAnchorEl] =
11+
React.useState<PopoverProps['anchorEl']>(null);
12+
const classes = useStyles();
13+
const handleClickPopover = (event: React.MouseEvent<HTMLElement>) => {
14+
setAnchorEl(anchorEl ? null : event.currentTarget);
15+
};
16+
17+
const handleClose = () => {
18+
setAnchorEl(null);
19+
};
20+
const open = Boolean(anchorEl);
21+
const id = open ? open : undefined;
22+
23+
return (
24+
<div className={classes.headerButton}>
25+
<Button
26+
component="label"
27+
aria-label={id}
28+
id={id}
29+
onClick={handleClickPopover}
30+
>
31+
{'Create Modules'}
32+
<Popover
33+
id={id}
34+
open={open}
35+
anchorEl={anchorEl}
36+
onClose={handleClose}
37+
anchorOrigin={{
38+
vertical: 'top',
39+
horizontal: 'center'
40+
}}
41+
transformOrigin={{
42+
vertical: 'bottom',
43+
horizontal: 'center'
44+
}}
45+
>
46+
<div className={classes.popover}>
47+
<div>
48+
<HelpIcon id={id} size="small" />
49+
</div>
50+
<div>
51+
Add modules to create a canvas for grouping your components.
52+
</div>
53+
</div>
54+
</Popover>
55+
</Button>
56+
</div>
57+
);
58+
};
59+
60+
const useStyles = makeStyles({
61+
popover: {
62+
backgroundColor: 'white',
63+
width: '200px',
64+
color: 'black',
65+
fontSize: '0.8rem',
66+
padding: '10px'
67+
}
68+
});
69+
export default HeaderButton;

app/src/components/left/ModulePanel.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import React, { useState } from 'react';
2-
3-
import { Button, Box } from '@mui/material';
2+
import Button from '@mui/material/Button';
3+
import Box from '@mui/material/Box';
44
import AddCircleIcon from '@mui/icons-material/AddCircle';
55
import ComponentDrag from './ComponentDrag';
66
import ComponentPanel from '../right/ComponentPanel';
77
import { RootState } from '../../redux/store';
88
import { useSelector } from 'react-redux';
99
import ComponentsContainer from './ComponentsContainer';
1010
import CreatePanel from './CreatePanel';
11+
import HeaderButton from './HeaderButton';
1112

1213
interface ModulePanelProps {
1314
isThemeLight: boolean;
1415
}
15-
16-
const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
16+
const ModulePanel: React.FC<ModulePanelProps> = ({
17+
isThemeLight
18+
}: ModulePanelProps) => {
1719
const state = useSelector((store: RootState) => store.appState);
1820
const [isCreatingModule, setIsCreatingModule] = useState(false);
1921
const [isEditingModule, setIsEditingModule] = useState(false);
@@ -30,26 +32,19 @@ const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
3032
setIsEditingModule(!isEditingModule);
3133
};
3234

33-
// Make visibility of custom components conditional ⭕️
34-
3535
return (
36-
<Box
37-
sx={{
38-
display: 'flex',
39-
flexDirection: 'column',
40-
alignItems: 'center',
41-
justifyContent: 'top',
42-
color: '#f7f4dc',
43-
textAlign: 'center',
44-
marginLeft: '15px'
45-
}}
46-
>
36+
<div className="modulePanelContainer">
4737
{isEditingModule ? (
48-
<CreatePanel isThemeLight={true} />
38+
<CreatePanel />
4939
) : (
50-
<div>
51-
<Button component="label">{'Create Modules'}</Button>
52-
{/* {isCreatingModule ? ( */}
40+
<div className="createComponent">
41+
<HeaderButton
42+
isThemeLight={true}
43+
infoText={
44+
'Add modules to create a canvas for grouping your components.'
45+
}
46+
headerName={'headerName'}
47+
/>
5348
<ComponentPanel
5449
setIsCreatingModule={setIsCreatingModule}
5550
isThemeLight={false}
@@ -59,7 +54,6 @@ const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
5954
isThemeLight={false}
6055
handleClickEditModule={handleClickEditModule}
6156
/>
62-
6357
{customComponents.length > 0 && (
6458
<div>
6559
<div
@@ -79,7 +73,7 @@ const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
7973
)}
8074
</div>
8175
)}
82-
</Box>
76+
</div>
8377
);
8478
};
8579

0 commit comments

Comments
 (0)