-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MU WPCOM: dashboard: add launchpad #41138
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3e736b5
MU WPCOM: dashboard: add launchpad
ellatrix 3329d42
changelog
ellatrix 7af23ee
Add option default value
ellatrix 909d1a7
Adjust relative links
ellatrix 6aa865e
Add celebrate modal
ellatrix 54a4fd3
track
ellatrix 70dd19b
Explicitly set context
ellatrix 852002a
Fix conditions to render widget
ellatrix 550f106
Use query param for modal
ellatrix 2dfa068
Render modal separately
ellatrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/packages/jetpack-mu-wpcom/changelog/add-dashboard-launch-steps
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: added | ||
|
||
Dashboard: add launchpad |
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
151 changes: 151 additions & 0 deletions
151
...-mu-wpcom/src/features/wpcom-dashboard-widgets/celebrate-launch/celebrate-launch-modal.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,151 @@ | ||
import { Gridicon, ConfettiAnimation } from '@automattic/components'; | ||
import { Button, Modal, Tooltip } from '@wordpress/components'; | ||
import { useCopyToClipboard } from '@wordpress/compose'; | ||
import { useState, useEffect } from '@wordpress/element'; | ||
import { Icon, copy } from '@wordpress/icons'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { wpcomTrackEvent } from '../../../common/tracks'; | ||
|
||
import './celebrate-launch-modal.scss'; | ||
|
||
/** | ||
* CelebrateLaunchModal component | ||
* | ||
* @param {object} props - Props. | ||
* @param {Function} props.onRequestClose - Callback on modal close. | ||
* @param {object} props.sitePlan - The site plan. | ||
* @param {string} props.siteDomain - The site domain. | ||
* @param {string} props.siteUrl - The site URL. | ||
* @param {boolean} props.hasCustomDomain - Whether the site has a custom domain. | ||
* | ||
* @return {JSX.Element} The CelebrateLaunchModal component. | ||
*/ | ||
export default function CelebrateLaunchModal( { | ||
onRequestClose, | ||
sitePlan = {}, | ||
siteDomain: siteSlug, | ||
siteUrl, | ||
hasCustomDomain, | ||
} ) { | ||
const translate = useTranslate(); | ||
const isPaidPlan = ! sitePlan.is_free; | ||
const isBilledMonthly = sitePlan.product_slug?.includes( 'monthly' ); | ||
const [ clipboardCopied, setClipboardCopied ] = useState( false ); | ||
|
||
useEffect( () => { | ||
wpcomTrackEvent( `calypso_launchpad_celebration_modal_view`, { | ||
product_slug: sitePlan.product_slug, | ||
} ); | ||
}, [ sitePlan.product_slug ] ); | ||
|
||
/** | ||
* Render the upsell content. | ||
* | ||
* @return {JSX.Element} The upsell content. | ||
*/ | ||
function renderUpsellContent() { | ||
let contentElement; | ||
let buttonText; | ||
let buttonHref; | ||
|
||
if ( ! isPaidPlan && ! hasCustomDomain ) { | ||
contentElement = ( | ||
<p> | ||
{ translate( | ||
'Supercharge your website with a {{strong}}custom address{{/strong}} that matches your blog, brand, or business.', | ||
{ components: { strong: <strong /> } } | ||
) } | ||
</p> | ||
); | ||
buttonText = translate( 'Claim your domain' ); | ||
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`; | ||
} else if ( isPaidPlan && isBilledMonthly && ! hasCustomDomain ) { | ||
contentElement = ( | ||
<p> | ||
{ translate( | ||
'Interested in a custom domain? It’s free for the first year when you switch to annual billing.' | ||
) } | ||
</p> | ||
); | ||
buttonText = translate( 'Claim your domain' ); | ||
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`; | ||
} else if ( isPaidPlan && ! hasCustomDomain ) { | ||
contentElement = ( | ||
<p> | ||
{ translate( | ||
'Your paid plan includes a domain name {{strong}}free for one year{{/strong}}. Choose one that’s easy to remember and even easier to share.', | ||
{ components: { strong: <strong /> } } | ||
) } | ||
</p> | ||
); | ||
buttonText = translate( 'Claim your free domain' ); | ||
buttonHref = `https://wordpress.com/domains/add/${ siteSlug }`; | ||
} else if ( hasCustomDomain ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="launched__modal-upsell"> | ||
<div className="launched__modal-upsell-content">{ contentElement }</div> | ||
<Button | ||
variant="primary" | ||
href={ buttonHref } | ||
onClick={ () => | ||
wpcomTrackEvent( `calypso_launchpad_celebration_modal_upsell_clicked`, { | ||
product_slug: sitePlan.product_slug, | ||
} ) | ||
} | ||
> | ||
<span>{ buttonText }</span> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
const ref = useCopyToClipboard( siteSlug, () => setClipboardCopied( true ) ); | ||
|
||
return ( | ||
<Modal onRequestClose={ onRequestClose } className="launched__modal"> | ||
<ConfettiAnimation /> | ||
<div className="launched__modal-content"> | ||
<div className="launched__modal-text"> | ||
<h1 className="launched__modal-heading"> | ||
{ translate( 'Congrats, your site is live!' ) } | ||
</h1> | ||
<p className="launched__modal-body"> | ||
{ translate( 'Now you can head over to your site and share it with the world.' ) } | ||
</p> | ||
</div> | ||
<div className="launched__modal-actions"> | ||
<div className="launched__modal-site"> | ||
<div className="launched__modal-domain"> | ||
<p className="launched__modal-domain-text">{ siteSlug }</p> | ||
<Tooltip | ||
text={ clipboardCopied ? translate( 'Copied to clipboard!' ) : '' } | ||
delay={ 0 } | ||
hideOnClick={ false } | ||
> | ||
<Button | ||
label={ translate( 'Copy URL' ) } | ||
className="launchpad__clipboard-button" | ||
borderless | ||
size="compact" | ||
ref={ ref } | ||
onMouseLeave={ () => setClipboardCopied( false ) } | ||
> | ||
<Icon icon={ copy } size={ 18 } /> | ||
</Button> | ||
</Tooltip> | ||
</div> | ||
|
||
<Button href={ siteUrl } target="_blank" className="launched__modal-view-site"> | ||
<Gridicon icon="domains" size={ 18 } /> | ||
<span className="launched__modal-view-site-text">{ translate( 'View site' ) }</span> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
{ renderUpsellContent() } | ||
</Modal> | ||
); | ||
} |
162 changes: 162 additions & 0 deletions
162
...u-wpcom/src/features/wpcom-dashboard-widgets/celebrate-launch/celebrate-launch-modal.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,162 @@ | ||
$breakpoint-mobile: 782px; //Mobile size. | ||
|
||
.launched__modal { | ||
p { | ||
font-size: 16px; | ||
margin: 0; | ||
} | ||
|
||
&.components-modal__frame { | ||
max-width: 640px; | ||
} | ||
|
||
.components-modal__header { | ||
padding: 48px; | ||
} | ||
|
||
.components-modal__content { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
&-content { | ||
padding: 48px; | ||
padding-bottom: 40px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 32px; | ||
|
||
@media (min-width: $breakpoint-mobile) { | ||
min-width: 640px; | ||
} | ||
} | ||
|
||
&-heading { | ||
color: var(--studio-gray-100); | ||
font-family: Recoleta, "Noto Serif", Georgia, "Times New Roman", Times, serif; | ||
font-size: 2rem; | ||
line-height: 40px; | ||
font-weight: 400; | ||
letter-spacing: 0.2px; | ||
margin: 0; | ||
padding-bottom: 8px; | ||
} | ||
|
||
&-domain { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
max-width: 100%; | ||
@media (min-width: $breakpoint-mobile) { | ||
max-width: 75%; | ||
} | ||
} | ||
|
||
&-body, | ||
&-domain-text { | ||
margin: 0; | ||
color: var(--studio-gray-80); | ||
font-size: 1rem; | ||
line-height: 24px; | ||
} | ||
|
||
&-domain-text { | ||
padding: 0 8px; | ||
|
||
// prevent text overflow | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
&-buttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: end; | ||
gap: 16px; | ||
} | ||
|
||
&-site { | ||
padding: 8px; | ||
background: var(--studio-gray-0); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
align-items: center; | ||
@media (min-width: $breakpoint-mobile) { | ||
flex-direction: row; | ||
} | ||
} | ||
|
||
.launchpad__clipboard-button { | ||
min-width: 18px; | ||
opacity: 0; | ||
} | ||
|
||
.launchpad__clipboard-button:focus { | ||
opacity: 1; | ||
} | ||
|
||
&-site:hover { | ||
.launchpad__clipboard-button { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&-customize { | ||
color: var(--studio-blue-50); | ||
font-size: 0.875rem; | ||
display: inline-flex; | ||
flex-direction: row; | ||
justify-content: start; | ||
gap: 6px; | ||
padding: 0; | ||
margin: 0; | ||
margin-top: 16px; | ||
} | ||
|
||
&-upsell { | ||
border-top: 1px solid var(--studio-gray-5); | ||
background: var(--studio-gray-0); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 32px 48px; | ||
gap: 32px; | ||
flex-direction: column; | ||
@media (min-width: $breakpoint-mobile) { | ||
flex-direction: row; | ||
} | ||
.components-button { | ||
height: 42px; | ||
} | ||
} | ||
|
||
&-upsell-content p { | ||
margin-bottom: 0; | ||
} | ||
|
||
&-upsell-content-highlight { | ||
font-weight: bold; | ||
} | ||
|
||
&-view-site { | ||
display: flex; | ||
gap: 4px; | ||
|
||
font-weight: 500; | ||
/* stylelint-disable-next-line */ | ||
font-size: 14px; | ||
line-height: 20px; | ||
letter-spacing: -0.154px; | ||
color: #101517; | ||
} | ||
|
||
&-view-site:visited { | ||
color: #101517; | ||
} | ||
|
||
&-view-site:hover { | ||
text-decoration: underline; | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is interesting, we have some components that use this, and others that use
@wordpress/i18n
. What's the story there? Maybe @jsnajdr knows. How to decide what to use...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think ideally we should switch to
@wordpress/i18n
. But I don't want to trigger string changes for this PR. Also, there's some use cases that can't be easily done with@wordpress/i18n
such as strings with HTML elements inside of them (I think).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have createInterpolateElement for that use-case. So I think we're covered there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looking a that, it does work a bit differently, and the strings would still have to change. I guess that could be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be wrong, but I don't think that translation strings using
i18n-calypso
'stranslate()
function would even be picked up, only the@wordpress/i18n
-style__()
,_x()
, and so on.We've generally avoided
@automattic/components
for similar reasons. It has (or has had in the past, anyway) a lot of stuff that's specific to Calypso that doesn't work so well in Jetpack.