Skip to content

Commit a538c27

Browse files
committed
Addressed minor issues and warnings. 3100 problems remain from original 6702. App continues to run with either npm run dev and npm start.
1 parent 525f24f commit a538c27

18 files changed

+380
-407
lines changed

.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
}
99
},
1010
"plugins": ["@typescript-eslint", "import", "react", "jsx-a11y"],
11+
"settings": {
12+
"react": {
13+
"version": "detect"
14+
}
15+
},
1116
"parser": "@typescript-eslint/parser",
1217
"env": {
1318
"browser": true,
@@ -19,7 +24,7 @@
1924
"linebreak-style": 0,
2025
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
2126
"no-unused-vars": "off", // disable the base rule, use the TypeScript version
22-
"no-console": "warn", // ensure that debugging statements are not left in the final version of the code
27+
"no-console": "off", // "warn": ensure that debugging statements are not left in the final version of the code; "off": disabled
2328
"prefer-const": "warn", // enforces that variables that are never reassigned should be declared as const
2429
"no-undef": "warn" // catch references to variables that have not been declared
2530
}

app/src/tutorial/States.tsx

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
/* eslint-disable max-len */
12
import React from 'react';
23
import createState from '../../../resources/state_tutorial_images/CreateState.png';
34
import codePreview from '../../../resources/state_tutorial_images/CodePreview.png';
4-
import fullStateManageTab from '../../../resources/state_tutorial_images/fullStateManageTab.png';
5+
import fullStateManageTab from '../../../resources/state_tutorial_images/fullStateManageTab.png';
56
import table1 from '../../../resources/state_tutorial_images/table1.gif';
67
import table3 from '../../../resources/state_tutorial_images/table3.gif';
78
import deleteState2 from '../../../resources/state_tutorial_images/delete.gif';
@@ -10,7 +11,7 @@ import codePreview2 from '../../../resources/state_tutorial_images/CodePreview2.
1011

