Skip to content

Commit f46c71b

Browse files
committed
Split loading vs non-loading
1 parent 016436b commit f46c71b

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

client/dashboard/sites/overview/site-card.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import { dateI18n } from '@wordpress/date';
1111
import { createInterpolateElement } from '@wordpress/element';
1212
import { __, sprintf } from '@wordpress/i18n';
1313
import { sitePHPVersionQuery, siteCurrentPlanQuery } from '../../app/queries';
14-
import { getIsBlurredProps } from '../../utils/is-blurred';
14+
import { IS_BLURRED_PROPS } from '../../utils/is-blurred';
1515
import { getSiteStatusLabel } from '../../utils/site-status';
1616
import { getFormattedWordPressVersion } from '../../utils/wp-version';
1717
import SitePreview from '../site-preview';
1818
import type { Site } from '../../data/types';
1919

2020
function PHPVersion( { siteSlug }: { siteSlug: string } ) {
2121
return (
22-
useQuery( sitePHPVersionQuery( siteSlug ) ).data ?? <span { ...getIsBlurredProps() }>X.Y</span>
22+
useQuery( sitePHPVersionQuery( siteSlug ) ).data ?? <span { ...IS_BLURRED_PROPS }>X.Y</span>
2323
);
2424
}
2525

@@ -130,20 +130,26 @@ function PlanDetails( { site }: { site: Site } ) {
130130
</>
131131
) : (
132132
<>
133-
<Text { ...getIsBlurredProps( { enabled: ! currentPlan } ) }>
134-
{ getPlanExpirationMessage(
135-
currentPlan ? currentPlan.expiry : new Date().toISOString()
136-
) }
137-
</Text>
138-
<Button
139-
{ ...getIsBlurredProps( { enabled: ! currentPlan } ) }
140-
href={
141-
currentPlan ? `/purchases/subscriptions/${ site.slug }/${ currentPlan.id }` : ''
142-
}
143-
variant="link"
144-
>
145-
{ __( 'Manage subscription' ) }
146-
</Button>
133+
{ currentPlan ? (
134+
<>
135+
<Text>{ getPlanExpirationMessage( currentPlan.expiry ) }</Text>
136+
<Button
137+
href={ `/purchases/subscriptions/${ site.slug }/${ currentPlan.id }` }
138+
variant="link"
139+
>
140+
{ __( 'Manage subscription' ) }
141+
</Button>
142+
</>
143+
) : (
144+
<>
145+
<Text { ...IS_BLURRED_PROPS }>
146+
{ getPlanExpirationMessage( new Date().toISOString() ) }
147+
</Text>
148+
<Button { ...IS_BLURRED_PROPS } href="" variant="link">
149+
{ __( 'Manage subscription' ) }
150+
</Button>
151+
</>
152+
) }
147153
</>
148154
) }
149155
</VStack>

client/dashboard/sites/overview/uptime-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { VisuallyHidden } from '@wordpress/components';
33
import { __, sprintf } from '@wordpress/i18n';
44
import { connection } from '@wordpress/icons';
55
import { siteMonitorUptimeQuery } from '../../app/queries';
6-
import { getIsBlurredProps } from '../../utils/is-blurred';
6+
import { IS_BLURRED_PROPS } from '../../utils/is-blurred';
77
import OverviewCard, { OverviewCardProgressBar } from '../overview-card';
88
import type { Site } from '../../data/types';
99

@@ -35,7 +35,7 @@ function UptimeCardEnabled( { siteSlug }: { siteSlug: string } ) {
3535
heading={
3636
uptimePercentage === undefined ? (
3737
<>
38-
<span { ...getIsBlurredProps() }>{ sprintf( percentageString, '100' ) }</span>
38+
<span { ...IS_BLURRED_PROPS }>{ sprintf( percentageString, '100' ) }</span>
3939
<VisuallyHidden>{ __( 'Loading…' ) }</VisuallyHidden>
4040
</>
4141
) : (
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import './style.scss';
22

3-
export function getIsBlurredProps( { enabled = true }: { enabled?: boolean } = {} ) {
4-
return enabled ? { className: 'is-blurred', inert: 'true' } : {};
5-
}
3+
export const IS_BLURRED_PROPS = {
4+
className: 'is-blurred',
5+
// Even for non-interactive elements we want this because it's equivalent to
6+
// `aria-hidden="true"`.
7+
inert: true,
8+
};

0 commit comments

Comments
 (0)