Skip to content

Commit 35d3bdc

Browse files
authored
Merge pull request #12 from oslabs-beta/addTutorial
Add tutorial for State Management Tab and update customization tutorial to include instructions for "Use State" button
2 parents 6a005ff + 7ae41fb commit 35d3bdc

22 files changed

+107
-35
lines changed

app/src/tutorial/Customization.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
2-
import display from '../../../resources/customizing_elements_images/Display.png';
3-
import height from '../../../resources/customizing_elements_images/Height.png';
4-
import width from '../../../resources/customizing_elements_images/Width.png';
5-
import backgroundColor from '../../../resources/customizing_elements_images/BackgroundColor.png';
6-
import text from '../../../resources/customizing_elements_images/Text.png';
7-
import link from '../../../resources/customizing_elements_images/Link.png';
8-
import cssClasses from '../../../resources/customizing_elements_images/CSS-Classes.png';
2+
import display from '../../../resources/customizing_elements_images/display.png';
3+
import height from '../../../resources/customizing_elements_images/height.png';
4+
import width from '../../../resources/customizing_elements_images/width.png';
5+
import backgroundColor from '../../../resources/customizing_elements_images/backgroundColor.png';
6+
import text from '../../../resources/customizing_elements_images/textState.png';
7+
import link from '../../../resources/customizing_elements_images/linkState.png';
8+
import cssClasses from '../../../resources/customizing_elements_images/CSS.png';
9+
import textGif from '../../../resources/customizing_elements_images/text.gif';
910

