This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/frontend/components/Layout/components/SidebarLink.js

35 lines
856 B
JavaScript
Raw Normal View History

2017-06-16 03:39:08 +00:00
// @flow
import React from 'react';
import { NavLink } from 'react-router-dom';
2017-09-25 03:03:03 +00:00
import { color, fontWeight } from 'styles/constants';
2017-06-16 03:39:08 +00:00
import styled from 'styled-components';
const activeStyle = {
color: color.black,
fontWeight: fontWeight.semiBold,
2017-06-16 03:39:08 +00:00
};
2017-09-24 21:25:14 +00:00
// This is a hack for `styleComponent()` as NavLink fails to render without `to` prop
const StyleableDiv = props => <div {...props} />;
const styleComponent = component => styled(component)`
display: block;
overflow: hidden;
text-overflow: ellipsis;
2017-09-25 03:03:03 +00:00
margin: 5px 24px;
color: ${color.slateDark};
2017-09-04 15:32:31 +00:00
font-size: 15px;
cursor: pointer;
&:hover {
color: ${color.text};
2017-06-16 03:39:08 +00:00
}
`;
function SidebarLink(props: Object) {
2017-09-24 21:25:14 +00:00
const Component = styleComponent(props.to ? NavLink : StyleableDiv);
return <Component exact activeStyle={activeStyle} {...props} />;
}
export default SidebarLink;