Skip to content

Commit ca586e0

Browse files
NataliaTepluhinayyx990803
authored andcommitted
feat: added instructions for lesson 3
1 parent fd37785 commit ca586e0

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

src/tutorial/src/step-3/App/style.css

+28
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,31 @@ input {
2626
background-color: teal;
2727
transition: background 0.5s;
2828
}
29+
30+
nav {
31+
display: flex;
32+
height: 30px;
33+
justify-content: space-between;
34+
align-items: center;
35+
padding: 0 20px;
36+
background-color: white;
37+
color: teal;
38+
font-size: 16px;
39+
text-transform: uppercase;
40+
}
41+
42+
nav button {
43+
text-transform: uppercase;
44+
padding: 0 8px;
45+
height: 100%;
46+
font-size: 16px;
47+
background-color: white;
48+
border: none;
49+
cursor: pointer;
50+
color: teal;
51+
}
52+
53+
nav button:hover {
54+
background-color: teal;
55+
color: white;
56+
}

src/tutorial/src/step-3/description.md

+38
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,41 @@ However, if we leave it like this, page will refresh and no text will be shown.
7272
</label>
7373
</form>
7474
```
75+
76+
Now, whenever user enter a number in the input field and presses <kbd>Enter</kbd>, we can see that game is started.
77+
78+
The last thing we want to implement in this lesson is hiding the input field when the game is already started and showing a button `Change colors number`. Clicking on the button will set the game to "not-started" and show the input again. First, let's add the button to our template:
79+
80+
```html{1-3}
81+
<nav>
82+
<button @click="gameStarted = false">Change squares number</button>
83+
</nav>
84+
<form @submit.prevent="gameStarted = true">
85+
<label for="colors">
86+
Enter number of colors and press Enter:
87+
<input id="colors" type="number" v-model="colorsNumber" />
88+
</label>
89+
</form>
90+
```
91+
92+
Now, let's display the `<nav>` conditionally when game is started:
93+
94+
```html{1-3}
95+
<nav v-if="gameStarted">
96+
<button @click="gameStarted = false">Change squares number</button>
97+
</nav>
98+
```
99+
100+
Just like you can use `if...else` in JavaScript, you can use `v-if` and `v-else` in Vue. So when `gameStarted` is `true`, we're displaying `<nav>`, else we're displaying the form:
101+
102+
```html
103+
<nav v-if="gameStarted">
104+
<button @click="gameStarted = false">Change squares number</button>
105+
</nav>
106+
<form v-else @submit.prevent="gameStarted = true">
107+
<label for="colors">
108+
Enter number of colors and press Enter:
109+
<input id="colors" type="number" v-model="colorsNumber" />
110+
</label>
111+
</form>
112+
```

0 commit comments

Comments
 (0)