PluginProbe
Extendify / 0.6.0
Extendify v0.6.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / components / SidebarNotice.js

SidebarNotice.js in Extendify 0.6.0, at src/components/SidebarNotice.js

91 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { safeHTML } from '@wordpress/dom'
2 import { useEffect, memo } from '@wordpress/element'
3 import { __, _n, _x, sprintf } from '@wordpress/i18n'
4 import { Icon } from '@wordpress/icons'
5 import classNames from 'classnames'
6 import { General } from '@extendify/api/General'
7 import { User as UserApi } from '@extendify/api/User'
8 import { useUserStore } from '@extendify/state/User'
9 import { brandMark } from './icons'
10
11 export const SidebarNotice = memo(function SidebarNotice() {
12 const remainingImports = useUserStore((state) => state.remainingImports)
13 const allowedImports = useUserStore((state) => state.allowedImports)
14 const count = remainingImports()
15 const link = `https://www.extendify.com/pricing/?utm_source=${encodeURIComponent(
16 window.extendifyData.sdk_partner,
17 )}&utm_medium=library&utm_campaign=import-counter&utm_content=get-more&utm_term=${
18 count > 0 ? 'has-imports' : 'no-imports'
19 }&utm_group=${useUserStore.getState().activeTestGroupsUtmValue()}`
20
21 useEffect(() => {
22 if (allowedImports < 1 || !allowedImports) {
23 const fallback = 5
24 UserApi.allowedImports()
25 .then((allowedImports) => {
26 allowedImports = /^[1-9]\d*$/.test(allowedImports)
27 ? allowedImports
28 : fallback
29 useUserStore.setState({ allowedImports })
30 })
31 .catch(() =>
32 useUserStore.setState({ allowedImports: fallback }),
33 )
34 }
35 }, [allowedImports])
36
37 if (!allowedImports) {
38 return null
39 }
40
41 return (
42 <a
43 target="_blank"
44 className="absolute bottom-4 left-0 mx-5 block bg-white rounded border-solid border border-gray-200 p-4 text-left no-underline group button-focus"
45 rel="noreferrer"
46 onClick={async () => await General.ping('fp-sb-click')}
47 href={link}>
48 <span className="flex -ml-1.5 space-x-1.5">
49 <Icon icon={brandMark} />
50 <span className="mb-1 text-gray-800 font-medium text-sm">
51 {__('Free Plan', 'extendify')}
52 </span>
53 </span>
54 <span className="text-gray-700 block ml-6 mb-1.5">
55 {sprintf(
56 _n(
57 'You have %s free pattern and layout import remaining this month.',
58 'You have %s free pattern and layout imports remaining this month.',
59 count,
60 'extendify',
61 ),
62 count,
63 )}
64 </span>
65 <span
66 className={classNames(
67 'block font-semibold ml-6 text-sm group-hover:underline',
68 {
69 'text-red-500': count < 2,
70 'text-wp-theme-500': count > 1,
71 },
72 )}
73 dangerouslySetInnerHTML={{
74 __html: safeHTML(
75 sprintf(
76 _x(
77 'Upgrade today %s',
78 'The replacement string is a right arrow and context is not lost if removed.',
79 'extendify',
80 ),
81 `<span class="text-base">
82 ${String.fromCharCode(8250)}
83 </span>`,
84 ),
85 ),
86 }}
87 />
88 </a>
89 )
90 })
91