Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,090 --> 00:00:03,900
In this lecture, we're going to make the tabs functional in the modal.
2
00:00:03,930 --> 00:00:06,960
The application is slowly starting to come together.
3
00:00:06,960 --> 00:00:08,670
The modal is functional.
4
00:00:08,700 --> 00:00:11,490
The next step is to add logic to the content.
5
00:00:11,490 --> 00:00:16,920
Inside the modal we have two forms which are the login and registration forms.
6
00:00:16,920 --> 00:00:19,950
Both forms shouldn't be appearing at the same time.
7
00:00:20,100 --> 00:00:22,680
Above the forms there are two buttons.
8
00:00:22,680 --> 00:00:27,180
We're going to make them functional by allowing the user to switch between forms.
9
00:00:27,180 --> 00:00:29,880
This functionality is known as tabs.
10
00:00:29,880 --> 00:00:31,290
Let's get started.
11
00:00:31,320 --> 00:00:34,980
Open the authentication component file in your editor.
12
00:00:37,230 --> 00:00:40,620
The first step is to tackle the current state of the tab.
13
00:00:40,650 --> 00:00:42,810
Which form should we show the user?
14
00:00:42,810 --> 00:00:45,870
We'll set the login form as the default form.
15
00:00:45,870 --> 00:00:51,150
We need to keep track of which form to show we have two options at our disposal.
16
00:00:51,150 --> 00:00:56,220
We can store this information in the store or we can store it as component data.
17
00:00:56,460 --> 00:00:59,010
We're going to store it as component data.
18
00:00:59,010 --> 00:01:03,000
This information doesn't need to be made available on a global level.
19
00:01:03,000 --> 00:01:08,730
Whenever you're creating data, you should ask yourself if the data needs to be available globally.
20
00:01:08,730 --> 00:01:12,420
If it does, storing it in the store is the way to go.
21
00:01:12,450 --> 00:01:16,500
Otherwise, storing it as component data will suffice.
22
00:01:16,500 --> 00:01:20,070
You never want to clutter your store with unnecessary data.
23
00:01:20,100 --> 00:01:21,960
Scroll down to the script.
24
00:01:21,960 --> 00:01:24,990
BLOCK We're going to define the data method.
25
00:01:27,170 --> 00:01:31,100
Inside the object, we're going to add a property called Tab.
26
00:01:31,130 --> 00:01:33,020
Its value will be the following.
27
00:01:33,020 --> 00:01:33,890
Log in.
28
00:01:36,080 --> 00:01:39,410
If the value is log in, we'll show the log in form.
29
00:01:39,410 --> 00:01:43,210
If the value is register, we'll show the registration form.
30
00:01:43,220 --> 00:01:47,960
Let's use this data to toggle the visibility of the forms in the template.
31
00:01:47,960 --> 00:01:50,540
Search for a comment that says Tabs.
32
00:01:52,620 --> 00:01:55,650
Below this comment are the links for the tabs.
33
00:01:55,650 --> 00:02:01,440
We're going to add Click Event listeners to both anchor elements with the Prevent Modifier.
34
00:02:06,250 --> 00:02:07,660
For the login link.
35
00:02:07,660 --> 00:02:10,930
We're going to set the tab property to log in.
36
00:02:13,000 --> 00:02:18,340
Next for the register link, we're going to set the TAB property to register.
37
00:02:20,560 --> 00:02:26,430
By updating their property, we should be able to toggle the tabs after changing the property.
38
00:02:26,440 --> 00:02:31,760
The last thing we need to do is change the appearance of the tabs on the login link.
39
00:02:31,780 --> 00:02:38,750
There are three classes called Hover Text White, Text White and BG Blue 600.
40
00:02:38,770 --> 00:02:44,220
These classes will change the background color of the link to blue and text color to white.
41
00:02:44,230 --> 00:02:47,320
They should only be applied if the tab is active.
42
00:02:47,410 --> 00:02:50,530
We're going to bind another class attribute.
43
00:02:52,670 --> 00:02:55,550
The value for this attribute will be an object.
44
00:02:55,580 --> 00:03:00,830
We're going to cut the three classes I mentioned earlier as a property to this object.
45
00:03:02,990 --> 00:03:04,160
For the condition.
46
00:03:04,160 --> 00:03:08,330
We will check if the TAB property is equal to log in.
47
00:03:10,550 --> 00:03:14,550
These classes will get applied if the user is viewing the login form.
48
00:03:14,570 --> 00:03:16,910
We're going to add another set of classes.
49
00:03:16,910 --> 00:03:23,720
If they're viewing the registration form, the class will toggle is called Hover Text Blue 600.
50
00:03:25,970 --> 00:03:31,010
This class will change the text color of an element to blue if it's being hovered over.
51
00:03:31,040 --> 00:03:36,050
We're adding this class because we want the user to know they can interact with an element.
52
00:03:36,050 --> 00:03:41,150
Adding a hover effect as a great way to show about an element can be interacted with.
53
00:03:41,180 --> 00:03:47,390
The condition for this class will be the following tab equals equals equals register.
54
00:03:49,550 --> 00:03:51,940
That takes care of the login tab.
55
00:03:51,950 --> 00:03:54,090
Let's work on the register tab.
56
00:03:54,110 --> 00:03:56,330
It's going to be similar to before.
57
00:03:56,360 --> 00:03:58,640
Let's copy the class attribute.
58
00:03:58,640 --> 00:03:59,450
We bind it.
59
00:03:59,480 --> 00:04:02,690
We'll paste it over to the register tab link.
60
00:04:04,820 --> 00:04:06,080
And the conditionals.
61
00:04:06,080 --> 00:04:07,550
We're going to flip them.
62
00:04:09,740 --> 00:04:14,690
This modification will give us the opposite of what we had, which is what we're looking for.
63
00:04:14,720 --> 00:04:16,310
There's one last step.
64
00:04:16,310 --> 00:04:21,510
We need to toggle the visibility of the forms below the unordered list element.
65
00:04:21,529 --> 00:04:23,800
There are two form elements.
66
00:04:23,810 --> 00:04:26,240
The first form is the login form.
67
00:04:26,270 --> 00:04:28,910
The other form is the registration form.
68
00:04:29,030 --> 00:04:34,450
We're going to be using conditional directives to toggle their appearance on the first form.
69
00:04:34,460 --> 00:04:36,920
We're going to add the V show directive.
70
00:04:36,950 --> 00:04:41,060
The condition will be the following tab equals equals equals.
71
00:04:41,060 --> 00:04:41,930
Log in.
72
00:04:44,070 --> 00:04:48,580
Lastly, another v show directive should be added to the second form.
73
00:04:48,600 --> 00:04:51,020
The condition will be the following tab.
74
00:04:51,030 --> 00:04:53,400
Equals equals equals register.
75
00:04:55,680 --> 00:04:56,660
We're finished.
76
00:04:56,670 --> 00:04:59,460
Save your changes and refresh the page.
77
00:05:01,600 --> 00:05:06,730
If you open the modal, the login form appears, the registration form is gone.
78
00:05:06,760 --> 00:05:12,880
The links above should have the proper classes applied to them since the login form is displaying,
79
00:05:12,880 --> 00:05:16,180
the login link should have a background colour of blue.
80
00:05:16,210 --> 00:05:22,280
If we click on the register link, the login form disappears while the register form appears.
81
00:05:22,300 --> 00:05:24,160
The tabs also change.
82
00:05:24,190 --> 00:05:24,960
Great.
83
00:05:24,970 --> 00:05:30,730
After verifying that it does work, we can move on to the next step, which is to add form validation.
84
00:05:30,730 --> 00:05:33,010
We'll cover that in the next section.
7750
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.