UNPKG

@totalsoft/rocket-ui

Version:

A set of reusable and composable React components built on top of Material UI core for developing fast and friendly web applications interfaces.

43 lines 1.59 kB
import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; import { useNavigate } from 'react-router'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import IconButton from '../IconButton'; /** * BackToButton allow users to navigate to a provided path. * * Props of the [Material-UI Button](https://mui.com/material-ui/api/button/#props) component are also available. */ const BackToButton = ({ path, options, fontSize = 'small', iconProps = {}, size = 'medium', ...rest }) => { const navigate = useNavigate(); const onBackTo = useCallback(() => navigate(path, options), [navigate, options, path]); return (React.createElement(IconButton, { "aria-label": "back", onClick: onBackTo, size: size, ...rest }, React.createElement(ArrowBackIcon, { fontSize: fontSize, ...iconProps }))); }; BackToButton.propTypes = { /** * @default 'medium' * Size of the button */ size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large']), /** * @deprecated Use `iconProps` instead * @default 'small' * Size of the icon. */ fontSize: PropTypes.oneOf(['inherit', 'small', 'medium', 'large']), /** * The properties of the icon. */ iconProps: PropTypes.object, /** * Path where browser will be directed to when the button is clicked. */ path: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, /** * Options to pass to the navigate */ options: PropTypes.object }; export default BackToButton; //# sourceMappingURL=BackToButton.js.map