Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,430 --> 00:00:07,390
So now that we have created this component, let's start passing in the necessary data via props.
2
00:00:08,200 --> 00:00:14,860
So we need to just pass in pretty much everything that we have here, which is actually stored in this
3
00:00:14,860 --> 00:00:16,420
option object.
4
00:00:16,900 --> 00:00:24,760
So very simply, in order to do this, we can just say colon option is equal to option like so.
5
00:00:25,110 --> 00:00:27,850
So that's going to be the first thing that we're going to pass in.
6
00:00:28,060 --> 00:00:35,890
And that's pretty much going to deal with the the title as well as the button values as well as the
7
00:00:35,890 --> 00:00:36,730
category.
8
00:00:37,180 --> 00:00:40,210
Now we also need the options state.
9
00:00:40,540 --> 00:00:44,260
Well, this is relatively easily can be easily done as well.
10
00:00:44,290 --> 00:00:50,590
All we can do here is just say options and then this can be options like so, which is going to correspond
11
00:00:51,010 --> 00:00:53,800
to our option state over here.
12
00:00:54,640 --> 00:00:59,860
So that is actually all that is that we need to pass in to our component.
13
00:01:00,250 --> 00:01:07,360
But now what we need to do is accept those props and then utilize them inside of our template.
14
00:01:07,840 --> 00:01:11,840
So over here, I'm going to go ahead and just write a script tag.
15
00:01:11,860 --> 00:01:13,300
Let's get rid of all of this stuff.
16
00:01:13,660 --> 00:01:15,460
We're going to say script set up.
17
00:01:15,730 --> 00:01:20,350
We're also going to say that the language is going to be TypeScript, of course.
18
00:01:21,130 --> 00:01:27,070
So now what I'm going to do is I am going to get access to these props.
19
00:01:27,370 --> 00:01:32,650
Now, with scripts set up, we have this thing called defined props that we can auto import.
20
00:01:33,010 --> 00:01:35,280
And then right over here, we invoke it.
21
00:01:35,290 --> 00:01:41,890
And then inside of an object, we typically describe the type of the props.
22
00:01:42,190 --> 00:01:48,190
So over here, we're expecting an option, and that's going to be an object.
23
00:01:48,940 --> 00:01:52,500
And then over here, we can also say options.
24
00:01:52,510 --> 00:01:56,170
And that's also going to be an object like so.
25
00:01:56,500 --> 00:02:03,970
So just as a quick clarification, the option is going to be just one of these objects in this array.
26
00:02:03,970 --> 00:02:04,870
So could be this.
27
00:02:05,140 --> 00:02:10,330
And then the options object is going to be all of these right over here.
28
00:02:11,260 --> 00:02:14,740
So our state so is going to be an object and it's going to be an object.
29
00:02:15,070 --> 00:02:21,250
However, the issue with this that I find is that, you know, this is very, very generic and it's
30
00:02:21,250 --> 00:02:24,130
not really going to give us a lot of good typing.
31
00:02:24,730 --> 00:02:30,370
So because we're using TypeScript, we actually don't necessarily have to do it this way.
32
00:02:30,760 --> 00:02:38,380
Instead, what we can do is we can actually utilize an interface to define the types of our props.
33
00:02:38,860 --> 00:02:43,900
So over here I can say something like Interface and I can say option props.
34
00:02:44,230 --> 00:02:50,110
And then over here I can say option, and I can say over here that this option key is also going to
35
00:02:50,110 --> 00:02:51,130
be an object.
36
00:02:51,430 --> 00:02:53,170
It's going to have a title.
37
00:02:54,040 --> 00:02:55,600
The title is going to be a string.
38
00:02:55,930 --> 00:02:58,030
Over here, it's also going to have a category.
39
00:02:58,330 --> 00:03:03,040
The category is going to be a string and then it's going to have a set of buttons.
40
00:03:03,250 --> 00:03:06,070
And this is going to be an array either.
41
00:03:06,370 --> 00:03:12,820
And so it's going to be an array with either all gender items or popularity items or all length items.
42
00:03:13,120 --> 00:03:18,010
So over here, what we can actually do is we can say gender and we can actually auto import that in.
43
00:03:19,120 --> 00:03:25,160
So over here you can auto import um imports gender from data.
44
00:03:25,410 --> 00:03:32,800
We can say that this is going to be either an array of gender enum values or let's go ahead over here
45
00:03:32,800 --> 00:03:34,600
and grab popularity.
46
00:03:34,930 --> 00:03:36,270
And it's also grab length.
47
00:03:36,940 --> 00:03:43,150
So over here we can say or it's going to be an array of popularity enum values or is going to be an
48
00:03:43,150 --> 00:03:46,180
array of length enum values.
49
00:03:46,180 --> 00:03:50,500
So that's just one thing that we can do to specify they could be either one or the other.
50
00:03:51,700 --> 00:03:55,900
Now, over here, let's also define what the options is going to look like.
51
00:03:56,680 --> 00:04:00,580
So the options is going to look like we're going to have a key that is going to be gender.
52
00:04:00,580 --> 00:04:04,090
This is going to be a value of gender.
53
00:04:04,780 --> 00:04:13,450
We're also going to have popularity that's going to have a value of popularity and then length that's
54
00:04:13,450 --> 00:04:16,240
going to have the value of length.
55
00:04:17,240 --> 00:04:24,020
And now, instead of defining it like we did before, we can just use those curly or these triangle
56
00:04:24,020 --> 00:04:24,620
brackets.
57
00:04:24,620 --> 00:04:25,580
Right over here.
58
00:04:25,940 --> 00:04:26,540
Right in there.
59
00:04:26,540 --> 00:04:28,880
We can define our props.
60
00:04:29,780 --> 00:04:35,780
So now what we can do if we do props, Dot, you can see that it knows exactly what is going to be in
61
00:04:35,780 --> 00:04:38,210
there and it knows exactly what that type is.
62
00:04:38,660 --> 00:04:43,040
So that's just another and I think a better way of defining our props.
63
00:04:43,670 --> 00:04:43,970
Okay.
64
00:04:43,970 --> 00:04:45,920
So this is looking really good.
65
00:04:46,280 --> 00:04:52,010
So now let's actually utilize those props inside of our template.
66
00:04:52,790 --> 00:04:57,800
So the first thing that I want to do here is I want to get rid and actually, let's just go ahead and
67
00:04:58,040 --> 00:04:59,690
comment out the buttons for now.
68
00:04:59,810 --> 00:05:02,840
Just so we can see our progress, I'm going to comment them out.
69
00:05:03,470 --> 00:05:07,250
And then right over here, I'm going to go ahead and save this and refresh.
70
00:05:07,460 --> 00:05:10,910
And now you see here that we have three choose your genders.
71
00:05:10,940 --> 00:05:12,050
Why do we have that?
72
00:05:12,380 --> 00:05:16,040
Because we're iterating over this array.
73
00:05:16,280 --> 00:05:22,100
So this array has three elements or we have three different iterations, and we're rendering this options
74
00:05:22,100 --> 00:05:23,690
component three different times.
75
00:05:23,960 --> 00:05:28,580
And right now, inside of the options component, we basically just have an each one with this hardcoded
76
00:05:28,580 --> 00:05:29,060
text.
77
00:05:29,420 --> 00:05:30,530
So you can see that this works.
78
00:05:31,340 --> 00:05:38,180
But now what do you actually want to do instead is I want to access the props dot title now inside of
79
00:05:38,180 --> 00:05:38,750
the template.
80
00:05:38,750 --> 00:05:42,890
We actually don't have to say props dot option, dot title.
81
00:05:43,160 --> 00:05:49,130
Instead, what we can very simply use is just the object, the key inside of the prop itself.
82
00:05:49,400 --> 00:05:54,500
So what I mean by that is we don't have to do props dot option, dot title.
83
00:05:55,220 --> 00:05:59,720
Instead, we can actually forgo the props itself and just say option dot title.
84
00:06:00,350 --> 00:06:06,140
Now, if we did that, you can very quickly see we have choose your gender, choose your popularity.
85
00:06:06,170 --> 00:06:09,380
Let me zoom in here once more and choose your name length so it's working.
86
00:06:09,380 --> 00:06:10,310
A Okay.
87
00:06:11,180 --> 00:06:14,150
Now let's go ahead and start rendering some of these buttons.
88
00:06:14,180 --> 00:06:17,200
Now, the buttons are going to be a little bit more complicated.
89
00:06:18,470 --> 00:06:20,600
And I'll show you why in a bit.
90
00:06:20,900 --> 00:06:23,710
But really here, what we want to do is we just want to iterate.
91
00:06:23,720 --> 00:06:31,580
We just don't have one button as we want to render a button for every single element that we have in
92
00:06:31,580 --> 00:06:32,660
this array.
93
00:06:33,170 --> 00:06:34,640
So let's go ahead over here.
94
00:06:34,770 --> 00:06:38,000
What we're going to do is we're going to add a V force.
95
00:06:38,000 --> 00:06:41,060
We're going to say V four is equal to.
96
00:06:41,780 --> 00:06:47,780
And then over here, what we're going to do is we're going to grab the value because this is going to
97
00:06:47,780 --> 00:06:51,890
be either a gender dot, a boy, gender adult, whatever.
98
00:06:51,890 --> 00:06:58,260
I'm going to call that the value I'm going to say in option dot button.
99
00:06:58,790 --> 00:07:02,210
So what we call that here, option dot buttons.
100
00:07:03,390 --> 00:07:05,070
And then, of course, we need to give it a key.
101
00:07:05,910 --> 00:07:09,720
And over here, the key could be value because that is going to be unique.
102
00:07:10,380 --> 00:07:10,620
Okay.
103
00:07:10,620 --> 00:07:16,290
So we're going to do this iteration and then what we're going to do for the text is we're going to render
104
00:07:16,350 --> 00:07:17,910
the value itself.
105
00:07:18,180 --> 00:07:24,300
So remember, the value is indeed going to be an enum, but it actually corresponds to a text if you
106
00:07:24,300 --> 00:07:25,260
want to render it.
107
00:07:25,260 --> 00:07:29,880
And then it's going to correspond to the text that we want, which is girl, boy or unisex.
108
00:07:30,150 --> 00:07:32,280
So we're going to render that value in here.
109
00:07:32,730 --> 00:07:37,520
And then right over here, what we're going to do is we're going to utilize the options from our props.
110
00:07:37,530 --> 00:07:38,220
That's okay.
111
00:07:38,640 --> 00:07:44,760
And over here, what we're going to do is instead of hard coding gender, dot boy, we're going to say
112
00:07:44,760 --> 00:07:46,860
if that's equal to the value.
113
00:07:47,190 --> 00:07:50,760
And over here, we're going to say that that is also going to be equal to the value.
114
00:07:51,960 --> 00:07:56,580
And then over here, this could be popularity, this could be gender, this could be length.
115
00:07:56,580 --> 00:08:02,970
So over here, what we're going to say is that this is going to be option dot category like.
116
00:08:02,970 --> 00:08:03,390
So.
117
00:08:04,110 --> 00:08:06,060
So option dot category.
118
00:08:07,260 --> 00:08:08,780
And there you go.
119
00:08:08,790 --> 00:08:14,790
I think that should be it and everything should be working the way that we expected to.
120
00:08:15,480 --> 00:08:17,100
Go ahead and save that now.
121
00:08:17,100 --> 00:08:17,760
There we go.
122
00:08:17,790 --> 00:08:19,290
You can see that it is working.
123
00:08:19,710 --> 00:08:26,340
Now, the problem is and you probably can guess what the problem is here now is that the styling is
124
00:08:26,520 --> 00:08:32,430
scoped to the app dot view file and that's where our styles currently live.
125
00:08:32,730 --> 00:08:37,890
So what we need to do is now just create another stylesheet that is going to be scoped.
126
00:08:38,270 --> 00:08:44,880
What we need to do is just grab all of these options, all of these classes, so the options container
127
00:08:44,880 --> 00:08:45,840
can stay in here.
128
00:08:46,140 --> 00:08:52,230
But almost everything else with the option container, the option button's the option active all that.
129
00:08:52,230 --> 00:08:57,960
We can just pretty much cut it out, save it here and then paste it right in there.
130
00:08:58,500 --> 00:08:59,490
So there we go.
131
00:08:59,520 --> 00:09:04,050
So now it's looking a okay, so let's actually go and give this a quick test.
132
00:09:04,470 --> 00:09:10,200
And now, of course, you can see right away we have this one huge issue when it comes to this styling.
133
00:09:10,440 --> 00:09:11,400
We'll fix that later.
134
00:09:11,520 --> 00:09:12,630
But let's just check of this work.
135
00:09:12,660 --> 00:09:17,960
So if I click on this, this should change this state in the output view and it does.
136
00:09:17,970 --> 00:09:19,500
So that is looking good.
137
00:09:19,650 --> 00:09:22,950
Let's just pick by unique log and we click on that.
138
00:09:22,950 --> 00:09:23,660
We get this.
139
00:09:23,670 --> 00:09:24,090
Okay.
140
00:09:24,240 --> 00:09:30,150
I'm assuming this is right, Harrison, and maybe Harrison is not that unique, but whatever this name
141
00:09:30,150 --> 00:09:31,620
is, this is definitely unique.
142
00:09:32,460 --> 00:09:35,220
Now, I'm going to try to pronounce it just for you guys.
143
00:09:35,850 --> 00:09:40,280
I suck at pronouncing names Bar Thor or me.
144
00:09:40,870 --> 00:09:42,660
Okay, I give up.
145
00:09:43,110 --> 00:09:46,110
But you can see here where it is working A-OK.
146
00:09:46,470 --> 00:09:53,400
But right now, we're getting a huge problem when it comes to the styling, because right now what we're
147
00:09:53,400 --> 00:09:58,290
doing actually is we're a hardcoded the option left.
148
00:09:58,890 --> 00:10:06,000
So what we need to do is we actually need to figure out a way to exactly compute what the class should
149
00:10:06,000 --> 00:10:06,480
be.
150
00:10:06,960 --> 00:10:10,710
So let's actually do that in the next video.
14608
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.