| 1 |
import { Button } from '@wordpress/components' |
| 2 |
import { useEffect } from '@wordpress/element' |
| 3 |
import { __, sprintf } from '@wordpress/i18n' |
| 4 |
import { Icon } from '@wordpress/icons' |
| 5 |
import { useUserStore, useUserStoreReady } from '@library/state/User' |
| 6 |
import { openModal } from '@library/util/general' |
| 7 |
import { brandMark } from './icons' |
| 8 |
|
| 9 |
export const MainButtonWrapper = () => { |
| 10 |
const hasPendingNewImports = useUserStore( |
| 11 |
(state) => state.runningImports === -1, |
| 12 |
) |
| 13 |
const userDataReady = useUserStoreReady() |
| 14 |
|
| 15 |
useEffect(() => { |
| 16 |
if (userDataReady && hasPendingNewImports) { |
| 17 |
useUserStore.setState({ runningImports: 0 }) |
| 18 |
} |
| 19 |
}, [hasPendingNewImports, userDataReady]) |
| 20 |
|
| 21 |
return <MainButton text={__('Design Library', 'extendify')} /> |
| 22 |
} |
| 23 |
|
| 24 |
const MainButton = ({ buttonRef, text }) => ( |
| 25 |
<div className="extendify"> |
| 26 |
<Button |
| 27 |
variant="primary" |
| 28 |
ref={buttonRef} |
| 29 |
className="h-8 xs:h-9 px-1 min-w-0 xs:pl-2 xs:pr-3 sm:ml-2" |
| 30 |
onClick={() => openModal('main-button')} |
| 31 |
id="extendify-templates-inserter-btn" |
| 32 |
icon={ |
| 33 |
<Icon icon={brandMark} size={24} style={{ marginRight: 0 }} /> |
| 34 |
}> |
| 35 |
<span className="hidden xs:inline ml-1">{text}</span> |
| 36 |
</Button> |
| 37 |
</div> |
| 38 |
) |
| 39 |
|
| 40 |
export const CtaButton = () => ( |
| 41 |
<Button |
| 42 |
id="extendify-cta-button" |
| 43 |
style={{ |
| 44 |
margin: '1rem 1rem 0', |
| 45 |
width: 'calc(100% - 2rem)', |
| 46 |
justifyContent: ' center', |
| 47 |
}} |
| 48 |
onClick={() => openModal('patterns-cta')} |
| 49 |
isSecondary> |
| 50 |
{sprintf( |
| 51 |
// translators: %s: Extendify Library term. |
| 52 |
__('Discover patterns in the %s', 'extendify'), |
| 53 |
'Extendify Library', |
| 54 |
)} |
| 55 |
</Button> |
| 56 |
) |
| 57 |
|