Browse Source

more styles

merge-requests/6/head
rozetko 3 years ago
parent
commit
c450a4150e
  1. 28
      src/components/editors/IconsEditor.tsx
  2. 8
      src/components/editors/ThresholdsEditor.tsx

28
src/components/editors/IconsEditor.tsx

@ -121,7 +121,6 @@ export function IconsEditor({ onChange, value, context }: StandardEditorProps<Ic
}; };
const onConditionChange = (iconIdx: number, conditionIdx: number, field: keyof IconConfig, value: any) => { const onConditionChange = (iconIdx: number, conditionIdx: number, field: keyof IconConfig, value: any) => {
console.log(value);
// @ts-ignore // @ts-ignore
icons[iconIdx][field][conditionIdx] = value; icons[iconIdx][field][conditionIdx] = value;
@ -138,18 +137,25 @@ export function IconsEditor({ onChange, value, context }: StandardEditorProps<Ic
{icons.map((icon, iconIdx) => { {icons.map((icon, iconIdx) => {
return ( return (
<div key={iconIdx} className={styles.icon}> <div key={iconIdx} className={styles.icon}>
<IconButton name="trash-alt" onClick={() => removeIcon(iconIdx)}></IconButton> <IconButton
name="trash-alt"
onClick={() => removeIcon(iconIdx)}
tooltip="Delete Icon"
></IconButton>
<div className={styles.row}>
<Input <Input
type="url" type="url"
placeholder="Image URL" placeholder="Image URL"
value={icon.url} value={icon.url}
onChange={(evt) => onIconFieldChange(iconIdx, 'url', (evt.target as any).value)} onChange={(evt) => onIconFieldChange(iconIdx, 'url', (evt.target as any).value)}
/> />
</div>
<RadioButtonGroup <RadioButtonGroup
value={icon.position} value={icon.position}
options={positionOptions} options={positionOptions}
onChange={(newVal) => onIconFieldChange(iconIdx, 'position', newVal)} onChange={(newVal) => onIconFieldChange(iconIdx, 'position', newVal)}
/> />
<div className={styles.slider}>
<Slider <Slider
value={icon.size} value={icon.size}
min={1} min={1}
@ -157,9 +163,11 @@ export function IconsEditor({ onChange, value, context }: StandardEditorProps<Ic
step={1} step={1}
onAfterChange={(newVal) => onIconFieldChange(iconIdx, 'size', newVal)} onAfterChange={(newVal) => onIconFieldChange(iconIdx, 'size', newVal)}
/> />
</div>
{icon.conditions.map((condition, conditionIdx) => { {icon.conditions.map((condition, conditionIdx) => {
return ( return (
<div className={styles.condition}>
<HorizontalGroup key={conditionIdx} > <HorizontalGroup key={conditionIdx} >
<FieldNamePicker <FieldNamePicker
context={context} context={context}
@ -182,8 +190,10 @@ export function IconsEditor({ onChange, value, context }: StandardEditorProps<Ic
<IconButton <IconButton
name="trash-alt" name="trash-alt"
onClick={() => removeCondition(iconIdx, conditionIdx)} onClick={() => removeCondition(iconIdx, conditionIdx)}
tooltip="Delete Condition"
></IconButton> ></IconButton>
</HorizontalGroup> </HorizontalGroup>
</div>
); );
})} })}
<Button variant="secondary" onClick={() => addCondition(iconIdx)}> <Button variant="secondary" onClick={() => addCondition(iconIdx)}>
@ -206,6 +216,9 @@ export function IconsEditor({ onChange, value, context }: StandardEditorProps<Ic
interface IconsEditorStyles { interface IconsEditorStyles {
icons: string; icons: string;
icon: string; icon: string;
condition: string;
slider: string;
row: string;
} }
const getStyles = stylesFactory((theme: GrafanaTheme): IconsEditorStyles => { const getStyles = stylesFactory((theme: GrafanaTheme): IconsEditorStyles => {
@ -221,9 +234,18 @@ const getStyles = stylesFactory((theme: GrafanaTheme): IconsEditorStyles => {
padding-bottom: ${theme.spacing.formSpacingBase * 2}px; padding-bottom: ${theme.spacing.formSpacingBase * 2}px;
&:last-child { &:last-child {
border: none;
margin-bottom: 0; margin-bottom: 0;
} }
`, `,
condition: css`
margin-bottom: ${theme.spacing.xxs};
`,
slider: css`
padding-bottom: 0;
`,
row: css`
margin-bottom: ${theme.spacing.sm};
`,
}; };
}); });

8
src/components/editors/ThresholdsEditor.tsx

@ -103,7 +103,7 @@ export function ThresholdsEditor({ onChange, value, context }: StandardEditorPro
/> />
{config.thresholds.map((threshold, thresholdIdx) => { {config.thresholds.map((threshold, thresholdIdx) => {
return ( return (
<HorizontalGroup key={thresholdIdx} className={styles.row}> <HorizontalGroup key={thresholdIdx}>
<Input <Input
type="text" type="text"
value={'Color'} value={'Color'}
@ -138,7 +138,11 @@ 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)}
/> />
)} )}
<IconButton name="trash-alt" onClick={() => removeThreshold(thresholdIdx)}></IconButton> <IconButton
name="trash-alt"
onClick={() => removeThreshold(thresholdIdx)}
tooltip="Delete Threshold"
></IconButton>
</HorizontalGroup> </HorizontalGroup>
); );
})} })}

Loading…
Cancel
Save