| 1 |
import FontIconPicker from '@fonticonpicker/react-fonticonpicker'; |
| 2 |
import React, { useLayoutEffect } from 'react'; |
| 3 |
import styles from './editor.lazy.scss'; |
| 4 |
import renderSVG from '@Controls/renderIcon'; |
| 5 |
import { __ } from '@wordpress/i18n'; |
| 6 |
|
| 7 |
const UAGIconPicker = ( props ) => { |
| 8 |
// Add and remove the CSS on the drop and remove of the component. |
| 9 |
useLayoutEffect( () => { |
| 10 |
styles.use(); |
| 11 |
return () => { |
| 12 |
styles.unuse(); |
| 13 |
}; |
| 14 |
}, [] ); |
| 15 |
|
| 16 |
return ( |
| 17 |
<div className="components-base-control uag-icon-picker"> |
| 18 |
<span className="uag-control-label"> |
| 19 |
{ props?.label || |
| 20 |
__( 'Icon', 'ultimate-addons-for-gutenberg' ) } |
| 21 |
</span> |
| 22 |
<FontIconPicker |
| 23 |
icons={ props?.icons || wp.UAGBSvgIcons } |
| 24 |
renderFunc={ renderSVG } |
| 25 |
theme="default" |
| 26 |
value={ props.value } |
| 27 |
onChange={ props?.onChange } |
| 28 |
isMulti={ props.isMulti || false } |
| 29 |
noSelectedPlaceholder={ |
| 30 |
props.noSelectedPlaceholder || |
| 31 |
__( 'Select Icon', 'ultimate-addons-for-gutenberg' ) |
| 32 |
} |
| 33 |
/> |
| 34 |
{ props.help && ( |
| 35 |
<p className="uag-control-help-notice">{ props.help }</p> |
| 36 |
) } |
| 37 |
</div> |
| 38 |
); |
| 39 |
}; |
| 40 |
export default UAGIconPicker; |
| 41 |
|