Skip to content

Commit

Permalink
add cancel button (#307)
Browse files Browse the repository at this point in the history
* add cancel button
* add PropTypes
  • Loading branch information
anistouri authored Nov 3, 2023
1 parent 05d6bc3 commit 8370883
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/react-hook-form/utils/cancel-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Button } from '@mui/material';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

const CancelButton = ({
onClick,
variant,
disabled,
withCustomColor = true,
}) => {
return (
<Button
onClick={onClick}
variant={variant}
disabled={disabled}
color={withCustomColor ? 'customButton' : 'primary'}
>
<FormattedMessage id="cancel" />
</Button>
);
};

CancelButton.propTypes = {
onClick: PropTypes.func.isRequired,
variant: PropTypes.string,
disabled: PropTypes.bool,
withCustomColor: PropTypes.bool,
};

export default CancelButton;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export MidFormError from './components/react-hook-form/error-management/mid-form
export TextFieldWithAdornment from './components/react-hook-form/utils/text-field-with-adornment';
export FieldLabel from './components/react-hook-form/utils/field-label';
export SubmitButton from './components/react-hook-form/utils/submit-button';
export CancelButton from './components/react-hook-form/utils/cancel-button';
export {
genHelperPreviousValue,
genHelperError,
Expand Down

0 comments on commit 8370883

Please sign in to comment.