| 1 |
import { Button, PanelRow } from '@wordpress/components'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
export default function ButtonClearMedia({ |
| 5 |
nameAttributes, |
| 6 |
setAttributes, |
| 7 |
children = __('Clear Media', 'ghostkit'), |
| 8 |
}) { |
| 9 |
const handleClick = (e) => { |
| 10 |
const clearAttributes = {}; |
| 11 |
nameAttributes.forEach((name) => { |
| 12 |
clearAttributes[name] = ''; |
| 13 |
}); |
| 14 |
setAttributes(clearAttributes); |
| 15 |
|
| 16 |
e.preventDefault(); |
| 17 |
}; |
| 18 |
|
| 19 |
return ( |
| 20 |
<PanelRow> |
| 21 |
<Button |
| 22 |
variant="secondary" |
| 23 |
size="small" |
| 24 |
onClick={handleClick} |
| 25 |
className="is-small" |
| 26 |
style={{ marginLeft: 'auto' }} |
| 27 |
> |
| 28 |
{children} |
| 29 |
</Button> |
| 30 |
</PanelRow> |
| 31 |
); |
| 32 |
} |
| 33 |
|