mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
39 lines
866 B
TypeScript
39 lines
866 B
TypeScript
import React from "react";
|
|
import { browserHistory, Link } from "react-router";
|
|
|
|
import Icon from "components/Icon";
|
|
import classnames from "classnames";
|
|
|
|
interface IBackLinkProps {
|
|
text: string;
|
|
path?: string;
|
|
className?: string;
|
|
}
|
|
|
|
const baseClass = "back-link";
|
|
|
|
const BackLink = ({ text, path, className }: IBackLinkProps): JSX.Element => {
|
|
const backLinkClass = classnames(baseClass, className);
|
|
|
|
const onClick = (): void => {
|
|
if (path) {
|
|
browserHistory.push(path);
|
|
} else browserHistory.goBack();
|
|
};
|
|
|
|
return (
|
|
<Link className={backLinkClass} to={path || ""} onClick={onClick}>
|
|
<>
|
|
<Icon
|
|
name="chevron"
|
|
className={`${baseClass}__back-icon`}
|
|
direction="left"
|
|
color="core-fleet-blue"
|
|
/>
|
|
<span>{text}</span>
|
|
</>
|
|
</Link>
|
|
);
|
|
};
|
|
export default BackLink;
|