Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,060 --> 00:00:06,750
Let us go ahead and start implementing some of the things I discussed in the last video.
2
00:00:07,080 --> 00:00:14,130
The first thing that I want to do is I want to start passing some of the restaurant data as props to
3
00:00:14,130 --> 00:00:15,840
the road component.
4
00:00:16,200 --> 00:00:18,470
So right now, remember, everything is hard coded.
5
00:00:18,480 --> 00:00:20,580
It's always one, it's always McDonald's.
6
00:00:20,970 --> 00:00:23,820
But as you can see here, we have the rank.
7
00:00:23,820 --> 00:00:28,770
We also have the name for every single object inside of this JSON file.
8
00:00:29,190 --> 00:00:37,920
So what I want to do ideally, of course, is to pass that data in from the table to the restaurant.
9
00:00:38,310 --> 00:00:44,460
Now, let's remember that this right over here has quite a bit of data, and the restaurant only needs
10
00:00:44,820 --> 00:00:47,190
to know these two things right over here.
11
00:00:47,460 --> 00:00:53,460
So instead of passing the whole thing, I'm just going to pass these two things to rank as well as the
12
00:00:53,460 --> 00:00:53,910
name.
13
00:00:54,210 --> 00:00:55,380
So let's go ahead and do that.
14
00:00:55,920 --> 00:01:04,350
So right over here, I'm going to say something like name and this is going to be equal to restaurant.
15
00:01:04,380 --> 00:01:07,290
Again, keep in mind the spelling very, very tricky.
16
00:01:07,950 --> 00:01:09,930
And then over here, restaurant that name.
17
00:01:09,930 --> 00:01:11,250
And then we also want the rank.
18
00:01:11,250 --> 00:01:16,800
So I'm going to say that's going to be equal to restaurant, dot rank.
19
00:01:16,890 --> 00:01:17,860
Like so.
20
00:01:18,600 --> 00:01:19,020
Okay.
21
00:01:19,020 --> 00:01:21,360
I think that is pretty good.
22
00:01:21,660 --> 00:01:26,400
So now what we can do and we can, of course, do the exact same thing for the other one.
23
00:01:27,690 --> 00:01:28,530
Like so.
24
00:01:29,100 --> 00:01:30,930
And now what we can do is we can go over here.
25
00:01:30,960 --> 00:01:35,430
We can actually accept those props inside of the script.
26
00:01:35,800 --> 00:01:38,940
So I'm going to go ahead and create a script, get rid of this junk.
27
00:01:39,480 --> 00:01:40,770
I'm going to say set up.
28
00:01:40,890 --> 00:01:43,410
I'm going to say the Lang is equal to TypeScript.
29
00:01:44,190 --> 00:01:45,840
So Lang is equal to TypeScript.
30
00:01:46,120 --> 00:01:48,390
And then I say cost props.
31
00:01:49,050 --> 00:01:52,770
And I'm going to say that this is going to be equal to define props.
32
00:01:53,250 --> 00:01:57,630
Then over here, we are going to define our props, of course.
33
00:01:58,110 --> 00:02:00,180
Now we're going to define our problems with TypeScript.
34
00:02:00,180 --> 00:02:01,960
So let's create an interface.
35
00:02:01,980 --> 00:02:08,100
So say interface, you can just say here row props like so.
36
00:02:08,520 --> 00:02:10,400
So let's remember what we have here.
37
00:02:10,410 --> 00:02:14,610
So we're going to have a rank that is going to be a number.
38
00:02:15,000 --> 00:02:19,560
We're also going to have a name that is going to be a string.
39
00:02:20,280 --> 00:02:28,920
So now let's go over here and then right over here, let's create those triangle brackets and paste
40
00:02:28,920 --> 00:02:30,060
that in there.
41
00:02:30,460 --> 00:02:35,370
And now we should have access to both the rank as well as the string right over here.
42
00:02:35,850 --> 00:02:39,550
So now what we can do is we can just say rank and let's just see if it works.
43
00:02:39,570 --> 00:02:41,610
Let's just refresh and there we go.
44
00:02:41,640 --> 00:02:44,710
Now you can see one, two, three, four, five, six, seven, eight, 25.
45
00:02:44,730 --> 00:02:48,870
Then over here from 426 to 25.
46
00:02:49,440 --> 00:02:50,070
So that's good.
47
00:02:50,100 --> 00:02:52,770
Now, let's go ahead and change the name.
48
00:02:53,810 --> 00:02:59,270
So let's just say name and refresh for some reasons.
49
00:02:59,270 --> 00:03:01,220
Now reloading and there we go.
50
00:03:01,670 --> 00:03:06,050
So this is looking pretty darn good to me.
51
00:03:06,320 --> 00:03:11,330
One other thing that we're going to want to do is right over here inside of the ADF.
52
00:03:11,720 --> 00:03:16,430
This is going to be taking us to slash restaurants.
53
00:03:16,760 --> 00:03:19,610
Slash the name of the restaurant.
54
00:03:19,610 --> 00:03:22,580
So that's very something that's important to note.
55
00:03:23,090 --> 00:03:27,710
So let's actually go ahead and implement that right now.
56
00:03:28,730 --> 00:03:32,990
So let's go right over here and we're going to make those dynamic.
57
00:03:33,530 --> 00:03:36,080
Let's make this template literals like so.
58
00:03:36,860 --> 00:03:38,660
So over here, we're going to say.
59
00:03:40,720 --> 00:03:49,330
This is going to be slash restaurants and then slash whatever that name of the restaurant is.
60
00:03:49,990 --> 00:03:50,380
Okay.
61
00:03:50,590 --> 00:03:52,330
So that's pretty much all it is that we need.
62
00:03:52,330 --> 00:03:58,930
So now if I refresh and let's say click on Starbucks, I got redirected to slash restaurant slash Starbucks.
63
00:03:59,170 --> 00:04:02,860
Obviously, we're going to go for a four page, but we'll worry about that later.
64
00:04:04,300 --> 00:04:04,600
Okay.
65
00:04:04,600 --> 00:04:06,970
So that's pretty much just refresh this.
66
00:04:06,970 --> 00:04:10,840
So it's pretty much all is that we need over here.
67
00:04:11,110 --> 00:04:14,500
So the next thing I want to work on is the styling.
68
00:04:14,500 --> 00:04:19,120
So maybe have some of the grayness right over here as well as some of the white.
69
00:04:19,690 --> 00:04:23,320
So one thing that we can do is very simply just look at the rank.
70
00:04:23,710 --> 00:04:28,960
And if the rank is, let's say, an odd number, we're going to show.
71
00:04:28,960 --> 00:04:34,080
Gray If the rank is a not an odd number, we're going to show just pure white.
72
00:04:34,510 --> 00:04:39,400
So that's pretty much all that is that we are going to do.
73
00:04:40,300 --> 00:04:41,890
So in order to do this.
74
00:04:41,890 --> 00:04:45,220
What we're going to do is add this row right over here.
75
00:04:45,820 --> 00:04:48,640
I'm just going to add a dynamic style.
76
00:04:49,150 --> 00:04:57,040
So I'm going to say if the rank modulo so if the rank modulo two.
77
00:04:58,320 --> 00:05:04,560
So if the rank modulo two is not equal to zero.
78
00:05:04,860 --> 00:05:08,130
So if it's not equal to zero, I mean that this is an odd number.
79
00:05:08,490 --> 00:05:12,950
Then what I want to do is I want to add a background color.
80
00:05:12,960 --> 00:05:20,130
So I'm going to put this in a in this curly braces right over here.
81
00:05:20,130 --> 00:05:24,060
I'm going to say background color of our GBA.
82
00:05:24,970 --> 00:05:27,810
We could also add a class, but let's just do this dynamically.
83
00:05:28,360 --> 00:05:37,890
And over here we're going to say something like so and then we're going to give it 0.15 of of opacity.
84
00:05:38,310 --> 00:05:39,330
Now else.
85
00:05:39,510 --> 00:05:43,350
So else what we're going to do is just return nothing.
86
00:05:43,560 --> 00:05:44,550
We're going to keep it white.
87
00:05:45,390 --> 00:05:47,160
So now let's go over here and there we go.
88
00:05:47,190 --> 00:05:52,290
Now, you can see right away that it is looking a okay.
89
00:05:53,010 --> 00:05:58,590
Now, this actually might not be the best idea because now you can see we're getting like this weird
90
00:05:58,590 --> 00:05:59,970
checkers pattern.
91
00:06:00,420 --> 00:06:01,920
And I don't like that per se.
92
00:06:02,610 --> 00:06:07,710
So maybe instead of actually using the rank, what I'm going to do is use the index.
93
00:06:08,130 --> 00:06:10,950
So that is over here.
94
00:06:10,960 --> 00:06:12,190
We're just going to start with zero.
95
00:06:12,210 --> 00:06:15,180
And therefore, over here is going to be zero.
96
00:06:15,180 --> 00:06:16,120
Over here is going to be zero.
97
00:06:16,140 --> 00:06:20,970
Therefore, this is always going to be the exact same color, which is exactly what we have right over
98
00:06:20,970 --> 00:06:21,330
here.
99
00:06:22,510 --> 00:06:26,290
So in order to do this, all we're going to need to do is actually pass the index down.
100
00:06:27,100 --> 00:06:30,340
So we're going to need to grab the index from here.
101
00:06:31,180 --> 00:06:32,680
So we're going to say index like.
102
00:06:32,680 --> 00:06:35,450
So we're going to pass it down.
103
00:06:35,470 --> 00:06:36,310
We're going to say.
104
00:06:37,380 --> 00:06:39,840
Index is equal to index.
105
00:06:40,410 --> 00:06:42,200
And then over here, I do the same thing.
106
00:06:45,650 --> 00:06:50,900
We're going to say index is equal to index.
107
00:06:51,500 --> 00:06:53,040
So we're going to change this up a little bit.
108
00:06:53,060 --> 00:06:58,460
So over here, we're going to accept the index as a number.
109
00:06:59,060 --> 00:07:04,670
And over here we're going to say index modulo two is equal to zero.
110
00:07:05,690 --> 00:07:10,850
And if that's the case, then we want to, um, to do that.
111
00:07:11,270 --> 00:07:11,870
And there we go.
112
00:07:11,870 --> 00:07:12,860
So now we get this.
113
00:07:13,550 --> 00:07:16,010
This nice looking pattern that we have.
114
00:07:16,970 --> 00:07:19,660
Okay, so that's almost it.
115
00:07:19,700 --> 00:07:24,410
The last thing that we need to do is add this header right over here.
116
00:07:25,070 --> 00:07:29,900
So what I'm thinking of doing is actually introducing that into the row itself because it's kind of
117
00:07:29,900 --> 00:07:31,400
like a row as well.
118
00:07:31,790 --> 00:07:34,580
However, obviously it's styled a little bit differently.
119
00:07:34,970 --> 00:07:41,750
So what I'm going to do here is I'm going to say that this row is going to accept another prop and this
120
00:07:41,750 --> 00:07:46,160
prop is going to be called the row type.
121
00:07:46,760 --> 00:07:50,930
So I'm going to say here, row type.
122
00:07:52,890 --> 00:08:03,060
And this is going to be a string that is going to either be ahead or it's going to be whatever.
123
00:08:03,210 --> 00:08:08,130
And actually, maybe a better thing is just say is header and this is going to be a boolean.
124
00:08:08,940 --> 00:08:12,540
So what I'm going to do here is I'm going to say div.
125
00:08:14,200 --> 00:08:18,430
And this too, will have a class of row.
126
00:08:19,650 --> 00:08:23,790
And I'm only going to render this div v if.
127
00:08:24,670 --> 00:08:27,030
And then only if it is a header.
128
00:08:27,040 --> 00:08:28,960
So I'm going to say is header.
129
00:08:29,530 --> 00:08:32,200
Now over here we're going to have a V else.
130
00:08:32,290 --> 00:08:34,630
So else we're going to render this like so.
131
00:08:35,350 --> 00:08:41,650
And then right over here, what we're going to do is we are going to enter we're going to have an H
132
00:08:41,920 --> 00:08:46,420
for we're going to give this a class of header.
133
00:08:47,050 --> 00:08:48,670
And this is a good it's going to say rank.
134
00:08:49,330 --> 00:08:55,780
And then over here we're going to have another H for we're going to give this a class of header as well.
135
00:08:56,380 --> 00:08:58,720
And this is going to say chain.
136
00:08:59,590 --> 00:09:00,100
Okay.
137
00:09:00,490 --> 00:09:08,530
And now what we need to do is to go back to the table and then inside of the table, right above each
138
00:09:08,530 --> 00:09:14,530
row, we're going to render one extra restaurant, restaurant row.
139
00:09:14,530 --> 00:09:21,730
So I'm going to copy that because again, a tough word to spell and all I'm going to pass for props
140
00:09:21,730 --> 00:09:24,430
is is header.
141
00:09:25,720 --> 00:09:28,330
And then his header is going to be equal to true.
142
00:09:28,340 --> 00:09:29,050
Like so.
143
00:09:30,790 --> 00:09:32,230
Just like that.
144
00:09:32,590 --> 00:09:36,850
So I'm gonna do something to go out and copy this piece that in there for both of them.
145
00:09:37,540 --> 00:09:38,220
And there we go.
146
00:09:38,230 --> 00:09:43,990
So now you can see that we have this header right over here.
147
00:09:44,260 --> 00:09:53,680
Now, one thing that we also should do in this case is we should make these optional, these props optional,
148
00:09:53,680 --> 00:09:56,620
because we're not passing the props for every single one.
149
00:09:57,460 --> 00:10:03,730
As you can see here for this prop, what we're doing is we're not passing in the name and the rank or
150
00:10:03,730 --> 00:10:05,770
nor are we passing in the index.
151
00:10:06,760 --> 00:10:14,410
So what we should do again is just make these optional and we can do that by very simply just adding
152
00:10:14,410 --> 00:10:19,390
a question mark, saying that all these things are optional and you don't have to pass them in.
153
00:10:20,470 --> 00:10:26,500
Okay, so that's pretty much it and that will build out our page.
154
00:10:26,980 --> 00:10:36,100
So this was relatively involved and maybe you guys learned a little more view, but then that standpoint,
155
00:10:36,100 --> 00:10:37,330
it was pretty stale.
156
00:10:37,660 --> 00:10:43,330
So from now on, we're actually going to be learning quite a bit of new Knox concepts.
157
00:10:43,660 --> 00:10:47,710
And specifically what we're going to start working on is navigation.
158
00:10:47,980 --> 00:10:55,000
And uh, um, specifically again, what we're going to be working on is navigation to a specific page
159
00:10:55,000 --> 00:10:55,870
like so.
160
00:10:56,230 --> 00:10:58,180
So let's figure out exactly how we can do that.
14693
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.