| 1 |
import { useState } from '@wordpress/element'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
const Skipped = () => ( |
| 5 |
<div className="flex w-full items-start gap-2.5 px-2.5 py-2"> |
| 6 |
<div className="w-7 shrink-0" /> |
| 7 |
<div className="flex min-w-0 flex-1 flex-col gap-1"> |
| 8 |
<div className="flex items-center gap-2 border-l-4 border-l-wp-notice-neutral bg-gray-50 p-3 text-gray-900"> |
| 9 |
<div className="text-sm"> |
| 10 |
{__('Image selection skipped', 'extendify-local')} |
| 11 |
</div> |
| 12 |
</div> |
| 13 |
</div> |
| 14 |
</div> |
| 15 |
); |
| 16 |
|
| 17 |
const Failed = () => ( |
| 18 |
<div className="flex w-full items-start gap-2.5 px-2.5 py-2"> |
| 19 |
<div className="w-7 shrink-0" /> |
| 20 |
<div className="flex min-w-0 flex-1 flex-col gap-1"> |
| 21 |
<div className="flex items-center gap-2 border-l-4 border-l-wp-alert-red bg-wp-notice-error p-3 text-gray-900"> |
| 22 |
<div className="text-sm"> |
| 23 |
{__("The image couldn't be added", 'extendify-local')} |
| 24 |
</div> |
| 25 |
</div> |
| 26 |
</div> |
| 27 |
</div> |
| 28 |
); |
| 29 |
|
| 30 |
// A run that moved past the picker would otherwise render nothing. |
| 31 |
export const ImageToolMessage = ({ url, failed }) => { |
| 32 |
const [removed, setRemoved] = useState(false); |
| 33 |
|
| 34 |
if (!url) return failed ? <Failed /> : <Skipped />; |
| 35 |
|
| 36 |
if (removed) { |
| 37 |
return ( |
| 38 |
<div className="mb-4 ms-2 me-2 flex h-24 w-24 items-center justify-center rounded-lg border border-gray-300 bg-gray-50 p-2 text-center text-xs text-gray-700"> |
| 39 |
{__('Image removed', 'extendify-local')} |
| 40 |
</div> |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
return ( |
| 45 |
<div className="mb-4 ms-2 me-2"> |
| 46 |
<img |
| 47 |
className="m-0 h-24 w-auto max-w-full rounded-lg border border-gray-300 object-contain" |
| 48 |
src={url} |
| 49 |
alt={__('Selected image', 'extendify-local')} |
| 50 |
onError={() => setRemoved(true)} |
| 51 |
/> |
| 52 |
</div> |
| 53 |
); |
| 54 |
}; |
| 55 |
|