diff --git a/src/components/IconLayer.jsx b/src/components/IconLayer.tsx
similarity index 83%
rename from src/components/IconLayer.jsx
rename to src/components/IconLayer.tsx
index fafb1270..e92160ad 100644
--- a/src/components/IconLayer.jsx
+++ b/src/components/IconLayer.tsx
@@ -1,5 +1,4 @@
import React from 'react'
-import PropTypes from 'prop-types'
import IconLine from './IconLine'
import IconFill from './IconFill'
@@ -8,12 +7,12 @@ import IconBackground from './IconBackground'
import IconCircle from './IconCircle'
import IconMissing from './IconMissing'
-export default class IconLayer extends React.Component {
- static propTypes = {
- type: PropTypes.string.isRequired,
- style: PropTypes.object,
- }
+type IconLayerProps = {
+ type: string
+ style?: object
+};
+export default class IconLayer extends React.Component
{
render() {
const iconProps = { style: this.props.style }
switch(this.props.type) {
diff --git a/src/components/InputColor.jsx b/src/components/InputColor.tsx
similarity index 79%
rename from src/components/InputColor.jsx
rename to src/components/InputColor.tsx
index 02fb0965..7c919edd 100644
--- a/src/components/InputColor.jsx
+++ b/src/components/InputColor.tsx
@@ -1,36 +1,37 @@
import React from 'react'
import Color from 'color'
import ChromePicker from 'react-color/lib/components/chrome/Chrome'
-import PropTypes from 'prop-types'
+import {ColorResult} from 'react-color';
import lodash from 'lodash';
-function formatColor(color) {
+function formatColor(color: ColorResult): string {
const rgb = color.rgb
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`
}
-/*** Number fields with support for min, max and units and documentation*/
-export default class InputColor extends React.Component {
- static propTypes = {
- onChange: PropTypes.func.isRequired,
- name: PropTypes.string,
- value: PropTypes.string,
- doc: PropTypes.string,
- style: PropTypes.object,
- default: PropTypes.string,
- 'aria-label': PropTypes.string,
- }
+type InputColorProps = {
+ onChange(...args: unknown[]): unknown
+ name?: string
+ value?: string
+ doc?: string
+ style?: object
+ default?: string
+ 'aria-label'?: string
+};
+/*** Number fields with support for min, max and units and documentation*/
+export default class InputColor extends React.Component {
state = {
pickerOpened: false
}
+ colorInput: HTMLInputElement | null = null;
- constructor () {
- super();
+ constructor (props: InputColorProps) {
+ super(props);
this.onChangeNoCheck = lodash.throttle(this.onChangeNoCheck, 1000/30);
}
- onChangeNoCheck (v) {
+ onChangeNoCheck(v: string) {
this.props.onChange(v);
}
@@ -68,31 +69,31 @@ export default class InputColor extends React.Component {
}
}
- onChange (v) {
+ onChange (v: string) {
this.props.onChange(v === "" ? undefined : v);
}
render() {
const offset = this.calcPickerOffset()
- var currentColor = this.color.object()
- currentColor = {
+ const currentColor = this.color.object();
+ const currentChromeColor = {
r: currentColor.r,
g: currentColor.g,
b: currentColor.b,
// Rename alpha -> a for ChromePicker
- a: currentColor.alpha
+ a: currentColor.alpha!
}
const picker =
this.onChangeNoCheck(formatColor(c))}
/>