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

Fix styling on payment details page in mobile view. #9790

Merged
merged 14 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
4 changes: 4 additions & 0 deletions changelog/fix-7230-payments-details-mobile-view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix styling of transaction details page in mobile view.
4 changes: 3 additions & 1 deletion client/components/dispute-status-chip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ interface Props {
status: DisputeStatus | string;
dueBy?: CachedDispute[ 'due_by' ] | EvidenceDetails[ 'due_by' ];
prefixDisputeType?: boolean;
className?: string;
}
const DisputeStatusChip: React.FC< Props > = ( {
status,
dueBy,
prefixDisputeType,
className,
} ) => {
const mapping = displayStatus[ status ] || {};
let message = mapping.message || formatStringValue( status );
Expand All @@ -50,7 +52,7 @@ const DisputeStatusChip: React.FC< Props > = ( {
type = 'alert';
}

return <Chip message={ message } type={ type } />;
return <Chip className={ className } message={ message } type={ type } />;
};

export default DisputeStatusChip;
4 changes: 2 additions & 2 deletions client/components/payment-status-chip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import displayStatus from './mappings';
import Chip from '../chip';
import { formatStringValue } from 'utils';

const PaymentStatusChip = ( { status } ) => {
const PaymentStatusChip = ( { status, className } ) => {
const mapping = displayStatus[ status ] || {};
const message = mapping.message || formatStringValue( status );
const type = mapping.type || 'light';
return <Chip message={ message } type={ type } />;
return <Chip className={ className } message={ message } type={ type } />;
};

export default PaymentStatusChip;
7 changes: 6 additions & 1 deletion client/payment-details/dispute-details/dispute-notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ const DisputeNotice: React.FC< DisputeNoticeProps > = ( {
{ createInterpolateElement(
sprintf( noticeText, shopperDisputeReason ),
{
a: <ExternalLink href={ learnMoreDocsUrl } />,
a: (
<ExternalLink
className="dispute-notice-link"
href={ learnMoreDocsUrl }
/>
),
strong: <strong />,
}
) }
Expand Down
14 changes: 14 additions & 0 deletions client/payment-details/dispute-details/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,17 @@
margin-bottom: 0;
}
}

.dispute-notice {
.dispute-notice-link {
display: block;
}
}

@media screen and ( max-width: $break-small ) {
.wcpay-inline-notice.components-notice
.components-notice__content
a.dispute-notice-link {
white-space: normal;
}
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ for consistency, should this new classname follow BEM-naming?

Suggested change
.dispute-notice-link {
display: block;
}
}
@media screen and ( max-width: $break-small ) {
.wcpay-inline-notice.components-notice
.components-notice__content
a.dispute-notice-link {
white-space: normal;
}
.dispute-notice__link {
display: block;
}
}
@media screen and ( max-width: $break-small ) {
.wcpay-inline-notice.components-notice
.components-notice__content
a.dispute-notice__link {
white-space: normal;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 13db0c1.

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ exports[`Order details page should match the snapshot - Charge without payment i
<div
class="payment-details-summary__section"
>
<p
class="payment-details-summary__amount"
<div
class="payment-details-summary__amount_wrapper"
>
$15.00
<span
class="payment-details-summary__amount-currency"
<p
class="payment-details-summary__amount"
>
USD
</span>
$15.00
<span
class="payment-details-summary__amount-currency"
>
USD
</span>
</p>
<span
class="chip chip-light"
class="chip chip-light payment-details-summary__status"
>
Pending
</span>
</p>
</div>
<div
class="payment-details-summary__breakdown"
>
Expand Down
66 changes: 35 additions & 31 deletions client/payment-details/summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,37 +257,41 @@ const PaymentDetailsSummary: React.FC< PaymentDetailsSummaryProps > = ( {
<Flex direction="row" align="start">
<div className="payment-details-summary">
<div className="payment-details-summary__section">
<p className="payment-details-summary__amount">
<Loadable
isLoading={ isLoading }
placeholder={ __(
'Amount placeholder',
'woocommerce-payments'
) }
>
{ formattedAmount }
<span className="payment-details-summary__amount-currency">
{ charge.currency || 'USD' }
</span>
{ charge.dispute ? (
<DisputeStatusChip
status={ charge.dispute.status }
dueBy={
charge.dispute.evidence_details
?.due_by
}
prefixDisputeType={ true }
/>
) : (
<PaymentStatusChip
status={ getChargeStatus(
charge,
paymentIntent
) }
/>
) }
</Loadable>
</p>
<div className="payment-details-summary__amount_wrapper">
<p className="payment-details-summary__amount">
<Loadable
isLoading={ isLoading }
placeholder={ __(
'Amount placeholder',
'woocommerce-payments'
) }
>
{ formattedAmount }
<span className="payment-details-summary__amount-currency">
{ charge.currency || 'USD' }
</span>
</Loadable>
</p>
{ charge.dispute ? (
<DisputeStatusChip
className="payment-details-summary__status"
status={ charge.dispute.status }
dueBy={
charge.dispute.evidence_details
?.due_by
}
prefixDisputeType={ true }
/>
) : (
<PaymentStatusChip
className="payment-details-summary__status"
status={ getChargeStatus(
charge,
paymentIntent
) }
/>
) }
</div>
<div className="payment-details-summary__breakdown">
{ renderStorePrice ? (
<p className="payment-details-summary__breakdown__settlement-currency">
Expand Down
16 changes: 16 additions & 0 deletions client/payment-details/summary/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
flex-grow: 1;
}

.payment-details-summary__amount_wrapper {
display: flex;
align-items: center;
}

@media screen and ( max-width: $break-small ) {
.payment-details-summary__amount_wrapper {
flex-direction: column;
align-items: flex-start;

.payment-details-summary__status {
order: -1;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ Similarly, for consistency with BEM, I suggest we use - in amount-wrapper rather than _.

Suggested change
.payment-details-summary__amount_wrapper {
display: flex;
align-items: center;
}
@media screen and ( max-width: $break-small ) {
.payment-details-summary__amount_wrapper {
flex-direction: column;
align-items: flex-start;
.payment-details-summary__status {
order: -1;
}
}
}
.payment-details-summary__amount-wrapper {
display: flex;
align-items: center;
}
@media screen and ( max-width: $break-small ) {
.payment-details-summary__amount-wrapper {
flex-direction: column;
align-items: flex-start;
.payment-details-summary__status {
order: -1;
}
}
}

Copy link
Contributor Author

@shendy-a8c shendy-a8c Dec 2, 2024

Choose a reason for hiding this comment

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

Addressed in 13c3890.


.payment-details-summary__amount {
@include font-size( 32 );
font-weight: 300;
Expand Down
Loading
Loading