Skip to content

Commit d1d7ddd

Browse files
committed
Cleaned up code after inline styling was completed using classes
1 parent 1d61492 commit d1d7ddd

File tree

4 files changed

+157
-102
lines changed

4 files changed

+157
-102
lines changed

src/components/HtmlAttr.tsx

Lines changed: 104 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const availableButtonTypes = {
6262
// function for generating the button types for select dropdown
6363
// uses Object.keys method on object of drop down types
6464
const buttonTypeOptions = [
65-
<option value="" key="" />,
65+
<option value='' key='' />,
6666
...Object.keys(availableButtonTypes).map(type => (
6767
<option value={type} key={type} style={{ color: '#000' }}>
6868
{type == null ? '' : type}
@@ -76,13 +76,16 @@ let buttonTypeTemp: string;
7676
// HtmlAttr is creating attributes grabbed from htmlElement & placing them
7777
// as the new state
7878
class HtmlAttr extends Component<HTMLAttrPropsInt, StateInt> {
79-
state = HTMLelements[this.props.focusChild.htmlElement].attributes.reduce((acc, attr) => {
80-
acc[attr] = '';
79+
state = HTMLelements[this.props.focusChild.htmlElement].attributes.reduce(
80+
(acc, attr) => {
81+
acc[attr] = '';
8182

82-
return acc;
83-
}, {});
83+
return acc;
84+
},
85+
{}
86+
);
8487

85-
// looks like:
88+
// State looks like:
8689
// className: '',
8790
// id: '',
8891
// type: '',
@@ -123,96 +126,108 @@ class HtmlAttr extends Component<HTMLAttrPropsInt, StateInt> {
123126

124127
const focusChildType = focusChild.htmlElement;
125128

126-
const HtmlForm = HTMLelements[focusChildType].attributes.map((attr: string, i: number) => (
127-
<Grid container spacing={0} key={i} style={{ marginTop: '10px', marginRight: '20px' }}>
128-
<Grid item xs={1}>
129-
{/* if the attr being rendered for the HTMLForm is a button, then give it a special
129+
const HtmlForm = HTMLelements[focusChildType].attributes.map(
130+
(attr: string, i: number) => (
131+
<Grid
132+
container
133+
spacing={0}
134+
key={i}
135+
style={{ marginTop: '10px', marginRight: '20px' }}
136+
>
137+
<Grid item xs={1}>
138+
{/* if the attr being rendered for the HTMLForm is a button, then give it a special
130139
condition to render a "select" component rather than a text-input component */}
131-
{attr == 'type' ? (
132-
<FormControl required>
133-
<InputLabel className={classes.light} htmlFor="htmlType">
134-
Type
135-
</InputLabel>
136-
<Select
137-
native
138-
className={classes.light}
139-
id="htmlType"
140-
placeholder="title"
141-
onChange={this.handleChange}
142-
value={buttonTypeTemp}
143-
defaultValue={'button'}
144-
style={{
145-
background: '#424242',
146-
height: '45px',
147-
width: '146px',
148-
marginBottom: '23px',
149-
marginTop: '0px',
150-
color: '#fff',
151-
paddingLeft: '14px'
140+
{attr == 'type' ? (
141+
<FormControl required>
142+
<InputLabel className={classes.light} htmlFor='htmlType'>
143+
Type
144+
</InputLabel>
145+
<Select
146+
native
147+
className={classes.light}
148+
id='htmlType'
149+
placeholder='title'
150+
onChange={this.handleChange}
151+
value={buttonTypeTemp}
152+
defaultValue={'button'}
153+
style={{
154+
background: '#424242',
155+
height: '45px',
156+
width: '146px',
157+
marginBottom: '23px',
158+
marginTop: '0px',
159+
color: '#fff',
160+
paddingLeft: '14px'
161+
}}
162+
required
163+
>
164+
{buttonTypeOptions}
165+
</Select>
166+
</FormControl>
167+
) : (
168+
<TextField
169+
InputLabelProps={{
170+
classes: {
171+
root: classes.cssLabel,
172+
focused: classes.cssFocused,
173+
input: classes.input
174+
}
175+
}}
176+
InputProps={{
177+
classes: {
178+
root: classes.cssOutlinedInput,
179+
focused: classes.cssFocused,
180+
notchedOutline: classes.notchedOutline,
181+
input: classes.input
182+
}
152183
}}
153-
required
154-
>
155-
{buttonTypeOptions}
156-
</Select>
157-
</FormControl>
158-
) : (
159-
<TextField
160-
InputLabelProps={{
161-
classes: {
162-
root: classes.cssLabel,
163-
focused: classes.cssFocused,
164-
input: classes.input
165-
}
184+
style={{ background: '#424242', height: '70%' }}
185+
label={attr}
186+
variant='outlined'
187+
id={attr}
188+
onChange={this.handleChange}
189+
value={this.state[attr]}
190+
/>
191+
)}
192+
</Grid>
193+
<Grid item xs={2}>
194+
<Fab
195+
variant='extended'
196+
size='small'
197+
color='default'
198+
aria-label='Save'
199+
style={{
200+
marginLeft: '10px',
201+
marginTop: '5px',
202+
marginBottom: '10px'
166203
}}
167-
InputProps={{
168-
classes: {
169-
root: classes.cssOutlinedInput,
170-
focused: classes.cssFocused,
171-
notchedOutline: classes.notchedOutline,
172-
input: classes.input
173-
}
204+
onClick={e => {
205+
e.preventDefault();
206+
this.handleSave(attr);
174207
}}
175-
style={{ background: '#424242', height: '70%' }}
176-
label={attr}
177-
variant="outlined"
178-
id={attr}
179-
onChange={this.handleChange}
180-
value={this.state[attr]}
181-
/>
182-
)}
183-
</Grid>
184-
<Grid item xs={2}>
185-
<Fab
186-
variant="extended"
187-
size="small"
188-
color="default"
189-
aria-label="Save"
190-
style={{
191-
marginLeft: '10px',
192-
marginTop: '5px',
193-
marginBottom: '10px'
194-
}}
195-
onClick={e => {
196-
e.preventDefault();
197-
this.handleSave(attr);
198-
}}
199-
>
200-
<SaveIcon />
201-
Save
202-
</Fab>
203-
</Grid>
204-
<Grid item xs={3}>
205-
<Paper className={classes.root} style={{ height: '70%' }}>
206-
<p style={{ color: 'black' }}>
207-
{focusChild.HTMLInfo[attr] ? focusChild.HTMLInfo[attr] : ' no attribute assigned'}
208-
</p>
209-
</Paper>
208+
>
209+
<SaveIcon />
210+
Save
211+
</Fab>
212+
</Grid>
213+
<Grid item xs={3}>
214+
<Paper className={classes.root} style={{ height: '70%' }}>
215+
<p style={{ color: 'black' }}>
216+
{focusChild.HTMLInfo[attr]
217+
? focusChild.HTMLInfo[attr]
218+
: ' no attribute assigned'}
219+
</p>
220+
</Paper>
221+
</Grid>
210222
</Grid>
211-
</Grid>
212-
));
223+
)
224+
);
213225

214226
return <div className={'htmlattr'}>{HtmlForm}</div>;
215227
}
216228
}
217229

218-
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(HtmlAttr));
230+
export default connect(
231+
mapStateToProps,
232+
mapDispatchToProps
233+
)(withStyles(styles)(HtmlAttr));

src/components/Props.tsx

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import React, { Component, Fragment } from 'react';
22
import { connect } from 'react-redux';
33
import { withStyles, Theme } from '@material-ui/core/styles';
44
import FormControl from '@material-ui/core/FormControl';
5+
import Grow from '@material-ui/core/Grow';
6+
import Paper from '@material-ui/core/Paper';
57
import Grid from '@material-ui/core/Grid';
68
import TextField from '@material-ui/core/TextField';
79
import Button from '@material-ui/core/Button';
10+
import Input from '@material-ui/core/Input';
811
import Select from '@material-ui/core/Select';
912
import Switch from '@material-ui/core/Switch';
1013
import InputLabel from '@material-ui/core/InputLabel';
@@ -58,7 +61,10 @@ const styles = (theme: any) => ({
5861
borderRadius: '11px',
5962
height: '40%',
6063
overflowWrap: 'break-word',
61-
padding: '8px'
64+
paddingLeft: '15px',
65+
paddingTop: '5px',
66+
paddingBottom: '5px',
67+
fontSize: '1.2rem'
6268
},
6369
inputLabel: {
6470
fontSize: '1.3rem',
@@ -68,14 +74,17 @@ const styles = (theme: any) => ({
6874
color: '#fff'
6975
},
7076
select: {
71-
color: '#000',
77+
color: '#fff',
7278
marginBottom: '10px',
73-
width: '100%',
74-
backgroundColor: '#65BAEE',
79+
width: '8rem',
80+
backgroundColor: '#91D1F9',
7581
borderRadius: '11px',
7682
height: '40%',
7783
overflowWrap: 'break-word',
78-
padding: '8px'
84+
paddingLeft: '15px',
85+
paddingTop: '5px',
86+
paddingBottom: '5px',
87+
fontSize: '1.2rem'
7988
},
8089
selectLabel: {
8190
fontSize: '1.3rem',
@@ -84,6 +93,25 @@ const styles = (theme: any) => ({
8493
top: '-2.5rem',
8594
color: '#fff'
8695
},
96+
addProp: {
97+
width: '15rem',
98+
marginLeft: '3rem',
99+
height: '4rem',
100+
transition: 'all 0.1s ease-out',
101+
border: '2px solid #33eb91',
102+
background: 'transparent',
103+
color: '#fff',
104+
'&:hover': {
105+
transform: 'scale(1.1)',
106+
fontSize: '1.2rem',
107+
backgroundColor: '#33eb91',
108+
color: '#006400'
109+
}
110+
},
111+
dataTable: {
112+
border: '1px solid red',
113+
backgroundColor: 'red'
114+
},
87115
light: {
88116
color: '#eee'
89117
},
@@ -144,6 +172,8 @@ class Props extends Component<PropsPropsInt, StateInt> {
144172
};
145173
}
146174

175+
// using useState to locally check a clickedValue
176+
147177
handleChange = (event: MouseEvent | any) => {
148178
if (event.target.id === 'propVariable') {
149179
this.setState({
@@ -207,8 +237,6 @@ class Props extends Component<PropsPropsInt, StateInt> {
207237
render() {
208238
const { focusComponent, classes, deleteProp } = this.props;
209239

210-
console.log('this is focus component', focusComponent);
211-
212240
// this will display the two fields of data at the focused component level
213241
const rowHeader = ['Prop', 'Type'];
214242

@@ -312,9 +340,8 @@ class Props extends Component<PropsPropsInt, StateInt> {
312340
onChange={this.handleChange}
313341
value={this.state.propType}
314342
required
315-
>
316-
{typeOptions}
317-
</Select>
343+
children={typeOptions}
344+
/>
318345
</FormControl>
319346
</Grid>
320347
{/* MAYBE not needed for React Components? */}
@@ -343,15 +370,29 @@ class Props extends Component<PropsPropsInt, StateInt> {
343370
// disabled={!this.state.propKey || !this.state.propType}
344371
variant='contained'
345372
size='large'
373+
className={classes.addProp}
346374
>
347375
ADD PROP
348376
</Button>
349377
</Grid>
350378
</Grid>
351379
</form>
352380
</Grid>
353-
<Grid item xs={8}>
381+
<Grid
382+
item
383+
xs={8}
384+
style={{
385+
height: '17rem',
386+
overflow: 'scroll',
387+
marginTop: '1rem',
388+
paddingBottom: '1rem',
389+
paddingTop: '0'
390+
}}
391+
>
354392
<DataTable
393+
InputProps={{
394+
className: classes.dataTable
395+
}}
355396
rowHeader={rowHeader}
356397
rowData={propsRows}
357398
deletePropHandler={deleteProp}

src/public/styles/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ div.Component-horizontalScrollContainer-543 {
106106

107107
/* affects component props layout in Component Props Tab */
108108

109-
/* left side comp label */
109+
/* left side comp label */ ///
110110
#app
111111
> div
112112
> div

src/utils/componentRender.util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ const componentRender = (
144144
.join('\n')}
145145
146146
interface Props {
147-
${console.log('being USED from props')}
148147
${props.map(prop => `${prop.key}: ${typeSwitcher(prop.type)}\n`)}
149148
};
150149

0 commit comments

Comments
 (0)