Skip to content

Commit 598eb9a

Browse files
authored
Merge pull request #1832 from ember-learn/super-rentals-tutorial
Tutorial Updates
2 parents 45264aa + a2aedd9 commit 598eb9a

File tree

72 files changed

+182
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+182
-140
lines changed

guides/release/tutorial/part-1/automated-testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Once we are done patting ourselves on the back, go ahead and run the following c
3333
$ ember generate acceptance-test super-rentals
3434
installing acceptance-test
3535
create tests/acceptance/super-rentals-test.js
36+
37+
Running "lint:fix" script...
3638
```
3739

3840
This is called a _[generator](https://cli.emberjs.com/release/basic-use/cli-commands/#generatemorefiles)_ command in Ember CLI. Generators automatically create files for us based on Ember's conventions and populate them with the appropriate boilerplate content, similar to how `ember new` initially created a skeleton app for us. It typically follows the pattern `ember generate <type> <name>`, where `<type>` is the kind of thing we are generating, and `<name>` is what we want to call it.

guides/release/tutorial/part-1/building-pages.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
In this chapter, you will build the first few pages of your Ember app and set up links between them. By the end of this chapter, you should have two new pages – an about page and a contact page. These pages will be linked to from your landing page:
44

5-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (homepage) by the end of the chapter" width="1024" height="250">
5+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (homepage) by the end of the chapter" width="1024" height="251">
66

7-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (about page) by the end of the chapter" width="1024" height="274">
7+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (about page) by the end of the chapter" width="1024" height="275">
88

9-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (contact page) by the end of the chapter" width="1024" height="444">
9+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (contact page) by the end of the chapter" width="1024" height="445">
1010

1111
While building these pages, you will learn about:
1212

@@ -112,7 +112,7 @@ Ember comes with strong _conventions_ and sensible defaults—if we were startin
112112

113113
Once you have added the route and the template above, we should have the new page available to us at `http://localhost:4200/getting-in-touch`.
114114

115-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page" width="1024" height="394">
115+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page" width="1024" height="395">
116116

117117
## Linking Pages with the `<LinkTo>` Component
118118

@@ -181,11 +181,11 @@ However, when clicking on one of these special links, Ember will intercept the c
181181

182182
<!-- TODO: make this a gif instead -->
183183

184-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Index page after adding the link" width="1024" height="250">
184+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Index page after adding the link" width="1024" height="251">
185185

186-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="About page after adding the link" width="1024" height="274">
186+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="About page after adding the link" width="1024" height="275">
187187

188-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page after adding the link" width="1024" height="444">
188+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page after adding the link" width="1024" height="445">
189189

190190
We will learn more about how all of this works soon. In the meantime, go ahead and click on the link in the browser. Did you notice how snappy that was?
191191

