All language subtitles for 003 Adding a _Header_ Component_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,120 --> 00:00:03,454 Now of course 2 00:00:03,454 --> 00:00:04,530 we're going to populate these folders 3 00:00:04,530 --> 00:00:07,350 step-by-step fro to this module. 4 00:00:07,350 --> 00:00:10,510 I wanna start with the header for now. 5 00:00:10,510 --> 00:00:13,400 So with this tool bar at the top 6 00:00:13,400 --> 00:00:16,100 and therefor in the layout folder here 7 00:00:16,100 --> 00:00:18,730 I will add a header JS file 8 00:00:20,020 --> 00:00:23,750 and that will hold my header code. 9 00:00:23,750 --> 00:00:25,780 The header will also need some styling 10 00:00:25,780 --> 00:00:28,460 so side-by-sides to header JS 11 00:00:28,460 --> 00:00:32,180 I will add a header dot module CSS file. 12 00:00:32,180 --> 00:00:34,410 Dot module because I will use 13 00:00:34,410 --> 00:00:37,860 the built in CSS modules support 14 00:00:37,860 --> 00:00:42,760 which modern React projects created with create React app 15 00:00:42,760 --> 00:00:45,163 which does set up isn't the end per wide. 16 00:00:46,030 --> 00:00:48,540 So this CSS file will be need 17 00:00:48,540 --> 00:00:50,910 and speaking of that file 18 00:00:50,910 --> 00:00:54,960 you find this header dot module CSS file attached 19 00:00:54,960 --> 00:00:56,030 to this lecture 20 00:00:56,030 --> 00:00:58,540 and you can simply replace yours with it 21 00:00:58,540 --> 00:00:59,980 or simply copy it 22 00:00:59,980 --> 00:01:01,950 on the provided styles 23 00:01:01,950 --> 00:01:04,010 which are some styles I came up with 24 00:01:04,010 --> 00:01:06,110 to give this header the look you saw in 25 00:01:06,110 --> 00:01:09,170 the preview at the beginning of this module. 26 00:01:09,170 --> 00:01:11,090 Of course you can also write your own styles 27 00:01:11,090 --> 00:01:12,340 if you would prefer that. 28 00:01:13,750 --> 00:01:16,240 Now in the header JS file 29 00:01:16,240 --> 00:01:19,320 we wanna have the JSX structure 30 00:01:19,320 --> 00:01:20,890 for our header. 31 00:01:20,890 --> 00:01:21,730 And therefor here 32 00:01:21,730 --> 00:01:25,730 I will export a header Component function 33 00:01:25,730 --> 00:01:28,700 where we get some props 34 00:01:28,700 --> 00:01:30,620 and of course we'll also 35 00:01:30,620 --> 00:01:32,270 well exports this function 36 00:01:32,270 --> 00:01:34,550 to make it available outside of this file 37 00:01:34,550 --> 00:01:37,540 because they will use it in a different file. 38 00:01:37,540 --> 00:01:40,180 And inside of this Component function 39 00:01:40,180 --> 00:01:42,650 I don't need complex logic 40 00:01:42,650 --> 00:01:44,730 or state or anything like that 41 00:01:44,730 --> 00:01:46,910 instead there I will just return 42 00:01:46,910 --> 00:01:49,890 the JSX code for this header. 43 00:01:49,890 --> 00:01:54,890 And here I actually wanna have two blocks of code. 44 00:01:54,950 --> 00:01:58,530 One block of code will be the header itself 45 00:01:58,530 --> 00:02:00,620 so that toolbar 46 00:02:00,620 --> 00:02:02,540 the second part will be 47 00:02:02,540 --> 00:02:04,910 the image below the header. 48 00:02:04,910 --> 00:02:06,630 Though we could also split 49 00:02:06,630 --> 00:02:08,130 that into two separate Components 50 00:02:08,130 --> 00:02:12,130 if we wanted to here I will keep it in one Component 51 00:02:12,130 --> 00:02:14,060 but again that is definitely a split 52 00:02:14,060 --> 00:02:15,340 you could also make 53 00:02:15,340 --> 00:02:18,160 have two Components instead of one. 54 00:02:18,160 --> 00:02:20,930 Now here I will use a React Fragment 55 00:02:20,930 --> 00:02:23,730 so that built in Fragment Component 56 00:02:23,730 --> 00:02:26,290 and therefor I wanna import React from React 57 00:02:26,290 --> 00:02:28,580 so that I can access React Fragment 58 00:02:29,610 --> 00:02:32,980 alternatively we of course just import Fragment 59 00:02:32,980 --> 00:02:35,993 and use that directly as a Component like this. 60 00:02:36,890 --> 00:02:40,000 And I'm using this Fragment Component as a rapper 61 00:02:40,000 --> 00:02:45,000 because we must only have one root element returned here 62 00:02:45,000 --> 00:02:48,600 that's true for any place where you use JSX 63 00:02:48,600 --> 00:02:51,200 you must only have one root element. 64 00:02:51,200 --> 00:02:52,120 And in there 65 00:02:52,120 --> 00:02:54,870 I actually wanna have two sibling elements. 66 00:02:54,870 --> 00:02:58,260 A header using the built in header Component 67 00:02:58,260 --> 00:03:01,680 and then a div which will hold the image. 68 00:03:01,680 --> 00:03:02,770 And again that would be 69 00:03:02,770 --> 00:03:05,530 the two Components you could also separate 70 00:03:05,530 --> 00:03:08,330 into separate Component files and functions. 71 00:03:08,330 --> 00:03:10,723 Here I'll keep it in one Component though. 72 00:03:12,320 --> 00:03:14,460 Now, inside of the header here 73 00:03:14,460 --> 00:03:17,530 which is a default HTML five element 74 00:03:17,530 --> 00:03:21,730 I'll have an h1 element where I'll say React meals 75 00:03:21,730 --> 00:03:24,900 which is just the name of this application I came up with. 76 00:03:24,900 --> 00:03:27,750 Of course you can choose any name you want. 77 00:03:27,750 --> 00:03:30,150 And then side-by-side to that 78 00:03:30,150 --> 00:03:33,870 I wanna have a button which will open the cart later. 79 00:03:33,870 --> 00:03:35,610 So for the moment I'll just add a button 80 00:03:35,610 --> 00:03:37,740 with the name of cart like this 81 00:03:37,740 --> 00:03:39,680 I will change this code in a couple 82 00:03:39,680 --> 00:03:41,320 of seconds or minutes though 83 00:03:42,850 --> 00:03:44,420 before we changed a button though 84 00:03:44,420 --> 00:03:46,420 let's have a look at that div 85 00:03:46,420 --> 00:03:48,850 and then that's div I wanna have an image. 86 00:03:48,850 --> 00:03:51,370 So the built in image element 87 00:03:51,370 --> 00:03:55,320 and here I'm providing an image to you 88 00:03:55,320 --> 00:03:57,180 which you find attached as well. 89 00:03:57,180 --> 00:03:59,750 And it will add an essence folder 90 00:03:59,750 --> 00:04:01,380 in the source directory 91 00:04:01,380 --> 00:04:03,260 so next two Components 92 00:04:03,260 --> 00:04:06,070 where this image will actually be stored in. 93 00:04:06,070 --> 00:04:09,130 So attached you find that meals.jpg file 94 00:04:09,130 --> 00:04:12,473 and I will just copy that into that assets folder. 95 00:04:14,540 --> 00:04:16,829 This is an image which is provided locally 96 00:04:16,829 --> 00:04:19,899 as part of the React application. 97 00:04:19,899 --> 00:04:23,920 Now how can we use that image here in this JSX file? 98 00:04:23,920 --> 00:04:25,750 Well we can use this image in a way 99 00:04:25,750 --> 00:04:28,640 which could look strange when you first see it 100 00:04:28,640 --> 00:04:31,990 but which is very easy to use once you're used to it 101 00:04:31,990 --> 00:04:34,800 you can simply import images 102 00:04:34,800 --> 00:04:37,820 and it's a bit like importing CSS files. 103 00:04:37,820 --> 00:04:40,448 It's not really a JavaScript feature 104 00:04:40,448 --> 00:04:43,220 but instead imports like that 105 00:04:43,220 --> 00:04:46,519 so importing CSS files or importing images 106 00:04:46,519 --> 00:04:49,470 is supported by this project setup 107 00:04:49,470 --> 00:04:50,700 which we're using here 108 00:04:50,700 --> 00:04:52,370 and behind the scenes 109 00:04:52,370 --> 00:04:54,810 the import is simply transformed 110 00:04:54,810 --> 00:04:57,890 to include the image in the finished application 111 00:04:57,890 --> 00:05:00,050 which we could deploy to a server 112 00:05:00,050 --> 00:05:02,390 and to generate a link to that image 113 00:05:02,390 --> 00:05:04,430 which is then dynamically inserted in 114 00:05:04,430 --> 00:05:06,000 the generators code. 115 00:05:06,000 --> 00:05:07,060 So there's a lot of behind 116 00:05:07,060 --> 00:05:08,863 the scenes magic going on here. 117 00:05:09,930 --> 00:05:12,640 For us we simply import meals image 118 00:05:12,640 --> 00:05:14,220 though this name is up to you 119 00:05:15,090 --> 00:05:18,760 from going up, going up 120 00:05:18,760 --> 00:05:20,883 assets, meals JPG. 121 00:05:22,270 --> 00:05:24,590 And here the file extension matters 122 00:05:24,590 --> 00:05:26,860 just as for a CSS files 123 00:05:26,860 --> 00:05:29,470 because this tells that build process 124 00:05:29,470 --> 00:05:31,590 that this is not a JavaScript file 125 00:05:31,590 --> 00:05:33,300 but in this case an image file 126 00:05:33,300 --> 00:05:35,630 and that therefor it should be transformed 127 00:05:35,630 --> 00:05:38,653 and injected appropriately behind the scenes. 128 00:05:39,510 --> 00:05:41,780 And then we can use this import image 129 00:05:41,780 --> 00:05:43,340 as a source here 130 00:05:43,340 --> 00:05:45,460 by binding the source dynamically 131 00:05:45,460 --> 00:05:46,900 with curly braces 132 00:05:46,900 --> 00:05:49,063 and pointing at meals image. 133 00:05:50,040 --> 00:05:53,460 This is how you can include a local image. 134 00:05:53,460 --> 00:05:56,580 Of course if this would be an image on some server 135 00:05:56,580 --> 00:05:59,610 and you'll had a URL to that image 136 00:05:59,610 --> 00:06:04,610 you could just add that URL to some image 137 00:06:05,690 --> 00:06:07,810 to some image dot JPG. 138 00:06:07,810 --> 00:06:10,290 You could add that if you had such a URL 139 00:06:11,210 --> 00:06:13,210 but here since it's a local image 140 00:06:13,210 --> 00:06:14,700 part of the project 141 00:06:14,700 --> 00:06:16,693 we instead use that other approach. 142 00:06:18,220 --> 00:06:20,030 Now we can always add an alt text 143 00:06:23,660 --> 00:06:26,050 a table full of delicious food 144 00:06:27,550 --> 00:06:28,820 something like this. 145 00:06:28,820 --> 00:06:32,200 And with that I got the general structure 146 00:06:32,200 --> 00:06:35,253 for this header Component finished. 147 00:06:36,105 --> 00:06:38,480 Though there are things missing 148 00:06:38,480 --> 00:06:40,630 for example the styling. 149 00:06:40,630 --> 00:06:44,840 Here on the header Component on the header element 150 00:06:44,840 --> 00:06:46,750 I wanna add a class name 151 00:06:46,750 --> 00:06:49,770 and since we added this CSS file 152 00:06:49,770 --> 00:06:51,800 which uses CSS modules 153 00:06:51,800 --> 00:06:52,930 we import classes 154 00:06:55,640 --> 00:06:59,600 from that module dot CSS file. 155 00:06:59,600 --> 00:07:01,920 So from header module dot CSS 156 00:07:01,920 --> 00:07:04,860 and here as a class and for the header 157 00:07:04,860 --> 00:07:07,030 we should point at classes dot header 158 00:07:08,550 --> 00:07:10,780 because in that CSS file 159 00:07:10,780 --> 00:07:12,000 if you have a look at it 160 00:07:12,000 --> 00:07:14,470 there is a header CSS class to find 161 00:07:14,470 --> 00:07:17,290 and as you'll learn in the styling section 162 00:07:17,290 --> 00:07:19,823 this is how you use CSS modules then. 163 00:07:21,680 --> 00:07:22,560 Now on that's div 164 00:07:22,560 --> 00:07:23,450 which holds the image 165 00:07:23,450 --> 00:07:25,460 I'll also add a class name 166 00:07:25,460 --> 00:07:29,520 and here it's classes main image written like this. 167 00:07:29,520 --> 00:07:32,130 Since it's a CSS class with a dash inside of it 168 00:07:32,130 --> 00:07:34,500 we can't use to dot notation 169 00:07:34,500 --> 00:07:36,780 and that's simply another CSS class 170 00:07:36,780 --> 00:07:37,833 to find in there. 171 00:07:39,950 --> 00:07:43,593 Now with that the general header structure is finished. 172 00:07:45,090 --> 00:07:46,500 With that we can now go 173 00:07:46,500 --> 00:07:49,780 to app JS to our root Component 174 00:07:49,780 --> 00:07:54,780 and there we can import header from slash Components 175 00:07:57,720 --> 00:08:01,540 layout header like this 176 00:08:02,710 --> 00:08:05,470 and then instead of this h2 tag here 177 00:08:05,470 --> 00:08:08,263 I will use my header. 178 00:08:09,580 --> 00:08:11,220 And actually I also don't want 179 00:08:11,220 --> 00:08:13,010 that div here anymore 180 00:08:13,010 --> 00:08:15,210 instead here for the moment 181 00:08:15,210 --> 00:08:17,000 I will just use a Fragment 182 00:08:17,960 --> 00:08:21,010 which I of course need to import from React. 183 00:08:21,010 --> 00:08:23,970 The React import itself is missing here because 184 00:08:23,970 --> 00:08:25,100 as you learned 185 00:08:25,100 --> 00:08:28,170 you can omit that in modern React projects 186 00:08:28,170 --> 00:08:29,540 like this one 187 00:08:29,540 --> 00:08:31,730 you can always add it as well though. 188 00:08:31,730 --> 00:08:34,250 You can always also import React 189 00:08:34,250 --> 00:08:36,960 from React and it won't hurt either. 190 00:08:36,960 --> 00:08:38,400 Technically it's required 191 00:08:38,400 --> 00:08:41,220 because of what JSX is transformed 192 00:08:41,220 --> 00:08:42,640 to behind the scenes 193 00:08:42,640 --> 00:08:45,070 But in some projects setups like this one 194 00:08:45,070 --> 00:08:46,383 you can simply omit it. 195 00:08:47,290 --> 00:08:48,810 And with that if you saved it 196 00:08:48,810 --> 00:08:50,883 you should have that header here. 197 00:08:51,910 --> 00:08:54,110 And this is a good start 198 00:08:54,110 --> 00:08:56,340 this is now our toolbar 199 00:08:56,340 --> 00:08:58,760 of course the code button in the header 200 00:08:58,760 --> 00:09:00,450 doesn't look at all like 201 00:09:00,450 --> 00:09:02,560 the button you saw in the preview though. 202 00:09:02,560 --> 00:09:05,263 And therefore that's what we're going to work on next. 14732

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.