1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/slider/slider.tsx
2022-04-06 10:34:16 -04:00

50 lines
1.2 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
// Wrapper for <Slider/> component
// API docs: https://material-ui.com/lab/api/slider/
import "./slider.scss";
import React, { Component } from "react";
import { cssNames } from "../../utils";
import type { SliderClassKey, SliderProps as MaterialSliderProps } from "@material-ui/core/Slider";
import MaterialSlider from "@material-ui/core/Slider";
export interface SliderProps extends Omit<MaterialSliderProps, "onChange"> {
className?: string;
onChange?(evt: React.FormEvent<any>, value: number): void;
}
const defaultProps: Partial<SliderProps> = {
step: 1,
min: 0,
max: 100,
};
export class Slider extends Component<SliderProps> {
static defaultProps = defaultProps as object;
private classNames: Partial<{ [P in SliderClassKey]: string }> = {
track: "track",
thumb: "thumb",
disabled: "disabled",
vertical: "vertical",
};
render() {
const { className, ...sliderProps } = this.props;
return (
<MaterialSlider
{...sliderProps}
classes={{
root: cssNames("Slider", className),
...this.classNames,
}}
/>
);
}
}