guides/release/tutorial/part-1/component-basics.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In this chapter, you will _[refactor](../../../components/introducing-components/#toc_breaking-it-into-pieces)_ your existing templates to use components. We will also be adding a site-wide navigation bar:
44

5-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="314">
5+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="315">
66

77
In doing so, you will learn about:
88

@@ -73,7 +73,7 @@ Let's try it out by editing the index template:
7373
7474
After saving the changes, your page should automatically reload, and, _voilà_... nothing changed? Well, that's exactly what we wanted to happen this time! We successfully _[refactored](../../../components/introducing-components/#toc_breaking-components-down-further)_ our index template to use the `<Jumbo>` component, and everything still works as expected. And the tests still pass!
7575

76-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page – nothing changed" width="1024" height="250">
76+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page – nothing changed" width="1024" height="251">
7777

7878
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Tests still passing after the refactor" width="1024" height="512">
7979

@@ -119,9 +119,9 @@ Let's do the same for our other two pages as well.
119119
120120
After saving, everything should look exactly the same as before, and all the tests should still pass. Very nice!
121121
122-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="About page – nothing changed" width="1024" height="274">
122+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="About page – nothing changed" width="1024" height="275">
123123
124-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Contact page – nothing changed" width="1024" height="444">
124+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Contact page – nothing changed" width="1024" height="445">
125125
126126
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Tests still passing another round of refactor" width="1024" height="512">
127127
@@ -135,6 +135,8 @@ Before we move on to the next component, let's write an automated test for our `
135135
$ ember generate component-test jumbo
136136
installing component-test
137137
create tests/integration/components/jumbo-test.js
138+
139+
Running "lint:fix" script...
138140
```
139141

140142
Here, we used the generator to generate a _[component test](../../../testing/testing-components/)_, also known as a rendering test. These are used to render and test a single component at a time. This is in contrast to the acceptance tests that we wrote earlier, which have to navigate and render entire pages worth of content.
@@ -158,7 +160,7 @@ module('Integration | Component | jumbo', function (hooks) {
158160
159161
await render(hbs`<Jumbo />`);
160162
161-
assert.dom(this.element).hasText('');
163+
assert.dom().hasText('');
162164
163165
// Template block usage:
164166
await render(hbs`
@@ -167,7 +169,7 @@ module('Integration | Component | jumbo', function (hooks) {
167169
</Jumbo>
168170
`);
169171
170-
assert.dom(this.element).hasText('template block text');
172+
assert.dom().hasText('template block text');
171173
assert.dom('.jumbo').exists();
172174
assert.dom('.jumbo').hasText('Hello World');
173175
assert.dom('.jumbo .tomster').exists();
@@ -248,7 +250,7 @@ Next, we will add our `<NavBar>` component to the top of each page:
248250

249251
Voilà, we made another component!
250252

251-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page with nav" width="1024" height="314">
253+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page with nav" width="1024" height="315">
252254

253255
<div class="cta">
254256
<div class="cta-note">

guides/release/tutorial/part-1/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Welcome to the Ember Tutorial!
44

55
In this tutorial, we will use Ember to build an application called Super Rentals. This will be a website for browsing interesting places to stay during your next vacation. Check out the [finished app](https://ember-super-rentals.netlify.com) to get a sense of the scope of the project.
66

7-
<img src="/images/tutorial/part-2/provider-components/[email protected]" alt="The finished Super Rentals app" width="1024" height="1327">
7+
<img src="/images/tutorial/part-2/provider-components/[email protected]" alt="The finished Super Rentals app" width="1024" height="1328">
88

99
Along the way, you will learn everything you need to know to build a basic Ember application. If you get stuck at any point during the tutorial, feel free to download <https://github.com/ember-learn/super-rentals/tree/super-rentals-tutorial-output> for a complete working example.
1010

guides/release/tutorial/part-1/interactive-components.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In this chapter, you will add interactivity to the page, allowing the user to cl
44

55
<!-- TODO: make this a gif instead -->
66

7-
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (default image size)" width="1024" height="1129">
7+
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (default image size)" width="1024" height="1130">
88

99
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (large image size)" width="1024" height="1500">
1010

@@ -34,6 +34,8 @@ Ember optionally allows us to associate JavaScript code with a component for exa
3434
$ ember generate component-class rental/image
3535
installing component-class
3636
create app/components/rental/image.js
37+
38+
Running "lint:fix" script...
3739
```
3840

3941
This generated a JavaScript file with the same name as our component's template at `app/components/rental/image.js`. It contains a _[JavaScript class](https://javascript.info/class)_, _[inheriting](https://javascript.info/class-inheritance)_ from `@glimmer/component`.
@@ -199,7 +201,7 @@ With that, we have created our first _interactive_ component. Go ahead and try i
199201

200202
<!-- TODO: make this a gif instead -->
201203

202-
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (default size)" width="1024" height="1129">
204+
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (default size)" width="1024" height="1130">
203205

204206
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (large size)" width="1024" height="1500">
205207

guides/release/tutorial/part-1/more-about-components.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
It's time to finally work on the rentals listing:
44

5-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1129">
5+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1130">
66

77
While building this list of rental properties, you will learn about:
88

@@ -19,10 +19,12 @@ Let's start by creating the `<Rental>` component. This time, we will use the com
1919
$ ember generate component rental
2020
installing component
2121
create app/components/rental.hbs
22-
skip app/components/rental.js
22+
skip app/components/rental.ts
2323
tip to add a class, run `ember generate component-class rental`
2424
installing component-test
2525
create tests/integration/components/rental-test.js
26+
27+
Running "lint:fix" script...
2628
```
2729

2830
The generator created two new files for us, a component template at `app/components/rental.hbs`, and a component test file at `tests/integration/components/rental-test.js`.
@@ -68,7 +70,7 @@ module('Integration | Component | rental', function (hooks) {
6870
test('it renders information about a rental property', async function (assert) {
6971
await render(hbs`<Rental />`);
7072

71-
assert.dom(this.element).hasText('');
73+
assert.dom().hasText('');
7274

7375
// Template block usage:
7476
await render(hbs`
@@ -77,7 +79,7 @@ module('Integration | Component | rental', function (hooks) {
7779
</Rental>
7880
`);
7981

80-
assert.dom(this.element).hasText('template block text');
82+
assert.dom().hasText('template block text');
8183
assert.dom('article').hasClass('rental');
8284
assert.dom('article h3').hasText('Grand Old Mansion');
8385
assert.dom('article .detail.owner').includesText('Veruca Salt');
@@ -112,7 +114,7 @@ Finally, let's invoke this a couple of times from our index template to populate
112114
113115
With that, we should see the `<Rental>` component showing our Grand Old Mansion three times on the page:
114116
115-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1129">
117+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1130">
116118
117119
Things are looking pretty convincing already; not bad for just a little bit of work!
118120
@@ -124,10 +126,12 @@ Next, let's add the image for the rental property. We will use the component gen
124126
$ ember generate component rental/image
125127
installing component
126128
create app/components/rental/image.hbs
127-
skip app/components/rental/image.js
129+
skip app/components/rental/image.ts
128130
tip to add a class, run `ember generate component-class rental/image`
129131
installing component-test
130132
create tests/integration/components/rental/image-test.js
133+
134+
Running "lint:fix" script...
131135
```
132136

133137
This time, we had a `/` in the component's name. This resulted in the component being created at `app/components/rental/image.hbs`, which can be invoked as `<Rental::Image>`.
@@ -173,7 +177,7 @@ Instead of hard-coding specific values for the `src` and `alt` attributes on the
173177
174178
We specified a `src` and an `alt` HTML attribute here, which will be passed along to the component and attached to the element where `...attributes` is applied in the component template. You can think of this as being similar to `{{yield}}`, but for HTML attributes specifically, rather than displayed content. In fact, we have already used this feature [earlier](../building-pages/) when we passed a `class` attribute to `<LinkTo>`.
175179
176-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The &lt;Rental::Image&gt; component in action" width="1024" height="1129">
180+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The &lt;Rental::Image&gt; component in action" width="1024" height="1130">
177181
178182
This way, our `<Rental::Image>` component is not coupled to any specific rental property on the site. Of course, the hard-coding problem still exists (we simply moved it to the `<Rental>` component), but we will deal with that soon. We will limit all the hard-coding to the `<Rental>` component, so that we will have an easier time cleaning it up when we switch to fetching real data.
179183
@@ -196,7 +200,7 @@ module('Integration | Component | rental/image', function (hooks) {
196200
197201
await render(hbs`<Rental::Image />`);
198202
199-
assert.dom(this.element).hasText('');
203+
assert.dom().hasText('');
200204
201205
// Template block usage:
202206
test('it renders the given image', async function (assert) {
@@ -210,7 +214,7 @@ module('Integration | Component | rental/image', function (hooks) {
210214
/>
211215
`);
212216
213-
assert.dom(this.element).hasText('template block text');
217+
assert.dom().hasText('template block text');
214218
assert
215219
.dom('.image img')
216220
.exists()

guides/release/tutorial/part-1/orientation.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ To verify that your installation was successful, run:
2424

2525
```shell
2626
$ ember --version
27-
ember-cli: 4.5.0
28-
node: 14.19.1
27+
ember-cli: 5.6.0
28+
node: 18.19.1
2929
os: linux x64
3030
```
3131

@@ -38,7 +38,7 @@ We can create a new project using Ember CLI's `new` command. It follows the patt
3838
```shell
3939
$ ember new super-rentals --lang en
4040
installing app
41-
Ember CLI v4.5.0
41+
Ember CLI v5.6.0
4242

4343
Creating a new Ember app in /home/runner/work/super-rentals-tutorial/super-rentals-tutorial/dist/code/super-rentals:
4444
create .editorconfig
@@ -48,6 +48,8 @@ Creating a new Ember app in /home/runner/work/super-rentals-tutorial/super-renta
4848
create .github/workflows/ci.yml
4949
create .prettierignore
5050
create .prettierrc.js
51+
create .stylelintignore
52+
create .stylelintrc.js
5153
create .template-lintrc.js
5254
create .watchmanconfig
5355
create README.md
@@ -75,7 +77,6 @@ Creating a new Ember app in /home/runner/work/super-rentals-tutorial/super-renta
7577
create tests/integration/.gitkeep
7678
create tests/test-helper.js
7779
create tests/unit/.gitkeep
78-
create vendor/.gitkeep
7980

8081
Installing packages... This might take a couple of minutes.
8182
npm: Installing dependencies ...
@@ -140,8 +141,6 @@ super-rentals
140141
│ │ └── .gitkeep
141142
│ ├── index.html
142143
│ └── test-helper.js
143-
├── vendor
144-
│ └── .gitkeep
145144
├── .editorconfig
146145
├── .ember-cli
147146
├── .eslintcache
@@ -150,6 +149,8 @@ super-rentals
150149
├── .gitignore
151150
├── .prettierignore
152151
├── .prettierrc.js
152+
├── .stylelintignore
153+
├── .stylelintrc.js
153154
├── .template-lintrc.js
154155
├── .watchmanconfig
155156
├── README.md
@@ -158,25 +159,29 @@ super-rentals
158159
├── package-lock.json
159160
└── testem.js
160161
161-
17 directories, 36 files
162+
16 directories, 37 files
162163
```
163164

164165
We'll learn about the purposes of these files and folders as we go. For now, just know that we'll spend most of our time working within the `app` folder.
165166

166167
## Starting and Stopping the Development Server
167168

168-
Ember CLI comes with a lot of different commands for a variety of development tasks, such as the `ember new` command that we saw earlier. It also comes with a _development server_, which we can launch with the `ember server` command:
169+
Ember CLI comes with a lot of different commands for a variety of development tasks, such as the `ember new` command that we saw earlier. It also comes with a _development server_, which we can launch within the project with the `npm start` command:
169170

170171
```shell
171-
$ ember server
172+
$ npm start
173+
174+
175+
> ember serve
176+
172177
building...
173178

174179
Build successful (9761ms) – Serving on http://localhost:4200/
175180
```
176181

177182
The development server is responsible for compiling our app and serving it to the browsers. It may take a while to boot up. Once it's up and running, open your favorite browser and head to <http://localhost:4200>. You should see the following welcome page:
178183

179-
<img src="/images/tutorial/part-1/orientation/[email protected]" alt="Welcome to Ember!" width="1024" height="906">
184+
<img src="/images/tutorial/part-1/orientation/[email protected]" alt="Welcome to Ember!" width="1024" height="919">
180185

181186
<div class="cta">
182187
<div class="cta-note">
@@ -190,7 +195,7 @@ The development server is responsible for compiling our app and serving it to th
190195
</div>
191196
</div>
192197

193-
You can exit out of the development server at any time by typing `Ctrl + C` into the terminal window where `ember server` is running. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `ember server` command. We recommend having two terminal windows open: one to run the server in background, another to type other Ember CLI commands.
198+
You can exit out of the development server at any time by typing `Ctrl + C` into the terminal window where `npm start` is running. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `npm start` command. We recommend having two terminal windows open: one to run the server in background, another to type other Ember CLI commands.
194199

195200
## Editing Files and Live Reload
196201

@@ -201,9 +206,9 @@ As text on the welcome page pointed out, the source code for the page is located
201206
```handlebars { data-filename="app/templates/application.hbs" data-diff="-1,-2,-3,-4,-5,-6,-7,+8" }
202207
{{page-title "SuperRentals"}}
203208
204-
{{!-- The following component displays Ember's default welcome message. --}}
209+
{{! The following component displays Ember's default welcome message. }}
205210
<WelcomePage />
206-
{{!-- Feel free to remove this! --}}
211+
{{! Feel free to remove this! }}
207212
208213
{{outlet}}
209214
Hello World!!!

0 commit comments

Comments
 (0)