diff --git a/packages/grafana-ui/src/components/PanelOptionsGroup/PanelOptionsGroup.tsx b/packages/grafana-ui/src/components/PanelOptionsGroup/PanelOptionsGroup.tsx index 7ce4b8335ff..8516760d6f3 100644 --- a/packages/grafana-ui/src/components/PanelOptionsGroup/PanelOptionsGroup.tsx +++ b/packages/grafana-ui/src/components/PanelOptionsGroup/PanelOptionsGroup.tsx @@ -1,26 +1,38 @@ // Libraries -import React, { SFC } from 'react'; +import React, { FunctionComponent } from 'react'; interface Props { title?: string; onClose?: () => void; - children: JSX.Element | JSX.Element[]; + children: JSX.Element | JSX.Element[] | boolean; + onAdd?: () => void; } -export const PanelOptionsGroup: SFC = props => { +export const PanelOptionsGroup: FunctionComponent = props => { return (
- {props.title && ( + {props.onAdd ? (
- {props.title} - {props.onClose && ( - - )} +
+ ) : ( + props.title && ( +
+ {props.title} + {props.onClose && ( + + )} +
+ ) )} -
{props.children}
+ {props.children &&
{props.children}
}
); }; diff --git a/packages/grafana-ui/src/components/PanelOptionsGroup/_PanelOptionsGroup.scss b/packages/grafana-ui/src/components/PanelOptionsGroup/_PanelOptionsGroup.scss index cfc832afa98..b5b815cf57c 100644 --- a/packages/grafana-ui/src/components/PanelOptionsGroup/_PanelOptionsGroup.scss +++ b/packages/grafana-ui/src/components/PanelOptionsGroup/_PanelOptionsGroup.scss @@ -7,18 +7,57 @@ .panel-options-group__header { padding: 4px 8px; - font-size: 1.1rem; background: $panel-options-group-header-bg; position: relative; border-radius: $border-radius $border-radius 0 0; + display: flex; + align-items: center; .btn { position: absolute; right: 0; - top: 0px; + top: 0; } } +.panel-options-group__add-btn { + background: none; + border: none; + display: flex; + align-items: center; + padding: 0; + + &:hover { + .panel-options-group__add-circle { + background-color: $btn-success-bg; + color: $text-color-strong; + } + } +} + +.panel-options-group__add-circle { + @include gradientBar($btn-success-bg, $btn-success-bg-hl, $text-color); + + border-radius: 50px; + width: 20px; + height: 20px; + display: flex; + align-items: center; + justify-content: center; + margin-right: 6px; + + i { + position: relative; + top: 1px; + } +} + +.panel-options-group__title { + font-size: 1.1rem; + position: relative; + top: 1px; +} + .panel-options-group__body { padding: 20px; diff --git a/packages/grafana-ui/src/components/ThresholdsEditor/_ThresholdsEditor.scss b/packages/grafana-ui/src/components/ThresholdsEditor/_ThresholdsEditor.scss index 61278321572..200adfbfd75 100644 --- a/packages/grafana-ui/src/components/ThresholdsEditor/_ThresholdsEditor.scss +++ b/packages/grafana-ui/src/components/ThresholdsEditor/_ThresholdsEditor.scss @@ -1,11 +1,11 @@ .thresholds { - margin-bottom: 10px; + margin-bottom: 20px; } .thresholds-row { display: flex; flex-direction: row; - height: 70px; + height: 62px; } .thresholds-row:first-child > .thresholds-row-color-indicator { @@ -21,21 +21,21 @@ } .thresholds-row-add-button { + @include buttonBackground($btn-success-bg, $btn-success-bg-hl, $text-color); + align-self: center; margin-right: 5px; - color: $green; height: 24px; width: 24px; - background-color: $green; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; -} -.thresholds-row-add-button > i { - color: $white; + &:hover { + color: $text-color-strong; + } } .thresholds-row-color-indicator { diff --git a/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.test.tsx b/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.test.tsx index bbad3e5a7ca..caa09c9e5ff 100644 --- a/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.test.tsx +++ b/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { ValueMappingsEditor, Props } from './ValueMappingsEditor'; -import { MappingType } from '../../types/panel'; +import { MappingType } from '../../types'; const setup = (propOverrides?: object) => { const props: Props = { diff --git a/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.tsx b/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.tsx index ca0a6e71f4a..f9646781048 100644 --- a/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.tsx +++ b/packages/grafana-ui/src/components/ValueMappingsEditor/ValueMappingsEditor.tsx @@ -1,8 +1,8 @@ import React, { PureComponent } from 'react'; import MappingRow from './MappingRow'; -import { MappingType, ValueMapping } from '../../types/panel'; -import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup'; +import { MappingType, ValueMapping } from '../../types'; +import { PanelOptionsGroup } from '..'; export interface Props { valueMappings: ValueMapping[]; @@ -81,8 +81,7 @@ export class ValueMappingsEditor extends PureComponent { const { valueMappings } = this.state; return ( - -
+ {valueMappings.length > 0 && valueMappings.map((valueMapping, index) => ( { removeValueMapping={() => this.onRemoveMapping(valueMapping.id)} /> ))} -
-
-
- -
-
Add mapping
-
); } diff --git a/packages/grafana-ui/src/components/ValueMappingsEditor/__snapshots__/ValueMappingsEditor.test.tsx.snap b/packages/grafana-ui/src/components/ValueMappingsEditor/__snapshots__/ValueMappingsEditor.test.tsx.snap index 8a465ff88df..b0dd7d81840 100644 --- a/packages/grafana-ui/src/components/ValueMappingsEditor/__snapshots__/ValueMappingsEditor.test.tsx.snap +++ b/packages/grafana-ui/src/components/ValueMappingsEditor/__snapshots__/ValueMappingsEditor.test.tsx.snap @@ -2,55 +2,37 @@ exports[`Render should render component 1`] = ` -
- - + -
-
-
- -
-
- Add mapping -
-
+ } + />
`;