All language subtitles for 019 Styling with 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,060 --> 00:00:05,180 In the first demo application we built, 2 00:00:05,180 --> 00:00:08,770 I gave you one CSS file that contained the styles 3 00:00:08,770 --> 00:00:11,570 for all components. 4 00:00:11,570 --> 00:00:13,600 That works for a small demo 5 00:00:13,600 --> 00:00:17,100 but not necessarily for a bigger project. 6 00:00:17,100 --> 00:00:20,280 There, you typically want to have different CSS files 7 00:00:20,280 --> 00:00:22,300 for your different components 8 00:00:22,300 --> 00:00:25,400 and hence, the CSS file which I provided to you here 9 00:00:25,400 --> 00:00:26,573 is very slim. 10 00:00:27,490 --> 00:00:30,820 Now, when it comes to styling the different components, 11 00:00:30,820 --> 00:00:34,260 it would be even nicer if the styles 12 00:00:34,260 --> 00:00:37,630 set up in a specific CSS file 13 00:00:37,630 --> 00:00:42,630 would then be scoped to the component to which they belong. 14 00:00:42,880 --> 00:00:46,240 So it would be nice if next to MainNavigation, 15 00:00:46,240 --> 00:00:48,810 we could add let's say a MainNavigation.css file 16 00:00:48,810 --> 00:00:51,980 we could add let's say a MainNavigation.css file 17 00:00:51,980 --> 00:00:55,160 and then define the styles in that file 18 00:00:55,160 --> 00:00:58,800 that belong to this MainNavigation.js file. 19 00:00:58,800 --> 00:01:02,780 And they should not affect any other component. 20 00:01:02,780 --> 00:01:04,550 That's something you'll often want, 21 00:01:04,550 --> 00:01:06,650 because in bigger react projects, 22 00:01:06,650 --> 00:01:10,850 you often work with hundreds or thousands of components 23 00:01:10,850 --> 00:01:11,940 and you want to make sure 24 00:01:11,940 --> 00:01:14,843 that your styles don't clash with each other. 25 00:01:16,200 --> 00:01:19,470 Now the good thing is that Create React App, 26 00:01:19,470 --> 00:01:22,500 this tool which we use for creating this project, 27 00:01:22,500 --> 00:01:26,620 gives us a project that has a feature built in 28 00:01:26,620 --> 00:01:30,270 that allows us to scope styles to components. 29 00:01:30,270 --> 00:01:34,500 And that feature is called CSS modules. 30 00:01:34,500 --> 00:01:37,310 It's a behind-the-scenes code transformation, 31 00:01:37,310 --> 00:01:42,040 which will make sure that we can attach CSS files 32 00:01:42,040 --> 00:01:44,700 to specific components. 33 00:01:44,700 --> 00:01:48,450 For this, we first of all need to name our CSS files 34 00:01:48,450 --> 00:01:49,570 in a certain way. 35 00:01:49,570 --> 00:01:54,570 We need to make sure that they end with .module.css 36 00:01:54,630 --> 00:01:55,490 So in this case, 37 00:01:55,490 --> 00:02:00,450 the file is named MainNavigation.module.css 38 00:02:01,670 --> 00:02:03,840 And then in MainNavigation.js, 39 00:02:03,840 --> 00:02:08,009 we can import from this CSS file. 40 00:02:08,009 --> 00:02:10,160 That certainly looks strange, 41 00:02:10,160 --> 00:02:11,360 and it's not something 42 00:02:11,360 --> 00:02:14,500 that would work in standard JavaScript 43 00:02:14,500 --> 00:02:17,460 but since we have this extra built step here, 44 00:02:17,460 --> 00:02:21,110 which parses and transforms our code 45 00:02:21,110 --> 00:02:23,330 before it reaches the browser, 46 00:02:23,330 --> 00:02:26,730 we can actually import from CSS. 47 00:02:26,730 --> 00:02:30,850 And that is what we're already doing in index.js by the way. 48 00:02:30,850 --> 00:02:34,320 We're importing a CSS file and behind the scenes, 49 00:02:34,320 --> 00:02:38,570 that will tell the build process that this CSS code 50 00:02:38,570 --> 00:02:42,730 should be injected into the loaded page as well. 51 00:02:42,730 --> 00:02:45,250 We can do the same here in MainNavigation.js 52 00:02:45,250 --> 00:02:49,180 but now to attach this styling 53 00:02:49,180 --> 00:02:53,720 or this style file and its classes to this component, 54 00:02:53,720 --> 00:02:55,558 we don't import just MainNavigation.module.css like this 55 00:02:55,558 --> 00:02:59,410 we don't import just MainNavigation.module.css like this 56 00:02:59,410 --> 00:03:04,260 but instead we import something, for example, classes, 57 00:03:04,260 --> 00:03:07,483 this name is up to you, from this file. 58 00:03:08,930 --> 00:03:10,280 Now I named it classes 59 00:03:10,280 --> 00:03:13,300 because this something here, which we import, 60 00:03:13,300 --> 00:03:16,370 will actually be a JavaScript object 61 00:03:16,370 --> 00:03:18,763 where all the CSS classes you define in this CSS file 62 00:03:18,763 --> 00:03:22,270 where all the CSS classes you define in this CSS file 63 00:03:22,270 --> 00:03:26,160 will be properties of this object. 64 00:03:26,160 --> 00:03:29,700 And you can then use them in your JSX code 65 00:03:29,700 --> 00:03:33,190 to attach those classes to your elements 66 00:03:33,190 --> 00:03:36,369 and behind the scenes everything will be transformed such 67 00:03:36,369 --> 00:03:37,202 that those class names are made unique per component. 68 00:03:37,202 --> 00:03:42,100 that those class names are made unique per component. 69 00:03:42,100 --> 00:03:43,720 So let me give you an example. 70 00:03:43,720 --> 00:03:47,000 We could go to the header JSX element here 71 00:03:47,000 --> 00:03:49,790 and add the class name prop, 72 00:03:49,790 --> 00:03:53,550 and set this not to a hard-coded string 73 00:03:53,550 --> 00:03:57,720 but instead to a dynamic value with curly braces 74 00:03:57,720 --> 00:04:01,770 and set it equal to classes.header 75 00:04:03,490 --> 00:04:07,010 Now we can add a class named header 76 00:04:07,010 --> 00:04:10,860 because here I am accessing header on classes 77 00:04:10,860 --> 00:04:13,350 to this CSS file. 78 00:04:13,350 --> 00:04:16,310 And any styles we define in here 79 00:04:16,310 --> 00:04:20,550 would then only affect this component here. 80 00:04:20,550 --> 00:04:23,670 So if I save this and I gave this a red color, 81 00:04:23,670 --> 00:04:26,143 you see now that's colored red. 82 00:04:27,030 --> 00:04:31,510 And if I had another header class in another component, 83 00:04:31,510 --> 00:04:35,530 it would not be red because the styles are scoped 84 00:04:35,530 --> 00:04:36,823 as I just explained. 85 00:04:38,090 --> 00:04:40,830 Now the goal is here not to make this red 86 00:04:40,830 --> 00:04:44,610 but instead I prepared some other styles for you, 87 00:04:44,610 --> 00:04:46,440 which you'll find attached. 88 00:04:46,440 --> 00:04:50,780 You'll find a MainNavigation.module.css file attached 89 00:04:50,780 --> 00:04:53,380 and you can simply replace your MainNavigation.module 90 00:04:54,645 --> 00:04:56,393 CSS file with mine. 91 00:04:57,450 --> 00:05:00,400 Now in here, I defined a bunch of styles for you 92 00:05:00,400 --> 00:05:02,940 and therefore, we now just have to wire them up 93 00:05:02,940 --> 00:05:04,320 to the elements. 94 00:05:04,320 --> 00:05:07,640 We already added the header class to the header. 95 00:05:07,640 --> 00:05:10,440 On this div with the logo text, 96 00:05:10,440 --> 00:05:15,440 you should add classes.logo and that's actually it already. 97 00:05:16,000 --> 00:05:19,800 And with that, if you save this, let me zoom out a bit, 98 00:05:19,800 --> 00:05:24,800 now we got this good looking navigation bar at the top here. 99 00:05:25,130 --> 00:05:27,940 By the way, it's not optimized for mobile 100 00:05:27,940 --> 00:05:30,440 since this is not really a CSS course 101 00:05:30,440 --> 00:05:33,110 but I want to focus on react instead. 102 00:05:33,110 --> 00:05:36,570 But now with that, we added this nice navigation bar 103 00:05:36,570 --> 00:05:40,930 and we added it such that we have component specific styles, 104 00:05:40,930 --> 00:05:43,913 which are also scoped to this component. 8326

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