2019-09-17 20:48:37 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-04-30 00:34:37 +02:00
|
|
|
import AddIcon from '../images/plus.svg';
|
|
|
|
import RemoveIcon from '../images/minus.svg';
|
2019-09-17 20:48:37 +02:00
|
|
|
|
|
|
|
const AddRemoveButton = ({ type, onClick }) => {
|
2020-04-30 00:34:37 +02:00
|
|
|
const alt = type === 'add' ? 'Add to collection' : 'Remove from collection';
|
|
|
|
const Icon = type === 'add' ? AddIcon : RemoveIcon;
|
2019-09-17 20:48:37 +02:00
|
|
|
|
|
|
|
return (
|
2020-04-30 00:34:37 +02:00
|
|
|
<button
|
|
|
|
className="overlay__close-button"
|
|
|
|
onClick={onClick}
|
|
|
|
aria-label={alt}
|
|
|
|
>
|
|
|
|
<Icon focusable="false" aria-hidden="true" />
|
2019-09-17 20:48:37 +02:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AddRemoveButton.propTypes = {
|
|
|
|
type: PropTypes.oneOf(['add', 'remove']).isRequired,
|
|
|
|
onClick: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AddRemoveButton;
|