Skip to content
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

Implement the dotlink version of Link in Bio flow on Stepper #71204

Merged
merged 15 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ button {
* Tailored flow stylings
*/
.newsletter,
.link-in-bio:not(.domains) {
.link-in-bio:not(.domains),
.link-in-bio-tld:not(.domains) {
&:not(.launchpad):not(.subscribers) {
@include onboarding-break-mobile-landscape {
padding: 40px 0 0;
Expand All @@ -168,6 +169,7 @@ button {

.newsletter,
.link-in-bio,
.link-in-bio-tld,
.setup-form__form {
button {
&[type="submit"] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
LINK_IN_BIO_FLOW,
NEWSLETTER_FLOW,
ECOMMERCE_FLOW,
VIDEOPRESS_FLOW,
FREE_FLOW,
isLinkInBioFlow,
} from '@automattic/onboarding';
import { createInterpolateElement, useMemo } from '@wordpress/element';
import { useI18n } from '@wordpress/react-i18n';
Expand All @@ -18,7 +18,7 @@ const useIntroContent = ( flowName: string | null ): IntroContent => {
const { __ } = useI18n();

return useMemo( () => {
if ( flowName === LINK_IN_BIO_FLOW ) {
if ( isLinkInBioFlow( flowName ) ) {
return {
title: createInterpolateElement(
__( 'You’re 3 minutes away from<br />a stand-out Link in Bio site.<br />Ready? ' ),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
LINK_IN_BIO_FLOW,
LINK_IN_BIO_TLD_FLOW,
NEWSLETTER_FLOW,
VIDEOPRESS_FLOW,
FREE_FLOW,
Expand All @@ -23,6 +24,7 @@ export function getLaunchpadTranslations( flow: string | null ): TranslatedLaunc
);
break;
case LINK_IN_BIO_FLOW:
case LINK_IN_BIO_TLD_FLOW:
translatedStrings.flowName = translate( 'Link in Bio' );
translatedStrings.title = translate( "You're ready to link and launch" );
translatedStrings.launchTitle = translate( "You're ready to link and launch" );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
StepContainer,
isNewsletterOrLinkInBioFlow,
LINK_IN_BIO_FLOW,
isLinkInBioFlow,
isFreeFlow,
} from '@automattic/onboarding';
import { useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -118,7 +118,7 @@ const ProcessingStep: Step = function ( props ) {
const isJetpackPowered = isNewsletterOrLinkInBioFlow( flowName );

// Currently we have the Domains and Plans only for link in bio
if ( flowName === LINK_IN_BIO_FLOW || isFreeFlow( flowName ) ) {
if ( isLinkInBioFlow( flowName ) || isFreeFlow( flowName ) ) {
return <TailoredFlowPreCheckoutScreen flowName={ flowName } />;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NEWSLETTER_FLOW, LINK_IN_BIO_FLOW } from '@automattic/onboarding';
import { NEWSLETTER_FLOW, LINK_IN_BIO_FLOW, LINK_IN_BIO_TLD_FLOW } from '@automattic/onboarding';
import { useI18n } from '@wordpress/react-i18n';
import PropTypes from 'prop-types';
import { useRef, useState, useEffect } from 'react';
Expand All @@ -15,6 +15,7 @@ const useSteps = ( flowName: string ) => {

switch ( flowName ) {
case LINK_IN_BIO_FLOW:
case LINK_IN_BIO_TLD_FLOW:
steps = [
{ title: __( 'Great choices. Nearly there!' ) },
{ title: __( 'Shining and polishing your Bio' ) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}
.newsletter,
.link-in-bio,
.link-in-bio-tld,
.free {
.signup-header {
.signup-header__right {
Expand Down Expand Up @@ -96,7 +97,8 @@
}
}

.link-in-bio {
.link-in-bio,
.link-in-bio-tld {
.processing-step__container {
background-color: #d0cce3;
background-image:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Site } from '@automattic/data-stores';
import {
ECOMMERCE_FLOW,
LINK_IN_BIO_FLOW,
isLinkInBioFlow,
addPlanToCart,
createSiteWithCart,
} from '@automattic/onboarding';
Expand Down Expand Up @@ -33,14 +34,14 @@ const SiteCreationStep: Step = function SiteCreationStep( { navigation, flow } )

const { setPendingAction } = useDispatch( ONBOARD_STORE );

const theme = flow === LINK_IN_BIO_FLOW ? 'pub/lynx' : 'pub/lettre';
const theme = isLinkInBioFlow( LINK_IN_BIO_FLOW ) ? 'pub/lynx' : 'pub/lettre';
const isPaidDomainItem = Boolean( domainCartItem?.product_slug );

// Default visibility is public
let siteVisibility = Site.Visibility.PublicIndexed;

// Link-in-bio flow defaults to "Coming Soon"
if ( flow === LINK_IN_BIO_FLOW ) {
if ( isLinkInBioFlow( flow ) ) {
siteVisibility = Site.Visibility.PublicNotIndexed;
}

Expand Down
149 changes: 149 additions & 0 deletions client/landing/stepper/declarative-flow/link-in-bio-tld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { useLocale } from '@automattic/i18n-utils';
import { useFlowProgress, LINK_IN_BIO_TLD_FLOW } from '@automattic/onboarding';
import { useSelect, useDispatch } from '@wordpress/data';
import { translate } from 'i18n-calypso';
import { useEffect } from 'react';
import { recordFullStoryEvent } from 'calypso/lib/analytics/fullstory';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import wpcom from 'calypso/lib/wp';
import {
clearSignupDestinationCookie,
setSignupCompleteSlug,
persistSignupDestination,
setSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { useSiteSlug } from '../hooks/use-site-slug';
import { USER_STORE, ONBOARD_STORE } from '../stores';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import DomainsStep from './internals/steps-repository/domains';
import LaunchPad from './internals/steps-repository/launchpad';
import LinkInBioSetup from './internals/steps-repository/link-in-bio-setup';
import PatternsStep from './internals/steps-repository/patterns';
import PlansStep from './internals/steps-repository/plans';
import Processing from './internals/steps-repository/processing-step';
import SiteCreationStep from './internals/steps-repository/site-creation-step';
import type { Flow, ProvidedDependencies } from './internals/types';

const linkInBio: Flow = {
name: LINK_IN_BIO_TLD_FLOW,
get title() {
return translate( 'Link in Bio' );
},
useSteps() {
useEffect( () => {
recordTracksEvent( 'calypso_signup_start', { flow: this.name } );
recordFullStoryEvent( 'calypso_signup_start_link_in_bio', { flow: this.name } );
}, [] );

return [
{ slug: 'domains', component: DomainsStep },
{ slug: 'patterns', component: PatternsStep },
{ slug: 'linkInBioSetup', component: LinkInBioSetup },
{ slug: 'plans', component: PlansStep },
{ slug: 'siteCreationStep', component: SiteCreationStep },
{ slug: 'processing', component: Processing },
{ slug: 'launchpad', component: LaunchPad },
];
},

useStepNavigation( _currentStepSlug, navigate ) {
const flowName = this.name;
const { setStepProgress } = useDispatch( ONBOARD_STORE );
const flowProgress = useFlowProgress( { stepName: _currentStepSlug, flowName } );
const siteSlug = useSiteSlug();
const userIsLoggedIn = useSelect( ( select ) => select( USER_STORE ).isCurrentUserLoggedIn() );
const locale = useLocale();

setStepProgress( flowProgress );

// trigger guides on step movement, we don't care about failures or response
wpcom.req.post(
'guides/trigger',
{
apiNamespace: 'wpcom/v2/',
},
{
flow: flowName,
step: _currentStepSlug,
}
);

const logInUrl =
locale && locale !== 'en'
? `/start/account/user/${ locale }?variationName=${ flowName }&pageTitle=Link%20in%20Bio&redirect_to=/setup/${ flowName }/patterns`
: `/start/account/user?variationName=${ flowName }&pageTitle=Link%20in%20Bio&redirect_to=/setup/${ flowName }/patterns`;
Comment on lines +71 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do this manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we don't. This PR focuses on making the flow work first, so I simply refer to how link-in-bio.ts does it for now. It can be improved as a separate PR for sure :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @alshakero, this is how we are doing in the LiB flow as well, I think it can be good here for this PR :)


// for the standard Link in Bio flow
southp marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor thing, I think you can change/remove this comment here 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The suggested fix has been taken :D

const submit = ( providedDependencies: ProvidedDependencies = {} ) => {
recordSubmitStep( providedDependencies, '', flowName, _currentStepSlug );

switch ( _currentStepSlug ) {
case 'domains':
clearSignupDestinationCookie();

if ( userIsLoggedIn ) {
return navigate( 'plans' );
}

return window.location.assign( logInUrl );

case 'patterns':
return navigate( 'linkInBioSetup' );

case 'linkInBioSetup':
return navigate( 'plans' );

case 'plans':
return navigate( 'siteCreationStep' );

case 'siteCreationStep':
return navigate( 'processing' );

case 'processing':
if ( providedDependencies?.goToCheckout ) {
const destination = `/setup/${ flowName }/launchpad?siteSlug=${ providedDependencies.siteSlug }`;
persistSignupDestination( destination );
setSignupCompleteSlug( providedDependencies?.siteSlug );
setSignupCompleteFlowName( flowName );
const returnUrl = encodeURIComponent(
`/setup/${ flowName }/launchpad?siteSlug=${ providedDependencies?.siteSlug }`
);

return window.location.assign(
`/checkout/${ encodeURIComponent(
( providedDependencies?.siteSlug as string ) ?? ''
) }?redirect_to=${ returnUrl }&signup=1`
);
}
return navigate( `launchpad?siteSlug=${ providedDependencies?.siteSlug }` );

case 'launchpad': {
return navigate( 'processing' );
}
}
return providedDependencies;
};

const goBack = () => {
return;
};

const goNext = () => {
switch ( _currentStepSlug ) {
case 'launchpad':
return window.location.assign( `/view/${ siteSlug }` );

default:
return navigate( 'intro' );
}
};

const goToStep = ( step: string ) => {
navigate( step );
};

return { goNext, goBack, goToStep, submit };
},
};

export default linkInBio;
3 changes: 3 additions & 0 deletions client/landing/stepper/declarative-flow/registered-flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const availableFlows: Record< string, () => Promise< { default: Flow } > > = {
'link-in-bio': () =>
import( /* webpackChunkName: "link-in-bio-flow" */ '../declarative-flow/link-in-bio' ),

'link-in-bio-tld': () =>
import( /* webpackChunkName: "link-in-bio-tld-flow" */ '../declarative-flow/link-in-bio-tld' ),

podcasts: () => import( /* webpackChunkName: "podcasts-flow" */ '../declarative-flow/podcasts' ),

'link-in-bio-post-setup': () =>
Expand Down
12 changes: 11 additions & 1 deletion packages/onboarding/src/flow-progress/use-flow-progress.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LINK_IN_BIO_FLOW, LINK_IN_BIO_TLD_FLOW } from '../utils/flows';

/* eslint-disable no-restricted-imports */
interface FlowProgress {
stepName?: string;
Expand All @@ -14,7 +16,7 @@ const flows: Record< string, { [ step: string ]: number } > = {
subscribers: 4,
launchpad: 5,
},
'link-in-bio': {
[ LINK_IN_BIO_FLOW ]: {
intro: 0,
user: 0,
patterns: 1,
Expand All @@ -23,6 +25,14 @@ const flows: Record< string, { [ step: string ]: number } > = {
plans: 4,
launchpad: 5,
},
[ LINK_IN_BIO_TLD_FLOW ]: {
domains: 0,
user: 1,
patterns: 2,
linkInBioSetup: 3,
plans: 4,
launchpad: 5,
},
free: {
intro: 0,
user: 0,
Expand Down