Skip to content

Commit fbe4e1f

Browse files
authored
Merge pull request #3867 from reduxframework/update-extendify-9r22mu0
Update Extendify Library
2 parents ed781b1 + 2154d38 commit fbe4e1f

31 files changed

+439
-306
lines changed
2.53 KB
Loading

extendify-sdk/public/build/extendify.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extendify-sdk/public/build/extendify.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extendify-sdk/readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: extendify, richtabor, kbat82, clubkert, arturgrabo
33
Tags: page builder, editor, patterns, drag-and-drop, blocks, visual editor, wysiwyg, design, website builder, landing page builder, front-end builder
44
Requires at least: 5.4
55
Tested up to: 5.9.0
6-
Stable tag: 0.3.1
6+
Stable tag: 0.4.0
77
Requires PHP: 5.6
88
License: GPLv2
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -120,6 +120,12 @@ Nope! Extendify imports lightweight block-based content that is served directly
120120

121121
== Changelog ==
122122

123+
= 0.4.0 - 2022-02-08 =
124+
- Enhance layout view with autoscroll
125+
- Improve modal layout design consistency
126+
- Remove NeedsRegistrationModal
127+
- Add various performance improvements
128+
123129
= 0.3.1 - 2022-01-26 =
124130
- Add singular value when import count is 1
125131
- Remove destructuring within block filters

extendify-sdk/src/app.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
@apply focus:border-transparent focus:outline-none focus:shadow-none;
2525
}
2626

27+
div.extendify button.extendify-skip-to-sr-link:focus {
28+
@apply fixed z-high top-0 bg-white p-4;
29+
}
30+
2731
.button-extendify-main {
2832
@apply bg-extendify-main button-focus cursor-pointer transition duration-200 p-1.5 px-3 text-white hover:text-white no-underline hover:bg-extendify-main-dark active:bg-gray-900 active:text-white focus:text-white whitespace-nowrap rounded text-base;
2933
}
@@ -156,3 +160,20 @@
156160
.is-template--inactive::before {
157161
border-color: #fdeab6;
158162
}
163+
164+
.extendify-tooltip-default:not(.is-without-arrow)[data-y-axis="bottom"]::after {
165+
border-bottom-color: #1e1e1e;
166+
}
167+
.extendify-tooltip-default:not(.is-without-arrow)::before {
168+
@apply border-transparent;
169+
}
170+
.extendify-tooltip-default:not(.is-without-arrow) .components-popover__content {
171+
min-width: 250px;
172+
@apply border-transparent bg-gray-900 text-white p-4;
173+
}
174+
.extendify-bottom-arrow::after {
175+
content: "";
176+
bottom: -15px;
177+
@apply border-8 border-transparent w-0 h-0 inline-block absolute transform -translate-y-px;
178+
border-top-color: #1e1e1e !important;
179+
}

extendify-sdk/src/buttons.js

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
11
import { __ } from '@wordpress/i18n'
2-
import { renderToString, render } from '@wordpress/element'
2+
import { render } from '@wordpress/element'
33
import { registerPlugin } from '@wordpress/plugins'
4-
import { openModal } from './util/general'
54
import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post'
65
import { Icon } from '@wordpress/icons'
76
import { brandMark } from './components/icons/'
87
import LibraryAccessModal from './components/LibraryAccessModal'
8+
import { CtaButton, MainButton } from './components/MainButtons'
99

