Fix types, abandon propTypes
This commit is contained in:
parent
715bcb3c96
commit
0d0da6cfdc
1 changed files with 7 additions and 38 deletions
|
@ -15,12 +15,10 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as PropTypes from 'prop-types';
|
|
||||||
import { replaceableComponent } from '../../../utils/replaceableComponent';
|
|
||||||
|
|
||||||
type SliderProps = {
|
type IProps = {
|
||||||
// A callback for the selected value
|
// A callback for the selected value
|
||||||
onSelectionChange: (value: number) => null;
|
onSelectionChange: (value: number) => void;
|
||||||
|
|
||||||
// The current value of the slider
|
// The current value of the slider
|
||||||
value: number;
|
value: number;
|
||||||
|
@ -34,24 +32,7 @@ type SliderProps = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Slider extends React.Component<SliderProps> {
|
export default class Slider extends React.Component<IProps> {
|
||||||
static propTypes = {
|
|
||||||
|
|
||||||
// A callback for the new value onclick
|
|
||||||
onSelectionChange: PropTypes.func,
|
|
||||||
|
|
||||||
// The current value of the slider
|
|
||||||
value: PropTypes.number,
|
|
||||||
|
|
||||||
// The range and values of the slider
|
|
||||||
// Currently only supports an ascending, constant interval range
|
|
||||||
values: PropTypes.arrayOf(PropTypes.number),
|
|
||||||
|
|
||||||
// A function for formatting the the values
|
|
||||||
displayFunc: PropTypes.func,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
_offset(values: number[], value: number): number {
|
_offset(values: number[], value: number): number {
|
||||||
return (value - values[0]) / (values[values.length - 1] - values[0]) * 100;
|
return (value - values[0]) / (values[values.length - 1] - values[0]) * 100;
|
||||||
}
|
}
|
||||||
|
@ -83,9 +64,9 @@ export default class Slider extends React.Component<SliderProps> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DotProps = {
|
type DotIProps = {
|
||||||
// Callback for behaviour onclick
|
// Callback for behavior onclick
|
||||||
onClick: () => null,
|
onClick: () => void,
|
||||||
|
|
||||||
// Whether the dot should appear active
|
// Whether the dot should appear active
|
||||||
active: boolean,
|
active: boolean,
|
||||||
|
@ -94,19 +75,7 @@ type DotProps = {
|
||||||
label: string,
|
label: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.elements.Dot")
|
class Dot extends React.Component<DotIProps> {
|
||||||
class Dot extends React.Component<DotProps> {
|
|
||||||
static propTypes = {
|
|
||||||
// Callback for behaviour onclick
|
|
||||||
onClick: PropTypes.func,
|
|
||||||
|
|
||||||
// Whether the dot should appear active
|
|
||||||
active: PropTypes.bool,
|
|
||||||
|
|
||||||
// The label on the dot
|
|
||||||
label: PropTypes.string,
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): React.ReactNode {
|
render(): React.ReactNode {
|
||||||
const className = "mx_Slider_dot" + (this.props.active ? " mx_Slider_dotActive" : "");
|
const className = "mx_Slider_dot" + (this.props.active ? " mx_Slider_dotActive" : "");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue