Skip to content

Commit 893927a

Browse files
committed
added header button with popover
1 parent 4cd722b commit 893927a

File tree

7 files changed

+148
-79
lines changed

7 files changed

+148
-79
lines changed

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const AddContextForm = ({
4242
setCurrentContext,
4343
errorMsg,
4444
errorStatus,
45-
setErrorStatus,
45+
setErrorStatus
4646
}) => {
4747
const { allContext } = contextStore;
4848
const [btnDisabled, setBtnDisabled] = useState(false);
@@ -66,7 +66,7 @@ const AddContextForm = ({
6666
// event handle for confirmation modal
6767
const handleClose = (
6868
event: React.SyntheticEvent | Event,
69-
reason?: string,
69+
reason?: string
7070
) => {
7171
if (reason === 'clickaway') {
7272
return;
@@ -77,7 +77,7 @@ const AddContextForm = ({
7777

7878
const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
7979
props,
80-
ref,
80+
ref
8181
) {
8282
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
8383
});
@@ -103,11 +103,11 @@ const AddContextForm = ({
103103
<Box sx={{ display: 'flex', gap: 2, mb: 4 }}>
104104
<TextField
105105
InputProps={{
106-
style: { color: color },
106+
style: { color: color }
107107
}}
108108
onChange={handleChange}
109109
sx={{
110-
width: 425,
110+
width: 425
111111
}}
112112
label="context"
113113
value={contextInput}
@@ -138,7 +138,7 @@ const AddContextForm = ({
138138
textTransform: 'capitalize',
139139
height: '50px',
140140
width: '100px',
141-
fontSize: '15px',
141+
fontSize: '15px'
142142
}}
143143
>
144144
Create
@@ -172,7 +172,7 @@ const AddContextForm = ({
172172
textTransform: 'capitalize',
173173
height: '50px',
174174
width: '100px',
175-
fontSize: '15px',
175+
fontSize: '15px'
176176
}}
177177
>
178178
Delete

app/src/components/left/ComponentDrag.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RootState } from '../../redux/store';
55
import makeStyles from '@mui/styles/makeStyles';
66
import { useSelector } from 'react-redux';
77
import ComponentPanelItem from '../right/ComponentPanelItem';
8+
import HeaderButton from '../left/HeaderButton';
89

910
const useStyles = makeStyles({
1011
panelWrapper: {
@@ -41,6 +42,10 @@ const ComponentDrag = ({
4142
}): JSX.Element | null => {
4243
const classes = useStyles();
4344
const state = useSelector((store: RootState) => store.appState);
45+
let buttonTitle =
46+
state.projectType === 'Next.js' || state.projectType === 'Gatsby.js'
47+
? 'Pages'
48+
: 'Root';
4449

4550
const isFocus = (targetId: number) =>
4651
state.canvasFocus.componentId === targetId ? true : false;
@@ -50,11 +55,18 @@ const ComponentDrag = ({
5055
return (
5156
<div className={classes.panelWrapper}>
5257
<div className={classes.panelWrapperList}>
53-
<h4 className={classes.darkThemeFontColor} style={{ color: '#f88e16' }}>
58+
<HeaderButton
59+
headerName={buttonTitle}
60+
id={buttonTitle}
61+
infoText={
62+
'The root serves as the entry point for the rest of the app. Use a root component as the foundation from which all the rest of your hierarchy is nested.'
63+
}
64+
/>
65+
{/* <h4 className={classes.darkThemeFontColor} style={{ color: '#f88e16' }}>
5466
{state.projectType === 'Next.js' || state.projectType === 'Gatsby.js'
5567
? 'Pages'
5668
: 'Root Module(s)'}
57-
</h4>
69+
</h4> */}
5870
<Grid
5971
container
6072
direction="column"

app/src/components/left/CreatePanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import MUIItem from './MUIItem';
1414
import HTMLItem from './HTMLItem';
1515
import HTMLPanel from './HTMLPanel';
1616
import ComponentDrag from './ComponentDrag';
17+
import HeaderButton from './HeaderButton';
1718

1819
/**
1920
* Provides a user interface for managing HTMLitems & MUIItems in the application. It features accordions for different categories
@@ -191,7 +192,7 @@ const CreatePanel = (props): JSX.Element => {
191192
'Speed Dial'
192193
]);
193194

194-
const makeMenuCategory = (typeArray, name, idx) =>
195+
const makeMenuCategory = (typeArray, name, idx, infoText) =>
195196
name ? (
196197
<>
197198
<Box
@@ -219,7 +220,14 @@ const CreatePanel = (props): JSX.Element => {
219220

220221
return (
221222
<div className={'MUIItems'}>
222-
<Button component="label">{'Custom Elements'}</Button>
223+
{/* <HeaderButton
224+
isThemeLight={props.isThemeLight}
225+
infoText={`Add more HTML elements to drag and drop onto your canvas.
226+
Each element requires a tag. For a list of all possible HTML elements,
227+
please refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element.`}
228+
headerName={'Custom Elements'}
229+
id={'CustomElementsBtn'}
230+
/> */}
223231
<HTMLPanel isThemeLight={props.isThemeLight} />
224232
{makeMenuCategory([
225233
state.HTMLTypes.filter((type) => type.id > 10000).map(

app/src/components/left/HTMLPanel.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Snackbar from '@mui/material/Snackbar';
1111
import { addElement } from '../../redux/reducers/slice/appStateSlice';
1212
import { emitEvent } from '../../helperFunctions/socket';
1313
import { RootState } from '../../redux/store';
14+
import HelpIcon from '@mui/icons-material/Help';
15+
import Popover, { PopoverProps } from '@mui/material/Popover';
1416

1517
/**
1618
* Provides a user interface for creating custom HTML elements in the application. It includes
@@ -27,6 +29,9 @@ import { RootState } from '../../redux/store';
2729
*/
2830
const HTMLPanel = (props): JSX.Element => {
2931
const classes = useStyles();
32+
const [anchorEl, setAnchorEl] =
33+
React.useState<PopoverProps['anchorEl']>(null);
34+
3035
const [tag, setTag] = useState('');
3136
const [name, setName] = useState('');
3237
const [errorMsg, setErrorMsg] = useState('');
@@ -143,7 +148,15 @@ const HTMLPanel = (props): JSX.Element => {
143148
document.removeEventListener('keydown', handleCreateElement);
144149
};
145150
}, []);
151+
const handleClickPopover = (event: React.MouseEvent<HTMLElement>) => {
152+
setAnchorEl(anchorEl ? null : event.currentTarget);
153+
};
146154

155+
const handleClose = () => {
156+
setAnchorEl(null);
157+
};
158+
const open = Boolean(anchorEl);
159+
const id = open ? open : undefined;
147160
const handleAlertClose = (
148161
event: React.SyntheticEvent | Event,
149162
reason?: string
@@ -174,6 +187,26 @@ const HTMLPanel = (props): JSX.Element => {
174187
onChange={handleNameChange}
175188
helperText={errorMsg}
176189
/>
190+
<HelpIcon
191+
id={'helpicon'}
192+
size="medium"
193+
sx={{ alignSelf: 'center', marginLeft: '12px' }}
194+
onClick={handleClickPopover}
195+
/>
196+
<Popover
197+
id={id}
198+
open={open}
199+
anchorEl={anchorEl}
200+
onClose={handleClose}
201+
anchorOrigin={{
202+
vertical: 'top',
203+
horizontal: 'right'
204+
}}
205+
transformOrigin={{
206+
vertical: 'bottom',
207+
horizontal: 'left'
208+
}}
209+
></Popover>
177210
</div>
178211
<div className={classes.inputWrapper}>
179212
<TextField

app/src/components/left/HeaderButton.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,28 @@ const HeaderButton = (props) => {
2727
aria-label={id}
2828
id={id}
2929
onClick={handleClickPopover}
30+
key={props.headerName}
3031
>
31-
{'Module Editor'}
32+
{props.headerName}
3233
<Popover
3334
id={id}
3435
open={open}
3536
anchorEl={anchorEl}
3637
onClose={handleClose}
3738
anchorOrigin={{
3839
vertical: 'top',
39-
horizontal: 'center'
40+
horizontal: 'right'
4041
}}
4142
transformOrigin={{
4243
vertical: 'bottom',
43-
horizontal: 'center'
44+
horizontal: 'left'
4445
}}
4546
>
4647
<div className={classes.popover}>
47-
{/* <div>
48+
<div className={classes.popoverIcon}>
4849
<HelpIcon id={id} size="small" />
49-
</div> */}
50-
<div>
51-
Add modules to create a canvas for grouping your components.
5250
</div>
51+
<div>{props.infoText}</div>
5352
</div>
5453
</Popover>
5554
</Button>
@@ -58,12 +57,21 @@ const HeaderButton = (props) => {
5857
};
5958

6059
const useStyles = makeStyles({
60+
headerButton: {
61+
alignSelf: 'center'
62+
},
6163
popover: {
62-
backgroundColor: 'white',
63-
width: '200px',
64+
backgroundColor: '#ffdbbb',
65+
display: 'flex',
6466
color: 'black',
6567
fontSize: '0.8rem',
66-
padding: '10px'
68+
padding: '8px',
69+
width: '300px'
70+
},
71+
popoverIcon: {
72+
paddingRight: '10px',
73+
paddingLeft: '8px',
74+
paddingTop: '10px'
6775
}
6876
});
6977
export default HeaderButton;

app/src/components/left/ModulePanel.tsx

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22
import Button from '@mui/material/Button';
33
import Box from '@mui/material/Box';
4-
import AddCircleIcon from '@mui/icons-material/AddCircle';
4+
55
import ComponentDrag from './ComponentDrag';
66
import ComponentPanel from '../right/ComponentPanel';
77
import { RootState } from '../../redux/store';
@@ -55,38 +55,25 @@ const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
5555
{isEditingModule ? (
5656
<CreatePanel />
5757
) : (
58-
<div className="createComponent">
58+
<div
59+
className="createComponent"
60+
style={{
61+
color: '#f88e16',
62+
textAlign: 'center'
63+
}}
64+
>
5965
<HeaderButton
60-
isThemeLight={true}
61-
infoText={
62-
'Add modules to create a canvas for grouping your components.'
63-
}
64-
headerName={'headerName'}
66+
isThemeLight={'true'}
67+
infoText={`Add modules to create a canvas for grouping your components.
68+
Once created, you can drag modules into other modules to link them.
69+
Each module will be exported as its own file.`}
70+
headerName={'Add Modules'}
6571
/>
6672
<ComponentPanel
6773
setIsCreatingModule={setIsCreatingModule}
6874
isThemeLight={false}
6975
/>
70-
<Grid container justifyContent="space-around" columnSpacing={2}>
71-
{htmlTypesToRender.map((option) => {
72-
if (
73-
(option.name === 'Switch' ||
74-
option.name === 'LinkTo' ||
75-
option.name === 'Route') &&
76-
state.projectType === 'Classic React'
77-
) {
78-
return (
79-
<HTMLItem
80-
name={option.name}
81-
key={`html-${option.name}`}
82-
id={option.id}
83-
icon={option.icon}
84-
handleDelete={handleDelete}
85-
/>
86-
);
87-
}
88-
})}
89-
</Grid>
76+
9077
<ComponentDrag
9178
isVisible={true}
9279
isThemeLight={false}
@@ -97,16 +84,40 @@ const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
9784
<div
9885
style={{
9986
color: '#f88e16',
100-
textAlign: 'center',
101-
padding: '20px'
87+
textAlign: 'center'
88+
10289
// border: '1px solid #101012'
10390
}}
10491
>
105-
Other Modules
92+
<HeaderButton headerName="Other Modules" infoText="" />
10693
</div>
10794
<ComponentsContainer
10895
handleClickEditModule={handleClickEditModule}
10996
/>
97+
<HeaderButton
98+
headerName="Add Router"
99+
infoText="Turn a module into a single page app with a router."
100+
/>
101+
<Grid container justifyContent="space-around" columnSpacing={2}>
102+
{htmlTypesToRender.map((option) => {
103+
if (
104+
(option.name === 'Switch' ||
105+
option.name === 'LinkTo' ||
106+
option.name === 'Route') &&
107+
state.projectType === 'Classic React'
108+
) {
109+
return (
110+
<HTMLItem
111+
name={option.name}
112+
key={`html-${option.name}`}
113+
id={option.id}
114+
icon={option.icon}
115+
handleDelete={handleDelete}
116+
/>
117+
);
118+
}
119+
})}
120+
</Grid>
110121
</div>
111122
)}
112123
</div>

0 commit comments

Comments
 (0)