add button in header
This commit is contained in:
@@ -1,26 +1,36 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import React, { SFC } from 'react';
|
import React, { FunctionComponent } from 'react';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title?: string;
|
title?: string;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
children: JSX.Element | JSX.Element[];
|
children: JSX.Element | JSX.Element[] | boolean;
|
||||||
|
onAdd?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PanelOptionsGroup: SFC<Props> = props => {
|
export const PanelOptionsGroup: FunctionComponent<Props> = props => {
|
||||||
return (
|
return (
|
||||||
<div className="panel-options-group">
|
<div className="panel-options-group">
|
||||||
{props.title && (
|
{props.onAdd ? (
|
||||||
<div className="panel-options-group__header">
|
<div className="panel-options-group__header" style={{ cursor: 'pointer' }} onClick={props.onAdd}>
|
||||||
{props.title}
|
<div className="panel-options-group__add">
|
||||||
{props.onClose && (
|
<i className="fa fa-plus" />
|
||||||
<button className="btn btn-link" onClick={props.onClose}>
|
</div>
|
||||||
<i className="fa fa-remove" />
|
<span className="panel-options-group__title">{props.title}</span>
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
props.title && (
|
||||||
|
<div className="panel-options-group__header">
|
||||||
|
{props.title}
|
||||||
|
{props.onClose && (
|
||||||
|
<button className="btn btn-link" onClick={props.onClose}>
|
||||||
|
<i className="fa fa-remove" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
<div className="panel-options-group__body">{props.children}</div>
|
{props.children && <div className="panel-options-group__body">{props.children}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,13 +11,26 @@
|
|||||||
background: $panel-options-group-header-bg;
|
background: $panel-options-group-header-bg;
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: $border-radius $border-radius 0 0;
|
border-radius: $border-radius $border-radius 0 0;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 0px;
|
top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.panel-options-group__add {
|
||||||
|
background-color: $btn-success-bg;
|
||||||
|
border-radius: 50px;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.panel-options-group__title {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-options-group__body {
|
.panel-options-group__body {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
import MappingRow from './MappingRow';
|
import MappingRow from './MappingRow';
|
||||||
import { MappingType, ValueMapping } from '../../types/panel';
|
import { MappingType, ValueMapping } from '../../types';
|
||||||
import { PanelOptionsGroup } from '../PanelOptionsGroup/PanelOptionsGroup';
|
import { PanelOptionsGroup } from '..';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
valueMappings: ValueMapping[];
|
valueMappings: ValueMapping[];
|
||||||
@@ -81,8 +81,7 @@ export class ValueMappingsEditor extends PureComponent<Props, State> {
|
|||||||
const { valueMappings } = this.state;
|
const { valueMappings } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PanelOptionsGroup title="Value Mappings">
|
<PanelOptionsGroup title="Add mapping" onAdd={this.addMapping}>
|
||||||
<div>
|
|
||||||
{valueMappings.length > 0 &&
|
{valueMappings.length > 0 &&
|
||||||
valueMappings.map((valueMapping, index) => (
|
valueMappings.map((valueMapping, index) => (
|
||||||
<MappingRow
|
<MappingRow
|
||||||
@@ -92,13 +91,6 @@ export class ValueMappingsEditor extends PureComponent<Props, State> {
|
|||||||
removeValueMapping={() => this.onRemoveMapping(valueMapping.id)}
|
removeValueMapping={() => this.onRemoveMapping(valueMapping.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
|
||||||
<div className="add-mapping-row" onClick={this.addMapping}>
|
|
||||||
<div className="add-mapping-row-icon">
|
|
||||||
<i className="fa fa-plus" />
|
|
||||||
</div>
|
|
||||||
<div className="add-mapping-row-label">Add mapping</div>
|
|
||||||
</div>
|
|
||||||
</PanelOptionsGroup>
|
</PanelOptionsGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user