All language subtitles for 009 Adding The _ErrorModal_ 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:01,752 --> 00:00:05,490 So, we want such an error modal. 2 00:00:05,490 --> 00:00:08,720 Now a modal is simply does overlay box. 3 00:00:08,720 --> 00:00:10,730 And for me that's a UI element, 4 00:00:10,730 --> 00:00:12,460 we could be using in different parts 5 00:00:12,460 --> 00:00:13,570 of the app. 6 00:00:13,570 --> 00:00:15,200 This of course is a trivial app 7 00:00:15,200 --> 00:00:17,170 that has only one part, 8 00:00:17,170 --> 00:00:18,310 but we're always thinking 9 00:00:18,310 --> 00:00:19,220 from the perspective 10 00:00:19,220 --> 00:00:21,660 of potentially bigger apps. 11 00:00:21,660 --> 00:00:23,860 Therefore I'll add it into UI folder 12 00:00:23,860 --> 00:00:25,390 because such an error modal, 13 00:00:25,390 --> 00:00:27,683 it could be a reusable UI element. 14 00:00:28,870 --> 00:00:32,720 So I'll add my ErrorModal.js file in there. 15 00:00:32,720 --> 00:00:33,670 And in that file, 16 00:00:33,670 --> 00:00:36,550 we of course import react from react. 17 00:00:36,550 --> 00:00:38,316 We got our error modal here, 18 00:00:38,316 --> 00:00:40,790 which got some props, 19 00:00:40,790 --> 00:00:43,763 and we export this like that. 20 00:00:44,990 --> 00:00:47,100 Now that's the first step. 21 00:00:47,100 --> 00:00:48,780 Now the second step, 22 00:00:48,780 --> 00:00:49,830 is of course to fill 23 00:00:49,830 --> 00:00:51,020 that with some life. 24 00:00:51,020 --> 00:00:53,350 And generally, it's totally up to you, 25 00:00:53,350 --> 00:00:55,770 how you wanna structure your modal. 26 00:00:55,770 --> 00:00:56,720 I actually want 27 00:00:56,720 --> 00:00:58,580 to reuse that card, 28 00:00:58,580 --> 00:01:00,653 so import card from, 29 00:01:01,510 --> 00:01:03,380 card like this, 30 00:01:03,380 --> 00:01:04,750 and use this as a wrapper 31 00:01:04,750 --> 00:01:06,120 for the entire modal, 32 00:01:06,120 --> 00:01:06,953 because I liked 33 00:01:06,953 --> 00:01:08,000 that rounded corners, 34 00:01:08,000 --> 00:01:08,833 look hands on, 35 00:01:08,833 --> 00:01:11,090 I wanna use that therefore. 36 00:01:11,090 --> 00:01:12,890 Now inside of that card, 37 00:01:12,890 --> 00:01:16,280 my modal should have different sections. 38 00:01:16,280 --> 00:01:18,030 I wanna have a header, 39 00:01:18,030 --> 00:01:19,350 with the H two tag, 40 00:01:19,350 --> 00:01:21,363 where we actually can output some title. 41 00:01:22,590 --> 00:01:23,770 Now below that, 42 00:01:23,770 --> 00:01:24,990 I wanna have a div, 43 00:01:24,990 --> 00:01:26,560 which holds my main content. 44 00:01:26,560 --> 00:01:27,860 And in there a paragraph 45 00:01:27,860 --> 00:01:28,900 with DRR message, 46 00:01:28,900 --> 00:01:31,210 I wanna display eventually. 47 00:01:31,210 --> 00:01:32,973 And below that, a footer. 48 00:01:34,570 --> 00:01:35,930 Now in that footer, 49 00:01:35,930 --> 00:01:37,590 I wanna have a button which we can click 50 00:01:37,590 --> 00:01:38,920 to close the modal. 51 00:01:38,920 --> 00:01:40,300 So for that I'll import button 52 00:01:40,300 --> 00:01:41,750 from that slash button 53 00:01:41,750 --> 00:01:43,930 to all the reuse, this component. 54 00:01:43,930 --> 00:01:47,230 And this, shows us this re-usability of components. 55 00:01:47,230 --> 00:01:48,470 We're using the card, 56 00:01:48,470 --> 00:01:50,190 in various places of the app. 57 00:01:50,190 --> 00:01:51,450 We're using the button 58 00:01:51,450 --> 00:01:53,000 in different places of the app. 59 00:01:53,000 --> 00:01:55,500 And we only defined these components 60 00:01:55,500 --> 00:01:56,980 and their styles once. 61 00:01:56,980 --> 00:01:59,160 And we can build our entire UI 62 00:01:59,160 --> 00:02:01,420 with these reusable building blocks. 63 00:02:01,420 --> 00:02:02,910 That's really the heart 64 00:02:02,910 --> 00:02:04,250 and the core idea 65 00:02:04,250 --> 00:02:07,043 or one of the core ideas of react. 66 00:02:07,890 --> 00:02:10,169 So, we got the button here, 67 00:02:10,169 --> 00:02:11,310 and hence the footer. 68 00:02:11,310 --> 00:02:13,110 We can add such a button 69 00:02:13,110 --> 00:02:14,360 and say, okay, 70 00:02:14,360 --> 00:02:16,180 or something like that on it. 71 00:02:16,180 --> 00:02:19,550 So that this is our closed modal button in the end. 72 00:02:21,020 --> 00:02:22,920 Now, between the H two tags here, 73 00:02:22,920 --> 00:02:24,460 I wanna have some title. 74 00:02:24,460 --> 00:02:25,293 And of course 75 00:02:25,293 --> 00:02:28,890 that modal should be configurable from outside. 76 00:02:28,890 --> 00:02:30,460 I don't wanna hard code, the title 77 00:02:30,460 --> 00:02:32,550 and the message into this component. 78 00:02:32,550 --> 00:02:34,530 It should also be reusable. 79 00:02:34,530 --> 00:02:35,550 So that we can use it 80 00:02:35,550 --> 00:02:37,120 in different places of the app, 81 00:02:37,120 --> 00:02:39,253 to show different error messages. 82 00:02:40,290 --> 00:02:43,120 Hence here, I, I'll put something dynamic, 83 00:02:43,120 --> 00:02:44,500 between curly braces 84 00:02:44,500 --> 00:02:47,123 and use, let's say props.title. 85 00:02:47,970 --> 00:02:49,480 Again, it's your component. 86 00:02:49,480 --> 00:02:51,830 You can use any prop name you want here, 87 00:02:51,830 --> 00:02:54,000 but I expect to get a title prop, 88 00:02:54,000 --> 00:02:54,836 which holds the text, 89 00:02:54,836 --> 00:02:56,683 which should be output here. 90 00:02:57,730 --> 00:02:59,130 Now between the paragraphs, 91 00:02:59,130 --> 00:03:01,940 I want to output props.message. 92 00:03:01,940 --> 00:03:04,800 So that we also expect a message prop which, 93 00:03:04,800 --> 00:03:05,715 well, holds the message 94 00:03:05,715 --> 00:03:07,215 that shouldn't be output here. 95 00:03:09,020 --> 00:03:11,480 And I also want some styling. 96 00:03:11,480 --> 00:03:12,313 For data attached 97 00:03:12,313 --> 00:03:16,140 to find the errormodal.module.CSS file. 98 00:03:16,140 --> 00:03:16,973 And you can, again, 99 00:03:16,973 --> 00:03:19,810 just drag that into your UI folder next 100 00:03:19,810 --> 00:03:21,680 to the error modal JS file, 101 00:03:21,680 --> 00:03:23,550 and then import it here. 102 00:03:23,550 --> 00:03:27,120 Import classes from ./ErrorModal.module.CSS. 103 00:03:30,900 --> 00:03:33,670 Because I'm also using CSS modules here, 104 00:03:33,670 --> 00:03:35,820 to have unique class names. 105 00:03:35,820 --> 00:03:36,810 And there are a couple 106 00:03:36,810 --> 00:03:38,910 of classes that should be attached. 107 00:03:38,910 --> 00:03:40,280 For example here, 108 00:03:40,280 --> 00:03:41,840 on the card itself, 109 00:03:41,840 --> 00:03:45,593 I wanna add the classes.modal class. 110 00:03:46,450 --> 00:03:47,650 Which is one of the classes 111 00:03:47,650 --> 00:03:49,803 to find here in the CSS file. 112 00:03:51,240 --> 00:03:53,390 In addition on the header, 113 00:03:53,390 --> 00:03:58,163 I want to have the classes.header class. 114 00:03:59,010 --> 00:04:00,360 And on that div 115 00:04:00,360 --> 00:04:02,300 that's surrounds the paragraph, 116 00:04:02,300 --> 00:04:06,423 I will add the classes.content class. 117 00:04:08,160 --> 00:04:09,340 On the footer, 118 00:04:09,340 --> 00:04:10,590 we'll also add a class, 119 00:04:10,590 --> 00:04:13,840 and that's the classes.actions class. 120 00:04:13,840 --> 00:04:16,829 And these are all CSS classes predefined 121 00:04:16,829 --> 00:04:18,392 in that CSS file. 122 00:04:19,970 --> 00:04:23,520 With that, we'll have a basic modal, 123 00:04:23,520 --> 00:04:24,670 and we can already see 124 00:04:24,670 --> 00:04:26,130 that in action. 125 00:04:26,130 --> 00:04:26,963 The question is, 126 00:04:26,963 --> 00:04:29,080 where do we wanna render it, 127 00:04:29,080 --> 00:04:31,840 as part of which component? 128 00:04:31,840 --> 00:04:34,880 And you can actually argue about that. 129 00:04:34,880 --> 00:04:36,140 You can argue 130 00:04:36,140 --> 00:04:37,200 that it should be rendered 131 00:04:37,200 --> 00:04:38,790 inside of add user, 132 00:04:38,790 --> 00:04:41,660 because ultimately it will be this component 133 00:04:41,660 --> 00:04:43,930 that will trigger the modal. 134 00:04:43,930 --> 00:04:45,390 You could also argue, 135 00:04:45,390 --> 00:04:47,350 that it's a general overlay 136 00:04:47,350 --> 00:04:49,030 over the entire UI 137 00:04:49,030 --> 00:04:50,550 and therefore logically, 138 00:04:50,550 --> 00:04:52,570 it should be rendered as high 139 00:04:52,570 --> 00:04:55,020 as possible in the component tree. 140 00:04:55,020 --> 00:04:55,980 Something like inside 141 00:04:55,980 --> 00:04:56,980 of the app component 142 00:04:56,980 --> 00:04:58,273 or anything like that. 143 00:04:59,350 --> 00:05:01,560 Now, I will go for the place 144 00:05:01,560 --> 00:05:04,100 where it actually is, being cost, 145 00:05:04,100 --> 00:05:07,060 and that would be add user component, 146 00:05:07,060 --> 00:05:10,310 but you can definitely also pick a different place. 147 00:05:10,310 --> 00:05:11,440 You then of course, we'll need 148 00:05:11,440 --> 00:05:14,060 to update your state management appropriately. 149 00:05:14,060 --> 00:05:15,950 I will write state management code, 150 00:05:15,950 --> 00:05:17,960 that ensures that it works here 151 00:05:17,960 --> 00:05:19,763 inside of the add user component. 152 00:05:21,000 --> 00:05:23,760 So here I wanna output my error modal, 153 00:05:23,760 --> 00:05:24,920 and therefore, we have 154 00:05:24,920 --> 00:05:26,350 to import it, of course. 155 00:05:26,350 --> 00:05:27,540 So we go here, 156 00:05:27,540 --> 00:05:29,410 and import error modal 157 00:05:29,410 --> 00:05:33,323 from UI error modal. 158 00:05:35,160 --> 00:05:36,780 Now we also need to configure it. 159 00:05:36,780 --> 00:05:38,700 We need to set a title, 160 00:05:38,700 --> 00:05:40,490 and we'll soon set this dynamically 161 00:05:40,490 --> 00:05:42,250 but now I'll set it to, 162 00:05:42,250 --> 00:05:44,280 an error occurred, 163 00:05:44,280 --> 00:05:46,010 and the message which we can set 164 00:05:46,010 --> 00:05:48,983 to, something went wrong. 165 00:05:50,410 --> 00:05:52,140 But this will not work. 166 00:05:52,140 --> 00:05:53,870 And do you know why? 167 00:05:53,870 --> 00:05:55,600 I briefly touched on it 168 00:05:55,600 --> 00:05:57,513 in the debugging section. 169 00:05:59,660 --> 00:06:01,020 Well, if we try to save this, 170 00:06:01,020 --> 00:06:02,200 we'll get an error. 171 00:06:02,200 --> 00:06:03,200 We'll get the error 172 00:06:03,200 --> 00:06:05,530 that we got adjacent JSX elements, 173 00:06:05,530 --> 00:06:07,563 and that this is not allowed basically. 174 00:06:08,450 --> 00:06:09,930 Indeed react doesn't allow, 175 00:06:09,930 --> 00:06:13,123 two side by side components being rendered, 176 00:06:14,440 --> 00:06:16,130 directly as a root element 177 00:06:16,130 --> 00:06:17,545 of your return statement. 178 00:06:17,545 --> 00:06:19,280 And you therefore need to wrap this, 179 00:06:19,280 --> 00:06:21,730 for example, in an extra div. 180 00:06:21,730 --> 00:06:24,000 We'll later see a different solution for this, 181 00:06:24,000 --> 00:06:26,030 for now we'll just take extra div, 182 00:06:26,030 --> 00:06:27,610 and put our error modal 183 00:06:27,610 --> 00:06:30,060 and our card, into that div. 184 00:06:30,060 --> 00:06:31,380 So that the div has returned 185 00:06:31,380 --> 00:06:32,710 by the return statement. 186 00:06:32,710 --> 00:06:34,310 And then inside of the div, 187 00:06:34,310 --> 00:06:36,513 we can have adjacent elements. 188 00:06:37,440 --> 00:06:38,810 And with that it compiles, 189 00:06:38,810 --> 00:06:40,380 and if you reload, 190 00:06:40,380 --> 00:06:42,080 hey, this doesn't look too bad. 191 00:06:42,080 --> 00:06:43,383 We got our modal here. 192 00:06:44,820 --> 00:06:46,610 Now, of course it's not dynamic. 193 00:06:46,610 --> 00:06:48,770 Of course we can close it right now. 194 00:06:48,770 --> 00:06:51,580 And of course, one crucial thing is missing, 195 00:06:51,580 --> 00:06:54,520 and that's a backdrop for the modal. 196 00:06:54,520 --> 00:06:57,810 So a overlay between this modal overlay 197 00:06:57,810 --> 00:06:59,710 and the actual main page. 198 00:06:59,710 --> 00:07:00,590 So to be calm, 199 00:07:00,590 --> 00:07:01,760 to interact with the rest 200 00:07:01,760 --> 00:07:02,680 of the main page, 201 00:07:02,680 --> 00:07:05,590 which currently, is possible. 202 00:07:05,590 --> 00:07:07,580 So, to make sure we can't interact 203 00:07:07,580 --> 00:07:09,410 with the rest of the page, 204 00:07:09,410 --> 00:07:11,140 back in the error modal, 205 00:07:11,140 --> 00:07:12,560 I'll add an extra div, 206 00:07:12,560 --> 00:07:15,400 next to the card, not inside of it, 207 00:07:15,400 --> 00:07:17,900 but next to it, and therefore, 208 00:07:17,900 --> 00:07:18,900 as we just learned, 209 00:07:18,900 --> 00:07:20,460 we need a general div, 210 00:07:20,460 --> 00:07:21,660 that wraps both, 211 00:07:21,660 --> 00:07:22,600 that extra div 212 00:07:22,600 --> 00:07:24,070 and the card. 213 00:07:24,070 --> 00:07:25,540 And on that extra div, 214 00:07:25,540 --> 00:07:26,880 I'll add a class 215 00:07:26,880 --> 00:07:30,403 and that's the classes.backdrop class. 216 00:07:31,510 --> 00:07:32,940 The device itself is empty 217 00:07:32,940 --> 00:07:36,120 but this backdrop CSS class makes sure, 218 00:07:36,120 --> 00:07:38,900 that we have this grayish, 219 00:07:38,900 --> 00:07:42,523 black transparentish background behind the modal. 220 00:07:43,450 --> 00:07:44,283 If we now save everything, 221 00:07:44,283 --> 00:07:45,980 you can see the background here, 222 00:07:45,980 --> 00:07:47,350 and now I can't interact 223 00:07:47,350 --> 00:07:49,310 with the form anymore, for example. 224 00:07:50,660 --> 00:07:51,493 So with that, 225 00:07:51,493 --> 00:07:52,580 we've got the model in place. 226 00:07:52,580 --> 00:07:54,070 Now, of course, the goal is 227 00:07:54,070 --> 00:07:56,410 to show it only sometimes, 228 00:07:56,410 --> 00:07:57,660 only if we do try 229 00:07:57,660 --> 00:07:59,290 to submit invalid data. 230 00:07:59,290 --> 00:08:00,703 And of course we wanna make sure 231 00:08:00,703 --> 00:08:02,423 that we can also dismiss it. 15493

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