-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[not verified] Add preview email feature
[not verified] add button to newsletter panel
- Loading branch information
Showing
5 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: enhancement | ||
|
||
enhancement Add Email Preview Feature |
67 changes: 67 additions & 0 deletions
67
projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import apiFetch from '@wordpress/api-fetch'; | ||
import { Button, Flex, FlexBlock, FlexItem, Modal, TextControl } from '@wordpress/components'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { useState } from '@wordpress/element'; | ||
import { __ } from '@wordpress/i18n'; | ||
import './email-preview.scss'; | ||
|
||
export default function EmailPreview() { | ||
const [ isModalOpen, setIsModalOpen ] = useState( false ); | ||
const [ emailSent, setEmailSent ] = useState( false ); | ||
const postId = useSelect( select => select( 'core/editor' ).getCurrentPostId() ); | ||
|
||
return ( | ||
<> | ||
<FlexItem> | ||
<Button isPrimary onClick={ () => setIsModalOpen( true ) }> | ||
{ __( 'Send test email', 'jetpack' ) } | ||
</Button> | ||
</FlexItem> | ||
{ isModalOpen && ( | ||
<Modal | ||
className="jetpack-send-email-preview-modal" | ||
title={ __( 'Send a test email', 'jetpack' ) } | ||
onRequestClose={ () => setIsModalOpen( false ) } | ||
> | ||
{ emailSent ? ( | ||
<p>{ __( 'Email sent successfully', 'jetpack' ) }</p> | ||
) : ( | ||
<Flex> | ||
<FlexBlock> | ||
<TextControl | ||
className="email-field" | ||
value={ window?.Jetpack_Editor_Initial_State?.tracksUserData?.email } | ||
disabled={ true } | ||
/> | ||
</FlexBlock> | ||
<FlexItem> | ||
<Button | ||
className="send-button" | ||
isPrimary | ||
onClick={ () => { | ||
apiFetch( { | ||
path: '/wpcom/v2/send-email-preview/', | ||
method: 'POST', | ||
data: { | ||
id: postId, | ||
}, | ||
} ) | ||
.then( () => { | ||
// Handle response here | ||
setEmailSent( true ); | ||
} ) | ||
.catch( () => { | ||
// Handle error here | ||
} ); | ||
} } | ||
> | ||
{ __( 'Send', 'jetpack' ) } | ||
</Button> | ||
</FlexItem> | ||
</Flex> | ||
) } | ||
</Modal> | ||
) } | ||
</> | ||
); | ||
} |
26 changes: 26 additions & 0 deletions
26
projects/plugins/jetpack/extensions/blocks/subscriptions/email-preview.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.jetpack-send-email-preview-modal { | ||
height: 200px; | ||
width: 645px; | ||
left: 391px; | ||
top: 392px; | ||
border-radius: 0px; | ||
|
||
.email-field { | ||
width: 266px; | ||
height: 44px; | ||
border-radius: 3px; | ||
padding: 12px 16px; | ||
} | ||
|
||
.send-button { | ||
margin-left: 12px; /* 12px to the right of the email field */ | ||
} | ||
|
||
/* More styles for the email text */ | ||
.email-field::placeholder { | ||
width: 201px; | ||
height: 20px; | ||
top: 12px; | ||
left: 16px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters