Skip to content

Commit fdaa9de

Browse files
yashwinclaude
andcommitted
A4A: Use the new badge style on Reports, Amplify, Partner Directory, and payment settings
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent de9db13 commit fdaa9de

10 files changed

Lines changed: 74 additions & 85 deletions

File tree

client/a8c-for-agencies/sections/amplify/primary/overview/sections/score-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Badge } from '@automattic/components';
1+
import { Badge } from '@automattic/ui';
22
import {
33
Card,
44
CardBody,
@@ -135,7 +135,7 @@ export default function AmplifyScoreCard() {
135135
<Text as="code" variant="muted" size={ 12 }>
136136
{ SAMPLE_URL }
137137
</Text>
138-
<Badge type="success">{ __( 'Audit complete' ) }</Badge>
138+
<Badge intent="success">{ __( 'Audit complete' ) }</Badge>
139139
</HStack>
140140

141141
<ToggleGroupControl

client/a8c-for-agencies/sections/amplify/primary/reports/reports-content.scss

Lines changed: 0 additions & 6 deletions
This file was deleted.

client/a8c-for-agencies/sections/amplify/primary/reports/reports-content.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Badge } from '@automattic/components';
1+
import { Badge } from '@automattic/ui';
22
import { useBreakpoint } from '@automattic/viewport-react';
33
import {
44
Button,
@@ -25,13 +25,10 @@ import { recordTracksEvent } from 'calypso/state/analytics/actions';
2525
import { errorNotice, successNotice } from 'calypso/state/notices/actions';
2626
import ArchiveReportConfirmationDialog from './archive-report-confirmation-dialog';
2727
import useAmplifyReportRows, { AmplifyReportRow } from './use-report-rows';
28-
import type { BadgeType } from '@automattic/components';
2928
import type { Action, Field } from '@wordpress/dataviews';
3029
import type { AmplifyMode } from 'calypso/a8c-for-agencies/data/amplify/types';
3130
import type { ReactNode } from 'react';
3231

33-
import './reports-content.scss';
34-
3532
function modeLabel( mode: AmplifyMode ): string {
3633
switch ( mode ) {
3734
case 'human':
@@ -45,12 +42,6 @@ function modeLabel( mode: AmplifyMode ): string {
4542
}
4643
}
4744

48-
const MODE_BADGE_TYPE: Record< AmplifyMode, BadgeType > = {
49-
human: 'info-blue',
50-
ai: 'info-purple',
51-
full: 'info-green',
52-
};
53-
5445
function formatTimestamp( iso: string ): string {
5546
return new Date( iso ).toLocaleString( undefined, {
5647
month: 'short',
@@ -64,16 +55,16 @@ function ScoreBadge( { score, label }: { score: number | null; label: string } )
6455
if ( score === null ) {
6556
return null;
6657
}
67-
let type: BadgeType;
58+
let intent: 'success' | 'warning' | 'error';
6859
if ( score >= 80 ) {
69-
type = 'success';
60+
intent = 'success';
7061
} else if ( score >= 50 ) {
71-
type = 'warning';
62+
intent = 'warning';
7263
} else {
73-
type = 'error';
64+
intent = 'error';
7465
}
7566
return (
76-
<Badge type={ type }>
67+
<Badge intent={ intent }>
7768
{ sprintf(
7869
/* translators: %1$s is the score label (e.g. Human), %2$d is the numeric score */
7970
__( '%1$s %2$d' ),
@@ -132,12 +123,7 @@ export default function AmplifyReportsContent() {
132123
label: __( 'Analysis type' ),
133124
getValue: ( { item }: { item: AmplifyReportRow } ) => modeLabel( item.mode ),
134125
render: ( { item }: { item: AmplifyReportRow } ): ReactNode => (
135-
<Badge
136-
type={ MODE_BADGE_TYPE[ item.mode ] }
137-
className={ `amplify-report-mode-badge is-${ item.mode }` }
138-
>
139-
{ modeLabel( item.mode ) }
140-
</Badge>
126+
<Badge>{ modeLabel( item.mode ) }</Badge>
141127
),
142128
enableHiding: true,
143129
enableSorting: true,
@@ -190,7 +176,7 @@ export default function AmplifyReportsContent() {
190176
render: ( { item }: { item: AmplifyReportRow } ): ReactNode => {
191177
if ( item.rowStatus === 'failed' ) {
192178
return (
193-
<Badge type="error" title={ item.failureReason }>
179+
<Badge intent="error" title={ item.failureReason }>
194180
{ __( 'Analysis failed' ) }
195181
</Badge>
196182
);

client/a8c-for-agencies/sections/partner-directory/dashboard/index.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { BadgeType } from '@automattic/components';
21
import { Button, ExternalLink } from '@wordpress/components';
32
import { check } from '@wordpress/icons';
43
import clsx from 'clsx';
@@ -27,21 +26,21 @@ import {
2726
mapAgencyDetailsFormData,
2827
mapApplicationFormData,
2928
} from '../utils/map-application-form-data';
30-
import DashboardStatusBadge from './status-badge';
29+
import DashboardStatusBadge, { StatusBadgeIntent } from './status-badge';
3130

3231
import './style.scss';
3332

3433
interface DirectoryApplicationStatus {
3534
key: string;
3635
brand: string;
3736
status: string;
38-
type: BadgeType;
37+
intent: StatusBadgeIntent;
3938
}
4039

4140
interface StatusBadge {
4241
key: string;
4342
label: string;
44-
type: BadgeType;
43+
intent: StatusBadgeIntent;
4544
}
4645

4746
const PartnerDirectoryDashboard = () => {
@@ -70,27 +69,27 @@ const PartnerDirectoryDashboard = () => {
7069
pending: {
7170
key: 'pending',
7271
label: translate( 'Pending' ),
73-
type: 'warning',
72+
intent: 'warning',
7473
},
7574
approved: {
7675
key: 'approved',
7776
label: translate( 'Approved' ),
78-
type: 'success',
77+
intent: 'success',
7978
},
8079
rejected: {
8180
key: 'rejected',
8281
label: translate( 'Not approved' ),
83-
type: 'error',
82+
intent: 'error',
8483
},
8584
closed: {
8685
key: 'closed',
8786
label: translate( 'Closed' ),
88-
type: 'info',
87+
intent: 'info',
8988
},
9089
unknown: {
9190
key: 'unknown',
9291
label: '-',
93-
type: 'info',
92+
intent: 'info',
9493
},
9594
};
9695
}, [ translate ] );
@@ -177,7 +176,7 @@ const PartnerDirectoryDashboard = () => {
177176
statuses.push( {
178177
brand: availableDirectories[ directory.directory ],
179178
status: applicationStatusTypeMap[ directory.status || 'unknown' ].label,
180-
type: applicationStatusTypeMap[ directory.status || 'unknown' ].type,
179+
intent: applicationStatusTypeMap[ directory.status || 'unknown' ].intent,
181180
key: applicationStatusTypeMap[ directory.status || 'unknown' ].key,
182181
} );
183182
return statuses;
@@ -266,7 +265,7 @@ const PartnerDirectoryDashboard = () => {
266265
<DashboardStatusBadge
267266
statusProps={ {
268267
status: application.status,
269-
type: application.type,
268+
intent: application.intent,
270269
} }
271270
showPopoverOnLoad={ showPopoverOnLoad }
272271
/>
@@ -361,7 +360,7 @@ const PartnerDirectoryDashboard = () => {
361360
description={
362361
applicationWasSubmitted && directoryApplicationStatuses.length > 0 ? (
363362
<div className="partner-directory-dashboard__brand-status-section">
364-
{ directoryApplicationStatuses.map( ( { brand, status, type } ) => {
363+
{ directoryApplicationStatuses.map( ( { brand, status, intent } ) => {
365364
const showPopoverOnLoad =
366365
directoryApplicationStatuses.filter( ( { key } ) => key === 'rejected' )
367366
.length === 1;
@@ -370,7 +369,7 @@ const PartnerDirectoryDashboard = () => {
370369
<DashboardStatusBadge
371370
statusProps={ {
372371
status,
373-
type,
372+
intent,
374373
} }
375374
showPopoverOnLoad={ showPopoverOnLoad }
376375
/>

client/a8c-for-agencies/sections/partner-directory/dashboard/status-badge.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import { BadgeType, Button, Badge } from '@automattic/components';
1+
import { Button } from '@automattic/components';
2+
import { Badge } from '@automattic/ui';
23
import { useTranslate } from 'i18n-calypso';
3-
import { useRef, useState, useCallback, useEffect } from 'react';
4+
import { useRef, useState, useCallback, useEffect, ComponentProps } from 'react';
45
import { useDispatch, useSelector } from 'calypso/state';
56
import { recordTracksEvent } from 'calypso/state/analytics/actions';
67
import { savePreference } from 'calypso/state/preferences/actions';
78
import { getPreference } from 'calypso/state/preferences/selectors';
89
import A4APopover from '../../../components/a4a-popover';
910

11+
export type StatusBadgeIntent = ComponentProps< typeof Badge >[ 'intent' ];
12+
1013
interface Props {
1114
statusProps: {
1215
status: string;
13-
type: BadgeType;
16+
intent: StatusBadgeIntent;
1417
};
1518
showPopoverOnLoad: boolean;
1619
}
@@ -66,11 +69,9 @@ export default function DashboardStatusBadge( { statusProps, showPopoverOnLoad }
6669
if ( ! popoverContent ) {
6770
return (
6871
<span>
69-
<Badge
70-
className="step-section-item__status"
71-
children={ statusProps.status }
72-
type={ statusProps.type }
73-
/>
72+
<Badge className="step-section-item__status" intent={ statusProps.intent }>
73+
{ statusProps.status }
74+
</Badge>
7475
</span>
7576
);
7677
}
@@ -88,11 +89,9 @@ export default function DashboardStatusBadge( { statusProps, showPopoverOnLoad }
8889
tabIndex={ 0 }
8990
ref={ wrapperRef }
9091
>
91-
<Badge
92-
className="step-section-item__status"
93-
children={ statusProps.status }
94-
type={ statusProps.type }
95-
/>
92+
<Badge className="step-section-item__status" intent={ statusProps.intent }>
93+
{ statusProps.status }
94+
</Badge>
9695
{ showPopover && popoverContent && (
9796
<A4APopover
9897
title={ translate(

client/a8c-for-agencies/sections/partner-directory/dashboard/style.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
flex-direction: column;
4949
gap: 8px;
5050

51-
.badge {
52-
min-width: 100px;
53-
margin-inline-end: 8px;
54-
text-align: center;
55-
}
51+
> div {
52+
display: flex;
53+
align-items: center;
54+
gap: 8px;
5655

57-
span {
58-
color: var(--color-text-black);
56+
> span {
57+
color: var(--color-text-black);
58+
}
5959
}
6060
}
6161

client/a8c-for-agencies/sections/partner-directory/lead-matching/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import page from '@automattic/calypso-router';
2-
import { Badge } from '@automattic/components';
2+
import { Badge } from '@automattic/ui';
33
import { Card, CardBody, ToggleControl, Button } from '@wordpress/components';
44
import { __, sprintf } from '@wordpress/i18n';
55
import clsx from 'clsx';
@@ -513,15 +513,15 @@ const LeadMatchingForm = ( { initialFormData, profile }: Props ) => {
513513
<CardBody className="partner-directory-lead-matching__status-content">
514514
{ eligibilityState === 'eligible' && (
515515
<>
516-
<Badge type="success">{ __( 'Eligible for leads' ) }</Badge>
516+
<Badge intent="success">{ __( 'Eligible for leads' ) }</Badge>
517517
<span className="partner-directory-lead-matching__status-text">
518518
{ __( 'Your preferences are saved. You can update them anytime.' ) }
519519
</span>
520520
</>
521521
) }
522522
{ eligibilityState === 'not-accepting' && (
523523
<>
524-
<Badge type="warning">{ __( 'Not eligible' ) }</Badge>
524+
<Badge intent="warning">{ __( 'Not eligible' ) }</Badge>
525525
<span className="partner-directory-lead-matching__status-text">
526526
{ __(
527527
'Turn on Accepting new clients to be included in lead matching and receive leads.'
@@ -531,7 +531,7 @@ const LeadMatchingForm = ( { initialFormData, profile }: Props ) => {
531531
) }
532532
{ eligibilityState === 'ready' && (
533533
<>
534-
<Badge type="info-blue">{ __( '1 step left' ) }</Badge>
534+
<Badge intent="info">{ __( '1 step left' ) }</Badge>
535535
<span className="partner-directory-lead-matching__status-text">
536536
{ __(
537537
'All questions answered — click Update preferences to start receiving leads'

client/a8c-for-agencies/sections/referrals/primary/bank-details/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { Badge } from '@automattic/ui';
12
import { useDesktopBreakpoint } from '@automattic/viewport-react';
3+
import { Tooltip } from '@wordpress/components';
24
import { useTranslate } from 'i18n-calypso';
35
import { LayoutWithGuidedTour as Layout } from 'calypso/a8c-for-agencies/components/layout/layout-with-guided-tour';
46
import LayoutTop from 'calypso/a8c-for-agencies/components/layout/layout-with-payment-notification';
@@ -8,7 +10,6 @@ import {
810
A4A_MIGRATIONS_LINK,
911
A4A_WOOPAYMENTS_LINK,
1012
} from 'calypso/a8c-for-agencies/components/sidebar-menu/lib/constants';
11-
import StatusBadge from 'calypso/a8c-for-agencies/components/step-section-item/status-badge';
1213
import { getAccountStatus } from 'calypso/dashboard/agency/earn/payout-settings/get-account-status';
1314
import { TipaltiPayoutSettings } from 'calypso/dashboard/agency/earn/payout-settings/tipalti-payout-settings';
1415
import LayoutBody from 'calypso/layout/hosting-dashboard/body';
@@ -61,6 +62,20 @@ const getPageInfo = (
6162
};
6263
}
6364
};
65+
66+
function PaymentStatusBadge( {
67+
intent,
68+
tooltip,
69+
children,
70+
}: {
71+
intent: 'success' | 'warning' | 'error';
72+
tooltip?: string;
73+
children?: string;
74+
} ) {
75+
const badge = <Badge intent={ intent }>{ children ?? '' }</Badge>;
76+
return tooltip ? <Tooltip text={ tooltip }>{ badge }</Tooltip> : badge;
77+
}
78+
6479
export default function ReferralsBankDetails( { type }: { type?: 'migrations' | 'woopayments' } ) {
6580
const translate = useTranslate();
6681
const isDesktop = useDesktopBreakpoint();
@@ -98,12 +113,9 @@ export default function ReferralsBankDetails( { type }: { type?: 'migrations' |
98113
comment: '%(status) is subscription status',
99114
components: {
100115
badge: (
101-
<StatusBadge
102-
statusProps={ {
103-
children: accountStatus.status,
104-
type: accountStatus.statusType,
105-
tooltip: accountStatus.statusReason,
106-
} }
116+
<PaymentStatusBadge
117+
intent={ accountStatus.statusType }
118+
tooltip={ accountStatus.statusReason }
107119
/>
108120
),
109121
},

client/a8c-for-agencies/sections/referrals/primary/bank-details/style.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ $iframe-background-color: #f7f7f7;
2626
.bank-details__status {
2727
@include body-large;
2828
color: var(--color-accent-80);
29-
30-
.badge {
31-
margin-inline-start: 6px;
32-
}
29+
display: flex;
30+
align-items: center;
31+
gap: 6px;
3332
}
3433

3534
.referrals-overview__link {

0 commit comments

Comments
 (0)