Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,440 --> 00:00:07,910
OK, now let's start moving our components into their own folders, so the first thing I'm going to
2
00:00:07,910 --> 00:00:11,440
show you is actually our new folder structure.
3
00:00:11,900 --> 00:00:17,930
So we're actually going to have two folders, one of four components, which is going to hold all of
4
00:00:17,930 --> 00:00:22,350
our reusable components and one for our page components.
5
00:00:22,790 --> 00:00:24,070
So what's a page?
6
00:00:24,800 --> 00:00:29,090
Well, when you think about our home page, it's also a component, but it's a component that we're
7
00:00:29,090 --> 00:00:31,250
probably not going to use more than once.
8
00:00:31,610 --> 00:00:39,470
So any page that we make, I'm going to make a new component folder for inside of our pages, separate
9
00:00:39,470 --> 00:00:41,420
it from our reusable components.
10
00:00:42,680 --> 00:00:45,350
So let's begin with our homepage component.
11
00:00:46,720 --> 00:00:55,600
And we're going to do component touch aspects and we're going to move our code here into our homepage.
12
00:00:56,920 --> 00:01:02,320
And then we're also going to copy our styles and we're just going to move this into our home page as
13
00:01:02,320 --> 00:01:02,590
well.
14
00:01:05,690 --> 00:01:06,110
Now.
15
00:01:07,510 --> 00:01:08,710
We don't need this anymore.
16
00:01:09,900 --> 00:01:16,080
And we have to update our apt just to point to the new location of our home page component.
17
00:01:17,820 --> 00:01:22,770
So Stu pages, homepage, Homebake about.
18
00:01:23,730 --> 00:01:27,600
Now, if we save and if we make sure to save this as well.
19
00:01:28,630 --> 00:01:32,190
If we go back to our app, we should see everything is the same.
20
00:01:33,570 --> 00:01:40,620
OK, now let's start moving our directory and our menu item into their own components.
21
00:01:41,680 --> 00:01:44,830
So let's first start with our menu item component.
22
00:01:46,860 --> 00:01:50,760
So let's make a menu item folder in our components folder.
23
00:01:51,830 --> 00:01:55,230
And then make a menu item component Dutch.
24
00:01:56,720 --> 00:02:03,890
Now, we're also going to need those menu item styles, so let's make a menu item styles Sasseville
25
00:02:03,890 --> 00:02:04,290
file as well.
26
00:02:05,240 --> 00:02:07,760
Let's copy over our menu item styles.
27
00:02:08,900 --> 00:02:11,690
Into our menu item styles that success.
28
00:02:12,650 --> 00:02:18,860
And then in our chase, let's import react from react.
29
00:02:20,010 --> 00:02:26,280
And for our menu item, we're going to use a functional component because we don't really need our component
30
00:02:26,280 --> 00:02:28,160
to hold any state, at least not for now.
31
00:02:28,260 --> 00:02:30,090
So let's start with a functional component.
32
00:02:31,250 --> 00:02:33,230
So let's do menu item.
33
00:02:34,700 --> 00:02:35,870
Equals a function.
34
00:02:36,960 --> 00:02:43,110
That returns to us what we had in our home page component, so let's just copy this over.
35
00:02:50,210 --> 00:02:58,430
We probably want to be able to dynamically generate title by passing a title into our menu component
36
00:02:58,430 --> 00:02:59,450
right as a props.
37
00:03:00,110 --> 00:03:09,500
So instead of doing something like props, a title like this, we might also need some other properties
38
00:03:09,500 --> 00:03:10,370
to be passed in.
39
00:03:10,640 --> 00:03:14,690
If we look at our application, we're going to see that each one of these has a different.
40
00:03:15,940 --> 00:03:16,990
Image, right?
41
00:03:17,590 --> 00:03:29,020
So what we can do is we can actually structure the title off of our props for now and then we can just
42
00:03:29,620 --> 00:03:35,990
populate our component with that destruction value of title from our props.
43
00:03:36,040 --> 00:03:42,250
This is the exact same thing as writing props, that title, except we're pulling that title value off
44
00:03:42,250 --> 00:03:49,240
of our props and then setting it to this title value inside of our function so we can use it whenever
45
00:03:49,240 --> 00:03:49,720
we want.
46
00:03:50,680 --> 00:03:54,490
And then let's export out our menu item.
47
00:03:56,570 --> 00:03:59,150
And now we have our menu items.
48
00:04:00,260 --> 00:04:03,200
Now, let's make our directory component.
49
00:04:04,740 --> 00:04:15,000
So let's make a directory folder and inside we will make our directory DOT component, Dutch RSX and
50
00:04:15,000 --> 00:04:21,140
just like earlier, we'll also need a stylesheet for this directory styles dot Sath.
51
00:04:22,020 --> 00:04:24,150
So let's copy over our homepage.
52
00:04:24,150 --> 00:04:27,690
S for our directory now because we got the menu item.
53
00:04:27,690 --> 00:04:28,560
We don't need this anymore.
54
00:04:29,610 --> 00:04:34,170
So let's just get rid of it, but let's copy over our directory menu code.
55
00:04:35,650 --> 00:04:36,970
Into our directory says.
56
00:04:37,920 --> 00:04:38,820
And then.
57
00:04:40,330 --> 00:04:43,360
Let's import react from react.
58
00:04:44,870 --> 00:04:53,630
And this one will need to be a class component because we do need to store the state value of those
59
00:04:53,630 --> 00:04:58,880
menu items that we want to pass and create our menu items with.
60
00:04:58,880 --> 00:04:59,160
Right.
61
00:04:59,480 --> 00:05:06,080
So just like when we did our monster's Rolodex and we had that card list component, this one is going
62
00:05:06,080 --> 00:05:12,070
to have a directory with a state value of those menu items.
63
00:05:12,380 --> 00:05:18,410
So let's make a class of directory that extends react component.
64
00:05:20,700 --> 00:05:27,480
And remember earlier, the first time we were actually importing it as a regular import from react,
65
00:05:27,480 --> 00:05:34,470
but this component class actually also exists on the react namespace that we import from react.
66
00:05:34,470 --> 00:05:37,770
So we don't even need to do an additional import.
67
00:05:37,950 --> 00:05:39,810
We can just do react component.
68
00:05:41,070 --> 00:05:46,920
So inside of our directory class, we need that constructor, right, we always need our constructor.
69
00:05:48,060 --> 00:05:53,580
And inside of our constructor, we need to call super so that we pull in all the things we need from
70
00:05:53,580 --> 00:06:02,820
our Riak component into our class, and then we're going to set our state value right now because we're
71
00:06:02,820 --> 00:06:04,260
populating menu items.
72
00:06:04,830 --> 00:06:08,900
Each of these menu items is kind of like a section, right?
73
00:06:09,510 --> 00:06:16,830
So I'm actually just going to call it section, and that's going to be an array value that I have here
74
00:06:16,830 --> 00:06:18,180
for you in a different file.
75
00:06:19,940 --> 00:06:28,260
And what it is, is it's just an array of objects that have a title and an image URL and the image,
76
00:06:28,260 --> 00:06:34,580
you are always going to point to an image that's stored somewhere else online for these images.
77
00:06:36,340 --> 00:06:39,790
So inside of our render.
78
00:06:40,960 --> 00:06:50,890
We want to return what we had in our home page, so let's go back to our home page and let's copy this
79
00:06:50,890 --> 00:06:52,990
directory menu, because that's all we really need.
80
00:06:55,210 --> 00:06:56,110
And now.
81
00:06:57,310 --> 00:07:00,820
We want to map through our.
82
00:07:01,860 --> 00:07:02,930
Sections, right?
83
00:07:05,250 --> 00:07:12,720
And we want to pass these section objects into our menu item so that it can create the menu items,
84
00:07:13,470 --> 00:07:19,350
but let's also import our menu item component from our.
85
00:07:20,770 --> 00:07:22,480
Menu item, component folder.
86
00:07:25,450 --> 00:07:31,380
And now we know that we have to pass in afunction to our map call, right?
87
00:07:32,110 --> 00:07:40,240
So in our map, Kolubara, we're going to get a section and what we want to render is the menu item.
88
00:07:43,360 --> 00:07:49,540
So there are many ways we can pass the props and right, we can just we know that we want a title,
89
00:07:49,750 --> 00:07:50,140
right?
90
00:07:50,140 --> 00:07:54,310
So if we want to pass the title, we could easily just do section title.
91
00:07:55,240 --> 00:08:01,630
But what we want to do is be cut, we know we need this value, this title value, we know we need the
92
00:08:01,630 --> 00:08:04,540
image URL and we want the ID for our key as well.
93
00:08:04,690 --> 00:08:05,070
Right.
94
00:08:06,370 --> 00:08:13,320
What we can do instead of doing this, which we have to type section every time we can, actually to
95
00:08:13,360 --> 00:08:16,380
structure all these values off of our section.
96
00:08:16,960 --> 00:08:18,820
So we're going to get the title.
97
00:08:19,390 --> 00:08:20,800
We're going to get the image URL.
98
00:08:22,070 --> 00:08:26,480
And we're going to get the ID and now we can just do this.
99
00:08:29,150 --> 00:08:34,190
And now we have our ID and our title going in to our menu item.
100
00:08:35,760 --> 00:08:41,100
So let's make sure to export our directory.
101
00:08:43,940 --> 00:08:47,810
OK, and then we got to make sure also to bring our stylesheet in.
102
00:08:49,460 --> 00:08:55,070
So I think I didn't do that for a menu item either, so let's do that as well for our menu item.
103
00:08:57,210 --> 00:08:58,050
And then.
104
00:08:59,090 --> 00:09:05,630
We got to go into our homepage and replace our old code with our new components.
105
00:09:07,600 --> 00:09:10,690
So let's go and import in our directory.
106
00:09:13,130 --> 00:09:14,030
From.
107
00:09:16,630 --> 00:09:18,250
Our components folder.
108
00:09:20,000 --> 00:09:21,350
Our directory.
109
00:09:22,540 --> 00:09:23,770
And then the directory component.
110
00:09:25,570 --> 00:09:31,060
And now we can replace all of this with just our directory.
111
00:09:34,680 --> 00:09:35,640
And if we go back.
112
00:09:37,360 --> 00:09:38,830
We should see that everything is the same.
113
00:09:39,940 --> 00:09:40,430
Awesome.
114
00:09:40,610 --> 00:09:44,890
OK, now what about our images?
115
00:09:45,850 --> 00:09:53,560
Well, you remember in our directory we had that image URL, so let's just pass that also into our menu
116
00:09:53,560 --> 00:09:53,830
item.
117
00:09:57,460 --> 00:10:03,460
So we're going to pass this image real value into our menu item and then in our menu item component.
118
00:10:04,530 --> 00:10:14,130
We are going to actually do something different, so react actually gives every one of these HTML markup
119
00:10:14,130 --> 00:10:24,630
elements, another property called style and style takes an object that has proper values equal to six
120
00:10:24,660 --> 00:10:25,010
values.
121
00:10:25,020 --> 00:10:27,340
You want to apply to this element.
122
00:10:27,960 --> 00:10:32,280
So what we want to do is we want to set a background image.
123
00:10:32,310 --> 00:10:32,670
Right.
124
00:10:33,210 --> 00:10:38,070
And these CSFs values, instead of being the Kabab case that we're used to seeing here.
125
00:10:38,100 --> 00:10:41,580
Right with the dashes, is going to be in Canel case.
126
00:10:42,480 --> 00:10:51,000
And we want to set it equal to the image you are L. that we just passed into this component from our
127
00:10:51,000 --> 00:10:51,560
directory.
128
00:10:52,200 --> 00:10:57,180
What we got to do in order to make this work and success is we have to actually pass it as you are,
129
00:10:57,180 --> 00:10:57,720
El.
130
00:10:58,900 --> 00:11:06,940
With the string interpolated value of image URL, and this is really awesome, because this allows us
131
00:11:07,240 --> 00:11:15,970
to dynamically make styles on our components, which is super convenient, because if we want it, if
132
00:11:15,970 --> 00:11:19,010
this image were all change, our access value changes as well.
133
00:11:19,600 --> 00:11:20,770
And that's really cool.
134
00:11:21,490 --> 00:11:27,010
So we just have to update another style in our actual stylesheet regarding what this background image
135
00:11:27,010 --> 00:11:27,940
URL is going to be.
136
00:11:28,350 --> 00:11:35,020
So we always want our image or else to have that background image be centered and covering the whole
137
00:11:35,020 --> 00:11:35,380
div.
138
00:11:35,950 --> 00:11:41,710
So let's go into our menu item and let's do a background position.
139
00:11:41,710 --> 00:11:42,000
Right.
140
00:11:42,010 --> 00:11:49,650
We want it to always be centered and then we want the background size to be cover.
141
00:11:50,080 --> 00:11:53,530
So we want our background image to cover the whole thing.
142
00:11:53,530 --> 00:11:55,560
And then the position should always be in the center.
143
00:11:56,110 --> 00:12:01,810
And now if we look, we see that our component has our images.
144
00:12:02,530 --> 00:12:06,760
But if we look at this, this is a little bigger as well, right, than these ones.
145
00:12:08,250 --> 00:12:13,740
So we know that these two need to be a larger size, so how do we do this?
146
00:12:14,070 --> 00:12:21,000
Well, typically in normal access, we could just add a class that would tell this component that it's
147
00:12:21,000 --> 00:12:21,350
larger.
148
00:12:21,360 --> 00:12:23,270
So it should have skills related to that.
149
00:12:23,790 --> 00:12:32,610
While we can do that as well, with react so inside of our directory, what we can do is we can actually
150
00:12:32,610 --> 00:12:39,540
pass in a size value, which is equal to large.
151
00:12:39,690 --> 00:12:40,070
Right.
152
00:12:41,010 --> 00:12:48,600
And then we do that for our last two, for our men's and women's sections, and then we can just pass
153
00:12:48,600 --> 00:12:52,320
that size value also into our component.
154
00:12:55,510 --> 00:12:57,400
And now on our menu item.
155
00:12:58,760 --> 00:12:59,390
Component.
156
00:13:00,400 --> 00:13:09,100
We can also dynamically add in our class name value right here, right, because we are getting this
157
00:13:09,100 --> 00:13:12,340
size value, if it's nothing, it's not going to render anything.
158
00:13:12,340 --> 00:13:16,260
But if it is present, then we want to add it to our class name.
159
00:13:16,840 --> 00:13:19,870
So let's just string interpolate in.
160
00:13:22,240 --> 00:13:25,630
That value with this.
161
00:13:26,630 --> 00:13:35,930
Sorry, with size, right, and then we also always wanted to have what we had earlier, which was menu
162
00:13:35,930 --> 00:13:36,290
item.
163
00:13:38,590 --> 00:13:43,090
And now if we look at our menu item code.
164
00:13:45,250 --> 00:13:55,210
We also got to add in that style for it by doing Ambersons Sign, so if our menu item also has Dotts.
165
00:13:56,500 --> 00:13:57,130
Large.
166
00:13:59,100 --> 00:14:04,560
Then we want to give it a larger height of 380 pixels.
167
00:14:05,490 --> 00:14:12,720
And now if we save and we go back, we see that our images, these ones are large, but these ones stay
168
00:14:12,720 --> 00:14:13,520
the same, right?
169
00:14:13,680 --> 00:14:14,580
They haven't changed.
170
00:14:15,880 --> 00:14:25,090
So that's one of the great things we can do with building out our components, is that we can use these
171
00:14:25,090 --> 00:14:32,050
properties and we can write JavaScript to give them a dynamically changing value so that it lends us
172
00:14:32,050 --> 00:14:36,460
a lot more flexibility when we're building and styling our components.
173
00:14:37,550 --> 00:14:43,970
OK, now in the next section, we're going to style this menu item a little bit more with some of those
174
00:14:43,970 --> 00:14:48,080
transitions and some of these colors that we see in our final product.
15981
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.