All language subtitles for 015 Adding a Layout Wrapper Component_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,280 --> 00:00:05,650 Now we practiced those core basics again. 2 00:00:05,650 --> 00:00:08,570 One very basic feature is missing though 3 00:00:08,570 --> 00:00:10,010 and that would be links. 4 00:00:10,010 --> 00:00:12,400 At the moment we can only navigate around 5 00:00:12,400 --> 00:00:15,780 by manually changing the URL. 6 00:00:15,780 --> 00:00:17,600 Now I want to add some navigation 7 00:00:17,600 --> 00:00:20,950 and whilst you can definitely also do this on your own, 8 00:00:20,950 --> 00:00:22,880 I would recommend that we do it together, 9 00:00:22,880 --> 00:00:25,030 because I want to build a brand new component 10 00:00:25,030 --> 00:00:26,990 with a specific styling. 11 00:00:26,990 --> 00:00:30,490 And hence, that will be easier if we do it together here. 12 00:00:30,490 --> 00:00:33,060 But definitely feel free to also pause here 13 00:00:33,060 --> 00:00:35,790 and build your own basic dummy navigation 14 00:00:35,790 --> 00:00:40,060 which allows you to switch between the quotes, 15 00:00:40,060 --> 00:00:42,540 and NewQuote page. 16 00:00:42,540 --> 00:00:44,920 We'll work on getting to the Quote-ID page 17 00:00:44,920 --> 00:00:46,023 a little bit later. 18 00:00:47,110 --> 00:00:48,700 Now to build it together though, 19 00:00:48,700 --> 00:00:50,770 I'll dive into that layout folder, 20 00:00:50,770 --> 00:00:55,130 and here I prepared two CSS files for two components 21 00:00:55,130 --> 00:00:56,523 which we'll add together. 22 00:00:57,550 --> 00:01:01,060 The first component will be a main navigation component 23 00:01:01,060 --> 00:01:04,022 which I'll store in the MainNavigation JS file. 24 00:01:04,879 --> 00:01:08,110 As the name suggests, the job of this component will be, 25 00:01:08,110 --> 00:01:10,743 to render a main navigation bar. 26 00:01:11,890 --> 00:01:14,290 So in here, I'll add a regular component 27 00:01:14,290 --> 00:01:18,010 MainNavigation component function, 28 00:01:18,010 --> 00:01:20,603 as we did it many times before in this course. 29 00:01:21,930 --> 00:01:25,713 And then here in this component, I want to return a header. 30 00:01:26,730 --> 00:01:29,340 And in that header, I want to have a div, 31 00:01:29,340 --> 00:01:31,470 which holds my logo text 32 00:01:31,470 --> 00:01:35,240 which could be Great Quotes or anything like this. 33 00:01:35,240 --> 00:01:39,100 And next to that div, I'll add a nav element 34 00:01:39,100 --> 00:01:41,190 which will then store an onward list 35 00:01:41,190 --> 00:01:43,290 with a couple of lists items, 36 00:01:43,290 --> 00:01:46,253 where every list item should hold a link. 37 00:01:48,550 --> 00:01:50,170 Now we'll need some styling here, 38 00:01:50,170 --> 00:01:52,690 and therefore I'll import classes 39 00:01:52,690 --> 00:01:57,320 from ./MainNavigation.module.CSS. 40 00:01:57,320 --> 00:02:00,793 So from that CSS file, which I already provided to you. 41 00:02:01,800 --> 00:02:03,210 And then on that header, 42 00:02:03,210 --> 00:02:07,230 you should add a className of classes.header, 43 00:02:07,230 --> 00:02:12,230 on that div you can add a className of classes.logo. 44 00:02:12,610 --> 00:02:15,640 And these are all predefined CSS classes 45 00:02:15,640 --> 00:02:19,403 which you find in this CSS file, which I provided to you. 46 00:02:20,460 --> 00:02:23,603 And on the nav element, it's classes.nav. 47 00:02:25,486 --> 00:02:28,090 Now for these list items, as I just mentioned 48 00:02:28,090 --> 00:02:29,860 I want to have links in there. 49 00:02:29,860 --> 00:02:33,630 And you did learn that having an anchor tag is not optimal. 50 00:02:33,630 --> 00:02:36,170 At least not if you add it like this, 51 00:02:36,170 --> 00:02:39,030 because that would then trigger the browser default, 52 00:02:39,030 --> 00:02:40,720 of sending a new request. 53 00:02:40,720 --> 00:02:41,993 And we don't want that. 54 00:02:42,980 --> 00:02:45,680 Instead, we learned that React Router, 55 00:02:45,680 --> 00:02:47,980 gives us specific components 56 00:02:47,980 --> 00:02:50,710 which we can use for rendering links. 57 00:02:50,710 --> 00:02:54,720 And there we have the Link component for a standard link 58 00:02:54,720 --> 00:02:57,820 and the NavLink component for a standard link 59 00:02:57,820 --> 00:03:02,780 which also gets a specific CSS class, if it's active. 60 00:03:02,780 --> 00:03:05,550 And here I'll use that NavLink. 61 00:03:05,550 --> 00:03:07,513 And then in this first list item, 62 00:03:08,590 --> 00:03:10,840 we can add a NavLink, 63 00:03:10,840 --> 00:03:15,270 with a text off All Quotes between the NavLink components, 64 00:03:15,270 --> 00:03:18,533 which leads to /quotes, for example. 65 00:03:20,410 --> 00:03:23,090 And I'll also set the activeClassName prop here 66 00:03:23,090 --> 00:03:26,550 to classes.active, so that this link gets 67 00:03:26,550 --> 00:03:30,140 the active CSS class, if it is active. 68 00:03:30,140 --> 00:03:34,063 And of course that is a class which I use in this CSS file. 69 00:03:36,320 --> 00:03:39,050 Now I'll repeat this entire list item 70 00:03:39,050 --> 00:03:42,430 and add a second list item where we could say, 71 00:03:42,430 --> 00:03:46,183 Add a Quote, and this then leads to /newquote. 72 00:03:48,740 --> 00:03:51,953 And with that, we should have the finished MainNavigation. 73 00:03:52,890 --> 00:03:55,930 Now we could add this main navigation here 74 00:03:55,930 --> 00:03:59,820 in the App JS file, above to Switch statement 75 00:03:59,820 --> 00:04:02,850 but I will actually also add another component 76 00:04:02,850 --> 00:04:05,350 the Layout component, which I'll store 77 00:04:05,350 --> 00:04:08,583 in a Layout JS file in that Layout folder. 78 00:04:09,650 --> 00:04:12,220 This will be a very simple component. 79 00:04:12,220 --> 00:04:15,160 I'll again create it as a Functional Component 80 00:04:16,100 --> 00:04:18,363 and export it like this. 81 00:04:19,399 --> 00:04:21,680 And here I'll also import classes 82 00:04:21,680 --> 00:04:25,680 from ./layout.module.css file using 83 00:04:25,680 --> 00:04:28,363 that existing CSS file, which you find here. 84 00:04:29,560 --> 00:04:31,500 Now, the goal of this component is, 85 00:04:31,500 --> 00:04:34,520 to render the MainNavigation side by side 86 00:04:34,520 --> 00:04:36,653 with the actual page content. 87 00:04:37,740 --> 00:04:40,180 And for this I'll return a Fragment 88 00:04:40,180 --> 00:04:44,080 since I want to have adjacent JSX elements. 89 00:04:44,080 --> 00:04:47,550 Fragment is imported from React of course 90 00:04:47,550 --> 00:04:50,810 and then here we can render the MainNavigation. 91 00:04:50,810 --> 00:04:53,966 And for that make sure that you import MainNavigation, 92 00:04:53,966 --> 00:04:57,010 this MainNavigation component we just worked on, 93 00:04:57,010 --> 00:04:59,293 from that MainNavigation file. 94 00:05:00,320 --> 00:05:01,720 And side by side to it, 95 00:05:01,720 --> 00:05:05,740 I'll add a Main element which gets a class 96 00:05:05,740 --> 00:05:09,910 of classes.main, and here I then want to render 97 00:05:09,910 --> 00:05:11,623 the actual page content. 98 00:05:12,690 --> 00:05:15,420 Now, of course the actual page content is determined 99 00:05:15,420 --> 00:05:18,470 in the App JS file by these Routes still. 100 00:05:18,470 --> 00:05:20,010 But we also learned in this course 101 00:05:20,010 --> 00:05:21,620 what we can do in this case. 102 00:05:21,620 --> 00:05:24,340 I want to use Layout as a wrapper 103 00:05:24,340 --> 00:05:27,660 around this Switch statement here in the end 104 00:05:27,660 --> 00:05:30,230 so that whatever Route is chosen rendered, 105 00:05:30,230 --> 00:05:32,320 it's wrapped by the Layout. 106 00:05:32,320 --> 00:05:35,290 And we can create such wrapper components 107 00:05:35,290 --> 00:05:40,290 by using props and to be precise props.children. 108 00:05:43,320 --> 00:05:48,320 And then we can go to App.JS and import, Layout from 109 00:05:50,657 --> 00:05:55,270 ./components/layout/layout, 110 00:05:55,270 --> 00:05:58,890 and then simply wrap Layout 111 00:05:58,890 --> 00:06:01,863 around this Switch statement here. 112 00:06:05,510 --> 00:06:09,060 And if we do all of that and you save all files 113 00:06:09,060 --> 00:06:11,080 you should know have this navigation. 114 00:06:11,080 --> 00:06:14,010 And you see that the active link is highlighted. 115 00:06:14,010 --> 00:06:17,350 It's a bit whiter than the inactive link, 116 00:06:17,350 --> 00:06:20,423 so we can switch and that highlighting changes. 117 00:06:21,600 --> 00:06:26,600 And now if I go to quotes/sum-id, 118 00:06:28,840 --> 00:06:31,670 we also have to quote detail page here. 119 00:06:31,670 --> 00:06:34,500 And if I then add /comments we also have that here. 120 00:06:34,500 --> 00:06:37,840 And now the form isn't as big anymore. 121 00:06:37,840 --> 00:06:39,600 Now that's still all not working, 122 00:06:39,600 --> 00:06:41,530 and that's of course it's not the final page 123 00:06:41,530 --> 00:06:43,803 but it's one step closer. 9704

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