File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { FC } from "react" ;
2
- import { Link } from "react-router-dom" ;
2
+ import { NavLink } from "react-router-dom" ;
3
3
import { Nav } from "react-bootstrap" ;
4
4
5
5
const links = [
@@ -18,14 +18,15 @@ const Sidebar: FC = () => {
18
18
return (
19
19
< Nav className = "sidebar d-block rounded position-fixed m-2 light-bg" >
20
20
{ links . map ( ( link , index ) => (
21
- < Nav . Link
21
+ < NavLink
22
22
key = { index }
23
- as = { Link }
24
23
to = { link . to }
25
- className = "sidebar__link p-4 secondary-fg"
24
+ className = { ( { isActive } ) =>
25
+ `sidebar__link p-4 d-block secondary-fg text-decoration-none ${ isActive ? "active" : "" } `
26
+ }
26
27
>
27
28
{ link . text }
28
- </ Nav . Link >
29
+ </ NavLink >
29
30
) ) }
30
31
</ Nav >
31
32
) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ body, html {
43
43
background-color : var (--colour-primary-medium );
44
44
}
45
45
46
+ .sidebar__link .active {
47
+ background-color : var (--colour-primary );
48
+ color : var (--colour-primary-light );
49
+ }
50
+
46
51
.main-content {
47
52
width : calc (100% - 15rem );
48
53
height : calc (100% - 4.7rem );
You can’t perform that action at this time.
0 commit comments