From eb7b2481f631cec5953265eef4ebc3f2fa7e496a Mon Sep 17 00:00:00 2001 From: muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> Date: Wed, 16 Nov 2022 23:30:39 +0530 Subject: Transform JSX components to TSX (#755) * color picker types * Import * SetupAssistant * Services & appear * ServiceWebView * SettingsLayout * ImportantScreen * WorkspaceDrawer * SetupAssistant * chore: update vscode settings * chore: removed stale Import screen component & its tree --- src/components/ui/ColorPickerInput.tsx | 102 --------------------------- src/components/ui/colorPickerInput/index.tsx | 88 +++++++++++++++++++++++ src/components/ui/effects/Appear.tsx | 21 ++++-- 3 files changed, 104 insertions(+), 107 deletions(-) delete mode 100644 src/components/ui/ColorPickerInput.tsx create mode 100644 src/components/ui/colorPickerInput/index.tsx (limited to 'src/components/ui') diff --git a/src/components/ui/ColorPickerInput.tsx b/src/components/ui/ColorPickerInput.tsx deleted file mode 100644 index da1fffb71..000000000 --- a/src/components/ui/ColorPickerInput.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { - ChangeEvent, - ChangeEventHandler, - Component, - createRef, - RefObject, -} from 'react'; -import { observer } from 'mobx-react'; -import classnames from 'classnames'; -import { SliderPicker } from 'react-color'; -import { noop } from 'lodash'; -import { Field } from '../../@types/mobx-form.types'; - -interface IProps { - field: Field; - className?: string; - focus?: boolean; - onChange: ChangeEventHandler; -} - -// TODO - [TS DEBT] check if field can be spread instead of having it single field attribute in interface -@observer -class ColorPickerInput extends Component { - private inputElement: RefObject = - createRef(); - - componentDidMount() { - const { focus = false } = this.props; - if (focus) { - this.focus(); - } - } - - onChange(e: ChangeEvent) { - const { field, onChange = noop } = this.props; - - onChange(e); - if (field.onChange) { - field.onChange(e); - } - } - - focus() { - if (this.inputElement && this.inputElement.current) { - this.inputElement.current.focus(); - } - } - - handleChangeComplete = (color: { hex: string }) => { - const { field } = this.props; - field.value = color.hex; - }; - - render() { - const { field, className = null } = this.props; - - let { type } = field; - type = 'text'; - - return ( -
- -
- this.onChange(e)} - onBlur={field.onBlur} - onFocus={field.onFocus} - ref={this.inputElement} - disabled={field.disabled} - /> -
-
- ); - } -} - -export default ColorPickerInput; diff --git a/src/components/ui/colorPickerInput/index.tsx b/src/components/ui/colorPickerInput/index.tsx new file mode 100644 index 000000000..9bab6efec --- /dev/null +++ b/src/components/ui/colorPickerInput/index.tsx @@ -0,0 +1,88 @@ +import { + Component, + createRef, + InputHTMLAttributes, + ReactElement, + RefObject, +} from 'react'; +import { observer } from 'mobx-react'; +import classnames from 'classnames'; +import { SliderPicker } from 'react-color'; +import { noop } from 'lodash'; +import { FormFields } from '../../../@types/mobx-form.types'; + +interface IProps extends InputHTMLAttributes, FormFields { + className?: string; + focus?: boolean; + onColorChange?: () => void; + error: string; +} + +@observer +class ColorPickerInput extends Component { + private inputElement: RefObject = + createRef(); + + componentDidMount(): void { + const { focus = false } = this.props; + if (focus && this.inputElement && this.inputElement.current) { + this.inputElement.current.focus(); + } + } + + onChange({ hex }: { hex: string }): void { + const { onColorChange = noop, onChange = noop } = this.props; + onColorChange(); + onChange(hex); + } + + render(): ReactElement { + const { + id, + name, + value = '', + placeholder = '', + disabled = false, + className = null, + type = 'text', + error = '', + onChange = noop, + } = this.props; + + return ( +
+ +
+ +
+
+ ); + } +} + +export default ColorPickerInput; diff --git a/src/components/ui/effects/Appear.tsx b/src/components/ui/effects/Appear.tsx index bf097b6a6..2076f6ba6 100644 --- a/src/components/ui/effects/Appear.tsx +++ b/src/components/ui/effects/Appear.tsx @@ -5,11 +5,22 @@ interface IProps { children: ReactNode; transitionName?: string; className?: string; + transitionAppear?: boolean; + transitionLeave?: boolean; + transitionAppearTimeout?: number; + transitionEnterTimeout?: number; + transitionLeaveTimeout?: number; } + const Appear = ({ children, transitionName = 'fadeIn', className = '', + transitionAppear = true, + transitionLeave = true, + transitionAppearTimeout = 1500, + transitionEnterTimeout = 1500, + transitionLeaveTimeout = 1500, }: IProps): ReactElement | null => { const [mounted, setMounted] = useState(false); @@ -24,11 +35,11 @@ const Appear = ({ return ( {children} -- cgit v1.2.3-54-g00ecf