All language subtitles for 019 Adding Custom Components & CSS Modules_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,020 --> 00:00:03,780 So for this MeetupDetail page, 2 00:00:03,780 --> 00:00:06,370 I'll add a new functional component inside 3 00:00:06,370 --> 00:00:08,410 of that meetupId page, 4 00:00:08,410 --> 00:00:11,750 the MeetupDetails component. 5 00:00:11,750 --> 00:00:15,240 And I'll then export this as a default. 6 00:00:15,240 --> 00:00:17,310 Oops, like this. 7 00:00:17,310 --> 00:00:18,990 Not MeetupList. 8 00:00:18,990 --> 00:00:22,150 Like this and then here we return the content 9 00:00:22,150 --> 00:00:24,470 for the MeetupDetails page. 10 00:00:24,470 --> 00:00:26,600 Now, here it's, of course, up to you 11 00:00:26,600 --> 00:00:30,910 how you wanna display the details for a given item. 12 00:00:30,910 --> 00:00:32,930 I will output a fragment, 13 00:00:32,930 --> 00:00:34,800 which we need to import from react 14 00:00:34,800 --> 00:00:38,730 so that we can have multiple adjacent JSX elements. 15 00:00:38,730 --> 00:00:42,520 And I'll then start by outputting the image 16 00:00:42,520 --> 00:00:43,900 of that meetup item 17 00:00:43,900 --> 00:00:46,433 with some src and some alt text. 18 00:00:47,430 --> 00:00:51,780 Now, of course, later we will actually get the concrete data 19 00:00:51,780 --> 00:00:54,010 for a specific meetup item here. 20 00:00:54,010 --> 00:00:58,300 At the moment, we don't really have any meetup data source. 21 00:00:58,300 --> 00:01:01,910 We have this dummy array in the root index.js file 22 00:01:01,910 --> 00:01:03,630 but it's only available in there 23 00:01:03,630 --> 00:01:06,580 and whilst we could export this constant 24 00:01:06,580 --> 00:01:09,440 and then also use it in the MeetupDetail page, 25 00:01:09,440 --> 00:01:10,930 I will not do this here 26 00:01:10,930 --> 00:01:14,770 because we're soon going to connect a real backend anyways. 27 00:01:14,770 --> 00:01:16,040 And therefore, for the moment, 28 00:01:16,040 --> 00:01:18,830 I'll just hard code some data in here 29 00:01:18,830 --> 00:01:21,550 and I'll grab that data from the dummy data though, 30 00:01:21,550 --> 00:01:24,310 so from this DUMMY_MEETUPS array 31 00:01:24,310 --> 00:01:27,240 and I'll copy the image link here 32 00:01:27,240 --> 00:01:29,540 and use that as a source. 33 00:01:29,540 --> 00:01:34,540 And the alt text could be A First Meetup like this. 34 00:01:34,730 --> 00:01:38,020 Then below that, I will add a h1 tag 35 00:01:38,020 --> 00:01:41,690 where I say A First Meetup and then below that, 36 00:01:41,690 --> 00:01:46,440 a paragraph with The meetup description. 37 00:01:46,440 --> 00:01:50,290 And we can also add a address element here, 38 00:01:50,290 --> 00:01:52,930 which is a default HTML element 39 00:01:52,930 --> 00:01:54,893 where we have the address. 40 00:01:56,310 --> 00:01:57,330 Like that. 41 00:01:57,330 --> 00:02:00,210 That could be how we output the MeetupDetails, 42 00:02:00,210 --> 00:02:02,980 for the moment, with some dummy data. 43 00:02:02,980 --> 00:02:06,240 And if I add this here in the MeetupDetails component, 44 00:02:06,240 --> 00:02:08,430 if we reload this MeetupDetails page, 45 00:02:08,430 --> 00:02:10,092 this is what we see. 46 00:02:11,009 --> 00:02:14,820 And that's okay but of course, not the final style 47 00:02:14,820 --> 00:02:16,620 which I'd like to have. 48 00:02:16,620 --> 00:02:19,300 I'd like to center all the text actually 49 00:02:19,300 --> 00:02:24,020 and I would also like to shrink the image a little bit. 50 00:02:24,020 --> 00:02:26,540 Now, for that, I haven't prepared any styles, 51 00:02:26,540 --> 00:02:29,620 so we can just quickly add some styles together here 52 00:02:29,620 --> 00:02:33,220 and for this, I'll actually add a brand new component 53 00:02:33,220 --> 00:02:35,340 in the component's meetups folder, 54 00:02:35,340 --> 00:02:37,543 which I'll name MeetupDetail, 55 00:02:39,330 --> 00:02:42,240 like this and you don't have to create this component. 56 00:02:42,240 --> 00:02:46,810 I just like to keep my page component files pretty lean 57 00:02:46,810 --> 00:02:49,930 and outsource as much JSX code as possible 58 00:02:49,930 --> 00:02:51,850 into standalone components. 59 00:02:51,850 --> 00:02:54,730 But that is not something you have to do. 60 00:02:54,730 --> 00:02:56,530 Nonetheless, I will do it here 61 00:02:56,530 --> 00:02:58,000 and I'll copy that fragment 62 00:02:58,000 --> 00:03:01,210 from the MeetupDetails page component here 63 00:03:01,210 --> 00:03:05,910 and add it to the MeetupDetail single component. 64 00:03:05,910 --> 00:03:09,073 And create that MeetupDetail component here. 65 00:03:10,060 --> 00:03:14,220 And of course, also export MeetupDetail here 66 00:03:14,220 --> 00:03:19,220 and return that JSX code here then like this. 67 00:03:19,580 --> 00:03:22,340 And actually, accept props already 68 00:03:23,250 --> 00:03:26,960 and expect that I get this data through props now 69 00:03:26,960 --> 00:03:30,140 so that the data will be fetched in the page component later 70 00:03:30,140 --> 00:03:32,650 and will then passed into this component, 71 00:03:32,650 --> 00:03:33,940 which is then responsible 72 00:03:33,940 --> 00:03:37,400 for actually presenting the content. 73 00:03:37,400 --> 00:03:40,390 So here we then have props.image. 74 00:03:40,390 --> 00:03:44,500 Here for alt, we could use props.title. 75 00:03:44,500 --> 00:03:49,490 What we then also use here for the h1 tag, props.title. 76 00:03:49,490 --> 00:03:53,977 And here for the address, that would be props.address 77 00:03:54,930 --> 00:03:57,210 and here we have the description. 78 00:03:57,210 --> 00:03:59,253 Props.description. 79 00:04:00,110 --> 00:04:03,830 And on the MeetupDetails page component, 80 00:04:03,830 --> 00:04:07,290 we can now output this MeetupDetail component 81 00:04:07,290 --> 00:04:08,960 we just worked on. 82 00:04:08,960 --> 00:04:09,970 And for this, of course, 83 00:04:09,970 --> 00:04:13,350 import this MeetupDetail component up there. 84 00:04:13,350 --> 00:04:15,640 And now we just need to pass that data, 85 00:04:15,640 --> 00:04:17,779 which we expect in that component 86 00:04:17,779 --> 00:04:21,093 through props into that MeetupDetail component. 87 00:04:22,830 --> 00:04:26,150 So here we can then add the image property 88 00:04:26,150 --> 00:04:28,280 and then use our dummy image link 89 00:04:29,530 --> 00:04:32,830 or our dummy image content here for the moment. 90 00:04:32,830 --> 00:04:34,710 Set the title prop. 91 00:04:34,710 --> 00:04:37,053 First Meetup could be the title. 92 00:04:38,200 --> 00:04:43,200 Set the address prop to Some Street 5, Some City 93 00:04:44,570 --> 00:04:47,630 and last but not least, set the description prop 94 00:04:47,630 --> 00:04:50,633 to this is a first meetup. 95 00:04:51,650 --> 00:04:53,820 And then we can get rid of the fragment 96 00:04:53,820 --> 00:04:56,690 and that JSX content in the page component 97 00:04:56,690 --> 00:04:59,510 and just use the MeetupDetail component here. 98 00:04:59,510 --> 00:05:01,000 Now, why am I doing that? 99 00:05:01,000 --> 00:05:03,880 Again, just to keep the JSX code lean here 100 00:05:03,880 --> 00:05:06,670 and now also for styling reasons. 101 00:05:06,670 --> 00:05:09,490 We could have also imported a CSS file 102 00:05:09,490 --> 00:05:10,620 in the page component. 103 00:05:10,620 --> 00:05:14,160 This would work, it is a regular component after all. 104 00:05:14,160 --> 00:05:16,770 But I like to keep my pages folder lean 105 00:05:16,770 --> 00:05:20,480 and only have the page JS files in there. 106 00:05:20,480 --> 00:05:22,650 Now, for the other components on the other hand, 107 00:05:22,650 --> 00:05:25,810 it is quite common that we pair a JavaScript file 108 00:05:25,810 --> 00:05:27,550 with a CSS file 109 00:05:27,550 --> 00:05:28,800 and again, we could have done that 110 00:05:28,800 --> 00:05:30,410 in the pages folder as well 111 00:05:30,410 --> 00:05:32,740 but I wanna keep that folder leaner. 112 00:05:32,740 --> 00:05:34,280 Here for the components folder, 113 00:05:34,280 --> 00:05:37,150 it is more common to include these CSS files 114 00:05:37,150 --> 00:05:38,950 and hence here I'll now also add 115 00:05:38,950 --> 00:05:43,270 a MeetupDetail.module.css file. 116 00:05:43,270 --> 00:05:46,240 The .module.css is important by the way. 117 00:05:46,240 --> 00:05:50,340 We already used it all the time here silently so to say 118 00:05:50,340 --> 00:05:53,150 because I provided all these components to you 119 00:05:53,150 --> 00:05:55,350 but this actually unlocks a feature 120 00:05:55,350 --> 00:05:58,350 called CSS modules. 121 00:05:58,350 --> 00:06:01,680 It's a feature which you might know from standard React. 122 00:06:01,680 --> 00:06:05,290 It allows you to scope CSS class styles 123 00:06:05,290 --> 00:06:08,660 to a React component and it is supported out 124 00:06:08,660 --> 00:06:11,730 of the box in NextJS projects. 125 00:06:11,730 --> 00:06:14,710 If you name a CSS file like this, 126 00:06:14,710 --> 00:06:17,530 ending with .module.css 127 00:06:17,530 --> 00:06:20,600 and you then import it into your JavaScript file 128 00:06:20,600 --> 00:06:23,480 in a certain way, which I'll show you in a second, 129 00:06:23,480 --> 00:06:28,220 then the CSS styles defined in the CSS file 130 00:06:28,220 --> 00:06:30,900 will be scoped to this component. 131 00:06:30,900 --> 00:06:34,443 At least if you use CSS classes as selectors. 132 00:06:35,400 --> 00:06:37,300 Now, that special way of importing 133 00:06:37,300 --> 00:06:39,900 can bee seen in the other JavaScript files. 134 00:06:39,900 --> 00:06:41,200 It looks like this. 135 00:06:41,200 --> 00:06:45,100 We import classes or however you wanna name it 136 00:06:45,100 --> 00:06:46,703 from the CSS file. 137 00:06:47,600 --> 00:06:49,550 And that's a special way of importing, 138 00:06:49,550 --> 00:06:51,930 which will be picked up by NextJS 139 00:06:51,930 --> 00:06:52,940 and behind the scenes, 140 00:06:52,940 --> 00:06:56,010 it will then transform the CSS classes 141 00:06:56,010 --> 00:07:00,180 so that the class names are unique per component. 142 00:07:00,180 --> 00:07:03,470 And that ensures that your styles can't spill over 143 00:07:03,470 --> 00:07:05,240 to other components. 144 00:07:05,240 --> 00:07:08,823 That's why I also wanted to show this approach here. 145 00:07:09,720 --> 00:07:14,720 So now we can import classes from ./MeetupDetail.module.css 146 00:07:17,600 --> 00:07:22,330 like this and now classes is a JavaScript object in the end 147 00:07:22,330 --> 00:07:26,970 where any CSS classes you define in your CSS file 148 00:07:26,970 --> 00:07:30,350 will be available as properties on this object. 149 00:07:30,350 --> 00:07:31,980 And if you access them, 150 00:07:31,980 --> 00:07:35,180 the values will be the transformed CSS files, 151 00:07:35,180 --> 00:07:37,280 which are guaranteed to be unique. 152 00:07:37,280 --> 00:07:40,530 And that allows you to use the same CSS class names 153 00:07:40,530 --> 00:07:44,363 in different components without clashing with the styles. 154 00:07:45,340 --> 00:07:47,510 And now we could replace Fragment here 155 00:07:47,510 --> 00:07:51,270 with section and give that section a className 156 00:07:51,270 --> 00:07:55,640 of classes.detail let's say like this. 157 00:07:55,640 --> 00:08:00,640 And if we do that, we can now add a detail CSS class here 158 00:08:01,060 --> 00:08:04,430 in the MeetupDetail.module.css file. 159 00:08:04,430 --> 00:08:08,050 And the styles we define in there will then be applied 160 00:08:08,050 --> 00:08:09,150 to this section 161 00:08:09,150 --> 00:08:12,770 because it gets this transformed detail class 162 00:08:12,770 --> 00:08:14,230 under the hood. 163 00:08:14,230 --> 00:08:15,970 And that is a nice feature to have, 164 00:08:15,970 --> 00:08:18,693 which is why I also wanted to show it to you. 165 00:08:19,680 --> 00:08:22,100 Now, with that, we can, for example, 166 00:08:22,100 --> 00:08:26,880 select the image, which is inside of that element 167 00:08:26,880 --> 00:08:29,290 with the detail class, so this image. 168 00:08:29,290 --> 00:08:31,180 We can select this 169 00:08:31,180 --> 00:08:36,049 and then change its look, change its style. 170 00:08:36,049 --> 00:08:39,059 For example, give it a width of 100%, 171 00:08:39,059 --> 00:08:42,210 which ensures that it stays in the box 172 00:08:42,210 --> 00:08:46,033 that is reserved for this page by the layout component. 173 00:08:48,040 --> 00:08:51,203 We can also select the overall detail class again. 174 00:08:52,080 --> 00:08:54,760 So the entire section with that class on it 175 00:08:54,760 --> 00:08:57,430 and set text-align to center 176 00:08:57,430 --> 00:09:00,840 so that all the text elements are centered. 177 00:09:00,840 --> 00:09:03,420 And that could now be our MeetupDetail. 178 00:09:03,420 --> 00:09:04,620 Of course, you can tweak it. 179 00:09:04,620 --> 00:09:06,230 You can add more styles, 180 00:09:06,230 --> 00:09:09,820 you can make sure that it looks the way you want it to look. 181 00:09:09,820 --> 00:09:12,820 I don't wanna turn this into a CSS course. 182 00:09:12,820 --> 00:09:16,880 I just wanted to show you this CSS modules feature 183 00:09:16,880 --> 00:09:18,780 and show you this approach, 184 00:09:18,780 --> 00:09:21,900 which you don't have to use but which I like to use 185 00:09:21,900 --> 00:09:25,370 that I keep my page component files relatively lean, 186 00:09:25,370 --> 00:09:27,790 especially regarding the JSX code 187 00:09:27,790 --> 00:09:31,970 and I instead use embeddable standard React components 188 00:09:31,970 --> 00:09:34,080 for the actual JSX code 189 00:09:34,080 --> 00:09:37,430 and like in this case, for the styling. 190 00:09:37,430 --> 00:09:40,800 And with that, we have our MeetupDetail page in place 191 00:09:40,800 --> 00:09:44,810 and now we've got all these pages here which we need. 192 00:09:44,810 --> 00:09:46,950 Now, with that, we can work 193 00:09:46,950 --> 00:09:50,088 towards replacing that dummy data source, 194 00:09:50,088 --> 00:09:54,820 our dummy array here in the root index.js file 195 00:09:54,820 --> 00:09:58,653 with a real backend, with a real data source. 15254

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