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

Replace overview when site is with a pending migration #95497

Merged
merged 22 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 17 additions & 8 deletions client/components/hosting-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface HostingCardProps {
className?: string;
headingId?: string;
title?: string;
inGrid?: boolean;
children: ReactNode;
}

Expand All @@ -22,9 +23,19 @@ interface HostingCardDescriptionProps {
children: string | ReactNode;
}

export function HostingCard( { className, headingId, title, children }: HostingCardProps ) {
interface HostingCardLinkButtonProps {
to: string;
children: string | ReactNode;
hideOnMobile?: boolean;
}

interface HostingCardGridProps {
children: ReactNode;
}

export function HostingCard( { className, headingId, title, inGrid, children }: HostingCardProps ) {
return (
<Card className={ clsx( 'hosting-card', className ) }>
<Card className={ clsx( 'hosting-card', className, { 'hosting-card--in-grid': inGrid } ) }>
{ title && (
<h3 id={ headingId } className="hosting-card__title">
{ title }
Expand Down Expand Up @@ -52,12 +63,6 @@ export function HostingCardDescription( { children }: HostingCardDescriptionProp
return <p className="hosting-card__description">{ children }</p>;
}

interface HostingCardLinkButtonProps {
to: string;
children: string | ReactNode;
hideOnMobile?: boolean;
}

export function HostingCardLinkButton( {
to,
children,
Expand All @@ -75,3 +80,7 @@ export function HostingCardLinkButton( {
</Button>
);
}

export function HostingCardGrid( props: HostingCardGridProps ) {
return <div className="hosting-card-grid">{ props.children }</div>;
}
35 changes: 35 additions & 0 deletions client/components/hosting-card/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "@automattic/components/src/styles/typography";
@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";

.hosting-card {
width: 100%;
Expand All @@ -22,6 +23,27 @@
.form-select {
font-size: rem(14px) !important;
}

/* Styles for when it's inside a grid */
&--in-grid {
> p {
font-size: rem(14px);
margin-bottom: 0;
color: var(--color-text-subtle);
flex-grow: 1;
}

> a {
display: inline-block;
font-size: rem(13px);
font-weight: 400;
line-height: 16px;
}

> p + a {
margin-top: 20px;
}
}
}

h3.hosting-card__title {
Expand Down Expand Up @@ -58,3 +80,16 @@ a.hosting-card__link-button {
display: none;
}
}

.hosting-card-grid {
display: grid;
grid-template-columns: 1fr;
grid-column-gap: 16px;
grid-row-gap: 16px;
padding: 0 20px;

@include break-medium {
grid-template-columns: 1fr 1fr 1fr;
padding: 0;
}
}
16 changes: 16 additions & 0 deletions client/components/hosting-hero/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Button } from '@wordpress/components';
import type { ReactNode, ComponentProps } from 'react';

import './style.scss';

interface HostingHeroProps {
children: ReactNode;
}

export function HostingHero( { children }: HostingHeroProps ) {
return <div className="hosting-hero">{ children }</div>;
}

export function HostingHeroButton( props: ComponentProps< typeof Button > ) {
return <Button variant="primary" className="hosting-hero-button" { ...props } />;
}
27 changes: 27 additions & 0 deletions client/components/hosting-hero/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import "@automattic/components/src/styles/typography";

.hosting-hero {
grid-column: 1 / -1;
text-align: center;
margin-bottom: 70px;

> h1 {
margin-top: 30px;
font-style: normal;
font-weight: 500;
font-size: rem(36px);
font-family: Recoleta, sans-serif;
}
> p {
font-style: normal;
font-weight: 400;
font-size: rem(18px);
}
}

.hosting-hero-button {
margin: 0 5px;
padding: 10px 14px;
font-size: rem(14px);
height: 40px;
}
28 changes: 13 additions & 15 deletions client/hosting/hosting-features/components/hosting-features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { FEATURE_SFTP, getPlan, PLAN_BUSINESS } from '@automattic/calypso-produc
import page from '@automattic/calypso-router';
import { Dialog } from '@automattic/components';
import { useHasEnTranslation } from '@automattic/i18n-utils';
import { Button, Spinner } from '@wordpress/components';
import { Spinner } from '@wordpress/components';
import { addQueryArgs } from '@wordpress/url';
import { translate } from 'i18n-calypso';
import { useRef, useState, useEffect } from 'react';
import { AnyAction } from 'redux';
import EligibilityWarnings from 'calypso/blocks/eligibility-warnings';
import { HostingCard } from 'calypso/components/hosting-card';
import { HostingCard, HostingCardGrid } from 'calypso/components/hosting-card';
import { HostingHero, HostingHeroButton } from 'calypso/components/hosting-hero';
import InlineSupportLink from 'calypso/components/inline-support-link';
import { useSiteTransferStatusQuery } from 'calypso/landing/stepper/hooks/use-site-transfer/query';
import { useSelector, useDispatch } from 'calypso/state';
Expand All @@ -28,7 +29,7 @@ type PromoCardProps = {
};

const PromoCard = ( { title, text, supportContext }: PromoCardProps ) => (
<HostingCard className="hosting-features__card" title={ title }>
<HostingCard inGrid className="hosting-features__card" title={ title }>
<p>{ text }</p>
{ translate( '{{supportLink}}Learn more{{/supportLink}}', {
components: {
Expand Down Expand Up @@ -204,9 +205,7 @@ const HostingFeatures = () => {
description = activateDescription;
buttons = (
<>
<Button
variant="primary"
className="hosting-features__button"
<HostingHeroButton
onClick={ () => {
if ( showActivationButton ) {
dispatch( recordTracksEvent( 'calypso_hosting_features_activate_click' ) );
Expand All @@ -215,7 +214,7 @@ const HostingFeatures = () => {
} }
>
{ translate( 'Activate now' ) }
</Button>
</HostingHeroButton>

<Dialog
additionalClassNames="plugin-details-cta__dialog-content"
Expand All @@ -239,36 +238,35 @@ const HostingFeatures = () => {
title = unlockTitle;
description = unlockDescription;
buttons = (
<Button
variant="primary"
className="hosting-features__button"
<HostingHeroButton
href={ upgradeLink }
onClick={ () =>
dispatch( recordTracksEvent( 'calypso_hosting_features_upgrade_plan_click' ) )
}
>
{ translate( 'Upgrade now' ) }
</Button>
</HostingHeroButton>
);
}

return (
<div className="hosting-features">
<div className="hosting-features__hero">
<HostingHero>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Components were extracted so that we could reuse them.

{ isTransferInProgress && <Spinner className="hosting-features__content-spinner" /> }
<h1>{ title }</h1>
<p>{ description }</p>
{ buttons }
</div>
<div className="hosting-features__cards">
</HostingHero>
<HostingCardGrid>
{ promoCards.map( ( card ) => (
<PromoCard
key={ card.title }
title={ card.title }
text={ card.text }
supportContext={ card.supportContext }
/>
) ) }
</div>
</HostingCardGrid>
</div>
);
};
Expand Down
60 changes: 4 additions & 56 deletions client/hosting/hosting-features/components/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,9 @@
@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";

.hosting-features__hero {
grid-column: 1 / -1;
text-align: center;
margin-bottom: 70px;

> h1 {
margin-top: 30px;
font-style: normal;
font-weight: 500;
font-size: rem(36px);
font-family: Recoleta, sans-serif;
}
> p {
font-style: normal;
font-weight: 400;
font-size: rem(18px);
}
.hosting-features__button {
margin: 0 5px;
padding: 10px 14px;
font-size: rem(14px);
height: 40px;
}

.hosting-features__content-spinner {
margin-top: 16px;
& + h1 {
margin-top: 0;
}
}
}

.hosting-features__cards {
display: grid;
grid-template-columns: 1fr;
grid-column-gap: 16px;
grid-row-gap: 16px;
padding: 0 20px;
@include break-medium {
grid-template-columns: 1fr 1fr 1fr;
padding: 0;
}
}

.hosting-features__card {
> p {
font-size: rem(14px);
margin-bottom: 20px;
color: var(--color-text-subtle);
flex-grow: 1;
}

> a {
font-size: rem(13px);
font-weight: 400;
line-height: 16px;
.hosting-features__content-spinner {
margin-top: 16px;
& + h1 {
margin-top: 0;
}
}
12 changes: 11 additions & 1 deletion client/hosting/overview/components/hosting-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ import ActiveDomainsCard from 'calypso/hosting/overview/components/active-domain
import PlanCard from 'calypso/hosting/overview/components/plan-card';
import QuickActionsCard from 'calypso/hosting/overview/components/quick-actions-card';
import SiteBackupCard from 'calypso/hosting/overview/components/site-backup-card';
import { isNotAtomicJetpack } from 'calypso/sites-dashboard/utils';
import {
isNotAtomicJetpack,
isMigrationInProgress,
getMigrationStatus,
} from 'calypso/sites-dashboard/utils';
import { useSelector } from 'calypso/state';
import { getSelectedSite } from 'calypso/state/ui/selectors';
import MigrationOverview from './migration-overview';
import SupportCard from './support-card';

import './style.scss';

const HostingOverview: FC = () => {
const site = useSelector( getSelectedSite );

if ( site && isMigrationInProgress( site ) && getMigrationStatus( site ) === 'pending' ) {
return <MigrationOverview site={ site } />;
}

const isJetpackNotAtomic = site && isNotAtomicJetpack( site );
const subtitle = isJetpackNotAtomic
? translate( 'Get a quick glance at your plans and upgrades.' )
Expand Down
Loading
Loading