10-
const openLibrary = (event) => {
11-
openModal(
12-
event.target.closest('[data-extendify-identifier]')?.dataset
13-
?.extendifyIdentifier,
14-
)
15-
}
16-
17-
// This returns true if the user object is null (Library never opened), or if it's enabled in the user settings
18-
const isAdmin = () =>
19-
window.extendifyData.user === null ||
20-
window.extendifyData?.user?.state?.isAdmin
10+
const userState = window.extendifyData?.user?.state
11+
const isAdmin = () => window.extendifyData.user === null || userState?.isAdmin
2112
const isGlobalLibraryEnabled = () =>
2213
window.extendifyData.sitesettings === null ||
2314
window.extendifyData?.sitesettings?.state?.enabled
2415
const isLibraryEnabled = () =>
2516
window.extendifyData.user === null
2617
? isGlobalLibraryEnabled()
27-
: window.extendifyData?.user?.state?.enabled
28-
29-
const mainButton = (
30-
<div id="extendify-templates-inserter" className="extendify">
31-
<button
32-
style="padding:4px 12px; height: 34px;"
33-
type="button"
34-
data-extendify-identifier="main-button"
35-
id="extendify-templates-inserter-btn"
36-
className="components-button bg-wp-theme-500 hover:bg-wp-theme-600 border-color-wp-theme-500 text-white ml-1">
37-
<Icon icon={brandMark} size={24} className="-ml-1 mr-1" />
38-
{__('Library', 'extendify')}
39-
</button>
40-
</div>
41-
)
18+
: userState?.enabled
4219

