Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,820 --> 00:00:01,840
In this video.
2
00:00:01,840 --> 00:00:06,550
What we're going to do is go ahead and build out the restaurants page.
3
00:00:06,970 --> 00:00:09,790
Now, let's remember exactly what this is going to look like.
4
00:00:09,820 --> 00:00:16,510
We have the nav bar, but we're also going to have this table right over here that's going to show the
5
00:00:16,510 --> 00:00:18,790
top 50 of restaurants.
6
00:00:19,240 --> 00:00:25,300
Now, building this from scratch, building out the HTML as well as this here says is going to be relatively
7
00:00:25,300 --> 00:00:29,890
cumbersome, boring, and it's not really going to be Nux related.
8
00:00:30,280 --> 00:00:37,390
So just for the HTML and cc, what we're going to do is just copy the component that builds out this
9
00:00:37,390 --> 00:00:43,750
table, but anything related to view and JavaScript and Nux we are going to do from scratch.
10
00:00:44,110 --> 00:00:46,330
So let's actually go ahead and do this.
11
00:00:46,600 --> 00:00:51,850
Now, in order to do this, what I need you to understand is this is going to be made up of two different
12
00:00:51,850 --> 00:00:52,600
components.
13
00:00:52,930 --> 00:00:59,590
So we have the table as a whole, and then within each table we have these rows and this row is going
14
00:00:59,590 --> 00:01:01,480
to be a component as well.
15
00:01:01,990 --> 00:01:06,040
So let's go ahead and go over here to our components directory.
16
00:01:06,250 --> 00:01:09,040
And I'm actually going to create a restaurant.
17
00:01:09,110 --> 00:01:15,100
So restaurants or restaurant component directory right over here.
18
00:01:15,760 --> 00:01:22,600
Now in here, I'm going to create a table dot view file, table W file like.
19
00:01:22,600 --> 00:01:29,560
So now attached to this video, you should be able to copy and paste a boilerplate template for both
20
00:01:29,560 --> 00:01:31,330
the table as well as the row.
21
00:01:31,720 --> 00:01:35,410
So I'm going to go ahead over here and I'll touch both of them in the video so you don't have to go
22
00:01:35,410 --> 00:01:36,280
search around.
23
00:01:36,760 --> 00:01:39,290
But you can see here we get this nice template.
24
00:01:39,310 --> 00:01:40,960
So let's go ahead and copy that in.
25
00:01:41,470 --> 00:01:42,760
I'm going to go ahead and piece that in.
26
00:01:42,760 --> 00:01:43,930
So this is for the table.
27
00:01:44,230 --> 00:01:50,590
So we got this div, we have this H1 and then right over here we have the table container and then in
28
00:01:50,590 --> 00:01:53,050
here we have both table columns.
29
00:01:53,050 --> 00:01:55,600
So as you can see here, we have two columns.
30
00:01:55,970 --> 00:02:00,520
Then over here we have both two divs that are going to house our rows.
31
00:02:00,910 --> 00:02:02,680
So I'm going to go ahead and save that.
32
00:02:03,040 --> 00:02:09,220
And then over here, I'm also going to create a row dot view file.
33
00:02:09,730 --> 00:02:11,230
Now I'm going to go back again.
34
00:02:11,230 --> 00:02:12,910
I'll have this linked for you guys.
35
00:02:14,110 --> 00:02:15,940
Just go ahead and copy this again.
36
00:02:15,940 --> 00:02:18,280
Just the HTML as well as some see as says.
37
00:02:18,670 --> 00:02:20,830
So we don't waste time doing this ourselves.
38
00:02:21,430 --> 00:02:21,850
All right.
39
00:02:21,850 --> 00:02:22,470
There we go.
40
00:02:22,480 --> 00:02:27,160
So you can see now we got this row, we have an H four that's indicating the rank.
41
00:02:27,520 --> 00:02:32,320
And then over here we have the anger tag that indicates a thing, the actual restaurant.
42
00:02:32,650 --> 00:02:37,630
Now, this is hardcoded, but obviously later on we're not going to hardcoded this.
43
00:02:37,630 --> 00:02:40,900
We are going to make it dynamic.
44
00:02:41,410 --> 00:02:48,040
So now what I want to do is I actually want to go to this table and just render one restaurant row.
45
00:02:48,340 --> 00:02:49,630
So remember how to do that.
46
00:02:49,630 --> 00:02:50,620
You go over here.
47
00:02:50,830 --> 00:02:53,650
This is the directory where the row live.
48
00:02:53,650 --> 00:02:55,090
So it's going to be a restaurant.
49
00:02:55,090 --> 00:02:57,490
Row is the component that we want to render.
50
00:02:58,000 --> 00:02:59,320
So restaurant.
51
00:02:59,320 --> 00:03:01,630
And again, keep in mind the spelling.
52
00:03:01,870 --> 00:03:03,970
Restaurant row.
53
00:03:04,000 --> 00:03:05,470
Very difficult words to spell.
54
00:03:06,160 --> 00:03:11,250
And now what we're going to do is inside of here, we're going to get rid of this h for.
55
00:03:11,680 --> 00:03:16,600
We're going to create a div we're going to wrap this in a container.
56
00:03:17,410 --> 00:03:22,240
And then in here we're going to say restaurant like so.
57
00:03:22,630 --> 00:03:26,890
And then we're going to say table just to render the table.
58
00:03:27,640 --> 00:03:31,330
So let's go over here and let's do a quick refresh.
59
00:03:31,330 --> 00:03:31,950
And there you go.
60
00:03:31,960 --> 00:03:34,990
You can see we have our wonderful table.
61
00:03:35,740 --> 00:03:37,750
So now what do we want to do?
62
00:03:38,140 --> 00:03:46,630
Well, now, of course, what we want to do is I think let's iterate over the array of restaurants and
63
00:03:46,630 --> 00:03:50,080
render a row for each particular restaurant.
64
00:03:50,410 --> 00:03:54,550
So I think that is the best thing to do at the moment.
65
00:03:55,180 --> 00:04:01,770
So that actually begs the question, well, where are we going to get that data from?
66
00:04:01,780 --> 00:04:03,670
So where are we going to get this restaurant data?
67
00:04:04,150 --> 00:04:12,790
Well, similarly to the row as well as the table file, I actually have some hard coded data that I'll
68
00:04:12,790 --> 00:04:16,570
also link in the attached to this video as well.
69
00:04:17,110 --> 00:04:19,330
So I'm going to go to it manually.
70
00:04:19,330 --> 00:04:21,300
But again, you guys are not going to have to do that.
71
00:04:21,310 --> 00:04:24,330
So this is just going to be a data dodge JSON file.
72
00:04:24,340 --> 00:04:27,700
This is going to have a bunch of different data about restaurants.
73
00:04:28,210 --> 00:04:28,990
So I'm going to go here.
74
00:04:28,990 --> 00:04:30,580
I'm just going to grab all that.
75
00:04:33,620 --> 00:04:38,150
I'm going to grab every single one and copy that.
76
00:04:38,480 --> 00:04:45,030
And then over here, right in the root directory, I'm going to create a data dot JSON file.
77
00:04:45,050 --> 00:04:46,730
I'm going to paste that data in.
78
00:04:47,030 --> 00:04:49,190
Again, this is just hard coded data.
79
00:04:49,880 --> 00:04:51,650
Typically, data would come from a server.
80
00:04:51,660 --> 00:04:57,130
We'll talk about how we can make HTTP requests to servers a little bit later, but there we go.
81
00:04:57,140 --> 00:04:59,060
This is what we have thus far.
82
00:04:59,330 --> 00:05:03,260
So each object has an idea, it has a rank.
83
00:05:03,290 --> 00:05:09,050
It also has the name of the restaurant, some content, which is Lorem Ibsen, which is consistent throughout
84
00:05:09,050 --> 00:05:15,110
every single one, the revenue, the number of stores they have as well as an image.
85
00:05:15,380 --> 00:05:17,260
So this is the data that we have.
86
00:05:17,630 --> 00:05:26,330
So now what I want to do is inside of this table, I want to essentially iterate over that data and
87
00:05:26,330 --> 00:05:30,650
then for each data I want to render a restaurant row.
88
00:05:31,310 --> 00:05:34,070
So let's actually go ahead and do that.
89
00:05:34,280 --> 00:05:39,800
But in order to do this, what I want to do here and let's actually take a look what we want to do here
90
00:05:39,800 --> 00:05:47,000
is we want to render the first 25 in this column and then the next 25 in this column.
91
00:05:47,330 --> 00:05:51,890
So we need to somehow split this because the data is just one large array.
92
00:05:52,370 --> 00:05:54,080
So I actually have a suggestion.
93
00:05:54,080 --> 00:05:55,190
Let's just go over here.
94
00:05:55,610 --> 00:06:01,520
Let's say script setup, let's get rid of this is just the boilerplate that I always get script set
95
00:06:01,520 --> 00:06:01,730
up.
96
00:06:01,730 --> 00:06:06,470
Lang is equal to TypeScript because of course we are going to be using TypeScript.
97
00:06:06,860 --> 00:06:11,180
And what I'm going to do here is I'm going to say I'm going to create a new constant and I'm going to
98
00:06:11,180 --> 00:06:16,100
call this restaurants organized first.
99
00:06:16,310 --> 00:06:18,620
That's so I'm going to call it and this is going to be an object.
100
00:06:19,070 --> 00:06:25,220
I'm going to say first and this is going to be and now what we're going to do is we're going to grab
101
00:06:25,220 --> 00:06:26,630
those restaurant data.
102
00:06:26,840 --> 00:06:34,280
So I'm going to say import restaurants from and I'm going to say from ads just so we can go to the root
103
00:06:34,280 --> 00:06:38,480
directory and then from data dot Jason so this is going to give us our restaurants.
104
00:06:39,060 --> 00:06:44,360
I'm going to say that this is going to be I'm going to go ahead and create a new array and this structure
105
00:06:44,360 --> 00:06:50,750
out everything in that array and then I'm going to splice from 0 to 25.
106
00:06:51,140 --> 00:07:01,190
So this should give us the first 25 elements and attach it to this first object right over here.
107
00:07:01,910 --> 00:07:09,620
And then we're going to say maybe second, and then over here we're going to say something like restaurants
108
00:07:10,340 --> 00:07:12,440
and then over here we're going to say Dot Splice.
109
00:07:12,770 --> 00:07:21,920
I say start from 25 and I want the next 25 like so and this should give us the first 25 as well as the
110
00:07:21,920 --> 00:07:23,480
second 25.
111
00:07:23,990 --> 00:07:24,650
So this is good.
112
00:07:24,650 --> 00:07:25,550
This is really good.
113
00:07:25,880 --> 00:07:31,430
Now, of course, what we can do is actually iterate over them in both of these columns.
114
00:07:31,910 --> 00:07:37,670
Now you could argue that we could also make these columns components as well, and then iterate over
115
00:07:37,670 --> 00:07:40,940
them, but we'll just leave it as it is for now.
116
00:07:41,600 --> 00:07:42,380
So let's go over here.
117
00:07:42,590 --> 00:07:51,530
We're going to say v four and what I'm going to say is V for and I'm going to say for the restaurant.
118
00:07:51,530 --> 00:07:58,730
Restaurant and then I'm going to say in restaurant organized dot first.
119
00:07:59,540 --> 00:08:01,760
And then, of course, we need to supply this with the key.
120
00:08:01,790 --> 00:08:09,020
So I'm going to say key is going to be equal to restaurant ID because remember, this has an ID restaurant
121
00:08:09,020 --> 00:08:09,760
that I.D. like.
122
00:08:09,770 --> 00:08:11,390
So let's go ahead and save that.
123
00:08:12,050 --> 00:08:18,230
And that should pretty much better should allow us to render multiple different restaurants.
124
00:08:18,230 --> 00:08:18,950
And there we go.
125
00:08:18,950 --> 00:08:23,090
Well, not multiple different restaurants, but for each iteration, we're going to render a restaurant.
126
00:08:23,930 --> 00:08:24,320
Okay.
127
00:08:24,320 --> 00:08:26,110
So that's step number one.
128
00:08:26,120 --> 00:08:29,360
Now, let's go ahead over here and let's do the exact same thing.
129
00:08:32,040 --> 00:08:39,150
Now over here, what we're going to do is we're going to say restaurant dot second and there we go.
130
00:08:39,330 --> 00:08:41,010
So this is looking good.
131
00:08:41,520 --> 00:08:45,150
Now, of course, now what we need to do is all quite a bit of things.
132
00:08:45,180 --> 00:08:47,220
There's just a lot that we actually need to do.
133
00:08:47,790 --> 00:08:52,050
So the first thing that we need to do, of course, is start accepting props so we don't, you know,
134
00:08:52,080 --> 00:08:53,430
hardcoded this data.
135
00:08:53,430 --> 00:08:55,300
We want to show more dynamic data.
136
00:08:55,330 --> 00:08:56,580
That's step number one.
137
00:08:57,210 --> 00:09:02,000
Step number two would be to show this header right over here.
138
00:09:02,010 --> 00:09:04,260
So this would be another thing that we would want to show.
139
00:09:04,680 --> 00:09:08,640
And then the other thing that we are missing is the highlighting.
140
00:09:08,640 --> 00:09:13,650
So you can see here, you know, over here we have this gray highlighting and we have this white highlighting,
141
00:09:13,650 --> 00:09:15,810
this gray highlighting and then this white highlighting.
142
00:09:16,680 --> 00:09:17,760
So this is what we have.
143
00:09:17,760 --> 00:09:20,910
And then obviously over here, we don't have that at the moment.
144
00:09:21,210 --> 00:09:23,730
So this is something that we actually need to work on.
145
00:09:24,000 --> 00:09:25,530
So let's do that in the next video.
13858
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.