-
Notifications
You must be signed in to change notification settings - Fork 2k
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
New Checkout: split layout (take 2) #41373
Changes from 33 commits
4d7ef8b
37b3788
7baa996
084834e
a914142
9cc0a13
b12be53
4ce26ea
946ce9e
ee8104a
b2085e4
a4150fe
8a554ad
b4555b6
e9ed68b
d1f734c
3dd40e4
7fe28da
840da4a
5545282
8a3bc98
c37dbb3
1567c2c
80786e3
2cf0b5a
28059bb
ad0d7e9
b1891e4
bb2074b
a53b033
0ba584f
a7ac92c
e3cd44b
8c82195
7a4d9bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,46 +3,109 @@ | |
*/ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { useLineItems, useTotal, renderDisplayValueMarkdown } from '@automattic/composite-checkout'; | ||
import { | ||
CheckoutCheckIcon, | ||
renderDisplayValueMarkdown, | ||
useLineItemsOfType, | ||
useTotal, | ||
} from '@automattic/composite-checkout'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isLineItemADomain } from '../hooks/has-domains'; | ||
|
||
export default function WPCheckoutOrderSummary( { siteUrl } ) { | ||
const [ items ] = useLineItems(); | ||
|
||
const firstDomainItem = items.find( isLineItemADomain ); | ||
const domainUrl = firstDomainItem ? firstDomainItem.sublabel : siteUrl; | ||
|
||
return <React.Fragment>{ domainUrl && <DomainURL>{ domainUrl }</DomainURL> }</React.Fragment>; | ||
} | ||
|
||
export function WPCheckoutOrderSummaryTitle() { | ||
export default function WPCheckoutOrderSummary() { | ||
const translate = useTranslate(); | ||
const taxes = useLineItemsOfType( 'tax' ); | ||
const total = useTotal(); | ||
|
||
return ( | ||
<CheckoutSummaryTitle> | ||
<span>{ translate( 'You are all set to check out' ) }</span> | ||
<CheckoutSummaryTotal> | ||
{ renderDisplayValueMarkdown( total.amount.displayValue ) } | ||
</CheckoutSummaryTotal> | ||
</CheckoutSummaryTitle> | ||
<> | ||
<CheckoutSummaryTitle>{ translate( 'Purchase Details' ) }</CheckoutSummaryTitle> | ||
<CheckoutSummaryFeatures> | ||
<CheckoutSummaryFeaturesTitle> | ||
{ translate( 'Included with your purchase' ) } | ||
</CheckoutSummaryFeaturesTitle> | ||
<CheckoutSummaryFeaturesList> | ||
<CheckoutSummaryFeaturesListItem> | ||
<WPCheckoutCheckIcon /> | ||
{ translate( 'Live chat and email support' ) } | ||
</CheckoutSummaryFeaturesListItem> | ||
<CheckoutSummaryFeaturesListItem> | ||
<WPCheckoutCheckIcon /> | ||
{ translate( 'Free custom domain for a year' ) } | ||
</CheckoutSummaryFeaturesListItem> | ||
<CheckoutSummaryFeaturesListItem> | ||
<WPCheckoutCheckIcon /> | ||
{ translate( 'Dozens of free themes' ) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ String reuse speeds up translation and improves consistency. The following string might make a good alternative and has already been translated 19 times: |
||
</CheckoutSummaryFeaturesListItem> | ||
<CheckoutSummaryFeaturesListItem> | ||
<WPCheckoutCheckIcon /> | ||
{ translate( 'Money back guarantee' ) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ String reuse speeds up translation and improves consistency. The following string might make a good alternative and has already been translated 17 times: |
||
</CheckoutSummaryFeaturesListItem> | ||
</CheckoutSummaryFeaturesList> | ||
</CheckoutSummaryFeatures> | ||
<CheckoutSummaryAmountWrapper> | ||
{ taxes.map( ( tax ) => ( | ||
<CheckoutSummaryLineItem key={ 'checkout-summary-line-item-' + tax.id }> | ||
<span>{ tax.label }</span> | ||
<span>{ renderDisplayValueMarkdown( tax.amount.displayValue ) }</span> | ||
</CheckoutSummaryLineItem> | ||
) ) } | ||
<CheckoutSummaryTotal> | ||
<span>{ translate( 'Total' ) }</span> | ||
<span>{ renderDisplayValueMarkdown( total.amount.displayValue ) }</span> | ||
</CheckoutSummaryTotal> | ||
</CheckoutSummaryAmountWrapper> | ||
</> | ||
); | ||
} | ||
|
||
const CheckoutSummaryTitle = styled.span` | ||
const CheckoutSummaryTitle = styled.h2` | ||
color: ${( props ) => props.theme.colors.textColor}; | ||
display: none; | ||
font-weight: ${( props ) => props.theme.weights.bold}; | ||
padding: 20px 20px 0; | ||
|
||
@media ( ${( props ) => props.theme.breakpoints.desktopUp} ) { | ||
display: none; | ||
} | ||
`; | ||
|
||
const CheckoutSummaryFeatures = styled.div` | ||
padding: 20px; | ||
`; | ||
|
||
const CheckoutSummaryFeaturesTitle = styled.h3` | ||
font-size: 16px; | ||
font-weight: ${( props ) => props.theme.weights.normal}; | ||
margin-bottom: 4px; | ||
`; | ||
|
||
const CheckoutSummaryFeaturesList = styled.ul` | ||
margin: 0; | ||
list-style: none; | ||
font-size: 14px; | ||
`; | ||
|
||
const WPCheckoutCheckIcon = styled( CheckoutCheckIcon )` | ||
fill: ${( props ) => props.theme.colors.success}; | ||
margin-right: 4px; | ||
vertical-align: bottom; | ||
`; | ||
|
||
const CheckoutSummaryFeaturesListItem = styled.li` | ||
margin-bottom: 4px; | ||
`; | ||
|
||
const CheckoutSummaryAmountWrapper = styled.div` | ||
border-top: 1px solid ${( props ) => props.theme.colors.borderColorLight}; | ||
padding: 20px; | ||
`; | ||
|
||
const CheckoutSummaryLineItem = styled.div` | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
`; | ||
|
||
const CheckoutSummaryTotal = styled.span` | ||
const CheckoutSummaryTotal = styled( CheckoutSummaryLineItem )` | ||
font-weight: ${( props ) => props.theme.weights.bold}; | ||
`; | ||
|
||
const DomainURL = styled.div` | ||
margin-top: -12px; | ||
word-break: break-word; | ||
`; |
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.
ℹ️ String reuse speeds up translation and improves consistency. The following string might make a good alternative and has already been translated 29 times:
translate( 'Email and live chat support' )
ES Score: 9See 2 additional suggestions in the PR translation status page