4320
// Add the MAIN button when Gutenberg is available and ready
4421
if (window._wpLoadBlockEditor) {
@@ -47,20 +24,21 @@ if (window._wpLoadBlockEditor) {
4724
if (!isGlobalLibraryEnabled() && !isAdmin()) {
4825
return
4926
}
50-
51-
// Redundant extra check added because of a bug where the above check wasn't working
52-
if (document.getElementById('extendify-templates-inserter-btn')) {
27+
if (document.getElementById('extendify-templates-inserter')) {
5328
return
5429
}
5530
if (!document.querySelector('.edit-post-header-toolbar')) {
5631
return
5732
}
33+
const buttonContainer = Object.assign(
34+
document.createElement('div'),
35+
{ id: 'extendify-templates-inserter' },
36+
)
5837
document
5938
.querySelector('.edit-post-header-toolbar')
60-
.insertAdjacentHTML('beforeend', renderToString(mainButton))
61-
document
62-
.getElementById('extendify-templates-inserter-btn')
63-
.addEventListener('click', openLibrary)
39+
.append(buttonContainer)
40+
render(<MainButton />, buttonContainer)
41+
6442
if (!isLibraryEnabled()) {
6543
document
6644
.getElementById('extendify-templates-inserter-btn')
@@ -73,9 +51,8 @@ if (window._wpLoadBlockEditor) {
7351

7452
// The CTA button inside patterns
7553
if (window._wpLoadBlockEditor) {
76-
const finish = window.wp.data.subscribe(() => {
54+
window.wp.data.subscribe(() => {
7755
requestAnimationFrame(() => {
78-
// Redundant extra check added because of a bug where the above check wasn't working
7956
if (!isGlobalLibraryEnabled() && !isAdmin()) {
8057
return
8158
}
@@ -85,27 +62,15 @@ if (window._wpLoadBlockEditor) {
8562
if (document.getElementById('extendify-cta-button')) {
8663
return
8764
}
88-
const ctaButton = (
89-
<div>
90-
<button
91-
id="extendify-cta-button"
92-
style="margin:1rem 1rem 0;width: calc(100% - 2rem);justify-content: center;"
93-
data-extendify-identifier="patterns-cta"
94-
className="components-button is-secondary">
95-
{__(
96-
'Discover patterns in Extendify Library',
97-
'extendify',
98-
)}
99-
</button>
100-
</div>
65+
const ctaButtonContainer = Object.assign(
66+
document.createElement('div'),
67+
{ id: 'extendify-cta-button-container' },
10168
)
69+
10270
document
10371
.querySelector('[id$=patterns-view]')
104-
.insertAdjacentHTML('afterbegin', renderToString(ctaButton))
105-
document
106-
.getElementById('extendify-cta-button')
107-
.addEventListener('click', openLibrary)
108-
finish()
72+
.prepend(ctaButtonContainer)
73+
render(<CtaButton />, ctaButtonContainer)
10974
})
11075
})
11176
}
Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import classnames from 'classnames'
22
import { Icon } from '@wordpress/icons'
33
import { __, _n, sprintf } from '@wordpress/i18n'
4-
import { useEffect } from '@wordpress/element'
4+
import { useEffect, memo, useRef } from '@wordpress/element'
55
import { alert, download } from './icons/'
66
import { useUserStore } from '../state/User'
77
import { User as UserApi } from '../api/User'
88
import { growthArrow } from './icons'
9+
import { safeHTML } from '@wordpress/dom'
910

10-
export const ImportCounter = () => {
11+
export const ImportCounter = memo(function ImportCounter() {
1112
const remainingImports = useUserStore((state) => state.remainingImports)
1213
const allowedImports = useUserStore((state) => state.allowedImports)
1314
const count = remainingImports()
@@ -17,9 +18,10 @@ export const ImportCounter = () => {
1718
? 'bg-extendify-main hover:bg-extendify-main-dark'
1819
: 'bg-extendify-alert'
1920
const icon = status === 'has-imports' ? download : alert
21+
const buttonRef = useRef()
2022

2123
useEffect(() => {
22-
if (!allowedImports) {
24+
if (allowedImports < 1 || !allowedImports) {
2325
const fallback = 5
2426
UserApi.allowedImports()
2527
.then((allowedImports) => {
@@ -39,29 +41,61 @@ export const ImportCounter = () => {
3941
}
4042

4143
return (
42-
<a
43-
target="_blank"
44-
rel="noreferrer"
45-
className={classnames(
46-
backgroundColor,
47-
'hidden sm:flex w-full no-underline button-focus text-sm justify-between py-3 px-4 text-white rounded',
48-
)}
49-
href={`https://www.extendify.com/pricing/?utm_source=${encodeURIComponent(
50-
window.extendifyData.sdk_partner,
51-
)}&utm_medium=library&utm_campaign=import-counter&utm_content=get-more&utm_term=${status}`}>
52-
<div className="flex items-center space-x-2 no-underline text-xs">
53-
<Icon icon={icon} size={14} />
54-
<span>
55-
{sprintf(
56-
_n('%s Import', '%s Imports', count, 'extendify'),
57-
count,
58-
)}
44+
// tabIndex for group focus animations
45+
<div tabIndex="0" className="group relative">
46+
<a
47+
target="_blank"
48+
ref={buttonRef}
49+
rel="noreferrer"
50+
className={classnames(
51+
backgroundColor,
52+
'hidden sm:flex w-full no-underline button-focus text-sm justify-between py-3 px-4 text-white rounded',
53+
)}
54+
href={`https://www.extendify.com/pricing/?utm_source=${encodeURIComponent(
55+
window.extendifyData.sdk_partner,
56+
)}&utm_medium=library&utm_campaign=import-counter&utm_content=get-more&utm_term=${status}`}>
57+
<span className="flex items-center space-x-2 no-underline text-xs">
58+
<Icon icon={icon} size={14} />
59+
<span>
60+
{sprintf(
61+
_n('%s Import', '%s Imports', count, 'extendify'),
62+
count,
63+
)}
64+
</span>
5965
</span>
66+
<span className="text-white text-sm no-underline font-medium outline-none flex items-center">
67+
{__('Get more', 'extendify')}
68+
<Icon icon={growthArrow} size={24} className="-mr-1.5" />
69+
</span>
70+
</a>
71+
<div
72+
className="invisible opacity-0 -translate-y-full absolute duration-300 delay-200 ease-in-out group-hover:-top-2.5 group-hover:opacity-100 group-hover:visible group-focus:-top-2.5 group-focus:opacity-100 group-focus:visible top-0 transform transition-all w-full extendify-bottom-arrow shadow-md"
73+
tabIndex="-1">
74+
<a
75+
href={`https://www.extendify.com/pricing/?utm_source=${encodeURIComponent(
76+
window.extendifyData.sdk_partner,
77+
)}&utm_medium=library&utm_campaign=import-counter-tooltip&utm_content=get-50-off&utm_term=${status}`}
78+
className="block bg-gray-900 text-white p-4 no-underline rounded bg-cover"
79+
style={{
80+
backgroundImage: `url(${window.extendifyData.asset_path}/logo-tips.png)`,
81+
}}>
82+
<span
83+
dangerouslySetInnerHTML={{
84+
__html: safeHTML(
85+
sprintf(
86+
__(
87+
'%1$sGet %2$s off%3$s Extendify Pro when you upgrade today!',
88+
'extendify',
89+
),
90+
'<strong>',
91+
'50%',
92+
'</strong>',
93+
),
94+
),
95+
}}
96+
/>
97+
</a>
6098
</div>
61-
<span className="text-white text-sm no-underline font-medium outline-none flex items-center">
62-
{__('Get more', 'extendify')}
63-
<Icon icon={growthArrow} size={24} className="-mr-1.5" />
64-
</span>
65-
</a>
99+
</div>
66100
)
67-
}
101+
})

extendify-sdk/src/components/ImportTemplateBlock.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ import { NoImportModal } from './modals/NoImportModal'
1414
import { ProModal } from './modals/ProModal'
1515

1616
const canImportMiddleware = Middleware([
17-
'NeedsRegistrationModal',
1817
'hasRequiredPlugins',
1918
'hasPluginsActivated',
2019
])
2120

22-
export function ImportTemplateBlock({ template }) {
21+
export function ImportTemplateBlock({ template, maxHeight }) {
2322
const importButtonRef = useRef(null)
2423
const once = useRef(false)
2524
const hasAvailableImports = useUserStore(
@@ -35,6 +34,7 @@ export function ImportTemplateBlock({ template }) {
3534
)
3635
const [loaded, setLoaded] = useState(false)
3736
const devMode = useIsDevMode()
37+
const [topValue, setTopValue] = useState(0)
3838

3939
const focusTrapInnerBlocks = () => {
4040
if (once.current) return
@@ -110,7 +110,7 @@ export function ImportTemplateBlock({ template }) {
110110
)
111111
const id = window.setTimeout(() => {
112112
frame.style.height = height + 'px'
113-
}, 1000)
113+
}, 2000)
114114
timeouts.push(id)
115115
}
116116
}
@@ -134,24 +134,53 @@ export function ImportTemplateBlock({ template }) {
134134
}
135135
}, [])
136136

137+
useEffect(() => {
138+
if (!Number.isInteger(maxHeight)) return
139+
const button = importButtonRef.current
140+
const handleIn = () => {
141+
// The live component changes over time so easier to query on demand
142+
const height = button.offsetHeight
143+
button.style.transitionDuration = height * 1.5 + 'ms'
144+
setTopValue(Math.abs(height - maxHeight) * -1)
145+
}
146+
const handleOut = () => {
147+
const height = button.offsetHeight
148+
button.style.transitionDuration = height / 1.5 + 'ms'
149+
setTopValue(0)
150+
}
151+
button.addEventListener('focus', handleIn)
152+
button.addEventListener('mouseenter', handleIn)
153+
button.addEventListener('blur', handleOut)
154+
button.addEventListener('mouseleave', handleOut)
155+
return () => {
156+
button.removeEventListener('focus', handleIn)
157+
button.removeEventListener('mouseenter', handleIn)
158+
button.removeEventListener('blur', handleOut)
159+
button.removeEventListener('mouseleave', handleOut)
160+
}
161+
}, [maxHeight])
162+
137163
return (
138164
<div className="relative group">
139165
<div
140166
role="button"
141167
tabIndex="0"
142-
ref={importButtonRef}
143168
aria-label={sprintf(
144169
__('Press to import %s', 'extendify'),
145170
template?.fields?.type,
146171
)}
147-
className="mb-6 md:mb-8 cursor-pointer button-focus"
172+
style={{ maxHeight }}
173+
className="m-0 cursor-pointer button-focus ease-in-out relative overflow-hidden bg-gray-100"
148174
onFocus={focusTrapInnerBlocks}
149175
onClick={importTemplate}
150176
onKeyDown={handleKeyDown}>
151177
<div
178+
ref={importButtonRef}
179+
style={{ top: topValue, transitionProperty: 'all' }}
152180
className={classNames('with-light-shadow relative', {
153181
[`is-template--${template.fields.status}`]:
154182
template?.fields?.status && devMode,
183+
'p-6 md:p-8': Number.isInteger(maxHeight),
155184
})}>
156185
<BlockPreview
157186
blocks={blocks}

0 commit comments

Comments
 (0)