aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/button
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-06-27 22:27:27 +0200
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-06-28 04:32:53 +0530
commit8715d489b58534470fc0d35b5961797bc0118e84 (patch)
tree563d81196d6026945ad1898bda76e078eb2a5d82 /src/components/ui/button
parentchore: transform containers/settings from js to tsx (#384) (diff)
downloadferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.tar.gz
ferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.tar.zst
ferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.zip
chore: turn error boundary into typescript
Diffstat (limited to 'src/components/ui/button')
-rw-r--r--src/components/ui/button/index.tsx20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx
index 9c64e909a..26fd6bcfe 100644
--- a/src/components/ui/button/index.tsx
+++ b/src/components/ui/button/index.tsx
@@ -2,7 +2,7 @@ import Icon from '@mdi/react';
2import classnames from 'classnames'; 2import classnames from 'classnames';
3import { Property } from 'csstype'; 3import { Property } from 'csstype';
4import { Component, MouseEvent } from 'react'; 4import { Component, MouseEvent } from 'react';
5import injectStyle, { WithStylesProps } from 'react-jss'; 5import withStyles, { WithStylesProps } from 'react-jss';
6import Loader from 'react-loader'; 6import Loader from 'react-loader';
7 7
8import { Theme } from '../../../themes'; 8import { Theme } from '../../../themes';
@@ -18,6 +18,7 @@ type ButtonType =
18 18
19interface IProps extends IFormField, WithStylesProps<typeof styles> { 19interface IProps extends IFormField, WithStylesProps<typeof styles> {
20 className?: string; 20 className?: string;
21 label?: string;
21 disabled?: boolean; 22 disabled?: boolean;
22 id?: string; 23 id?: string;
23 type?: 'button' | 'reset' | 'submit' | undefined; 24 type?: 'button' | 'reset' | 'submit' | undefined;
@@ -148,12 +149,19 @@ const styles = (theme: Theme) => ({
148}); 149});
149 150
150class ButtonComponent extends Component<IProps> { 151class ButtonComponent extends Component<IProps> {
151 public static defaultProps = { 152 customDefaultProps: {
153 disabled: boolean;
154 type: 'button' | 'reset' | 'submit' | undefined;
155 onClick: (
156 event: MouseEvent<HTMLButtonElement> | MouseEvent<HTMLAnchorElement>,
157 ) => void;
158 buttonType: ButtonType;
159 busy: boolean;
160 } = {
152 type: 'button', 161 type: 'button',
153 disabled: false, 162 disabled: false,
154 onClick: () => null, 163 onClick: () => null,
155 buttonType: 'primary' as ButtonType, 164 buttonType: 'primary' as ButtonType,
156 stretch: false,
157 busy: false, 165 busy: false,
158 }; 166 };
159 167
@@ -193,7 +201,7 @@ class ButtonComponent extends Component<IProps> {
193 href, 201 href,
194 target, 202 target,
195 htmlForm, 203 htmlForm,
196 } = this.props; 204 } = { ...this.customDefaultProps, ...this.props };
197 205
198 const { busy } = this.state; 206 const { busy } = this.state;
199 let showLoader = false; 207 let showLoader = false;
@@ -265,6 +273,4 @@ class ButtonComponent extends Component<IProps> {
265 } 273 }
266} 274}
267 275
268const Button = injectStyle(styles, { injectTheme: true })(ButtonComponent); 276export default withStyles(styles, { injectTheme: true })(ButtonComponent);
269
270export default Button;