p5.js-web-editor/client/components/AddRemoveButton.jsx

28 lines
686 B
React
Raw Normal View History

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