mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
use reflow to migrate from flow to typescript
This commit is contained in:
33
scm-ui/ui-components/src/buttons/SubmitButton.tsx
Normal file
33
scm-ui/ui-components/src/buttons/SubmitButton.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import Button, { ButtonProps } from './Button';
|
||||
|
||||
type SubmitButtonProps = ButtonProps & {
|
||||
scrollToTop: boolean;
|
||||
};
|
||||
|
||||
class SubmitButton extends React.Component<SubmitButtonProps> {
|
||||
static defaultProps = {
|
||||
scrollToTop: true,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { action, scrollToTop } = this.props;
|
||||
return (
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
{...this.props}
|
||||
action={event => {
|
||||
if (action) {
|
||||
action(event);
|
||||
}
|
||||
if (scrollToTop) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SubmitButton;
|
||||
Reference in New Issue
Block a user