1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 21:14:18 +00:00
pds-2021-g2-nest/code/frontend/src/components/ButtonSidebar.js

31 lines
856 B
JavaScript
Raw Normal View History

2021-04-21 13:53:23 +00:00
import React from "react"
import Style from "./ButtonSidebar.module.css"
import classNames from "classnames"
import make_icon from "../utils/make_icon"
import { Link } from "react-router-dom"
import { useRouteMatch } from "react-router"
2021-04-21 13:53:23 +00:00
export default function ButtonSidebar({ icon, children, to, className, ...props }) {
const match = useRouteMatch({
path: to,
strict: true,
exact: true,
});
if(match) {
className = classNames(Style.Active, className)
}
2021-04-21 13:53:23 +00:00
return (
<Link to={to} className={Style.ButtonLink}>
<div className={classNames(Style.ButtonSidebar, className)} {...props}>
{make_icon(icon, Style.ButtonIcon)}
<div className={Style.ButtonText}>
{children}
</div>
2021-04-21 13:53:23 +00:00
</div>
</Link>
2021-04-21 13:53:23 +00:00
)
}