Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cancel button #307

Merged
merged 7 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 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,28 @@
import React from 'react';
import { Button } from '@mui/material';
import { FormattedMessage } from 'react-intl';

const styles = {
removeButtonTextColor: (theme) => ({
color: theme.palette.text.primary,
}),
};
const CancelButton = ({
onClick,
variant,
disabled,
withCustomColor = true,
}) => {
return (
<Button
onClick={onClick}
variant={variant}
disabled={disabled}
sx={withCustomColor ? styles.removeButtonTextColor : null}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you use sx and not the color prop ?
https://mui.com/material-ui/api/button/#Button-prop-color

>
<FormattedMessage id="cancel" />
</Button>
);
};

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
Loading