mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added switch form component
This commit is contained in:
parent
7863d2d882
commit
9f1f5805ec
@ -19,3 +19,4 @@ export const Label: SFC<Props> = props => {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
46
public/app/core/components/Switch/Switch.tsx
Normal file
46
public/app/core/components/Switch/Switch.tsx
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
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';
|
|||||||
// 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> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user