PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / src / apps / js / blocks / course-elements / course-duration / edit.js

edit.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.8, at assets/src/apps/js/blocks/course-elements/course-duration/edit.js

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 courseDuration =
11 lpCourseData?.duration ||
12 '<div class="course-count-duration"><span class="course-duration">10 Weeks</span></div>';
13
14 return (
15 <>
16 <InspectorControls>
17 <PanelBody title={ __( 'Settings', 'learnpress' ) }>
18 <ToggleControl
19 label={ __( 'Show Label', 'learnpress' ) }
20 checked={ attributes.showLabel }
21 onChange={ ( value ) => {
22 setAttributes( {
23 showLabel: value,
24 } );
25 } }
26 />
27 <ToggleControl
28 label={ __( 'Show Icon', 'learnpress' ) }
29 checked={ attributes.showIcon }
30 onChange={ ( value ) => {
31 setAttributes( {
32 showIcon: value,
33 } );
34 } }
35 />
36 </PanelBody>
37 </InspectorControls>
38
39 <div { ...blockProps }>
40 <div className="info-meta-item">
41 <span className="info-meta-left">
42 { props.attributes.showIcon && (
43 <span dangerouslySetInnerHTML={ { __html: '<i class="lp-icon-clock-o"></i>' } } />
44 ) }
45 { props.attributes.showLabel ? 'Duration:' : '' }
46 </span>
47 <span
48 className="info-meta-right"
49 dangerouslySetInnerHTML={ {
50 __html: courseDuration,
51 } }
52 ></span>
53 </div>
54 </div>
55 </>
56 );
57 };
58
59 export default Edit;
60