45 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-08-24 15:09:42 +02:00
/**
2017-03-18 17:34:00 +01:00
*
* LeftMenuLink
*
*/
2016-08-24 15:09:42 +02:00
2017-08-17 15:39:09 +02:00
import _ from 'lodash';
2016-08-24 15:09:42 +02:00
import React from 'react';
2017-08-17 15:39:09 +02:00
import { FormattedMessage } from 'react-intl';
2017-08-21 15:12:53 +02:00
import { Link } from 'react-router-dom';
2017-08-17 15:39:09 +02:00
import styles from './styles.scss';
2016-08-24 15:09:42 +02:00
class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
2017-07-21 18:15:43 +02:00
// We need to create our own active url checker,
// because of the two levels router.
const isLinkActive = _.startsWith(window.location.pathname.replace('/admin', ''), this.props.destination);
2016-08-24 15:09:42 +02:00
return (
2017-08-17 15:03:03 +02:00
<li className={styles.item}>
2017-07-21 18:15:43 +02:00
<Link className={`${styles.link} ${isLinkActive ? styles.linkActive : ''}`} to={this.props.destination}>
<i className={`${styles.linkIcon} fa-${this.props.icon} fa`}></i>
<FormattedMessage
id={this.props.label}
defaultMessage='{label}'
values={{
label: this.props.label,
}}
className={styles.linkLabel}
/>
2016-08-25 10:47:15 +02:00
</Link>
2016-08-24 15:09:42 +02:00
</li>
);
}
}
LeftMenuLink.propTypes = {
2017-08-18 17:51:10 +02:00
destination: React.PropTypes.string.isRequired,
icon: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired,
2016-08-24 15:09:42 +02:00
};
export default LeftMenuLink;