index.js
52 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | const { __ } = wp.i18n; |
| 5 | |
| 6 | /** |
| 7 | * Internal dependencies |
| 8 | */ |
| 9 | import GiveHelpLink from '../help-link'; |
| 10 | import PlaceholderContainerAnimation from '../container-placeholder-animation'; |
| 11 | import './style.scss'; |
| 12 | |
| 13 | const GiveBlankSlate = ( props ) => { |
| 14 | const { |
| 15 | noIcon, |
| 16 | isLoader, |
| 17 | title, |
| 18 | description, |
| 19 | children, |
| 20 | helpLink, |
| 21 | } = props; |
| 22 | |
| 23 | // @todo: do not hard code wp content url that can be configure. |
| 24 | const giveLogo = '/wp-content/plugins/Give/assets/dist/images/give-icon-full-circle.svg'; |
| 25 | |
| 26 | const blockLoading = ( |
| 27 | <PlaceholderContainerAnimation /> |
| 28 | ); |
| 29 | |
| 30 | const blockLoaded = ( |
| 31 | <div className="block-loaded"> |
| 32 | { !! title && ( <h2 className="give-blank-slate__heading">{ title }</h2> ) } |
| 33 | { !! description && ( <p className="give-blank-slate__message">{ description }</p> ) } |
| 34 | { children } |
| 35 | { !! helpLink && ( <GiveHelpLink /> ) } |
| 36 | </div> |
| 37 | ); |
| 38 | |
| 39 | return ( |
| 40 | <div className="give-blank-slate"> |
| 41 | { ! noIcon && ( |
| 42 | <img className="give-blank-slate__image" |
| 43 | src={ `${ wpApiSettings.schema.url }${ giveLogo }` } |
| 44 | alt={ __( 'Give Icon' ) } /> |
| 45 | ) } |
| 46 | { !! isLoader ? blockLoading : blockLoaded } |
| 47 | </div> |
| 48 | ); |
| 49 | }; |
| 50 | |
| 51 | export default GiveBlankSlate; |
| 52 |