← All changes
|
assets/src/apps/js/blocks/course-elements/course-student/edit.js
+60
-60
4.3.8
→
4.4.9
View file →
| @@ -1,60 +1,60 @@ | ||
| 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 courseStudent = | |
| 11 | - lpCourseData?.student || | |
| 12 | - '<div class="course-count-student"><div class="course-count-student">3 Student</div></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 | - <div { ...blockProps }> | |
| 39 | - <div className="info-meta-item"> | |
| 40 | - <span className="info-meta-left"> | |
| 41 | - { attributes.showIcon && ( | |
| 42 | - <span | |
| 43 | - dangerouslySetInnerHTML={ { __html: '<i class="lp-icon-user-graduate"></i>' } } | |
| 44 | - /> | |
| 45 | - ) } | |
| 46 | - { attributes.showLabel ? 'Student:' : '' } | |
| 47 | - </span> | |
| 48 | - <span | |
| 49 | - className="info-meta-right" | |
| 50 | - dangerouslySetInnerHTML={ { | |
| 51 | - __html: courseStudent, | |
| 52 | - } } | |
| 53 | - ></span> | |
| 54 | - </div> | |
| 55 | - </div> | |
| 56 | - </> | |
| 57 | - ); | |
| 58 | -}; | |
| 59 | - | |
| 60 | -export default Edit; | |
| 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 courseStudent = | |
| 11 | + lpCourseData?.student || | |
| 12 | + '<div class="course-count-student"><div class="course-count-student">3 Student</div></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 | + <div { ...blockProps }> | |
| 39 | + <div className="info-meta-item"> | |
| 40 | + <span className="info-meta-left"> | |
| 41 | + { attributes.showIcon && ( | |
| 42 | + <span | |
| 43 | + dangerouslySetInnerHTML={ { __html: '<i class="lp-icon-user-graduate"></i>' } } | |
| 44 | + /> | |
| 45 | + ) } | |
| 46 | + { attributes.showLabel ? 'Student:' : '' } | |
| 47 | + </span> | |
| 48 | + <span | |
| 49 | + className="info-meta-right" | |
| 50 | + dangerouslySetInnerHTML={ { | |
| 51 | + __html: courseStudent, | |
| 52 | + } } | |
| 53 | + ></span> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + </> | |
| 57 | + ); | |
| 58 | +}; | |
| 59 | + | |
| 60 | +export default Edit; | |