You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/ts/components/session/SessionToggle.tsx

49 lines
860 B
TypeScript

import React from 'react';
import classNames from 'classnames';
interface Props {
active: boolean;
}
interface State {
active: boolean;
}
export class SessionToggle extends React.PureComponent<Props, State> {
public static readonly extendedDefaults = {
onClick: () => null,
};
constructor(props: any) {
super(props);
this.clickHandler = this.clickHandler.bind(this);
const { active } = this.props;
this.state = {
active: active,
};
}
public render() {
return (
<div
className={classNames(
'session-toggle',
this.state.active ? 'active' : ''
)}
role="button"
onClick={this.clickHandler}
>
<div className="knob" />
</div>
);
}
private clickHandler() {
this.setState({
active: !this.state.active,
});
}
}