Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,040 --> 00:00:04,019
In that hero.js file.
2
00:00:04,019 --> 00:00:06,750
We wanna build this hero component.
3
00:00:06,750 --> 00:00:10,290
So there's welcome component on the starting page
4
00:00:10,290 --> 00:00:14,100
where we present ourselves and therefore, of course
5
00:00:14,100 --> 00:00:18,250
create a functional component again and export that just
6
00:00:18,250 --> 00:00:21,400
as we always did it throughout this course.
7
00:00:21,400 --> 00:00:24,050
And now in this hero component
8
00:00:24,050 --> 00:00:25,760
I wanna return a section.
9
00:00:25,760 --> 00:00:28,350
So to standard section element.
10
00:00:28,350 --> 00:00:29,570
And in that section
11
00:00:29,570 --> 00:00:32,759
I then wanna have a couple of different elements.
12
00:00:32,759 --> 00:00:35,600
I wanna have an image where I show myself
13
00:00:35,600 --> 00:00:40,110
I wanna have some texts where I say hi, I'm Max.
14
00:00:40,110 --> 00:00:44,170
And some texts below that, where I introduce myself
15
00:00:44,170 --> 00:00:48,280
and write a couple of words about what this blog is about.
16
00:00:48,280 --> 00:00:51,920
Now I'll wrap the image in a div for styling purposes
17
00:00:51,920 --> 00:00:56,020
and we're going to add the actual image in a second.
18
00:00:56,020 --> 00:00:57,530
Below that div I then wanna
19
00:00:57,530 --> 00:01:01,927
have a h1 tag where I say, Hi, I'm Max.
20
00:01:03,430 --> 00:01:06,400
And of course, plug in your name here.
21
00:01:06,400 --> 00:01:09,390
And then below that a paragraph where I say something
22
00:01:09,390 --> 00:01:13,690
like I blog about web development
23
00:01:13,690 --> 00:01:18,690
especially front-end frameworks like Angular or React
24
00:01:20,050 --> 00:01:21,170
something like this.
25
00:01:21,170 --> 00:01:24,840
Of course feel free to fine tune this with your own texts
26
00:01:24,840 --> 00:01:27,483
and later also with your own image.
27
00:01:28,660 --> 00:01:30,170
Now we need some styling here.
28
00:01:30,170 --> 00:01:32,580
And for div we added to this hero modules
29
00:01:32,580 --> 00:01:35,170
CSS file and the effort to apply
30
00:01:35,170 --> 00:01:38,400
it we should import our classes from that file
31
00:01:38,400 --> 00:01:41,810
since we are using a .module.css file
32
00:01:41,810 --> 00:01:44,300
we are using CSS modules
33
00:01:44,300 --> 00:01:46,550
which means that the class is defined
34
00:01:46,550 --> 00:01:50,700
in that file will be transformed to behind the scenes, such
35
00:01:50,700 --> 00:01:54,540
that the styles effectively are scoped to this component.
36
00:01:54,540 --> 00:01:57,940
And don't spill over to other components.
37
00:01:57,940 --> 00:02:01,630
Even if we use the same elements and class name stair
38
00:02:01,630 --> 00:02:03,290
that's a pretty nice feature
39
00:02:03,290 --> 00:02:05,100
and that's why we're using it here.
40
00:02:05,100 --> 00:02:07,863
We have used it throughout this course already though.
41
00:02:08,970 --> 00:02:12,520
Now, which classes should be applied while on the section
42
00:02:12,520 --> 00:02:17,520
you'd wanna add a class of hero, which is simply one
43
00:02:17,820 --> 00:02:21,510
of the classes to find in the css file.
44
00:02:21,510 --> 00:02:26,403
On that image div I'll, add a class of image.
45
00:02:27,560 --> 00:02:30,140
And I don't have any classes on the h1
46
00:02:30,140 --> 00:02:35,040
and paragraph elements, because these will be styled
47
00:02:35,040 --> 00:02:38,773
with nested selectors inside of that css file.
48
00:02:40,050 --> 00:02:41,870
Okay, so now we got this.
49
00:02:41,870 --> 00:02:46,807
Now for the image I wanna use the next image component.
50
00:02:47,840 --> 00:02:51,670
So when we get this automatically optimized image
51
00:02:51,670 --> 00:02:54,970
which is automatically reduced in size
52
00:02:54,970 --> 00:02:57,210
and where different images are then loaded
53
00:02:57,210 --> 00:02:59,480
for different devices possibly.
54
00:02:59,480 --> 00:03:01,670
And which is also lazy loaded.
55
00:03:01,670 --> 00:03:03,320
And therefore we can import
56
00:03:03,320 --> 00:03:08,320
the image component from next image
57
00:03:08,570 --> 00:03:12,530
and of course, import should start with a lower case I,
58
00:03:12,530 --> 00:03:15,440
and then we can use this image component here inside
59
00:03:15,440 --> 00:03:16,591
of this image div.
60
00:03:16,591 --> 00:03:21,591
Now this image component needs a couple of attributes
61
00:03:22,820 --> 00:03:24,550
a couple of props.
62
00:03:24,550 --> 00:03:27,680
It needs to know its source, so a path
63
00:03:27,680 --> 00:03:31,250
to the image that should be loaded a path to the base image
64
00:03:31,250 --> 00:03:33,270
which is then automatically optimized
65
00:03:33,270 --> 00:03:35,600
and transformed by next.
66
00:03:35,600 --> 00:03:37,830
A alt text where I will simply
67
00:03:37,830 --> 00:03:41,980
say an image showing max, because I will soon add
68
00:03:41,980 --> 00:03:46,360
an image that shows myself and then a width and a height.
69
00:03:46,360 --> 00:03:49,220
And here you should kind of calculate
70
00:03:49,220 --> 00:03:51,030
and estimate which width
71
00:03:51,030 --> 00:03:53,483
and height you will need for your image.
72
00:03:54,700 --> 00:03:56,600
Now regarding the image file
73
00:03:56,600 --> 00:04:00,280
you find an example image attached, which you can use
74
00:04:00,280 --> 00:04:03,100
but of course you can also bring your own image.
75
00:04:03,100 --> 00:04:06,910
You don't have to use the one you find attached.
76
00:04:06,910 --> 00:04:11,910
Attached you, however, find a max.png file and you can drag
77
00:04:12,790 --> 00:04:16,680
and drop that into that public folder of your project.
78
00:04:16,680 --> 00:04:21,100
Though, there, I will actually create a sub folder images
79
00:04:21,100 --> 00:04:23,320
and in there I'll create another
80
00:04:23,320 --> 00:04:26,830
sub folder, site and I'll then drag
81
00:04:26,830 --> 00:04:30,043
this max.png file into that site folder.
82
00:04:30,920 --> 00:04:34,100
Now I'll do that because soon I will
83
00:04:34,100 --> 00:04:38,480
have another folder inside of images
84
00:04:38,480 --> 00:04:41,660
side by side to the site folder
85
00:04:41,660 --> 00:04:44,150
with the images for the block posts.
86
00:04:44,150 --> 00:04:47,210
That's why I have to separate site sub folder
87
00:04:47,210 --> 00:04:49,420
for images that belong to the site
88
00:04:49,420 --> 00:04:51,620
but not to the blog posts.
89
00:04:51,620 --> 00:04:52,560
For the moment of course,
90
00:04:52,560 --> 00:04:54,240
it's the only image we have though
91
00:04:54,240 --> 00:04:58,360
and now we wanna point at it with our image component.
92
00:04:58,360 --> 00:05:00,090
So they have a source here
93
00:05:00,090 --> 00:05:03,340
should be a path to that image.
94
00:05:03,340 --> 00:05:05,370
Now you learned that the path you
95
00:05:05,370 --> 00:05:08,670
construct here is ignoring the fact
96
00:05:08,670 --> 00:05:12,060
that the image lives in a public folder.
97
00:05:12,060 --> 00:05:15,160
Because content from the public folder is exposed
98
00:05:15,160 --> 00:05:19,490
on the root level of the running website in the end.
99
00:05:19,490 --> 00:05:22,040
So you don't need to dive into public here.
100
00:05:22,040 --> 00:05:24,810
You shouldn't dive into public here.
101
00:05:24,810 --> 00:05:29,810
Instead, this path can start on your route level
102
00:05:29,910 --> 00:05:34,820
and then just directly dive into images and then into site
103
00:05:34,820 --> 00:05:37,360
and then in my case point, that max.png
104
00:05:37,360 --> 00:05:39,023
since that's the image file.
105
00:05:40,090 --> 00:05:43,370
Now since we're using the next image component
106
00:05:43,370 --> 00:05:45,100
we also should find the width
107
00:05:45,100 --> 00:05:49,310
and height we want here since that is required by next image
108
00:05:49,310 --> 00:05:52,320
to produce the optimized images
109
00:05:52,320 --> 00:05:55,280
because it will then automatically shrink the base image
110
00:05:55,280 --> 00:05:58,760
which might be much bigger to that width and height.
111
00:05:58,760 --> 00:06:02,240
And it will also reduce the quality and much more.
112
00:06:02,240 --> 00:06:04,010
And here a width and height
113
00:06:04,010 --> 00:06:07,320
of roughly 300 pixels should work.
114
00:06:07,320 --> 00:06:10,300
We can then still overwrite the actual size
115
00:06:10,300 --> 00:06:13,210
of the image with css by targeting
116
00:06:13,210 --> 00:06:17,210
it with certain css rules and changing width and height.
117
00:06:17,210 --> 00:06:19,580
But of course the width and height you use here
118
00:06:19,580 --> 00:06:22,067
should be close to the actual width and height.
119
00:06:22,067 --> 00:06:24,080
You then render on the screen
120
00:06:24,080 --> 00:06:28,600
since otherwise you just waste size.
121
00:06:28,600 --> 00:06:31,020
If you load a pretty big image here
122
00:06:31,020 --> 00:06:35,820
and then you would use css code to render it with 100 pixels
123
00:06:35,820 --> 00:06:40,320
width and height, then you would just load a too big image
124
00:06:40,320 --> 00:06:42,330
even though you don't need it.
125
00:06:42,330 --> 00:06:45,150
On the upper hand if you load a too small image
126
00:06:45,150 --> 00:06:48,390
and you then use CSS to render a large image
127
00:06:48,390 --> 00:06:52,280
it would also be bad because then you would lose quality.
128
00:06:52,280 --> 00:06:53,830
That's why you wanna get close
129
00:06:53,830 --> 00:06:55,830
to the actual image you need.
130
00:06:55,830 --> 00:06:58,420
And the image component is pretty flexible.
131
00:06:58,420 --> 00:07:01,730
And in case your image can't have different sizes depending
132
00:07:01,730 --> 00:07:04,040
on the screen size and so on.
133
00:07:04,040 --> 00:07:05,100
You can always dive
134
00:07:05,100 --> 00:07:09,310
into the next image article to learn about different ways
135
00:07:09,310 --> 00:07:12,870
of configuring the image, specifically the layout prop
136
00:07:12,870 --> 00:07:16,320
which also allows you to define an image which can scale
137
00:07:16,320 --> 00:07:20,840
up and down with the viewport, with the responsive layout.
138
00:07:20,840 --> 00:07:24,230
By default, the image will have a layout of intrinsic
139
00:07:24,230 --> 00:07:27,300
and that will scale the image down to smaller view ports
140
00:07:27,300 --> 00:07:29,623
but not up for bigger view ports.
141
00:07:30,540 --> 00:07:34,010
So it will not produce any bigger images than the width
142
00:07:34,010 --> 00:07:35,950
and height we set here.
143
00:07:35,950 --> 00:07:37,270
And that will make sense
144
00:07:37,270 --> 00:07:41,710
for this application for the way we use the image here.
145
00:07:41,710 --> 00:07:43,730
So long story short with that, we set
146
00:07:43,730 --> 00:07:47,570
up the image with a certain width and height.
147
00:07:47,570 --> 00:07:49,860
We got our other content, and now we
148
00:07:49,860 --> 00:07:53,570
wanna use that hero component on the starting page.
149
00:07:53,570 --> 00:07:55,950
Now I am already rendering it here.
150
00:07:55,950 --> 00:07:57,860
Now we just need to import it.
151
00:07:57,860 --> 00:08:01,430
So we import Hero from and then let's
152
00:08:01,430 --> 00:08:02,285
go up one level, dive
153
00:08:02,285 --> 00:08:06,660
Into /components/home-page/ hero to import
154
00:08:06,660 --> 00:08:09,550
this component into the homepage.
155
00:08:09,550 --> 00:08:12,490
And I'll then get rid of the featured posts for the moment
156
00:08:12,490 --> 00:08:15,453
since we haven't populated that component yet.
157
00:08:16,820 --> 00:08:19,910
With that if we now run our development server
158
00:08:19,910 --> 00:08:24,840
with npm run dev we can visit local host free thousand
159
00:08:24,840 --> 00:08:28,050
and we should see this on the screen.
160
00:08:28,050 --> 00:08:32,080
This is this hero section with the styles I provided to you
161
00:08:32,080 --> 00:08:36,230
with the image I provided to you, or with your own image
162
00:08:36,230 --> 00:08:38,250
if you brought your own image.
163
00:08:38,250 --> 00:08:39,530
And that's looking good
164
00:08:39,530 --> 00:08:42,909
that's working now, let's take the next steps
165
00:08:42,909 --> 00:08:45,393
and let's continue working on this website.
13319
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.