snort/packages/app/src/Element/BackButton.tsx

30 lines
597 B
TypeScript
Raw Normal View History

import "./BackButton.css";
2023-02-08 21:10:26 +00:00
import { useIntl } from "react-intl";
2023-01-26 07:25:05 +00:00
2023-03-02 17:47:02 +00:00
import Icon from "Icons/Icon";
2023-01-26 07:25:05 +00:00
2023-02-08 21:10:26 +00:00
import messages from "./messages";
2023-02-06 21:42:47 +00:00
interface BackButtonProps {
text?: string;
onClick?(): void;
2023-02-06 21:42:47 +00:00
}
2023-02-08 21:10:26 +00:00
const BackButton = ({ text, onClick }: BackButtonProps) => {
const { formatMessage } = useIntl();
2023-02-06 21:42:47 +00:00
const onClickHandler = () => {
if (onClick) {
onClick();
2023-02-06 21:42:47 +00:00
}
};
2023-01-26 07:25:05 +00:00
return (
2023-02-06 21:42:47 +00:00
<button className="back-button" type="button" onClick={onClickHandler}>
2023-03-02 17:47:02 +00:00
<Icon name="arrowBack" />
2023-02-08 21:10:26 +00:00
{text || formatMessage(messages.Back)}
2023-01-26 07:25:05 +00:00
</button>
);
};
2023-01-26 07:25:05 +00:00
export default BackButton;