Dialog.js
61 lines
| 1 | import {__} from '@wordpress/i18n'; |
| 2 | import { useEffect } from '@wordpress/element'; |
| 3 | import './Dialog.scss' |
| 4 | import reachLogo from '../reach-logo.svg'; |
| 5 | |
| 6 | const SIDEBAR_SELECTORS = [ |
| 7 | '.interface-navigable-region.interface-interface-skeleton__secondary-sidebar', |
| 8 | '.spectra-ee-quick-access-container .spectra-ee-quick-access__sidebar' |
| 9 | ]; |
| 10 | |
| 11 | const Dialog = ( { onClose } ) => { |
| 12 | |
| 13 | useEffect(() => { |
| 14 | const sidebars = SIDEBAR_SELECTORS |
| 15 | .map(selector => document.querySelector(selector)) |
| 16 | .filter(Boolean); |
| 17 | |
| 18 | sidebars.forEach(sidebar => { |
| 19 | sidebar.style.zIndex = '0'; |
| 20 | }); |
| 21 | |
| 22 | const timeoutId = setTimeout(() => { |
| 23 | onClose(); |
| 24 | }, 10000); |
| 25 | |
| 26 | return () => { |
| 27 | sidebars.forEach(sidebar => { |
| 28 | sidebar.style.zIndex = ''; |
| 29 | }); |
| 30 | |
| 31 | clearTimeout(timeoutId); |
| 32 | }; |
| 33 | }, []); |
| 34 | |
| 35 | return <div id="hostinger-reach-block-dialog" className="hostinger-reach-block-dialog"> |
| 36 | <div className="hostinger-reach-block-dialog__close" onClick={onClose}></div> |
| 37 | <div className="hostinger-reach-block-dialog__logo"> |
| 38 | <img src={reachLogo} alt={__('Hostinger Reach Logo', 'hostinger-reach')} /> |
| 39 | </div> |
| 40 | <p>{ __('Your form is ready. Go to Reach to complete setup and create templates.', 'hostinger-reach') }</p> |
| 41 | <div className="hostinger-reach-block-dialog__actions"> |
| 42 | <Button link="https://reach.hostinger.com/" label={__('Go to Reach', 'hostinger-reach')} /> |
| 43 | </div> |
| 44 | </div> |
| 45 | } |
| 46 | |
| 47 | const Button = ({ link, label }) => { |
| 48 | return <div className="hostinger-reach-block-dialog__button"> |
| 49 | <a target="_blank" href={link}>{ label }</a> |
| 50 | <div className="hostinger-reach-block-dialog__button_indicator"> |
| 51 | <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 52 | <path d="M2.5 5.24792C2.5 3.72914 3.73122 2.49792 5.25 2.49792H6C6.41421 2.49792 6.75 2.83371 6.75 3.24792C6.75 3.66214 6.41421 3.99792 6 3.99792H5.25C4.55964 3.99792 4 4.55757 4 5.24792V10.686C4 11.3764 4.55964 11.936 5.25 11.936H10.7508C11.4411 11.936 12.0008 11.3764 12.0008 10.686V10.0001C12.0008 9.58591 12.3366 9.25012 12.7508 9.25012C13.165 9.25012 13.5008 9.58591 13.5008 10.0001V10.686C13.5008 12.2048 12.2696 13.436 10.7508 13.436H5.25C3.73122 13.436 2.5 12.2048 2.5 10.686V5.24792Z" fill="#1D1E20"/> |
| 53 | <path d="M12 5.06089L8.03033 9.03056C7.73744 9.32345 7.26256 9.32345 6.96967 9.03056C6.67678 8.73766 6.67678 8.26279 6.96967 7.9699L10.9393 4.00023H9C8.58579 4.00023 8.25 3.66444 8.25 3.25023C8.25 2.83601 8.58579 2.50023 9 2.50023L12.25 2.50023C12.9404 2.50023 13.5 3.05987 13.5 3.75023V7.00023C13.5 7.41444 13.1642 7.75023 12.75 7.75023C12.3358 7.75023 12 7.41444 12 7.00023V5.06089Z" fill="#1D1E20"/> |
| 54 | </svg> |
| 55 | </div> |
| 56 | </div> |
| 57 | } |
| 58 | |
| 59 | |
| 60 | export default Dialog; |
| 61 |