Browse Source

pretty styles

merge-requests/6/head
rozetko 3 years ago
parent
commit
9d6abbb424
  1. 2
      src/components/editors/IconsEditor.tsx
  2. 66
      src/components/editors/ThresholdsEditor.tsx

2
src/components/editors/IconsEditor.tsx

@ -241,7 +241,7 @@ const getStyles = stylesFactory((theme: GrafanaTheme): IconsEditorStyles => {
margin-bottom: ${theme.spacing.xxs}; margin-bottom: ${theme.spacing.xxs};
`, `,
slider: css` slider: css`
padding-bottom: 0; padding-bottom: ${theme.spacing.xxs};
`, `,
row: css` row: css`
margin-bottom: ${theme.spacing.sm}; margin-bottom: ${theme.spacing.sm};

66
src/components/editors/ThresholdsEditor.tsx

@ -7,6 +7,7 @@ import {
HorizontalGroup, HorizontalGroup,
IconButton, IconButton,
InlineField, InlineField,
InlineLabel,
InlineSwitch, InlineSwitch,
Input, Input,
stylesFactory, stylesFactory,
@ -18,6 +19,7 @@ import React from 'react';
import { css } from 'emotion'; import { css } from 'emotion';
import * as _ from 'lodash'; import * as _ from 'lodash';
interface Props { interface Props {
defaultColor: string; defaultColor: string;
arcBackground: string; arcBackground: string;
@ -71,59 +73,35 @@ export function ThresholdsEditor({ onChange, value, context }: StandardEditorPro
const styles = getStyles(theme.v1); const styles = getStyles(theme.v1);
return ( return (
<div> <div>
<Input <InlineField label="Default Gauge Color">
className={styles.row} <InlineLabel>
type="text"
value={'Default Gauge Color'}
disabled
prefix={
<div>
<ColorPicker <ColorPicker
color={config.defaultColor} color={config.defaultColor}
onChange={(val) => onFieldChange('defaultColor', val)} onChange={(val) => onFieldChange('defaultColor', val)}
enableNamedColors={true} enableNamedColors={true}
/> />
</div> </InlineLabel>
} </InlineField>
/>
<Input <InlineField label="Arc Background">
className={styles.row} <InlineLabel>
type="text"
value={'Arc Background'}
disabled
prefix={
<div>
<ColorPicker <ColorPicker
color={config.arcBackground} color={config.arcBackground}
onChange={(val) => onFieldChange('arcBackground', val)} onChange={(val) => onFieldChange('arcBackground', val)}
enableNamedColors={true} enableNamedColors={true}
/> />
</div> </InlineLabel>
} </InlineField>
/>
{config.thresholds.map((threshold, thresholdIdx) => { {config.thresholds.map((threshold, thresholdIdx) => {
return ( return (
<HorizontalGroup key={thresholdIdx}> <HorizontalGroup key={thresholdIdx}>
<Input
type="text"
value={'Color'}
disabled
prefix={
<div>
<ColorPicker
color={threshold.color}
onChange={(newVal) => onThresholdFieldChange(thresholdIdx, 'color', newVal)}
enableNamedColors={true}
/>
</div>
}
/>
<InlineField label="Use metric"> <InlineField label="Use metric">
<InlineSwitch <InlineSwitch
value={threshold.useMetric} value={threshold.useMetric}
onChange={(evt) => onThresholdFieldChange(thresholdIdx, 'useMetric', (evt.target as any).checked)} onChange={(evt) => onThresholdFieldChange(thresholdIdx, 'useMetric', (evt.target as any).checked)}
/> />
</InlineField> </InlineField>
<InlineField>
{threshold.useMetric ? ( {threshold.useMetric ? (
<FieldNamePicker <FieldNamePicker
context={context} context={context}
@ -138,11 +116,25 @@ export function ThresholdsEditor({ onChange, value, context }: StandardEditorPro
onChange={(evt) => onThresholdFieldChange(thresholdIdx, 'value', (evt.target as any).value)} onChange={(evt) => onThresholdFieldChange(thresholdIdx, 'value', (evt.target as any).value)}
/> />
)} )}
</InlineField>
<InlineField label="Color">
<InlineLabel>
<ColorPicker
color={threshold.color}
onChange={(newVal) => onThresholdFieldChange(thresholdIdx, 'color', newVal)}
enableNamedColors={true}
/>
</InlineLabel>
</InlineField>
<InlineField>
<InlineLabel width={0} className={styles.deleteButton}>
<IconButton <IconButton
name="trash-alt" name="trash-alt"
onClick={() => removeThreshold(thresholdIdx)} onClick={() => removeThreshold(thresholdIdx)}
tooltip="Delete Threshold" tooltip="Delete Threshold"
></IconButton> ></IconButton>
</InlineLabel>
</InlineField>
</HorizontalGroup> </HorizontalGroup>
); );
})} })}
@ -157,13 +149,13 @@ export function ThresholdsEditor({ onChange, value, context }: StandardEditorPro
} }
interface ThresholdsEditorStyles { interface ThresholdsEditorStyles {
row: string; deleteButton: string;
} }
const getStyles = stylesFactory((theme: GrafanaTheme): ThresholdsEditorStyles => { const getStyles = stylesFactory((theme: GrafanaTheme): ThresholdsEditorStyles => {
return { return {
row: css` deleteButton: css`
margin-bottom: ${theme.spacing.sm}; margin-right: 0px!important;
`, `,
}; };
}); });

Loading…
Cancel
Save