-
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.
Jetpack Pricing | Add amount saved in bundles to featured item card (#…
…70631) * Extract re-usage original price calculation to a hook * Create usePricingBreakdown to calculate the pricing breakdown * Create PricingBreakdown component to render the UI * Wire everything up * Some makeup * Fix sidebar padding for tablet viewpoint * Disable breakdown for products * Hide breakdown for normal products * Fix the breakdown for mobile view * Move some more logic from PricingBreakdown to usePricingBreakdown * Organise the code a bit * Move styles over to the new place * Create index file for PricingBreakdown * Use CSS var for white color * Move constants to plans list * Endure the correct value for amountSaved * Fix conflicts in CSS * Enable breakdown only for english locales * Fix margin for highlight on smaller screens * Create AmountSaved component * Wire it all up * Enable the UI only for english locales * Use Tooltip instead of clickable button
- Loading branch information
1 parent
7357a33
commit 76b16dd
Showing
6 changed files
with
93 additions
and
3 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
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
49 changes: 49 additions & 0 deletions
49
client/my-sites/plans/jetpack-plans/product-store/items-list/amount-saved.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,49 @@ | ||
import { Gridicon } from '@automattic/components'; | ||
import { Tooltip } from '@wordpress/components'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { usePricingBreakdown } from '../hooks/use-pricing-breakdown'; | ||
import { RenderPrice } from '../pricing-breakdown/render-price'; | ||
import { AmountSavedProps } from '../types'; | ||
|
||
export const AmountSaved: React.FC< AmountSavedProps > = ( { product, siteId } ) => { | ||
const includedProductSlugs = product.productsIncluded || []; | ||
const translate = useTranslate(); | ||
|
||
const { amountSaved, isFetching } = usePricingBreakdown( { | ||
includedProductSlugs, | ||
product, | ||
siteId, | ||
} ); | ||
|
||
return amountSaved && ! isFetching ? ( | ||
<Tooltip | ||
position="top left" | ||
text={ | ||
<span> | ||
{ translate( 'For details, click on "{{moreInfo/}}"', { | ||
components: { | ||
moreInfo: ( | ||
<span> | ||
{ translate( 'More about {{productName/}}', { | ||
components: { productName: <>{ product.shortName }</> }, | ||
} ) } | ||
</span> | ||
), | ||
}, | ||
} ) }{ ' ' } | ||
</span> | ||
} | ||
> | ||
<div className="amount-saved--tooltip-text"> | ||
<span> | ||
{ translate( 'Save {{amount/}}/mo vs buying individually', { | ||
components: { | ||
amount: <RenderPrice price={ amountSaved } />, | ||
}, | ||
} ) } | ||
</span> | ||
<Gridicon icon="info-outline" size={ 16 } /> | ||
</div> | ||
</Tooltip> | ||
) : null; | ||
}; |
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
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