Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,340 --> 00:00:08,610
The first part of our application that we're going to be building is the header I felt like this is
2
00:00:08,610 --> 00:00:16,080
a good place to start since it's the one central location that's present on every page and then it's
3
00:00:16,080 --> 00:00:19,190
the content under the header which changes.
4
00:00:19,380 --> 00:00:27,500
So it sort of acts as that backbone to the site and just felt like the obvious starting point to build
5
00:00:27,500 --> 00:00:34,670
that header though we're going to get familiar with the material UI app bar component.
6
00:00:34,670 --> 00:00:42,410
This component provides the basic functionality that you would expect out of a header such as spanning
7
00:00:42,410 --> 00:00:49,090
the entire length of the screen and always staying at the top so we're going to start putting our header
8
00:00:49,090 --> 00:00:57,550
together using this app bar component and take a look at some of the options that we have there so here
9
00:00:57,550 --> 00:01:06,190
we are on the app bar material UI documentation page which is under the components section and then
10
00:01:06,220 --> 00:01:09,660
the surfaces section is the first one right there.
11
00:01:09,670 --> 00:01:18,320
App bar and I wanted to start by just taking a look at some of these examples so this first one is a
12
00:01:18,320 --> 00:01:25,120
very simple app bar with a menu button over here which doesn't actually open anything up in this example.
13
00:01:25,250 --> 00:01:32,210
A simple title right here and then a action button over here the log in button.
14
00:01:32,420 --> 00:01:36,130
So if we take a look at the code that makes this happen.
15
00:01:37,100 --> 00:01:44,510
It may seem at first that there is a lot going on here but it actually is pretty simple to get it up
16
00:01:44,540 --> 00:01:45,700
and running.
17
00:01:45,860 --> 00:01:55,040
So you see here that they import the app bar from app material UI core as well as the toolbar and a
18
00:01:55,040 --> 00:01:57,370
few other components.
19
00:01:57,590 --> 00:02:05,060
And so if we go down and look this is all that it is right here and it starts with just an opening app
20
00:02:05,060 --> 00:02:09,360
bar tag with the position of static.
21
00:02:09,680 --> 00:02:18,020
And underneath that a toolbar sandwiched with all of the icons and typography and that log in button
22
00:02:18,020 --> 00:02:23,860
that you see and then it is a closing toolbar tag and the closing app bar tag.
23
00:02:23,900 --> 00:02:30,050
So really that is pretty simple and pretty straightforward for getting these lay down on the screen
24
00:02:30,320 --> 00:02:34,920
even if you don't obviously understand the icon button and the typography.
25
00:02:34,930 --> 00:02:35,360
Yeah.
26
00:02:35,390 --> 00:02:37,870
And what is going on with those components.
27
00:02:37,940 --> 00:02:45,400
But the app bar itself really is pretty straightforward so let's hop on over to the code editor and
28
00:02:45,400 --> 00:02:51,630
see if we can't get an app bar set up for ourselves.
29
00:02:51,640 --> 00:02:58,450
The first thing I want to do here is actually come up to the source folder and make a new folder inside
30
00:02:58,450 --> 00:02:59,230
of that.
31
00:02:59,230 --> 00:03:06,950
And we're just gonna call that UI and then go ahead and make a another folder and call that components
32
00:03:09,220 --> 00:03:17,620
then I'm going to move the UI folder inside of the components folder and move the app J.S. file inside
33
00:03:17,620 --> 00:03:20,570
of the components folder as well.
34
00:03:20,710 --> 00:03:24,000
Now that we've done that we need to go into the index.
35
00:03:24,010 --> 00:03:35,520
John J S file and where it's importing the app file we need to change that to dos slash components slash
36
00:03:35,610 --> 00:03:41,370
app J.S. so that just updates the file that we had moved right here.
37
00:03:41,370 --> 00:03:41,900
The app.
38
00:03:41,930 --> 00:03:42,760
Yes.
39
00:03:42,810 --> 00:03:52,490
And then inside of the UI folder I want to create a new file and named this header dot J S we're gonna
40
00:03:52,490 --> 00:04:03,100
make this a basic functional component so you can start by importing react from react and then you can
41
00:04:03,400 --> 00:04:17,370
export default a function header which is going to take props and open that and let's come back up here
42
00:04:17,430 --> 00:04:19,350
and import a couple more things.
43
00:04:19,410 --> 00:04:25,830
So let's import the app bar and make sure you have the camel case there.
44
00:04:25,830 --> 00:04:28,440
How that's capital a capital B.
45
00:04:28,660 --> 00:04:40,690
And then from at material dash UI slash core slash app bar.
46
00:04:41,040 --> 00:04:44,520
And then import toolbar.
47
00:04:44,520 --> 00:04:46,860
And this was not with a capital B.
48
00:04:46,860 --> 00:04:59,760
So just lowercase b there from at material dash UI slash core slash toolbar simple enough right.
49
00:05:00,810 --> 00:05:09,720
So we'll keep going and come down here and we will return some parentheses because it's going to be
50
00:05:09,720 --> 00:05:10,740
multi line.
51
00:05:10,740 --> 00:05:21,170
So we'll put the parentheses there and we'll start by opening up with an app bar tag and closing tag
52
00:05:21,480 --> 00:05:29,250
and inside of that toolbar opening and closing tag and inside of here and let's just put arc development
53
00:05:29,640 --> 00:05:31,660
and save.
54
00:05:31,770 --> 00:05:43,640
Now let's go back to the app Dodge's file and let's import the header that we just created in the components.
55
00:05:46,750 --> 00:05:47,530
Slash
56
00:05:50,470 --> 00:05:53,840
UI slash header.
57
00:05:53,840 --> 00:05:55,580
There we go.
58
00:05:55,580 --> 00:06:02,150
And now let's go ahead and put that header right in front or on top of that.
59
00:06:02,780 --> 00:06:04,370
Hello or says hello.
60
00:06:04,370 --> 00:06:10,610
And when I save this it's going to make it look a little better but I actually wanted it to look like
61
00:06:10,820 --> 00:06:11,570
this.
62
00:06:11,630 --> 00:06:18,260
So we'll save it like that and then open up our terminal or command line if you're on Windows and make
63
00:06:18,260 --> 00:06:26,030
sure to go to your project directory mine is in the documents folder and then the arc development folder
64
00:06:26,480 --> 00:06:36,820
and NPM start this up and then open up a browser window and voila you see that we have a full width
65
00:06:36,940 --> 00:06:45,650
spanning header now appearing on the page you will notice though the our words hello is actually gone
66
00:06:45,890 --> 00:06:52,520
and it's not actually gone but it's being covered up by the header here and that is something that will
67
00:06:52,520 --> 00:07:01,190
actually fix very soon when we do the styling lecture but let's go back to the code to take a little
68
00:07:01,190 --> 00:07:10,650
better look at how this is really working and let's go over to the header file and we only have two
69
00:07:10,650 --> 00:07:17,910
components in here but my first question when I was working with this was why do we need this toolbar
70
00:07:17,940 --> 00:07:18,570
component.
71
00:07:19,350 --> 00:07:28,680
So this actually helps lay out everything in a horizontal manner for the out bar whereas if we didn't
72
00:07:28,680 --> 00:07:31,670
include that it would start to stack content up vertically.
73
00:07:31,680 --> 00:07:38,790
When we start to add content to it and obviously for an app bar along the top you want it to be horizontal.
74
00:07:38,790 --> 00:07:47,640
So that is why the toolbar is there and with the app a bar component we actually have a default position
75
00:07:48,060 --> 00:07:54,930
of fixed which may help to have it included in the code just so you don't have to remember that that's
76
00:07:54,930 --> 00:08:01,260
the default but you can save this and you can see the page reloaded and nothing is changed because that
77
00:08:01,260 --> 00:08:02,220
is the default.
78
00:08:02,520 --> 00:08:09,930
But if we come back and we change this position of fixed to static and save the file and we head back
79
00:08:09,930 --> 00:08:17,010
over you see that now it's shrunk down and it doesn't completely span that full size and you also see
80
00:08:17,060 --> 00:08:21,570
our little hello that was covered up is now underneath it.
81
00:08:21,570 --> 00:08:27,750
So that's obviously not the work that we want and I'm not entirely sure of why you really would want
82
00:08:27,750 --> 00:08:34,440
to use that but we're going to go back and change that to fixed and we'll just leave that there so that
83
00:08:34,440 --> 00:08:36,890
you don't forget that that is set.
84
00:08:37,020 --> 00:08:44,910
Now behind the scenes material UI is taking care of all these styling and code necessary to make sure
85
00:08:44,910 --> 00:08:50,460
that our header is spanning the full width of the page like that and that's really what I like so much
86
00:08:50,460 --> 00:08:51,650
about this library.
87
00:08:51,660 --> 00:08:59,160
How it does such a good job of really clean abstractions they require very little configuration to get
88
00:08:59,220 --> 00:09:00,840
something up on the screen.
9735
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.