Files
Torkel Ödegaard 10badea19e Emotion: Upgrades emotion from 10 to 11 and updates all import paths (#32541)
* Babel: Updates babel dependencies to latest version

* Emotion: Upgrade form 10 to 11

* Fixing tests

* Updated to use emotion/css instead in test
2021-04-01 14:15:23 +02:00

29 lines
862 B
TypeScript

import { css } from '@emotion/css';
import React, { FunctionComponent } from 'react';
import { IconButton } from './IconButton';
interface Props {
index: number;
elements: any[];
onAdd: () => void;
onRemove: () => void;
}
/**
* A component used to show add & remove buttons for mutable lists of values. Wether to show or not the add or the remove buttons
* depends on the `index` and `elements` props. This enforces a consistent experience whenever this pattern is used.
*/
export const AddRemove: FunctionComponent<Props> = ({ index, onAdd, onRemove, elements }) => {
return (
<div
className={css`
display: flex;
`}
>
{index === 0 && <IconButton iconName="plus" onClick={onAdd} label="add" />}
{elements.length >= 2 && <IconButton iconName="minus" onClick={onRemove} label="remove" />}
</div>
);
};