All language subtitles for 5. Using TextFields - State Controlled Values

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,220 --> 00:00:05,620 We've got a good skeleton here going for our Contact Us page. 2 00:00:05,750 --> 00:00:11,750 But now we can go ahead and actually start setting up the inputs so that we can give the user a place 3 00:00:11,750 --> 00:00:17,930 to tell us their name email phone number and whatever message they have to tell us. 4 00:00:19,270 --> 00:00:26,590 So we'll come down and underneath the grid item container that's wrapping the email icon and the actual 5 00:00:26,590 --> 00:00:27,790 email text. 6 00:00:27,790 --> 00:00:32,430 Let's go ahead and underneath that grid I don't container wrapping both of those items. 7 00:00:32,560 --> 00:00:40,720 We'll create an adjacent grid item container and inside of here we'll have the first grid item containing 8 00:00:40,780 --> 00:00:51,650 a text field component we'll give this a label of name and then an I.D. of name as well. 9 00:00:51,680 --> 00:01:00,060 But notice I did the lower case and in this case let's close this off for now and let's go ahead and 10 00:01:00,390 --> 00:01:07,170 copy this text field component and we'll paste that two more times but what's changed the label here 11 00:01:07,170 --> 00:01:20,050 to email the I.D. to email and then change the name of phone and idea of phone we can save these and 12 00:01:20,050 --> 00:01:26,830 we'll see the page refresh and we'll now have some text fields here up on the screen and I actually 13 00:01:26,830 --> 00:01:30,460 realized I want each of these in their own grid item container. 14 00:01:30,460 --> 00:01:35,260 This is gonna help with the alignment and also with making sure they're on their own line I believe. 15 00:01:35,320 --> 00:01:39,100 So let's go ahead and we can cut out the e-mail. 16 00:01:39,100 --> 00:01:46,810 Let's add another grid item and we can paste that in right there and then cut the phone and then add 17 00:01:46,810 --> 00:01:50,530 a new grid item paste that in as well. 18 00:01:50,530 --> 00:01:55,990 So now let's save that and the page will refresh and it doesn't look any different yet but that will 19 00:01:55,990 --> 00:02:00,150 make the styling in alignment y easier. 20 00:02:00,250 --> 00:02:06,820 Now we can come in and we can click on the text field and you can see the label travels up above your 21 00:02:06,820 --> 00:02:11,110 cursor and allows you to type in whatever you want into the field. 22 00:02:11,110 --> 00:02:19,330 But right now these are uncontrolled text fields you notice that we did not set a value prop onto any 23 00:02:19,330 --> 00:02:20,560 of these text fields. 24 00:02:20,560 --> 00:02:25,020 And so the value is not being stored or managed anywhere or in any way. 25 00:02:25,180 --> 00:02:33,030 It is just being put into the input and that is all that's happening so to make this a controlled input 26 00:02:33,380 --> 00:02:39,420 and to make sure that we have access to whatever value is stored inside of these inputs let's go ahead 27 00:02:39,510 --> 00:02:43,450 and we'll come up to the top and next to our import for react. 28 00:02:43,470 --> 00:02:49,970 Well let's add our karma and d structure out the use state import as well. 29 00:02:50,020 --> 00:02:56,320 Now we can come down and underneath our classes and theme constant let's go ahead and we'll come down 30 00:02:56,350 --> 00:03:01,660 and add a constant and we're going to be using the U.S. State hook here. 31 00:03:01,660 --> 00:03:10,840 So we're going to create a name and a set name function and then we'll use the state with a default 32 00:03:10,930 --> 00:03:12,220 of an empty stream. 33 00:03:12,580 --> 00:03:22,540 And now we can go ahead and let's copy this paste that two more times change this to email and set email 34 00:03:23,020 --> 00:03:32,370 leave it set with a default of empty string and it will change the last one to phone and set phone. 35 00:03:32,450 --> 00:03:32,810 All right. 36 00:03:32,870 --> 00:03:37,470 Now we can scroll back down to our text fields and on the name. 37 00:03:37,490 --> 00:03:41,000 Let's give it a value of our name. 38 00:03:41,000 --> 00:03:48,980 State that we just created and then we can come down to the email give it a value of email in the phone 39 00:03:49,250 --> 00:03:52,600 a value of phone. 40 00:03:52,640 --> 00:03:57,770 Now if we save this we'll see the page refresh and we can see our inputs. 41 00:03:57,770 --> 00:04:01,890 But if we come and we click on it and we go to type something in. 42 00:04:01,900 --> 00:04:05,530 Well I'm trying I'm trying to type in but nothing is happening. 43 00:04:05,960 --> 00:04:13,500 And the reason for this is because we've set a fixed value here of our name state value and our name 44 00:04:13,500 --> 00:04:16,380 state value is set to an empty string. 45 00:04:16,400 --> 00:04:24,290 And so the value within this text field is set to the empty string no matter what I try to do obviously 46 00:04:24,290 --> 00:04:28,630 we want to be able to change that value after it is set initially. 47 00:04:28,640 --> 00:04:36,730 So what we can do is on our text field we're going to add in on a change prop this is a function that 48 00:04:36,740 --> 00:04:43,700 will be called every time there is a change to the text within our text field and we will use this then 49 00:04:43,700 --> 00:04:51,940 to change our name state value so we can open this up with our curly braces and create an arrow function. 50 00:04:51,950 --> 00:04:58,160 So we'll create an arrow function here and this is going to take an event and this will contain the 51 00:04:58,190 --> 00:05:01,460 text being currently entered into the input. 52 00:05:01,580 --> 00:05:09,890 So after the arrow function declaration then we will come in we'll take that event but we'll call set 53 00:05:10,010 --> 00:05:16,790 name and we'll call it with the event dot target dot value. 54 00:05:16,790 --> 00:05:24,170 So this is going to specify where the text that was put into our input and it's going to call the set 55 00:05:24,200 --> 00:05:28,310 name function with our state for the name. 56 00:05:28,400 --> 00:05:35,030 And it's going to update the value that we have stored inside so we can go ahead and save that now and 57 00:05:35,030 --> 00:05:36,500 we'll see the page refresh. 58 00:05:36,500 --> 00:05:43,040 And if I come into the name text field now I can begin to type and you can see that it is indeed popping 59 00:05:43,040 --> 00:05:48,960 up because now we are changing that state value with our on change function. 60 00:05:49,040 --> 00:05:54,230 So let's go ahead and we'll copy that on change function and paste that onto the email but make sure 61 00:05:54,230 --> 00:06:00,650 to change the function to set email and then we can leave even to dot target dot value and we'll do 62 00:06:00,650 --> 00:06:08,120 the same thing for phone said we'll change it to set phone we can save this now and once this refreshes 63 00:06:08,330 --> 00:06:16,390 all the inputs should be working once again now that we've got the basic skeleton for these text fields 64 00:06:16,630 --> 00:06:22,430 let's go ahead and we'll continue and let's add the text field for our message. 65 00:06:22,580 --> 00:06:25,300 This is going to be in its own separate container. 66 00:06:25,460 --> 00:06:31,790 So we'll find the grid item container grid item container. 67 00:06:31,790 --> 00:06:36,620 And so this grid item container wrapping all of the text fields. 68 00:06:36,620 --> 00:06:40,320 Make sure you come down and adjacent to that container. 69 00:06:40,340 --> 00:06:49,820 Let's add a new grid item just a grid item and this will wrap another text field component with a value 70 00:06:49,940 --> 00:06:58,850 of message an I.D. of message and then was paste in the on change property that we still have copied 71 00:06:59,210 --> 00:07:05,510 and change the set name to set message and we'll create those in just a second and then we can close 72 00:07:05,510 --> 00:07:13,550 off that text field component now let's go up real quick and we will create our constant of message 73 00:07:14,030 --> 00:07:16,050 and set message. 74 00:07:16,070 --> 00:07:23,180 With the U.S. State defaulting to the empty string we can scroll back down and if we save this we'll 75 00:07:23,180 --> 00:07:27,630 see the page refresh and we have a new text field here. 76 00:07:27,740 --> 00:07:33,860 And you notice I did not use a label and that's because I actually don't want this same effect here. 77 00:07:33,880 --> 00:07:38,330 See now they have the the label that travels up and above the field. 78 00:07:38,330 --> 00:07:43,980 I actually don't want that look for our message and we'll actually just go in and add a placeholder. 79 00:07:44,090 --> 00:07:48,680 But remember that this also needs to be a multi high line input. 80 00:07:48,680 --> 00:07:54,410 Remember from the design file that this actually takes up more space to kind of show that it's for a 81 00:07:54,410 --> 00:07:55,360 message. 82 00:07:55,370 --> 00:08:01,640 So if we scroll back down and we had gone over this in the text field overview there if we can now come 83 00:08:01,670 --> 00:08:07,660 and on the text field for our message let's go ahead and add the mall time line. 84 00:08:07,670 --> 00:08:10,820 Prop we can save this. 85 00:08:10,820 --> 00:08:17,420 And once a page refreshes if we begin to type into this field once it gets to the end of the line you 86 00:08:17,420 --> 00:08:20,810 can see we now keep creating new lines. 87 00:08:20,870 --> 00:08:22,130 This works pretty good. 88 00:08:22,130 --> 00:08:27,500 But I actually want to make sure that even if we don't have any text in here at all it should still 89 00:08:27,500 --> 00:08:34,130 be providing that extra space to show that it is for a message and we can do that if we set a fixed 90 00:08:34,280 --> 00:08:36,650 Rose property on here. 91 00:08:36,650 --> 00:08:40,370 And I'm going to set that to the number 10 and we can save this. 92 00:08:40,400 --> 00:08:43,790 We'll see the page refresh and our input is now. 93 00:08:43,820 --> 00:08:49,250 This whole space and you can kind of tell it's a little hard because the underline is only here on the 94 00:08:49,250 --> 00:08:52,290 bottom but our cursor is all the way here on the top. 95 00:08:52,310 --> 00:09:00,140 If I begin to type you see in that we have that huge big space before we'll get down to where the scroll 96 00:09:00,140 --> 00:09:02,710 bar will appear right there. 97 00:09:02,710 --> 00:09:06,450 And now it starts scrolling after the tenth line. 98 00:09:06,480 --> 00:09:09,630 I'll go ahead and delete all that text though and this is looking good. 99 00:09:09,630 --> 00:09:14,550 I know it's a little messed up here but we'll go and address all these styling for our inputs in the 100 00:09:14,550 --> 00:09:20,580 next video but we'll finish up with the structure for this real quick and let's get these send message 101 00:09:20,580 --> 00:09:21,870 button down here. 102 00:09:21,980 --> 00:09:29,820 And so we'll take the grid item wrapping the text field and create a new grid item adjacent to that 103 00:09:30,030 --> 00:09:38,780 and this will be wrapping a button with a variant of contained with the text send message inside. 104 00:09:38,790 --> 00:09:48,120 And that text is going to be sitting on top of an image with a source of airplane and an alt of paper 105 00:09:48,240 --> 00:09:55,740 airplane and we can close the image off and then come up to our imports and underneath the e-mail what's 106 00:09:55,780 --> 00:10:06,790 import the airplane from assets and then slash send Dias CVG let's save this and we'll see the page 107 00:10:06,820 --> 00:10:10,870 refresh and we now have a little send message button down there. 108 00:10:10,900 --> 00:10:12,470 So that's good enough for now. 109 00:10:12,490 --> 00:10:16,240 So let's go ahead and grab the content for our call to action now. 110 00:10:16,330 --> 00:10:22,840 So let's actually go into the UI folder and open up our call to action dot J.S. and we'll scroll down 111 00:10:23,170 --> 00:10:29,260 and here's the overall wrapping grid item container for the entire call to action. 112 00:10:29,260 --> 00:10:32,860 And we're going to go ahead and just grab everything inside of there. 113 00:10:32,860 --> 00:10:37,130 So this whole grid item inside as well as a grid item for the button. 114 00:10:37,300 --> 00:10:43,160 So everything inside of the call to action grid but not the outer grid itself. 115 00:10:43,240 --> 00:10:46,270 Let's go ahead and copy that flip over to our contact dot. 116 00:10:46,310 --> 00:10:53,530 Yes and we'll scroll down to the empty grid with the large nine property with our background and let's 117 00:10:53,530 --> 00:11:00,260 paste all of that in we then have a couple of things to fix and we'll first go back over to the call 118 00:11:00,260 --> 00:11:01,070 to action. 119 00:11:01,190 --> 00:11:06,740 And in our styles object let's go ahead and copy the estimate button style. 120 00:11:06,830 --> 00:11:07,940 So let's copy that. 121 00:11:07,990 --> 00:11:14,240 We'll come back over to our styles object and underneath the background style in our contact in our 122 00:11:14,240 --> 00:11:16,280 contact at DOT J.S. file. 123 00:11:16,280 --> 00:11:21,650 Let's go ahead and paste the estimate button style in and we'll flip it back to the call to action and 124 00:11:21,650 --> 00:11:25,070 then copy the learn button style as well. 125 00:11:25,070 --> 00:11:28,580 So we will copy that paste it underneath the estimate button. 126 00:11:28,580 --> 00:11:35,330 And now inside of our export default function call for the contact let's call the function with props 127 00:11:35,420 --> 00:11:36,400 as an input. 128 00:11:36,530 --> 00:11:39,670 And let's scroll down see what else we need to take care of. 129 00:11:39,710 --> 00:11:43,460 Looks like we need to create our matches small variable. 130 00:11:43,460 --> 00:11:53,420 So underneath the theme actually and scroll up and we need to import are use media query from material 131 00:11:53,480 --> 00:12:02,930 dash UI slash core slash use media query and let's come down and then create our constant of matches 132 00:12:02,990 --> 00:12:13,670 small with our use media querying called with the theme dot breakpoints dot down for small I think we 133 00:12:13,670 --> 00:12:19,790 still have one last issue and as the button arrow so let's go ahead and under you are import for use 134 00:12:19,790 --> 00:12:29,900 media query let's import the button arrow from dot slash UI slash button arrow now let's go ahead and 135 00:12:29,900 --> 00:12:36,260 give that to save and we'll see what happens and you can see that we've got the call to action text 136 00:12:36,500 --> 00:12:43,210 along with our button on the screen we won't go through and totally fix all of this yet but we can get 137 00:12:43,210 --> 00:12:49,660 this content down off the very top of the screen and move it down vertically into the center. 138 00:12:49,660 --> 00:12:57,820 So if we scroll down and we find the grid item container with our large of nine you can see this is 139 00:12:57,820 --> 00:13:04,600 a container and we're not setting the direction so it's set with a default direction of row and so with 140 00:13:04,600 --> 00:13:11,860 a direction of row your main axis is horizontal which we could specify using the justify property but 141 00:13:11,860 --> 00:13:16,480 we want to center this vertically which would be our cross axis in this case. 142 00:13:16,510 --> 00:13:24,670 So we need to set in a line items of center and save that and then we can see that our content jumps 143 00:13:24,670 --> 00:13:26,980 down into the center of the page. 144 00:13:26,980 --> 00:13:28,260 So this is looking good. 145 00:13:28,270 --> 00:13:31,020 This is definitely a great start for our contact page. 146 00:13:31,030 --> 00:13:36,310 We've got the full skeleton working well let's go ahead and actually make this look more like the design 147 00:13:36,310 --> 00:13:40,810 file by styling all of our inputs and getting that set up in the next video. 16889

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