-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert filter search component as reusable component. * Move listing section as a shared component. * Move useProductAndPlans as a shared hook. * Make listing section icon as optional. * Add Pressable filter support in useProductAndPlans hook. * Add Hosting section skeleton. * Remove unused CSS codes. * Implement Hosting card. * Fix explore button redirect. * Add WPCOM and Pressable section. * Address PR comments.
- Loading branch information
1 parent
9c4a81e
commit aefd48c
Showing
26 changed files
with
686 additions
and
151 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
client/a8c-for-agencies/components/filter-search/index.tsx
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,17 @@ | ||
import Search from 'calypso/components/search'; | ||
|
||
import './style.scss'; | ||
|
||
type Props = { | ||
label: string; | ||
onSearch: ( value: string ) => void; | ||
onClick?: () => void; | ||
}; | ||
|
||
export default function FilterSearch( { onSearch, onClick, label }: Props ) { | ||
return ( | ||
<div className="a4a-filter-search"> | ||
<Search onClick={ onClick } onSearch={ onSearch } placeholder={ label } compact hideFocus /> | ||
</div> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
client/a8c-for-agencies/components/filter-search/style.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,28 @@ | ||
@import "@wordpress/base-styles/breakpoints"; | ||
@import "@wordpress/base-styles/mixins"; | ||
|
||
.a4a-filter-search { | ||
flex-basis: 100%; | ||
|
||
@include break-xlarge { | ||
flex-basis: 360px; | ||
} | ||
|
||
.search { | ||
&.is-open { | ||
height: 46px; | ||
|
||
@include breakpoint-deprecated( ">660px" ) { | ||
height: 33px; | ||
} | ||
} | ||
margin-block-end: 0; | ||
border: 1px solid var(--color-neutral-10); | ||
} | ||
|
||
.search__input.form-text-input[type="search"] { | ||
font-size: rem(13px); | ||
font-weight: 400; | ||
color: var(--color-text); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...cts-overview/product-listing/constants.ts → ...gencies/sections/marketplace/constants.ts
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export const PRODUCT_FILTER_ALL = ''; | ||
export const PRODUCT_FILTER_PLANS = 'plans'; | ||
export const PRODUCT_FILTER_PRODUCTS = 'products'; | ||
export const PRODUCT_FILTER_PRESSABLE_PLANS = 'pressable-plans'; | ||
export const PRODUCT_FILTER_WOOCOMMERCE_EXTENSIONS = 'woocommerce-extensions'; | ||
export const PRODUCT_FILTER_VAULTPRESS_BACKUP_ADDONS = 'vaultpress-backup-addons'; |
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
39 changes: 39 additions & 0 deletions
39
...t/a8c-for-agencies/sections/marketplace/hosting-overview/hooks/use-hosting-description.ts
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,39 @@ | ||
import { TranslateResult, useTranslate } from 'i18n-calypso'; | ||
import { useMemo } from 'react'; | ||
|
||
/** | ||
* Returns hosting name and description with given product slug. | ||
* @param slug | ||
* @returns | ||
*/ | ||
export default function useHostingDescription( slug: string ): { | ||
name: TranslateResult; | ||
description: TranslateResult; | ||
} { | ||
const translate = useTranslate(); | ||
|
||
return useMemo( () => { | ||
let description = ''; | ||
let name = ''; | ||
|
||
switch ( slug ) { | ||
case 'pressable-hosting': | ||
name = translate( 'Pressable' ); | ||
description = translate( | ||
'9 custom plans built for agencies that include an intuitive control panel, easy site migration, staging environments, performance tools, and flexible upgrades & downgrades. ' | ||
); | ||
break; | ||
case 'wpcom-hosting': | ||
name = translate( 'Wordpress.com' ); | ||
description = translate( | ||
'Unbeatable uptime, unmetered bandwidth, and everything you need to streamline your development process, baked in. Perfect uptime. Fastest WP Bench score. A+ SSL grade.' | ||
); | ||
break; | ||
} | ||
|
||
return { | ||
name, | ||
description, | ||
}; | ||
}, [ slug, translate ] ); | ||
} |
62 changes: 62 additions & 0 deletions
62
client/a8c-for-agencies/sections/marketplace/hosting-overview/hosting-card/index.tsx
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,62 @@ | ||
import { Button } from '@automattic/components'; | ||
import { formatCurrency } from '@automattic/format-currency'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useDispatch } from 'calypso/state'; | ||
import { recordTracksEvent } from 'calypso/state/analytics/actions'; | ||
import { APIProductFamilyProduct } from 'calypso/state/partner-portal/types'; | ||
import { getHostingLogo, getHostingPageUrl } from '../../lib/hosting'; | ||
import useHostingDescription from '../hooks/use-hosting-description'; | ||
|
||
import './style.scss'; | ||
type Props = { | ||
plan: APIProductFamilyProduct; | ||
}; | ||
|
||
export default function HostingCard( { plan }: Props ) { | ||
const translate = useTranslate(); | ||
const dispatch = useDispatch(); | ||
|
||
const { name, description } = useHostingDescription( plan.family_slug ); | ||
|
||
const onExploreClick = () => { | ||
dispatch( | ||
recordTracksEvent( 'calypso_marketplace_hosting_overview_explore_plan_click', { | ||
hosting: plan.family_slug, | ||
} ) | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="hosting-card"> | ||
<div className="hosting-card__header">{ getHostingLogo( plan.family_slug ) }</div> | ||
|
||
<div className="hosting-card__price"> | ||
<b className="hosting-card__price-value"> | ||
{ translate( 'Starting at %(price)s', { | ||
args: { price: formatCurrency( Number( plan.amount ), plan.currency ) }, | ||
} ) } | ||
</b> | ||
<div className="hosting-card__price-interval"> | ||
{ plan.price_interval === 'day' && translate( 'USD per plan per day' ) } | ||
{ plan.price_interval === 'month' && translate( 'USD per plan per month' ) } | ||
</div> | ||
</div> | ||
|
||
<p className="hosting-card__description">{ description }</p> | ||
|
||
<Button | ||
className="hosting-card__explore-button" | ||
href={ getHostingPageUrl( plan.family_slug ) } | ||
onClick={ onExploreClick } | ||
primary | ||
> | ||
{ translate( 'Explore %(hosting)s plans', { | ||
args: { | ||
hosting: name, | ||
}, | ||
comment: '%(hosting)s is the name of the hosting provider.', | ||
} ) } | ||
</Button> | ||
</div> | ||
); | ||
} |
30 changes: 30 additions & 0 deletions
30
client/a8c-for-agencies/sections/marketplace/hosting-overview/hosting-card/style.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,30 @@ | ||
|
||
.hosting-card { | ||
padding: 1.5rem; | ||
border: 1px solid var(--color-neutral-10); | ||
border-radius: 4px; | ||
user-select: none; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 24px; | ||
} | ||
|
||
.hosting-card__price-value { | ||
font-size: 1.5rem; | ||
font-weight: 600; | ||
line-height: 1.1; | ||
} | ||
|
||
.hosting-card__price-interval { | ||
font-size: 0.75rem; | ||
line-height: 1.1; | ||
font-weight: 400; | ||
} | ||
|
||
.hosting-card__description { | ||
font-size: 0.875rem; | ||
line-height: 1.1; | ||
font-weight: 400; | ||
margin: 0; | ||
} |
74 changes: 74 additions & 0 deletions
74
client/a8c-for-agencies/sections/marketplace/hosting-overview/hosting-list/index.tsx
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,74 @@ | ||
import { SiteDetails } from '@automattic/data-stores'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useCallback, useMemo, useState } from 'react'; | ||
import FilterSearch from 'calypso/a8c-for-agencies/components/filter-search'; | ||
import { useDispatch } from 'calypso/state'; | ||
import { recordTracksEvent } from 'calypso/state/analytics/actions'; | ||
import useProductAndPlans from '../../hooks/use-product-and-plans'; | ||
import { getCheapestPlan } from '../../lib/hosting'; | ||
import ListingSection from '../../listing-section'; | ||
import HostingCard from '../hosting-card'; | ||
|
||
import './style.scss'; | ||
|
||
interface Props { | ||
selectedSite?: SiteDetails | null; | ||
} | ||
|
||
export default function HostingList( { selectedSite }: Props ) { | ||
const translate = useTranslate(); | ||
const dispatch = useDispatch(); | ||
|
||
const [ productSearchQuery, setProductSearchQuery ] = useState< string >( '' ); | ||
|
||
const { isLoadingProducts, pressablePlans } = useProductAndPlans( { | ||
selectedSite, | ||
productSearchQuery, | ||
} ); | ||
|
||
const cheapestPressablePlan = useMemo( | ||
() => ( pressablePlans.length ? getCheapestPlan( pressablePlans ) : null ), | ||
[ pressablePlans ] | ||
); | ||
|
||
const cheapestWPCOMPlan = cheapestPressablePlan | ||
? { ...cheapestPressablePlan, family_slug: 'wpcom-hosting' } | ||
: null; // FIXME: Need to fetch from API | ||
|
||
const onProductSearch = useCallback( | ||
( value: string ) => { | ||
setProductSearchQuery( value ); | ||
dispatch( | ||
recordTracksEvent( 'calypso_a4a_marketplace_hosting_overview_search_submit', { value } ) | ||
); | ||
}, | ||
[ dispatch ] | ||
); | ||
|
||
if ( isLoadingProducts ) { | ||
return ( | ||
<div className="hosting-list"> | ||
<div className="hosting-list__placeholder" /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="hosting-list"> | ||
<div className="hosting-list__actions"> | ||
<FilterSearch label={ translate( 'Search products' ) } onSearch={ onProductSearch } /> | ||
</div> | ||
|
||
<ListingSection | ||
title={ translate( 'Hosting' ) } | ||
description={ translate( | ||
'Mix and match powerful security, performance, and growth tools for your sites.' | ||
) } | ||
isTwoColumns | ||
> | ||
{ cheapestPressablePlan && <HostingCard plan={ cheapestPressablePlan } /> } | ||
{ cheapestWPCOMPlan && <HostingCard plan={ cheapestWPCOMPlan } /> } | ||
</ListingSection> | ||
</div> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
client/a8c-for-agencies/sections/marketplace/hosting-overview/hosting-list/style.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,12 @@ | ||
.hosting-list__placeholder { | ||
@include placeholder( --color-neutral-10 ); | ||
height: 43px; | ||
} | ||
|
||
.hosting-list__actions { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 16px; | ||
margin: 16px 0 32px; | ||
justify-content: space-between; | ||
} |
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
Oops, something went wrong.