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