All language subtitles for 002 Adding a _User_ 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,320 --> 00:00:03,210 Attached you'll find 2 00:00:03,210 --> 00:00:04,880 a simple starting project 3 00:00:04,880 --> 00:00:07,890 basically a pretty empty React application 4 00:00:07,890 --> 00:00:10,230 with an empty app component. 5 00:00:10,230 --> 00:00:13,860 And once you've downloaded and extracted the attached file, 6 00:00:13,860 --> 00:00:17,870 you just need to run npm-install to install all dependencies 7 00:00:17,870 --> 00:00:20,080 like the React library and thereafter, 8 00:00:20,080 --> 00:00:21,590 once you ran npm-install 9 00:00:21,590 --> 00:00:24,450 which I already did here you run npm start 10 00:00:24,450 --> 00:00:26,150 to start this application 11 00:00:26,150 --> 00:00:28,390 and you'll be greeted by such an empty screen 12 00:00:28,390 --> 00:00:31,280 because currently there is nothing inside of AppJS, 13 00:00:31,280 --> 00:00:33,583 nothing inside of our app component. 14 00:00:34,550 --> 00:00:38,040 Now in the application, which you saw in the last lecture, 15 00:00:38,040 --> 00:00:40,550 I wanna have a couple of different areas, 16 00:00:40,550 --> 00:00:42,840 a couple of different components. 17 00:00:42,840 --> 00:00:46,270 We had that component where we could enter our name 18 00:00:46,270 --> 00:00:47,500 and our age. 19 00:00:47,500 --> 00:00:49,760 We had that error modal, 20 00:00:49,760 --> 00:00:52,440 that error overlay component. 21 00:00:52,440 --> 00:00:55,100 We had a button to submit this and to confirm 22 00:00:55,100 --> 00:00:58,360 that we saw the error in that error modal, 23 00:00:58,360 --> 00:01:02,100 and we, of course. also had that list of users. 24 00:01:02,100 --> 00:01:05,360 Therefore, I'll start by roughly planning 25 00:01:05,360 --> 00:01:07,750 out the components we'll have. 26 00:01:07,750 --> 00:01:10,240 And for that I'll add a new components folder 27 00:01:10,240 --> 00:01:12,210 in which I wanna store those components. 28 00:01:12,210 --> 00:01:16,600 And I'll add a UI folder for general UI components 29 00:01:16,600 --> 00:01:18,200 which will have like the button. 30 00:01:19,160 --> 00:01:20,630 And in components, 31 00:01:20,630 --> 00:01:22,410 I'll also add a second folder 32 00:01:22,410 --> 00:01:24,480 and that will be my users folder 33 00:01:24,480 --> 00:01:26,703 for all the user related components. 34 00:01:27,710 --> 00:01:30,650 And now in there we can start adding component files 35 00:01:30,650 --> 00:01:32,400 and I'll start with that component 36 00:01:32,400 --> 00:01:34,980 that allows us to add a new user. 37 00:01:34,980 --> 00:01:36,780 Hence here in the user's folder, 38 00:01:36,780 --> 00:01:39,670 I'll add a new AddUser.js file 39 00:01:39,670 --> 00:01:43,263 which should hold the logic for us to add a new user. 40 00:01:44,400 --> 00:01:46,400 Now in there I wanna have a React component. 41 00:01:46,400 --> 00:01:48,200 So, of course, we have to import React 42 00:01:48,200 --> 00:01:49,490 from React as you learnt 43 00:01:49,490 --> 00:01:51,923 because we're going to use some JSX code here. 44 00:01:52,960 --> 00:01:56,100 I'll then add my AddUser component 45 00:01:56,100 --> 00:02:00,720 using this function syntax which we can use in JavaScript, 46 00:02:00,720 --> 00:02:03,440 an arrow function stored in a constant. 47 00:02:03,440 --> 00:02:05,350 Of course, as I mentioned before, 48 00:02:05,350 --> 00:02:08,360 you can also add a function like this 49 00:02:08,360 --> 00:02:09,610 nothing wrong with that 50 00:02:09,610 --> 00:02:11,280 but I'll go for this approach 51 00:02:11,280 --> 00:02:14,970 and I'll export this as my default 52 00:02:14,970 --> 00:02:17,360 so that we can import that component, 53 00:02:17,360 --> 00:02:20,493 that function into another file and use it there. 54 00:02:22,260 --> 00:02:24,920 Now, instead of AddUser in the end, 55 00:02:24,920 --> 00:02:27,590 we wanna render something on the screen 56 00:02:27,590 --> 00:02:31,050 which allows the user to enter a name and an age 57 00:02:31,050 --> 00:02:33,223 and have a button to confirm all of that. 58 00:02:34,210 --> 00:02:38,640 Therefore, in here, I will add a form let's say, 59 00:02:38,640 --> 00:02:43,640 and inside of that form I wanna have a label 60 00:02:44,050 --> 00:02:45,990 where I say username 61 00:02:45,990 --> 00:02:48,580 and of course that should all be returned 62 00:02:48,580 --> 00:02:51,340 so let's wrap it into brackets 63 00:02:51,340 --> 00:02:53,720 and then put a return statement in front of it. 64 00:02:53,720 --> 00:02:55,610 So there, I wanna have a label 65 00:02:55,610 --> 00:02:58,320 and I wanna have an input where the user then 66 00:02:58,320 --> 00:03:00,830 is actually to type that username. 67 00:03:00,830 --> 00:03:03,590 And that input will be of type text because well, 68 00:03:03,590 --> 00:03:05,143 expect some text there. 69 00:03:06,540 --> 00:03:07,830 Now for accessibility, 70 00:03:07,830 --> 00:03:11,650 we can also add an ID here username. 71 00:03:11,650 --> 00:03:12,870 And then on the label 72 00:03:12,870 --> 00:03:15,530 we would add the for attribute normally. 73 00:03:15,530 --> 00:03:20,020 Now for just like class is not a name that is available 74 00:03:20,020 --> 00:03:25,020 in JSX because these would be reserved JavaScript names 75 00:03:25,110 --> 00:03:27,700 and therefore it's htmlFor actually, 76 00:03:27,700 --> 00:03:30,400 that's the prop name for assigning 77 00:03:30,400 --> 00:03:33,320 that for attribute to a label. 78 00:03:33,320 --> 00:03:35,870 And with that we connect it to that input, 79 00:03:35,870 --> 00:03:38,480 and that's important for screen readers and so on 80 00:03:38,480 --> 00:03:40,850 so that they understand which label belongs 81 00:03:40,850 --> 00:03:41,683 to which input. 82 00:03:43,380 --> 00:03:44,640 So we got that. 83 00:03:44,640 --> 00:03:49,410 Now, I also need another pair of label and input 84 00:03:49,410 --> 00:03:54,330 for the age in years let's say. 85 00:03:54,330 --> 00:03:56,350 And here the type will be number 86 00:03:56,350 --> 00:03:59,210 because I expect to get a number here. 87 00:03:59,210 --> 00:04:03,373 Something like 31, 18, 25, and so on. 88 00:04:04,290 --> 00:04:06,210 Now I'll name this age, 89 00:04:06,210 --> 00:04:07,610 I'll give it an ID of age and therefore 90 00:04:07,610 --> 00:04:11,340 the htmlFor prop here also has a value of age. 91 00:04:11,340 --> 00:04:13,460 And with that I got these two inputs. 92 00:04:13,460 --> 00:04:16,990 Now, below those I want to have a button of type submit 93 00:04:17,959 --> 00:04:20,440 which will basically submit that form. 94 00:04:20,440 --> 00:04:23,783 And here I have AddUser as my text. 95 00:04:24,840 --> 00:04:27,240 So that's a straightforward form. 96 00:04:27,240 --> 00:04:28,580 Now, on the form here, 97 00:04:28,580 --> 00:04:32,180 I'll add the onSubmit prop to specify a function 98 00:04:32,180 --> 00:04:35,440 that should be executed when that form is submitted 99 00:04:35,440 --> 00:04:39,580 and therefore here I will actually add a new function 100 00:04:39,580 --> 00:04:42,253 inside of the AddUser component function. 101 00:04:43,440 --> 00:04:48,200 Let's say AddUserHandler function. 102 00:04:48,200 --> 00:04:50,730 Now here, I expect to get my event object 103 00:04:50,730 --> 00:04:53,758 and I will call event.preventDefault 104 00:04:53,758 --> 00:04:57,220 to prevent that default which for the submission event 105 00:04:57,220 --> 00:04:59,990 is that a request is sent. 106 00:04:59,990 --> 00:05:03,170 I don't want that default hence I prevent it here. 107 00:05:03,170 --> 00:05:06,700 And now can connect on submit here to AddUserHandler 108 00:05:06,700 --> 00:05:10,573 by passing AddUserHandler like this to onSubmit. 109 00:05:11,590 --> 00:05:13,610 Important as I explained before, 110 00:05:13,610 --> 00:05:15,580 don't add parentheses here. 111 00:05:15,580 --> 00:05:18,530 This would immediately execute AddUserHandler 112 00:05:18,530 --> 00:05:20,270 when this line is parsed. 113 00:05:20,270 --> 00:05:22,400 Instead, I just want to pass a pointer 114 00:05:22,400 --> 00:05:25,670 to that function to the onSubmit prop 115 00:05:25,670 --> 00:05:27,960 so that the form component internally 116 00:05:27,960 --> 00:05:30,720 can use that function when it needs to use it, 117 00:05:30,720 --> 00:05:33,153 i.e when that form is getting submitted. 118 00:05:34,160 --> 00:05:38,590 So with that we get this AddUserHandler here. 119 00:05:38,590 --> 00:05:43,410 Now let's go over to AppJS and let's import it here. 120 00:05:43,410 --> 00:05:48,410 So I import AddUser from ./components/Users/AddUser. 121 00:05:52,400 --> 00:05:57,240 And here in the div we can then add AddUser like that. 122 00:05:57,240 --> 00:06:00,093 That's how we can add this component here. 123 00:06:01,160 --> 00:06:02,120 And if we now save that 124 00:06:02,120 --> 00:06:05,410 and go back we should see this relatively ugly, 125 00:06:05,410 --> 00:06:08,040 but working component. 126 00:06:08,040 --> 00:06:11,350 I can click AddUser and the page is not reloading, 127 00:06:11,350 --> 00:06:13,380 which proves that this forms submission 128 00:06:13,380 --> 00:06:16,953 is effectively handled and the default is prevented. 129 00:06:17,800 --> 00:06:19,290 So that's the start. 130 00:06:19,290 --> 00:06:21,030 Now, some styling would be nice 131 00:06:21,030 --> 00:06:24,510 because that doesn't really look the way I want it to look. 132 00:06:24,510 --> 00:06:27,010 Now, I'll start an index CSS there. 133 00:06:27,010 --> 00:06:28,670 You got some basic styling. 134 00:06:28,670 --> 00:06:30,920 I'll go to the HTML element here 135 00:06:30,920 --> 00:06:35,920 and add a background styling of 1F, 1F, 1F like this 136 00:06:38,090 --> 00:06:41,260 and this will give us a nice dark grayish background. 137 00:06:41,260 --> 00:06:43,720 Now, I also want to wrap this username 138 00:06:43,720 --> 00:06:46,670 and age into a card you could say, 139 00:06:46,670 --> 00:06:48,960 into a container with rounded corners 140 00:06:48,960 --> 00:06:51,970 and with a white background 141 00:06:51,970 --> 00:06:53,820 and that's therefore something we'll build 142 00:06:53,820 --> 00:06:55,170 in the next lecture. 143 00:06:55,170 --> 00:06:57,520 Of course, feel free to try this on your own. 144 00:06:57,520 --> 00:06:59,530 Build such a wrapper and container 145 00:06:59,530 --> 00:07:02,130 maybe already with the right styles on your own. 146 00:07:02,130 --> 00:07:04,580 And in the next lecture, we'll build it together. 11324

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