| 1 |
|
| 2 |
import { useBlockProps } from '@wordpress/block-editor'; |
| 3 |
import { Placeholder } from '@wordpress/components'; |
| 4 |
import { __, sprintf } from '@wordpress/i18n'; |
| 5 |
import { page } from '@wordpress/icons'; |
| 6 |
|
| 7 |
const TEMPLATES = { |
| 8 |
'single-course': { |
| 9 |
title: __( 'LearnPress Single Course Template', 'learnpress' ), |
| 10 |
placeholder: 'single-course', |
| 11 |
}, |
| 12 |
'archive-course': { |
| 13 |
title: __( 'LearnPress Course Archive Template', 'learnpress' ), |
| 14 |
placeholder: 'archive-course', |
| 15 |
}, |
| 16 |
}; |
| 17 |
|
| 18 |
export default function Edit( { attributes } ) { |
| 19 |
const blockProps = useBlockProps(); |
| 20 |
const templateTitle = TEMPLATES[ attributes.template ]?.title ?? attributes.template; |
| 21 |
|
| 22 |
return ( |
| 23 |
<div { ...blockProps }> |
| 24 |
<Placeholder |
| 25 |
icon={ page } |
| 26 |
label={ templateTitle } |
| 27 |
className="wp-block-learnpress-template__placeholder" |
| 28 |
> |
| 29 |
<div className="wp-block-learnpress-template__placeholder-inner"> |
| 30 |
{ sprintf( |
| 31 |
/* translators: %s is the template title */ |
| 32 |
__( |
| 33 |
'This is an editor placeholder for the %s. This will be replaced by the template in your store and displayed with your course image(s), title, price, and so on. You can move this placeholder around and add further blocks around it to extend the template.', |
| 34 |
'learnpress' |
| 35 |
), |
| 36 |
templateTitle |
| 37 |
) } |
| 38 |
</div> |
| 39 |
</Placeholder> |
| 40 |
</div> |
| 41 |
); |
| 42 |
} |
| 43 |
|