|
1 | 1 | import React, { useContext } from "react"; |
| 2 | +import { NavLink } from "react-router-dom"; |
2 | 3 | import styled from "styled-components"; |
3 | 4 | import { IconKind, KindIcon } from "~components/KindIcon"; |
4 | 5 | import { Declaration } from "~components/Docs/api"; |
5 | 6 | import { DeclarationsContext } from "~components/Docs/DeclarationsContext"; |
6 | 7 |
|
7 | | -const SidebarLink = styled.a` |
| 8 | +const SidebarLink = styled(NavLink)` |
8 | 9 | display: block; |
9 | 10 | background: transparent; |
10 | 11 | border-radius: 6px; |
@@ -37,32 +38,30 @@ const SidebarKindIcon = styled(KindIcon)` |
37 | 38 | `; |
38 | 39 |
|
39 | 40 | export const SidebarElement: React.FC<{ |
40 | | - href: string; |
| 41 | + to: string; |
41 | 42 | icon: IconKind; |
42 | 43 | text: string; |
43 | | - active?: boolean; |
44 | | -}> = React.memo(({ href, icon, text, active }) => ( |
45 | | - <SidebarLink href={href} className={active ? "active" : undefined}> |
| 44 | +}> = React.memo(({ to, icon, text }) => ( |
| 45 | + <SidebarLink to={to}> |
46 | 46 | <SidebarKindIcon kind={icon} size="small" /> {text} |
47 | 47 | </SidebarLink> |
48 | 48 | )); |
49 | 49 |
|
50 | | -export const DeclarationSidebarElement: React.FC<{ declaration: Declaration; active?: boolean }> = React.memo(({ declaration, active }) => { |
| 50 | +export const DeclarationSidebarElement: React.FC<{ declaration: Declaration }> = React.memo(({ declaration }) => { |
51 | 51 | const { root } = useContext(DeclarationsContext); |
52 | 52 | return ( |
53 | 53 | <SidebarElement |
54 | | - href={`#${root}/${declaration.name}`} |
| 54 | + to={`${root}/${declaration.name}`} |
55 | 55 | icon={declaration.kind} |
56 | 56 | text={declaration.name} |
57 | | - active={active} |
58 | 57 | /> |
59 | 58 | ); |
60 | 59 | }); |
61 | 60 |
|
62 | 61 | export const SidebarGroupHeader = styled.div<{ $collapsed: boolean }>` |
63 | 62 | background: ${(props) => props.theme.sidebar}; |
64 | 63 | padding: 0 6px; |
65 | | - height: 100%; |
| 64 | + height: 28px; |
66 | 65 | box-sizing: border-box; |
67 | 66 | font-size: 14px; |
68 | 67 | font-weight: 600; |
|
0 commit comments