| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; |
| 3 |
import { PanelBody, ToggleControl } from '@wordpress/components'; |
| 4 |
import { useState, useEffect } from '@wordpress/element'; |
| 5 |
|
| 6 |
const Edit = ( props ) => { |
| 7 |
const blockProps = useBlockProps(); |
| 8 |
const { attributes, setAttributes, context } = props; |
| 9 |
const { lpCourseData } = context; |
| 10 |
const courseDelivery = '<span class="course-deliver-type">Private 1-1</span>'; |
| 11 |
|
| 12 |
return ( |
| 13 |
<> |
| 14 |
<InspectorControls> |
| 15 |
<PanelBody title={ __( 'Settings', 'learnpress' ) }> |
| 16 |
<ToggleControl |
| 17 |
label={ __( 'Show Label', 'learnpress' ) } |
| 18 |
checked={ attributes.showLabel } |
| 19 |
onChange={ ( value ) => { |
| 20 |
setAttributes( { |
| 21 |
showLabel: value, |
| 22 |
} ); |
| 23 |
} } |
| 24 |
/> |
| 25 |
<ToggleControl |
| 26 |
label={ __( 'Show Icon', 'learnpress' ) } |
| 27 |
checked={ attributes.showIcon } |
| 28 |
onChange={ ( value ) => { |
| 29 |
setAttributes( { |
| 30 |
showIcon: value, |
| 31 |
} ); |
| 32 |
} } |
| 33 |
/> |
| 34 |
</PanelBody> |
| 35 |
</InspectorControls> |
| 36 |
|
| 37 |
<div { ...blockProps }> |
| 38 |
<div className="info-meta-item"> |
| 39 |
<span className="info-meta-left"> |
| 40 |
{ attributes.showIcon && ( |
| 41 |
<span dangerouslySetInnerHTML={ { __html: '<i class="lp-icon-bookmark-o"></i>' } } /> |
| 42 |
) } |
| 43 |
{ attributes.showLabel ? __( 'Delivery type:', 'learnpress' ) : '' } |
| 44 |
</span> |
| 45 |
<span |
| 46 |
className="info-meta-right" |
| 47 |
dangerouslySetInnerHTML={ { |
| 48 |
__html: courseDelivery, |
| 49 |
} } |
| 50 |
></span> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
</> |
| 54 |
); |
| 55 |
}; |
| 56 |
|
| 57 |
export default Edit; |
| 58 |
|