1011
const Customization: React.FC<{
1112
classes: any;
@@ -20,13 +21,13 @@ const Customization: React.FC<{
2021
made in the <span className={classes.notLink} onClick={() => setPage('Customization')}>
2122
customization</span> panel will be reflected immediately in the <span className={classes.notLink} onClick={() => setPage('Code Preview')}>
2223
code preview </span> and demo render panel. See your changes in real time to decide what's best!<br/><br/>
23-
To customize an HTML element, drag it onto the canvas and select it on the canvas. Then use the desired cusotmization feature.
24+
To customize an HTML element, drag it onto the canvas and select it on the canvas. Then use the desired customization feature.
2425
Once done, press the save button to save your customization changes.
2526
</p>
2627
<hr />
2728
<h2>Display</h2>
2829
<div className={classes.imgWrapper}>
29-
<img src={display} />
30+
<img width='1300' src={display} />
3031
</div>
3132
<p className={classes.text}>
3233
After having moved a{' '}
@@ -64,7 +65,7 @@ const Customization: React.FC<{
6465
<hr />
6566
<h2>Width</h2>
6667
<div className={classes.imgWrapper}>
67-
<img src={width} />
68+
<img width='1300' src={width} />
6869
</div>
6970
<p className={classes.text}>
7071
Change the width of each{' '}
@@ -93,7 +94,7 @@ const Customization: React.FC<{
9394
<hr />
9495
<h2>Height</h2>
9596
<div className={classes.imgWrapper}>
96-
<img src={height} />
97+
<img width='1300' src={height} />
9798
</div>
9899
<p className={classes.text}>
99100
Change the height of each{' '}
@@ -122,7 +123,7 @@ const Customization: React.FC<{
122123
<hr />
123124
<h2>Background Color</h2>
124125
<div className={classes.imgWrapper}>
125-
<img src={backgroundColor} />
126+
<img width='1300' src={backgroundColor} />
126127
</div>
127128
<p className={classes.text}>
128129
Select an element and type in the color you wish to change the background
@@ -131,23 +132,31 @@ const Customization: React.FC<{
131132
<hr />
132133
<h2>Text</h2>
133134
<div className={classes.imgWrapper}>
134-
<img src={text} />
135+
<img width='1300' src={text} />
135136
</div>
136137
<p className={classes.text}>
137-
Add HTML text to a selected element on the canvas by typing in the desired text.
138+
Add HTML text to a selected element on the canvas by typing in the desired text.
139+
<br></br>
140+
<br></br>
141+
You can also add state to the text of your element by clicking the "Use State" button. As shown in the example below, when you click "Use State", a window will pop up, showing all state available in the current component. You can click on any of these state variables and it will applied to the HTML text. When you click "Save", you can see a live Demo Render of your customization changes.
142+
<br></br>
143+
<br></br>
144+
<div className={classes.imgWrapper}>
145+
<img width='1000' src={textGif} />
146+
</div>
138147
</p>
139148
<hr />
140149
<h2>Link</h2>
141150
<div className={classes.imgWrapper}>
142-
<img src={link} />
151+
<img width='1300' src={link} />
143152
</div>
144153
<p className={classes.text}>
145-
Add a hyperlink to a selected element on the canvas by typing in the url.
154+
Add a hyperlink to a selected element on the canvas by typing in the url.
146155
</p>
147156
<hr />
148157
<h2>CSS Classes</h2>
149158
<div className={classes.imgWrapper}>
150-
<img src={cssClasses} />
159+
<img width='1300' src={cssClasses} />
151160
</div>
152161
<p className={classes.text}>
153162
Change the CSS class of a selected element on the canvas by typing in the class name. <br/>

app/src/tutorial/ReusableComponents.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const ReusableComponents: React.FC<{
1111
<div className={classes.wrapper}>
1212
<h1 className={classes.title}>Reusable Components</h1>
1313
<hr/>
14-
<p className={classes.text}>To add a Reusable Component, use the New Component input form in the Creation Panel to name a Component. Leave the Root/Page checkbox unchecked. Then click Create to add a new Reusable Component.</p>
14+
<p className={classes.text}>NOTE: As of version 13.0, each reusable component can only have one parent. Otherwise, you will be prompted to generate a new component to nest.
15+
<br></br>
16+
<br></br>To add a Reusable Component, use the New Component input form in the Creation Panel to name a Component. Leave the Root/Page checkbox unchecked. Then click Create to add a new Reusable Component.</p>
1517
<div className={classes.imgWrapper}>
1618
<img className={classes.img} src={reusableComponents1} />
1719
</div>

app/src/tutorial/States.tsx

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,83 @@
11
import React from 'react';
22
import createState from '../../../resources/state_tutorial_images/CreateState.png';
3-
import stateTable from '../../../resources/state_tutorial_images/StateTable.png';
43
import codePreview from '../../../resources/state_tutorial_images/CodePreview.png';
5-
import deleteState from '../../../resources/state_tutorial_images/DeleteState.gif';
4+
import fullStateManageTab from '../../../resources/state_tutorial_images/fullStateManageTab.png';
5+
import table1 from '../../../resources/state_tutorial_images/table1.gif';
6+
import table3 from '../../../resources/state_tutorial_images/table3.gif';
7+
import deleteState2 from '../../../resources/state_tutorial_images/delete.gif';
8+
import display from '../../../resources/state_tutorial_images/display.gif';
9+
import codePreview2 from '../../../resources/state_tutorial_images/CodePreview2.png';
610

711
const States: React.FC<{
812
classes: any;
913
setPage: Function;
1014
}> = ({ classes, setPage }) => {
1115
return (
1216
<div className={classes.wrapper}>
13-
<h1 className={classes.title}>State Features</h1>
17+
<h1 className={classes.title}>State Management</h1>
1418
<hr />
15-
<h2>Create New State Hook</h2>
19+
<h2>Step 1: Click on the State Management Tab</h2>
1620
<p className={classes.text}>
17-
To create a new state hook for your prototype application by going to the Creation Panel tab in the bottom Panel. Type in a key
18-
and value for the state hook and it's type. Once done, press the save button to save the state hook.<br/><br/>
21+
Within this tab, there are two sections: "Create/Edit" and "Display".
22+
<br/><br/>
23+
<div className={classes.imgWrapper}>
24+
<img width="600" height="145" src={fullStateManageTab} />
25+
</div>
26+
</p>
27+
<h2>Step 2: Create a New State Variable</h2>
28+
<p className={classes.text}>
29+
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).
30+
<br/><br/>You can create your state variable with a key, an intial value, and a type (ex: string, number, boolean, etc).<br/><br/>
1931
<div className={classes.imgWrapper}>
2032
<img className={classes.medImg} src={createState} />
2133
</div>
2234
<br/><br/>
23-
Created state hooks can be viewed to the right in tabular form. This table will immediately add any created state hook.<br/><br/>
35+
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.
36+
<br/><br/>
2437
<div className={classes.imgWrapper}>
25-
<img className={classes.medImg} src={stateTable} />
26-
</div><br></br>
27-
Created state hooks will also be visible in the <span className={classes.notLink} onClick={() => setPage('Code Preview')} >code preview</span>.<br/><br/>
38+
<img width="600" src={table1} />
39+
</div>
40+
</p>
41+
<h2>Step 3: Pass in Props from Parent Component</h2>
42+
<p className={classes.text}>
43+
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.
44+
<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/>
2845
<div className={classes.imgWrapper}>
29-
<img className={classes.medImg} src={codePreview} />
46+
<img width="1100" src={table3} />
3047
</div>
31-
</p>
32-
<hr />
33-
<h2>Delete State Hook</h2>
48+
</p>
49+
<h2>Step 4: Delete Any Unnecessary State Variables</h2>
50+
<p className={classes.text}>
51+
If there are any state variables you want to delete, you can do so in the "Create/Edit" tab!
52+
<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/>
53+
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.
54+
<br/><br/>
55+
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.
56+
<br/><br/>
57+
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.
58+
<br/><br/>
59+
<div className={classes.imgWrapper}>
60+
<img width="1300" src={deleteState2} />
61+
</div>
62+
</p>
63+
<br/><br/>
64+
<h2>Step 5: Visualize the State Flow of Your Prototype Application</h2>
3465
<p className={classes.text}>
35-
To delete a created state hook, click the corresponding X for the state hook on the state hook table.<br/><br/>
66+
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/>
67+
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.
68+
<br/><br/>
3669
<div className={classes.imgWrapper}>
37-
<img className={classes.img} src={deleteState} />
38-
</div>
70+
<img width="1400" src={display} />
71+
</div>
72+
<br/><br/>
73+
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/>
74+
You can see below that the "num" and its associated React Hook have been passed in to the "Row" component from its parent component.
75+
<br/><br/>
76+
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.
77+
<br/><br/>
78+
<div className={classes.imgWrapper}>
79+
<img className={classes.medImg} src={codePreview2} />
80+
</div>
3981
</p>
4082
<hr />
4183
</div>

app/src/tutorial/Tutorial.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import ColorLensIcon from '@material-ui/icons/ColorLens';
2020
import SwapVertIcon from '@material-ui/icons/SwapVert';
2121
import KeyboardIcon from '@material-ui/icons/Keyboard';
2222
import BrushIcon from '@material-ui/icons/Brush';
23+
import HomeIcon from '@material-ui/icons/Home';
24+
import Button from '@material-ui/core/Button';
25+
2326

2427
const useStyles = makeStyles({
2528
root: {
@@ -137,10 +140,26 @@ const Tutorial: React.FC<RouteComponentProps> = () => {
137140
);
138141
});
139142
return (
143+
<>
144+
<div>
145+
<Link to='/' style={{textDecoration: 'none'}}>
146+
<Button
147+
variant='contained'
148+
color='primary'
149+
style={{ minWidth: '137.69px'}}
150+
className="navbarButton"
151+
id="ratingButton"
152+
endIcon={<HomeIcon/>}
153+
>
154+
HOME
155+
</Button>
156+
</Link>
157+
</div>
140158
<Container maxWidth="xl" className={classes.container}>
141159
<h1 className={classes.pageTitle}>ReacType Tutorial</h1>
142160
<div className={classes.wrapper}>{cards}</div>
143161
</Container>
162+
</>
144163
);
145164
};
146165
export default withRouter(Tutorial);
Loading
Binary file not shown.
149 KB
Loading
Loading
Loading
-48.4 KB
Binary file not shown.
-48.5 KB
Binary file not shown.
Loading
Loading
1.4 MB
Loading
Loading
Loading
Loading
1.7 MB
Loading
3.23 MB
Loading
Loading
84.3 KB
Loading
197 KB
Loading

0 commit comments

Comments
 (0)