diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2018-02-21 10:45:11 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2018-02-21 10:45:11 +0100 |
| commit | de737c54c413f96c35b4e9bc6280fc7d26e4fa83 (patch) | |
| tree | 0cf470c59b4c7c8a6327e64610f68f5facd78d6d /app/components/Switch.js | |
| parent | ae9c255b3ecdec341090c932db6cb261147a7382 (diff) | |
| parent | 1214138633bcca19a1b96622400f3fbcf4044bd9 (diff) | |
| download | mullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.tar.xz mullvadvpn-de737c54c413f96c35b4e9bc6280fc7d26e4fa83.zip | |
Merge branch 'update-flow'
Diffstat (limited to 'app/components/Switch.js')
| -rw-r--r-- | app/components/Switch.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/app/components/Switch.js b/app/components/Switch.js index b3f2f58a58..9032065e9a 100644 --- a/app/components/Switch.js +++ b/app/components/Switch.js @@ -1,30 +1,36 @@ // @flow -import React, { Component } from 'react'; +import * as React from 'react'; const CLICK_TIMEOUT = 1000; const MOVE_THRESHOLD = 10; export type SwitchProps = { + className?: string; isOn: boolean; onChange: ?((isOn: boolean) => void); }; -export default class Switch extends Component { - props: SwitchProps; +type State = { + ignoreChange: boolean, + initialPos: {x: number, y: number}, + startTime: ?number, +}; + +export default class Switch extends React.Component<SwitchProps, State> { static defaultProps: SwitchProps = { isOn: false, onChange: null - } - - isCapturingMouseEvents = false; - ref: ?HTMLInputElement; - onRef = (e: HTMLInputElement) => this.ref = e; + }; state = { ignoreChange: false, initialPos: {x: 0, y: 0}, startTime: (null: ?number) - } + }; + + isCapturingMouseEvents = false; + ref: ?HTMLInputElement; + onRef = (e: ?HTMLInputElement) => this.ref = e; handleMouseDown = (e: MouseEvent) => { const { clientX: x, clientY: y } = e; @@ -124,9 +130,9 @@ export default class Switch extends Component { } } - render(): React.Element<*> { + render() { const { isOn, onChange, ...otherProps } = this.props; // eslint-disable-line no-unused-vars - let className = ('switch' + ' ' + (otherProps.className || '')).trim(); + const className = ('switch ' + (otherProps.className || '')).trim(); return ( <input { ...otherProps } type="checkbox" |