1112
/**
1213
* States component provides a tutorial on state management in ReacType.
13-
*
14+
*
1415
* @param {object} props - Component props.
1516
* @param {object} props.classes - CSS classes for styling.
1617
* @param {Function} props.setPage - Function to set the current page.
@@ -19,77 +20,75 @@ import codePreview2 from '../../../resources/state_tutorial_images/CodePreview2.
1920
const States: React.FC<{
2021
classes: any;
2122
setPage: Function;
22-
}> = ({ classes, setPage }): JSX.Element => {
23-
return (
24-
<div className={classes.wrapper}>
25-
<h1 className={classes.title}>State Management</h1>
26-
<hr />
27-
<h2>Step 1: Click on the State Management Tab</h2>
28-
<p className={classes.text}>
29-
Within this tab, there are two sections: "Create/Edit" and "Display".
30-
<br/><br/>
31-
<div className={classes.imgWrapper}>
32-
<img width="600" height="145" src={fullStateManageTab} />
33-
</div>
34-
</p>
35-
<h2>Step 2: Create a New State Variable</h2>
36-
<p className={classes.text}>
37-
In the "Create/Edit" section of the State Manager, you can declare a new state variable. First make sure that you have selected the correct component on the left. This new state variable will be created inside the component highlighted with a red dot (as shown below).
38-
<br/><br/>You can create your state variable with a key, an intial value, and a type (ex: string, number, boolean, etc).<br/><br/>
39-
<div className={classes.imgWrapper}>
40-
<img className={classes.medImg} src={createState} />
41-
</div>
42-
<br/><br/>
43-
You will now see your new state variable in the "Current Component State" table. Also, you can see the React Hook that has been created for this state variable.
44-
<br/><br/>
45-
<div className={classes.imgWrapper}>
46-
<img width="600" src={table1} />
47-
</div>
48-
</p>
49-
<h2>Step 3: Pass in Props from Parent Component</h2>
50-
<p className={classes.text}>
51-
In the "Create/Edit" section of the State Manager, you can also view props available from the parent component. You can choose to import any of the state variables, with or without their associated React Hooks.
52-
<br/><br/>Just click the plus sign next to the state you want to import into the current component. This will automatically update the "Passed In Props from Parent" table on the far right.<br/><br/>
53-
<div className={classes.imgWrapper}>
54-
<img width="1100" src={table3} />
55-
</div>
56-
</p>
57-
<h2>Step 4: Delete Any Unnecessary State Variables</h2>
58-
<p className={classes.text}>
59-
If there are any state variables you want to delete, you can do so in the "Create/Edit" tab!
60-
<br/><br/>You can delete a state variable that was created in the current component by clicking the X next to it in the "Current Component State" table. <br/><br/>
61-
You can also delete state from the "Passed In Props From Parent" table. This will delete the passed in props from the current component, but won't delete the original state variable inside the parent component.
62-
<br/><br/>
63-
For example, in the gif below, we can see the "num" state variable being deleted from the component "Row". Its associated React Hook is also automatically deleted.
64-
<br/><br/>
65-
Then, the "setDarkMode" React Hook is deleted from "Passed In Props From Parent: App". However, if we click over to the "App" parent component, the "setDarkMode" React Hook is still available.
66-
<br/><br/>
67-
<div className={classes.imgWrapper}>
68-
<img width="1300" src={deleteState2} />
69-
</div>
70-
</p>
71-
<br/><br/>
72-
<h2>Step 5: Visualize the State Flow of Your Prototype Application</h2>
73-
<p className={classes.text}>
74-
Once you've added all your state variables to your components, you can click on the "Display" section of the State Manager. Here, you can see a tree diagram that shows the relationship between the components you have created. Click on each component to see its state variables -- including passed in props! <br/><br/>
75-
On the left side of the screen, click on other root components (if using Classic React) or pages (if using Next.js or GatsbyJS) to see their tree diagrams too.
76-
<br/><br/>
77-
<div className={classes.imgWrapper}>
78-
<img width="1400" src={display} />
79-
</div>
80-
<br/><br/>
81-
Created state variables and React Hooks will also be visible in the <span className={classes.notLink} onClick={() => setPage('Code Preview')} >code preview</span>.<br/><br/>
82-
You can see below that the "num" and its associated React Hook have been passed in to the "Row" component from its parent component.
83-
<br/><br/>
84-
On line 10, the state variable "darkMode" has been passed into the "Row" component from its parent, but without its React Hook, since we chose not to pass the hook down from the parent component.
85-
<br/><br/>
86-
<div className={classes.imgWrapper}>
87-
<img className={classes.medImg} src={codePreview2} />
88-
</div>
23+
}> = ({ classes, setPage }): JSX.Element => (
24+
<div className={classes.wrapper}>
25+
<h1 className={classes.title}>State Management</h1>
26+
<hr />
27+
<h2>Step 1: Click on the State Management Tab</h2>
28+
<p className={classes.text}>
29+
Within this tab, there are two sections: &quot;Create/Edit&quot; and &quot;Display&quot;.
30+
<br/><br/>
31+
<div className={classes.imgWrapper}>
32+
<img width="600" height="145" src={fullStateManageTab} />
33+
</div>
8934
</p>
90-
<hr />
35+
<h2>Step 2: Create a New State Variable</h2>
36+
<p className={classes.text}>
37+
In the &quot;Create/Edit&quot; section of the State Manager, you can declare a new state variable. First make sure that you have selected the correct component on the left. This new state variable will be created inside the component highlighted with a red dot (as shown below).
38+
<br/><br/>You can create your state variable with a key, an intial value, and a type (ex: string, number, boolean, etc).<br/><br/>
39+
<div className={classes.imgWrapper}>
40+
<img className={classes.medImg} src={createState} />
41+
</div>
42+
<br/><br/>
43+
You will now see your new state variable in the &quot;Current Component State&quot; table. Also, you can see the React Hook that has been created for this state variable.
44+
<br/><br/>
45+
<div className={classes.imgWrapper}>
46+
<img width="600" src={table1} />
9147
</div>
92-
);
93-
};
48+
</p>
49+
<h2>Step 3: Pass in Props from Parent Component</h2>
50+
<p className={classes.text}>
51+
In the &quot;Create/Edit&quot; section of the State Manager, you can also view props available from the parent component. You can choose to import any of the state variables, with or without their associated React Hooks.
52+
<br/><br/>Just click the plus sign next to the state you want to import into the current component. This will automatically update the &quot;Passed In Props from Parent&quot; table on the far right.<br/><br/>
53+
<div className={classes.imgWrapper}>
54+
<img width="1100" src={table3} />
55+
</div>
56+
</p>
57+
<h2>Step 4: Delete Any Unnecessary State Variables</h2>
58+
<p className={classes.text}>
59+
If there are any state variables you want to delete, you can do so in the &quot;Create/Edit&quot; tab!
60+
<br/><br/>You can delete a state variable that was created in the current component by clicking the X next to it in the &quot;Current Component State&quot; table. <br/><br/>
61+
You can also delete state from the &quot;Passed In Props From Parent&quot; table. This will delete the passed in props from the current component, but won&apos;t delete the original state variable inside the parent component.
62+
<br/><br/>
63+
For example, in the gif below, we can see the &quot;num&quot; state variable being deleted from the component &quot;Row&quot;. Its associated React Hook is also automatically deleted.
64+
<br/><br/>
65+
Then, the &quot;setDarkMode&quot; React Hook is deleted from &quot;Passed In Props From Parent: App&quot;. However, if we click over to the &quot;App&quot; parent component, the &quot;setDarkMode&quot; React Hook is still available.
66+
<br/><br/>
67+
<div className={classes.imgWrapper}>
68+
<img width="1300" src={deleteState2} />
69+
</div>
70+
</p>
71+
<br/><br/>
72+
<h2>Step 5: Visualize the State Flow of Your Prototype Application</h2>
73+
<p className={classes.text}>
74+
Once you&apos;ve added all your state variables to your components, you can click on the &quot;Display&quot; section of the State Manager. Here, you can see a tree diagram that shows the relationship between the components you have created. Click on each component to see its state variables -- including passed in props! <br/><br/>
75+
On the left side of the screen, click on other root components (if using Classic React) or pages (if using Next.js or GatsbyJS) to see their tree diagrams too.
76+
<br/><br/>
77+
<div className={classes.imgWrapper}>
78+
<img width="1400" src={display} />
79+
</div>
80+
<br/><br/>
81+
Created state variables and React Hooks will also be visible in the <span className={classes.notLink} onClick={() => setPage('Code Preview')} >code preview</span>.<br/><br/>
82+
You can see below that the &quot;num&quot; and its associated React Hook have been passed in to the &quot;Row&quot; component from its parent component.
83+
<br/><br/>
84+
On line 10, the state variable &quot;darkMode&quot; has been passed into the &quot;Row&quot; component from its parent, but without its React Hook, since we chose not to pass the hook down from the parent component.
85+
<br/><br/>
86+
<div className={classes.imgWrapper}>
87+
<img className={classes.medImg} src={codePreview2} />
88+
</div>
89+
</p>
90+
<hr />
91+
</div>
92+
);
9493

9594
export default States;

app/src/tutorial/Styling.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import codeChange from '../../../resources/customizing_elements_images/CodeChang
55

66
/**
77
* Styling component provides information about styling features in ReacType.
8-
*
8+
*
99
* @param {object} props - Component props.
1010
* @param {object} props.classes - CSS classes for styling.
1111
* @param {Function} props.setPage - Function to set the current page.
@@ -14,8 +14,7 @@ import codeChange from '../../../resources/customizing_elements_images/CodeChang
1414
const Styling: React.FC<{
1515
classes: any;
1616
setPage: Function;
17-
}> = ({ classes, setPage }): JSX.Element => {
18-
return (
17+
}> = ({ classes, setPage }): JSX.Element => (
1918
<div className={classes.wrapper}>
2019
<h1 className={classes.title}>Styling Features</h1>
2120
<hr />
@@ -47,6 +46,5 @@ const Styling: React.FC<{
4746
</p>
4847
<hr />
4948
</div>
50-
);
51-
};
49+
);
5250
export default Styling;

app/src/tutorial/Tutorial.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
import React, { useEffect } from 'react';
23
import makeStyles from '@mui/styles/makeStyles';
34
import Card from '@mui/material/Card';
@@ -29,29 +30,29 @@ const useStyles = makeStyles({
2930
width: 350,
3031
height: 300,
3132
margin: 20,
32-
border: `1px solid gray`,
33+
border: '1px solid gray',
3334
backgroundColor: Styling.tutorialGray,
3435
color: 'white',
3536
borderRadius: '5%',
36-
boxShadow: '10px 10px 10px gray'
37+
boxShadow: '10px 10px 10px gray',
3738
},
3839
bullet: {
3940
display: 'inline-block',
4041
margin: '0 2px',
41-
transform: 'scale(0.8)'
42+
transform: 'scale(0.8)',
4243
},
4344
title: {
4445
color: Styling.darkBlue,
4546
fontSize: 28,
46-
fontWeight: 500
47+
fontWeight: 500,
4748
},
4849
pos: {
4950
marginBottom: 12,
50-
margin: 20
51+
margin: 20,
5152
},
5253
icons: {
5354
color: Styling.darkBlue,
54-
fontSize: 125
55+
fontSize: 125,
5556
},
5657
pageTitle: {
5758
fontSize: 100,
@@ -60,30 +61,30 @@ const useStyles = makeStyles({
6061
border: `1px solid ${Styling.darkBlue}`,
6162
padding: '20px',
6263
backgroundColor: 'white',
63-
borderRadius: '10px'
64+
borderRadius: '10px',
6465
},
6566
container: {
6667
display: 'flex',
6768
justifyContent: 'center',
6869
flexDirection: 'column',
6970
alignItems: 'center',
70-
backgroundColor: 'lightgray'
71+
backgroundColor: 'lightgray',
7172
},
7273
wrapper: {
7374
display: 'flex',
7475
justifyContent: 'center',
7576
flexWrap: 'wrap',
76-
width: '75%'
77+
width: '75%',
7778
},
7879
cardWrapper: {
7980
display: 'flex',
8081
flexDirection: 'column',
81-
flexBasis: '33.333333%'
82+
flexBasis: '33.333333%',
8283
},
8384
cardActions: {
8485
alignSelf: 'center',
85-
justifySelf: 'center'
86-
}
86+
justifySelf: 'center',
87+
},
8788
});
8889

8990
/**
@@ -107,7 +108,7 @@ const Tutorial: React.FC<RouteComponentProps<{ learn: string }>> = (props): JSX.
107108
'Customization',
108109
'States',
109110
'CSS Editor',
110-
'Keyboard Shortcuts'
111+
'Keyboard Shortcuts',
111112
];
112113
const icons = [
113114
<MenuBookIcon className={classes.icons} />,
@@ -121,7 +122,7 @@ const Tutorial: React.FC<RouteComponentProps<{ learn: string }>> = (props): JSX.
121122
<ColorLensIcon className={classes.icons} />,
122123
<SwapVertIcon className={classes.icons} />,
123124
<BrushIcon className={classes.icons} />,
124-
<KeyboardIcon className={classes.icons} />
125+
<KeyboardIcon className={classes.icons} />,
125126
];
126127

127128
const body = document.querySelector('body');

0 commit comments

Comments
 (0)