import React from 'react'; import classNames from 'classnames'; import Slider from 'rc-slider'; import { SessionToggle } from '../SessionToggle'; import { SessionButton } from '../SessionButton'; import { SessionSettingType } from './SessionSettings'; import { SessionRadioGroup } from '../SessionRadioGroup'; interface Props { title: string; description?: string; type: SessionSettingType | undefined; value: any; options?: Array; onClick?: any; onSliderChange?: any; content: any; } interface State { sliderValue: number | null; } export class SessionSettingListItem extends React.Component { public static defaultProps = { inline: true, }; public constructor(props: Props) { super(props); this.state = { sliderValue: null, }; this.handleClick = this.handleClick.bind(this); } public render(): JSX.Element { const { title, description, type, value, content } = this.props; const inline = !!type && ![ SessionSettingType.Options, SessionSettingType.Slider, ].includes(type); const currentSliderValue = type === SessionSettingType.Slider && (this.state.sliderValue || value); return (
{title}
{description && (
{description}
)}
{type === SessionSettingType.Toggle && (
)} {type === SessionSettingType.Button && ( )} {type === SessionSettingType.Options && ( )} {type === SessionSettingType.Slider && (
{ this.handleSlider(sliderValue); }} />

{`${currentSliderValue} Hours`}

)}
); } private handleClick() { if (this.props.onClick) { this.props.onClick(); } } private handleSlider(value: any) { if (this.props.onSliderChange) { this.props.onSliderChange(value); } this.setState({ sliderValue: value, }); } }