Commit 9f1f5805 by Torkel Ödegaard

added switch form component

parent 7863d2d8
...@@ -19,3 +19,4 @@ export const Label: SFC<Props> = props => { ...@@ -19,3 +19,4 @@ export const Label: SFC<Props> = props => {
</span> </span>
); );
}; };
import React, { PureComponent } from 'react';
import _ from 'lodash';
export interface Props {
label: string;
checked: boolean;
labelClass?: string;
switchClass?: string;
onChange: (event) => any;
}
export interface State {
id: any;
}
export class Switch extends PureComponent<Props, State> {
state = {
id: _.uniqueId(),
};
internalOnChange = event => {
event.stopPropagation();
this.props.onChange(event);
};
render() {
const { labelClass, switchClass, label, checked } = this.props;
const labelId = `check-${this.state.id}`;
const labelClassName = `gf-form-label ${labelClass} pointer`;
const switchClassName = `gf-form-switch ${switchClass}`;
return (
<div className="gf-form">
{label && (
<label htmlFor={labelId} className={labelClassName}>
{label}
</label>
)}
<div className={switchClassName}>
<input id={labelId} type="checkbox" checked={checked} onChange={this.internalOnChange} />
<label htmlFor={labelId} />
</div>
</div>
);
}
}
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Label } from 'app/core/components/Forms/Forms'; import { Label } from 'app/core/components/Label/Label';
import { Team } from '../../types'; import { Team } from '../../types';
import { updateTeam } from './state/actions'; import { updateTeam } from './state/actions';
import { getRouteParamsId } from '../../core/selectors/location'; import { getRouteParamsId } from '../../core/selectors/location';
......
...@@ -5,6 +5,7 @@ import React, { PureComponent } from 'react'; ...@@ -5,6 +5,7 @@ import React, { PureComponent } from 'react';
// Components // Components
import Graph from 'app/viz/Graph'; import Graph from 'app/viz/Graph';
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries'; import { getTimeSeriesVMs } from 'app/viz/state/timeSeries';
import { Switch } from 'app/core/components/Switch/Switch';
// Types // Types
import { PanelProps, NullValueMode } from 'app/types'; import { PanelProps, NullValueMode } from 'app/types';
...@@ -35,10 +36,13 @@ export class Graph2 extends PureComponent<Props> { ...@@ -35,10 +36,13 @@ export class Graph2 extends PureComponent<Props> {
} }
export class TextOptions extends PureComponent<any> { export class TextOptions extends PureComponent<any> {
onChange = () => {};
render() { render() {
return ( return (
<div className="section gf-form-group"> <div className="section gf-form-group">
<h5 className="section-heading">Draw Modes</h5> <h5 className="section-heading">Draw Modes</h5>
<Switch label="Lines" checked={true} onChange={this.onChange} />
</div> </div>
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment