SparklineEditor.tsx 971 B

123456789101112131415161718192021222324252627282930313233
  1. // Libraries
  2. import React, { PureComponent } from 'react';
  3. // Components
  4. import { Switch, PanelOptionsGroup } from '@grafana/ui';
  5. // Types
  6. import { SparklineOptions } from './types';
  7. const labelWidth = 6;
  8. export interface Props {
  9. options: SparklineOptions;
  10. onChange: (options: SparklineOptions) => void;
  11. }
  12. export class SparklineEditor extends PureComponent<Props> {
  13. onToggleShow = () => this.props.onChange({ ...this.props.options, show: !this.props.options.show });
  14. onToggleFull = () => this.props.onChange({ ...this.props.options, full: !this.props.options.full });
  15. render() {
  16. const { show, full } = this.props.options;
  17. return (
  18. <PanelOptionsGroup title="Sparkline">
  19. <Switch label="Show" labelClass={`width-${labelWidth}`} checked={show} onChange={this.onToggleShow} />
  20. <Switch label="Full Height" labelClass={`width-${labelWidth}`} checked={full} onChange={this.onToggleFull} />
  21. </PanelOptionsGroup>
  22. );
  23. }
  24. }