Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,350 --> 00:00:03,950
Now, before we continue,
2
00:00:03,950 --> 00:00:06,750
I prepared some additional styles
3
00:00:06,750 --> 00:00:09,870
attached to find an updated index.css file
4
00:00:09,870 --> 00:00:12,640
which you can use to replace yours with it
5
00:00:12,640 --> 00:00:16,379
and you find a mainheader.modules.css file
6
00:00:16,379 --> 00:00:19,680
which you can drag and drop into your components folder.
7
00:00:19,680 --> 00:00:22,140
And in the MainHeader.js file
8
00:00:22,140 --> 00:00:26,760
you then need to import classes from MainHeader.module.css
9
00:00:26,760 --> 00:00:30,430
and add this class name, classes.header
10
00:00:30,430 --> 00:00:33,930
to your header HTML element.
11
00:00:33,930 --> 00:00:35,730
And if you do that,
12
00:00:35,730 --> 00:00:38,477
we got this basic styling here.
13
00:00:38,477 --> 00:00:39,350
Other than that,
14
00:00:39,350 --> 00:00:41,370
I haven't changed anything.
15
00:00:41,370 --> 00:00:44,710
Now why did I add those styles here though?
16
00:00:44,710 --> 00:00:48,040
Because I want to draw your attention to a problem
17
00:00:48,040 --> 00:00:52,400
or a requirement which we have in a lot of applications.
18
00:00:52,400 --> 00:00:55,790
We often want to highlight the active link
19
00:00:55,790 --> 00:00:57,170
in the navigation.
20
00:00:57,170 --> 00:00:59,200
Currently I'm on the welcome page
21
00:00:59,200 --> 00:01:03,950
but we can't tell that we are by looking at the navigation.
22
00:01:03,950 --> 00:01:07,010
Now I did add the hover styles here
23
00:01:07,010 --> 00:01:09,990
so that the active item is highlighted.
24
00:01:09,990 --> 00:01:13,380
But again, we don't see that when we're on the page,
25
00:01:13,380 --> 00:01:16,530
neither for welcome, nor for products.
26
00:01:16,530 --> 00:01:18,830
Now to a highlight the active link,
27
00:01:18,830 --> 00:01:22,580
react router has an extra feature which helps us.
28
00:01:22,580 --> 00:01:26,390
Instead of using the regular link, which we used here
29
00:01:26,390 --> 00:01:28,963
we can use the NavLink component.
30
00:01:29,860 --> 00:01:33,100
We can use NavLink to replace the standard link
31
00:01:33,100 --> 00:01:36,740
and NavLink works basically like the standard link.
32
00:01:36,740 --> 00:01:38,880
It still creates an anchored hack
33
00:01:38,880 --> 00:01:42,310
catches the clique prevents the browser default
34
00:01:42,310 --> 00:01:45,096
but it does more than that.
35
00:01:45,096 --> 00:01:49,349
NavLink also will set a CSS class
36
00:01:49,349 --> 00:01:52,240
on the active anchor item.
37
00:01:52,240 --> 00:01:56,180
We just need to tell NavLink, which class to add.
38
00:01:56,180 --> 00:02:01,100
And we do this by adding the active class name prop.
39
00:02:01,100 --> 00:02:04,440
And here we can then define a CSS class named
40
00:02:04,440 --> 00:02:07,300
that should be added on this link element.
41
00:02:07,300 --> 00:02:09,050
So on this anchor tech
42
00:02:09,050 --> 00:02:12,770
if that link is active and here we could,
43
00:02:12,770 --> 00:02:17,330
for example, say that classes.active should be added
44
00:02:17,330 --> 00:02:19,150
as a CSS class.
45
00:02:19,150 --> 00:02:23,170
So one of the classes, one of the CSS classes defined
46
00:02:23,170 --> 00:02:26,400
in this main header module CSS file.
47
00:02:26,400 --> 00:02:31,040
And I'll set this on both NavLinks that if they are active
48
00:02:31,040 --> 00:02:34,347
if we are on the page, this link leads to
49
00:02:34,347 --> 00:02:39,170
then this special CSS class should be added.
50
00:02:39,170 --> 00:02:42,930
For this, we just need to go to this CSS file.
51
00:02:42,930 --> 00:02:46,760
And then here on this last rule
52
00:02:46,760 --> 00:02:49,570
we want to add a selector where we select anchor
53
00:02:49,570 --> 00:02:52,940
texts that have the active class.
54
00:02:52,940 --> 00:02:55,150
So a.active.
55
00:02:55,150 --> 00:02:58,950
Active because that is the class I'm adding here
56
00:02:58,950 --> 00:03:00,493
in my JSX code.
57
00:03:01,700 --> 00:03:03,870
And with that, if we save this,
58
00:03:03,870 --> 00:03:07,420
we notice that now the active navigation item
59
00:03:07,420 --> 00:03:09,450
will be marked as such.
60
00:03:09,450 --> 00:03:12,750
If we visit the page to which it belongs.
61
00:03:12,750 --> 00:03:15,270
And that's a nice additional feature,
62
00:03:15,270 --> 00:03:16,230
which you want to have
63
00:03:16,230 --> 00:03:18,230
in a lot of applications you're building
64
00:03:18,230 --> 00:03:20,820
and it is easy to implement with help
65
00:03:20,820 --> 00:03:23,913
of NavLink and the active class named prop.
5013
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.