Skip to content

Commit a05cbe0

Browse files
committed
setup for the tutorial section
1 parent 8cc75aa commit a05cbe0

File tree

3 files changed

+70
-55
lines changed

3 files changed

+70
-55
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
body {
6+
font-family: sans-serif;
7+
margin: 20px;
8+
padding: 0;
9+
}
10+
11+
.square {
12+
background: #fff;
13+
border: 1px solid #999;
14+
float: left;
15+
font-size: 24px;
16+
font-weight: bold;
17+
line-height: 34px;
18+
height: 34px;
19+
margin-right: -1px;
20+
margin-top: -1px;
21+
padding: 0;
22+
text-align: center;
23+
width: 34px;
24+
}
25+
26+
.board-row:after {
27+
clear: both;
28+
content: "";
29+
display: table;
30+
}
31+
32+
.status {
33+
margin-bottom: 10px;
34+
}
35+
.game {
36+
display: flex;
37+
flex-direction: row;
38+
}
39+
40+
.game-info {
41+
margin-left: 20px;
42+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from reactpy import component, html
2+
3+
# start
4+
@component
5+
def square():
6+
return html.button({"class_name":"square"}, "X")

docs/src/learn/tutorial-tic-tac-toe.md

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You will build a small tic-tac-toe game during this tutorial. This tutorial does
1010

1111
</p>
1212

13-
!!! abstract "Note"
13+
!!! note
1414

1515
This tutorial is designed for people who prefer to **learn by doing** and want to quickly try making something tangible. If you prefer learning each concept step by step, start with [Describing the UI.](./your-first-component.md)
1616

@@ -53,72 +53,39 @@ Once you've played around with the finished tic-tac-toe game, keep scrolling. Yo
5353

5454
## Setup for the tutorial
5555

56-
In the live code editor below, click **Fork** in the top-right corner to open the editor in a new tab using the website CodeSandbox. CodeSandbox lets you write code in your browser and preview how your users will see the app you've created. The new tab should display an empty square and the starter code for this tutorial.
56+
In the code example below, click **Run** to open the editor in a new tab using the website Jupyter. Jupyter lets you write code in your browser and preview how your users will see the app you've created. The new tab should display an empty square and the starter code for this tutorial.
5757

58-
```js
59-
export default function Square() {
60-
return <button className="square">X</button>;
61-
}
62-
```
6358

64-
```css
65-
* {
66-
box-sizing: border-box;
67-
}
59+
=== "app.py"
6860

69-
body {
70-
font-family: sans-serif;
71-
margin: 20px;
72-
padding: 0;
73-
}
61+
```python
62+
{% include "../../examples/python/tutorial-tic-tac-toe/setup_for_the_tutorial.py" start="# start" %}
63+
```
7464

75-
.square {
76-
background: #fff;
77-
border: 1px solid #999;
78-
float: left;
79-
font-size: 24px;
80-
font-weight: bold;
81-
line-height: 34px;
82-
height: 34px;
83-
margin-right: -1px;
84-
margin-top: -1px;
85-
padding: 0;
86-
text-align: center;
87-
width: 34px;
88-
}
65+
=== "stylesheet.css"
8966

90-
.board-row:after {
91-
clear: both;
92-
content: "";
93-
display: table;
94-
}
67+
```css
68+
{% include "../../examples/css/tutorial-tic-tac-toe/setup_for_the_tutorial.css" %}
69+
```
9570

96-
.status {
97-
margin-bottom: 10px;
98-
}
99-
.game {
100-
display: flex;
101-
flex-direction: row;
102-
}
71+
=== ":material-play: Run"
10372

104-
.game-info {
105-
margin-left: 20px;
106-
}
107-
```
73+
```python
74+
# TODO
75+
```
10876

109-
<Note>
77+
!!! note
11078

111-
You can also follow this tutorial using your local development environment. To do this, you need to:
79+
You can also follow this tutorial using your local development environment. To do this, you need to:
11280

113-
1. Install [Node.js](https://nodejs.org/en/)
114-
1. In the CodeSandbox tab you opened earlier, press the top-left corner button to open the menu, and then choose **File > Export to ZIP** in that menu to download an archive of the files locally
115-
1. Unzip the archive, then open a terminal and `cd` to the directory you unzipped
116-
1. Install the dependencies with `npm install`
117-
1. Run `npm start` to start a local server and follow the prompts to view the code running in a browser
81+
1. Install [Python](https://www.python.org/downloads/)
82+
2. Copy the example above into a file called `app.py`
83+
3. Install Reactpy for the [backend](../reference/fastapi.md) of your choice.
84+
- For example: `pip install reactpy[fastapi]`
85+
4. Run `python app.py` to start a local server and follow the prompts to view the code running in a browser
11886

119-
If you get stuck, don't let this stop you! Follow along online instead and try a local setup again later.
87+
If you get stuck, don't let this stop you! Follow along online instead and try a local setup again later.
12088

121-
</Note>
12289

12390
## Overview
12491

0 commit comments

Comments
 (0)