2019-10-19 16:38:07 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
|
import { Route, Link } from 'react-router-dom';
|
2018-09-03 16:17:36 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
to: string;
|
|
|
|
|
label: string;
|
|
|
|
|
match?: string;
|
|
|
|
|
activeOnlyWhenExact?: boolean;
|
2018-09-03 16:17:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PrimaryNavigationLink extends React.Component<Props> {
|
|
|
|
|
renderLink = (route: any) => {
|
|
|
|
|
const { to, label } = this.props;
|
|
|
|
|
return (
|
2019-10-19 16:38:07 +02:00
|
|
|
<li className={route.match ? 'is-active' : ''}>
|
2018-09-03 16:17:36 +02:00
|
|
|
<Link to={to}>{label}</Link>
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { to, match, activeOnlyWhenExact } = this.props;
|
|
|
|
|
const path = match ? match : to;
|
|
|
|
|
return (
|
|
|
|
|
<Route
|
|
|
|
|
path={path}
|
|
|
|
|
exact={activeOnlyWhenExact}
|
|
|
|
|
children={this.renderLink}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PrimaryNavigationLink;
|