aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui
diff options
context:
space:
mode:
authorLibravatar Santhosh Chinnasamy <csesanthosh15@gmail.com>2022-05-16 11:35:34 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-05-16 06:20:11 -0500
commitbbde4a9d54d9c7dc03f34ca4113061a605dd5040 (patch)
tree240f6a34a6b772fb3e04d9bf96b1f36bc4cf7cca /src/components/ui
parent6.0.0-nightly.37 [skip ci] (diff)
downloadferdium-app-bbde4a9d54d9c7dc03f34ca4113061a605dd5040.tar.gz
ferdium-app-bbde4a9d54d9c7dc03f34ca4113061a605dd5040.tar.zst
ferdium-app-bbde4a9d54d9c7dc03f34ca4113061a605dd5040.zip
remove duplicate Button component
Diffstat (limited to 'src/components/ui')
-rw-r--r--src/components/ui/Button.js92
-rw-r--r--src/components/ui/button/index.tsx12
2 files changed, 8 insertions, 96 deletions
diff --git a/src/components/ui/Button.js b/src/components/ui/Button.js
deleted file mode 100644
index 882b39e69..000000000
--- a/src/components/ui/Button.js
+++ /dev/null
@@ -1,92 +0,0 @@
1import { Component } from 'react';
2import PropTypes from 'prop-types';
3import { observer, inject } from 'mobx-react';
4import Loader from 'react-loader';
5import classnames from 'classnames';
6
7// Can this file be merged into the './/button/index.tsx' file?
8class Button extends Component {
9 static propTypes = {
10 className: PropTypes.string,
11 label: PropTypes.string.isRequired,
12 disabled: PropTypes.bool,
13 onClick: PropTypes.func,
14 type: PropTypes.string,
15 buttonType: PropTypes.string,
16 loaded: PropTypes.bool,
17 htmlForm: PropTypes.string,
18 stores: PropTypes.shape({
19 settings: PropTypes.shape({
20 app: PropTypes.shape({
21 accentColor: PropTypes.string.isRequired,
22 }).isRequired,
23 }).isRequired,
24 }).isRequired,
25 };
26
27 static defaultProps = {
28 className: null,
29 disabled: false,
30 onClick: () => {},
31 type: 'button',
32 buttonType: '',
33 loaded: true,
34 htmlForm: '',
35 };
36
37 render() {
38 const {
39 label,
40 className,
41 disabled,
42 onClick,
43 type,
44 buttonType,
45 loaded,
46 htmlForm,
47 } = this.props;
48
49 const buttonProps = {
50 className: classnames({
51 'franz-form__button': true,
52 [`franz-form__button--${buttonType}`]: buttonType,
53 [`${className}`]: className,
54 }),
55 type,
56 };
57
58 if (disabled) {
59 buttonProps.disabled = true;
60 }
61
62 if (onClick) {
63 buttonProps.onClick = onClick;
64 }
65
66 if (htmlForm) {
67 buttonProps.form = htmlForm;
68 }
69
70 return (
71 // disabling rule as button has type defined in `buttonProps`
72 /* eslint-disable react/button-has-type */
73 <button {...buttonProps}>
74 <Loader
75 loaded={loaded}
76 lines={10}
77 scale={0.4}
78 color={
79 buttonType !== 'secondary'
80 ? '#FFF'
81 : this.props.stores.settings.app.accentColor
82 }
83 component="span"
84 />
85 {label}
86 </button>
87 /* eslint-enable react/button-has-type */
88 );
89 }
90}
91
92export default inject('stores')(observer(Button));
diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx
index 11369dcbd..822ddf48f 100644
--- a/src/components/ui/button/index.tsx
+++ b/src/components/ui/button/index.tsx
@@ -35,7 +35,11 @@ interface IProps extends IFormField, WithStylesProps<typeof styles> {
35let buttonTransition: string = 'none'; 35let buttonTransition: string = 'none';
36let loaderContainerTransition: string = 'none'; 36let loaderContainerTransition: string = 'none';
37 37
38if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { 38if (
39 typeof window !== 'undefined' &&
40 window &&
41 window.matchMedia('(prefers-reduced-motion: no-preference)')
42) {
39 buttonTransition = 'background .5s, opacity 0.3s'; 43 buttonTransition = 'background .5s, opacity 0.3s';
40 loaderContainerTransition = 'all 0.3s'; 44 loaderContainerTransition = 'all 0.3s';
41} 45}
@@ -259,6 +263,6 @@ class ButtonComponent extends Component<IProps> {
259 } 263 }
260} 264}
261 265
262export const Button = injectStyle(styles, { injectTheme: true })( 266const Button = injectStyle(styles, { injectTheme: true })(ButtonComponent);
263 ButtonComponent, 267
264); 268export default Button;