-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathOnboardingPromoNotice.js
More file actions
96 lines (87 loc) · 2.7 KB
/
Copy pathOnboardingPromoNotice.js
File metadata and controls
96 lines (87 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* global tiobDash */
import { __, sprintf } from '@wordpress/i18n';
import { createInterpolateElement, useState } from '@wordpress/element';
import { ajaxAction } from '../utils/rest';
const OnboardingPromoNotice = () => {
const shouldShowNotice = Boolean( tiobDash.onboardingPromoNotice?.show );
const showProMessage = Boolean( tiobDash.onboardingShowProNoticeText );
const emailBody = sprintf(
/* translators: %s: double line break in the starter site request email template */
__(
'Hi Neve team,%1$sI\'m looking for a starter site for the following project:%1$sProject type: (e.g. Restaurant, Law Firm, SaaS)%1$sKey pages needed: (e.g. Home, About, Services, Contact)%1$sStyle preference: (e.g. Minimal, Bold, Corporate)%1$sAny references: (optional)%1$sThanks',
'templates-patterns-collection'
),
'\n\n'
);
const requestSiteLink =
'mailto:contact@themeisle.com?subject=' +
encodeURIComponent(
__( 'Starter Site Request', 'templates-patterns-collection' )
) +
'&body=' +
encodeURIComponent( emailBody );
const noticeMessage = showProMessage
? createInterpolateElement(
__(
'Fresh designs built for every niche. Can\'t find what you\'re looking for? As a Pro user, <requestSiteLink>request a site</requestSiteLink> and we\'ll build it for you.',
'templates-patterns-collection'
),
{
requestSiteLink: (
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
<a
href={ requestSiteLink }
className="ob-onboarding-promo-link"
/>
),
}
)
: __(
'From free to pro, fresh designs built for every niche. More coming soon.',
'templates-patterns-collection'
);
const [ isVisible, setIsVisible ] = useState( shouldShowNotice );
if ( ! isVisible ) {
return null;
}
const dismissNotice = () => {
setIsVisible( false );
ajaxAction(
tiobDash.onboardingPromoNotice.ajaxURL,
'dismiss_onboarding_promo_notice',
tiobDash.onboardingPromoNotice.nonce
).catch( () => null );
};
return (
<div className="ob-onboarding-promo" role="status">
<div className="ob-onboarding-promo-badge">
{ __( 'New', 'templates-patterns-collection' ) }
</div>
<div className="ob-onboarding-promo-content">
<h3>
{ sprintf(
/* translators: %s: number of new starter sites */
__(
'%s new starter sites, just landed.',
'templates-patterns-collection'
),
'80+'
) }
</h3>
<p>{ noticeMessage }</p>
</div>
<button
type="button"
className="ob-onboarding-promo-close"
onClick={ dismissNotice }
aria-label={ __(
'Dismiss notice',
'templates-patterns-collection'
) }
>
×
</button>
</div>
);
};
export default OnboardingPromoNotice;