Skip to content

A local-first personal finance app

add more animations to reports (#7907)

Matt Fiddamane1e4fece908a
diff --git a/packages/desktop-client/src/components/reports/CalendarCardSkeleton.tsx b/packages/desktop-client/src/components/reports/CalendarCardSkeleton.tsx
new file mode 100644
index 0000000000..0f67b3ad34
--- /dev/null
+++ b/packages/desktop-client/src/components/reports/CalendarCardSkeleton.tsx
@@ -0,0 +1,75 @@
+import React from 'react';
+
+import { theme } from '@actual-app/components/theme';
+import { View } from '@actual-app/components/view';
+import { css, keyframes } from '@emotion/css';
+
+import { useReducedMotion } from '#hooks/useReducedMotion';
+
+const pulse = keyframes({
+ '0%, 100%': { opacity: 0.4 },
+ '50%': { opacity: 1 },
+});
+
+const cellBase = {
+ borderRadius: 4,
+ backgroundColor: theme.calendarCellBackground,
+};
+
+const staticCell = css({ ...cellBase, opacity: 0.7 });
+const pulsingCell = css({
+ ...cellBase,
+ animationName: pulse,
+ animationDuration: '1.6s',
+ animationTimingFunction: 'ease-in-out',
+ animationIterationCount: 'infinite',
+});
+
+export function CalendarCardSkeleton() {
+ const reducedMotion = useReducedMotion();
+ const cell = reducedMotion ? staticCell : pulsingCell;
+ return (
+ <View style={{ flex: 1, gap: 4 }} aria-hidden="true">
+ <View
+ style={{
+ display: 'grid',
+ gridTemplateColumns: 'repeat(7, 1fr)',
+ gap: 2,
+ }}
+ >
+ {Array.from({ length: 7 }, (_, i) => (
+ <View key={i} style={{ alignItems: 'center', padding: '3px 0' }}>
+ <div
+ className={cell}
+ style={{
+ width: 14,
+ height: 10,
+ backgroundColor: theme.pageTextSubdued,
+ }}
+ />
+ </View>
+ ))}
+ </View>
+ <View
+ style={{
+ flex: 1,
+ display: 'grid',
+ gridTemplateColumns: 'repeat(7, 1fr)',
+ gridTemplateRows: 'repeat(6, 1fr)',
+ gap: 2,
+ }}
+ >
+ {Array.from({ length: 42 }, (_, i) => (
+ <div
+ key={i}
+ className={cell}
+ // stagger the pulse diagonally
+ style={{
+ animationDelay: `${((i % 7) + Math.floor(i / 7)) * 0.04}s`,
+ }}
+ />
+ ))}
+ </View>
+ </View>
+ );
+}
diff --git a/packages/desktop-client/src/components/reports/FormulaResult.tsx b/packages/desktop-client/src/components/reports/FormulaResult.tsx
index 1dfc462e81..33941b5f90 100644
--- a/packages/desktop-client/src/components/reports/FormulaResult.tsx
+++ b/packages/desktop-client/src/components/reports/FormulaResult.tsx
@@ -17,7 +17,7 @@ import { useFormat } from '#hooks/useFormat';
import { useMergedRefs } from '#hooks/useMergedRefs';
import { useResizeObserver } from '#hooks/useResizeObserver';
-import { LoadingIndicator } from './LoadingIndicator';
+import { ReportCardValueSkeleton } from './ReportCardValueSkeleton';
const FONT_SIZE_SCALE_FACTOR = 1.6;
const CONTAINER_MARGIN = 8;
@@ -161,7 +161,7 @@ export function FormulaResult({
return (
<View style={{ flex: 1 }}>
- {loading && <LoadingIndicator />}
+ {loading && <ReportCardValueSkeleton />}
{!loading && (
<View
ref={mergedRef as Ref<HTMLDivElement>}
@@ -182,7 +182,7 @@ export function FormulaResult({
}}
>
{!showContent ? (
- <LoadingIndicator />
+ <ReportCardValueSkeleton />
) : (
<span aria-hidden="true">
<PrivacyFilter>{displayValue}</PrivacyFilter>
diff --git a/packages/desktop-client/src/components/reports/ReportCardValueSkeleton.tsx b/packages/desktop-client/src/components/reports/ReportCardValueSkeleton.tsx
new file mode 100644
index 0000000000..0677b402e2
--- /dev/null
+++ b/packages/desktop-client/src/components/reports/ReportCardValueSkeleton.tsx
@@ -0,0 +1,48 @@
+import React from 'react';
+
+import { theme } from '@actual-app/components/theme';
+import { View } from '@actual-app/components/view';
+import { css, keyframes } from '@emotion/css';
+
+import { useReducedMotion } from '#hooks/useReducedMotion';
+
+const pulse = keyframes({
+ '0%, 100%': { opacity: 0.15 },
+ '50%': { opacity: 0.4 },
+});
+
+const barBase = {
+ width: '55%',
+ maxWidth: 160,
+ height: 32,
+ borderRadius: 6,
+ backgroundColor: theme.pageText,
+};
+
+const staticBar = css({ ...barBase, opacity: 0.25 });
+const pulsingBar = css({
+ ...barBase,
+ animationName: pulse,
+ animationDuration: '1.4s',
+ animationTimingFunction: 'ease-in-out',
+ animationIterationCount: 'infinite',
+});
+
+export function ReportCardValueSkeleton() {
+ const reducedMotion = useReducedMotion();
+ return (
+ <View
+ style={{
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ width: '100%',
+ }}
+ >
+ <div
+ aria-hidden="true"
+ className={reducedMotion ? staticBar : pulsingBar}
+ />
+ </View>
+ );
+}
diff --git a/packages/desktop-client/src/components/reports/SummaryNumber.tsx b/packages/desktop-client/src/components/reports/SummaryNumber.tsx
index 1a3a4fbf9c..4ce60a571e 100644
--- a/packages/desktop-client/src/components/reports/SummaryNumber.tsx
+++ b/packages/desktop-client/src/components/reports/SummaryNumber.tsx
@@ -12,7 +12,7 @@ import { useFormat } from '#hooks/useFormat';
import { useMergedRefs } from '#hooks/useMergedRefs';
import { useResizeObserver } from '#hooks/useResizeObserver';
-import { LoadingIndicator } from './LoadingIndicator';
+import { ReportCardValueSkeleton } from './ReportCardValueSkeleton';
const FONT_SIZE_SCALE_FACTOR = 1.6;
const CONTAINER_MARGIN = 8;
@@ -77,7 +77,7 @@ export function SummaryNumber({
return (
<>
- {loading && <LoadingIndicator />}
+ {loading && <ReportCardValueSkeleton />}
{!loading && (
<View
ref={mergedRef as Ref<HTMLDivElement>}
@@ -112,7 +112,7 @@ export function SummaryNumber({
}}
>
{!hasSized ? (
- <LoadingIndicator />
+ <ReportCardValueSkeleton />
) : (
<FinancialText aria-hidden="true">
<PrivacyFilter>{displayAmount}</PrivacyFilter>
diff --git a/packages/desktop-client/src/components/reports/chart-theme.ts b/packages/desktop-client/src/components/reports/chart-theme.ts
index 054a7d40ac..23c35f4e26 100644
--- a/packages/desktop-client/src/components/reports/chart-theme.ts
+++ b/packages/desktop-client/src/components/reports/chart-theme.ts
@@ -1,4 +1,4 @@
-import { useIsTestEnv } from '#hooks/useIsTestEnv';
+import { useReducedMotion } from '#hooks/useReducedMotion';
export function getColorScale(name: string): string[] {
const scales: Record<string, string[]> = {
@@ -21,9 +21,9 @@ export function useRechartsAnimation(defaults?: {
animationDuration?: number;
isAnimationActive?: boolean;
}) {
- const isTestEnv = useIsTestEnv();
+ const reducedMotion = useReducedMotion();
- if (isTestEnv) {
+ if (reducedMotion) {
return {
isAnimationActive: false,
animationDuration: 0,
diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
index 07f88d8753..0514af3566 100644
--- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
@@ -192,7 +192,7 @@ export function AreaGraph({
showTooltip = true,
}: AreaGraphProps) {
const format = useFormat();
- const animationProps = useRechartsAnimation({ isAnimationActive: false });
+ const animationProps = useRechartsAnimation({ animationDuration: 1000 });
const privacyMode = usePrivacyMode();
const dataMax = Math.max(...data.intervalData.map(i => i[balanceTypeOp]));
diff --git a/packages/desktop-client/src/components/reports/graphs/CrossoverGraph.tsx b/packages/desktop-client/src/components/reports/graphs/CrossoverGraph.tsx
index 700bca34b1..08769a3302 100644
--- a/packages/desktop-client/src/components/reports/graphs/CrossoverGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/CrossoverGraph.tsx
@@ -160,7 +160,7 @@ export function CrossoverGraph({
}: CrossoverGraphProps) {
const privacyMode = usePrivacyMode();
const format = useFormat();
- const animationProps = useRechartsAnimation({ isAnimationActive: false });
+ const animationProps = useRechartsAnimation({ animationDuration: 1000 });
const tickFormatter = (tick: number) => {
if (privacyMode) {
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index 78a755f054..7d3fcef6ae 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -356,7 +356,7 @@ export function DonutGraph({
showOffBudget,
showTooltip = true,
}: DonutGraphProps) {
- const animationProps = useRechartsAnimation({ isAnimationActive: false });
+ const animationProps = useRechartsAnimation({ animationDuration: 500 });
const yAxis = groupBy === 'Interval' ? 'date' : 'name';
const splitData = groupBy === 'Interval' ? 'intervalData' : 'data';
@@ -447,6 +447,7 @@ export function DonutGraph({
dataKey={val => getVal(val)}
nameKey="name"
{...animationProps}
+ animationBegin={100}
data={adjustedGroupData}
innerRadius={chartInnerRadius}
outerRadius={chartMidRadius}
@@ -528,6 +529,7 @@ export function DonutGraph({
dataKey={val => getVal(val)}
nameKey="name"
{...animationProps}
+ animationBegin={100}
data={flatCategories}
innerRadius={chartMidRadius}
outerRadius={chartOuterRadius}
@@ -625,6 +627,7 @@ export function DonutGraph({
dataKey={val => getVal(val)}
nameKey={yAxis}
{...animationProps}
+ animationBegin={100}
data={data[splitData]?.map(item => ({ ...item })) ?? []}
innerRadius={chartInnerRadius}
labelLine={false}
diff --git a/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx b/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx
index 7366fa782c..781617a5a3 100644
--- a/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/NetWorthGraph.tsx
@@ -250,7 +250,7 @@ export function NetWorthGraph({
const privacyMode = usePrivacyMode();
const id = useId();
const format = useFormat();
- const animationProps = useRechartsAnimation({ isAnimationActive: false });
+ const animationProps = useRechartsAnimation({ animationDuration: 1000 });
const [isTooltipActive, setIsTooltipActive] = useState(false);
const [hoveredAccountId, setHoveredAccountId] = useState<string | null>(null);
diff --git a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
index aacef7998f..6a00b1e240 100644
--- a/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/SankeyGraph.tsx
@@ -1,8 +1,8 @@
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import type { CSSProperties } from 'react';
import { theme } from '@actual-app/components/theme';
-import { css } from '@emotion/css';
+import { css, keyframes } from '@emotion/css';
import { t } from 'i18next';
import {
Layer,
@@ -16,6 +16,23 @@ import type { SankeyData } from 'recharts/types/chart/Sankey';
import { Container } from '#components/reports/Container';
import { useFormat } from '#hooks/useFormat';
import { usePrivacyMode } from '#hooks/usePrivacyMode';
+import { useReducedMotion } from '#hooks/useReducedMotion';
+
+const fadeIn = keyframes({
+ from: { opacity: 0 },
+ to: { opacity: 1 },
+});
+
+// kept invisible until the card scrolls into view
+const hiddenClass = css({ opacity: 0 });
+
+// stagger the load fade-in left-to-right, keyed off horizontal position
+function fadeInClass(fraction: number) {
+ const delay = Math.max(0, Math.min(1, fraction)) * 0.3;
+ return css({
+ animation: `${fadeIn} 0.3s ease-out ${delay}s both`,
+ });
+}
type SankeyGraphNode = SankeyData['nodes'][number] & {
value: number;
@@ -39,7 +56,8 @@ type SankeyLinkProps = {
targetY: number;
targetControlX: number;
linkWidth: number;
- index: number;
+ containerWidth: number;
+ phase: 'waiting' | 'animating' | 'done';
payload: SankeyLinkPayload;
isHovered: boolean;
onMouseEnter: () => void;
@@ -54,20 +72,33 @@ function SankeyLink({
targetY,
targetControlX,
linkWidth,
+ containerWidth,
+ phase,
payload,
isHovered,
onMouseEnter,
onMouseLeave,
}: SankeyLinkProps) {
+ const reducedMotion = useReducedMotion();
+
if (payload.value <= 0) {
return null;
}
const linkColor = payload.color ?? theme.reportsGray;
const strokeWidth = linkWidth;
const strokeOpacity = isHovered ? 1 : 0.6;
+ // use the link's midpoint so it eases in with the columns it spans
+ const fraction = (sourceX + targetX) / 2 / containerWidth;
return (
<path
+ className={
+ reducedMotion || phase === 'done'
+ ? undefined
+ : phase === 'animating'
+ ? fadeInClass(fraction)
+ : hiddenClass
+ }
d={`M${sourceX},${sourceY} C${sourceControlX},${sourceY} ${targetControlX},${targetY} ${targetX},${targetY}`}
fill="none"
stroke={linkColor}
@@ -86,9 +117,9 @@ type SankeyNodeProps = {
y: number;
width: number;
height: number;
- index: number;
payload: SankeyGraphNode;
containerWidth: number;
+ phase: 'waiting' | 'animating' | 'done';
showPercentages?: boolean;
color?: string;
};
@@ -97,13 +128,14 @@ function SankeyNode({
y,
width,
height,
- index: _index,
payload,
containerWidth,
+ phase,
showPercentages,
}: SankeyNodeProps) {
const privacyMode = usePrivacyMode();
const format = useFormat();
+ const reducedMotion = useReducedMotion();
if (payload.value <= 0) {
return null;
@@ -134,7 +166,15 @@ function SankeyNode({
);
return (
- <Layer>
+ <Layer
+ className={
+ reducedMotion || phase === 'done'
+ ? undefined
+ : phase === 'animating'
+ ? fadeInClass(x / containerWidth)
+ : hiddenClass
+ }
+ >
<Rectangle x={x} y={y} width={width} height={height} fill={fillColor} />
{renderText(payload.name || '', height / 2)}
{renderText(
@@ -166,108 +206,148 @@ export function SankeyGraph({
const format = useFormat();
const [hoveredLinkIndex, setHoveredLinkIndex] = useState<number | null>(null);
+ // play the load animation once: wait until the card scrolls into view,
+ // run the fade-in, then stay in 'done' so later data changes (filters,
+ // date range) don't re-animate the chart in place. the viewport element
+ // is tracked as state because AutoSizer renders it on a later tick, so a
+ // useRef-based observer would attach before the element exists.
+ const [viewportEl, setViewportEl] = useState<HTMLDivElement | null>(null);
+ const [phase, setPhase] = useState<'waiting' | 'animating' | 'done'>(
+ 'waiting',
+ );
+
+ useEffect(() => {
+ if (!viewportEl || phase !== 'waiting') return;
+ const observer = new IntersectionObserver(([entry]) => {
+ if (entry.isIntersecting) {
+ setPhase('animating');
+ observer.disconnect();
+ }
+ });
+ observer.observe(viewportEl);
+ return () => observer.disconnect();
+ }, [viewportEl, phase]);
+
+ useEffect(() => {
+ if (phase !== 'animating') return;
+ // 0.3s duration + 0.3s max stagger, plus buffer
+ const timer = setTimeout(() => setPhase('done'), 700);
+ return () => clearTimeout(timer);
+ }, [phase]);
+
return (
<Container style={style}>
{(width, height) => (
- <ResponsiveContainer>
- <Sankey
- data={data}
- node={props => (
- <SankeyNode
- {...props}
- containerWidth={width}
- showPercentages={showPercentages}
- />
- )}
- link={props => (
- <SankeyLink
- {...props}
- isHovered={hoveredLinkIndex === props.index}
- onMouseEnter={() => setHoveredLinkIndex(props.index)}
- onMouseLeave={() => setHoveredLinkIndex(null)}
- />
- )}
- sort={false}
- iterations={128}
- nodePadding={23}
- width={width}
- height={height}
- margin={{
- left: 0,
- right: 0,
- top: 10,
- bottom: 25,
- }}
- >
- {showTooltip && (
- <Tooltip
- content={({ active, payload }) => {
- if (!active || !payload?.length) return null;
- const { value = 0, name = '' } = payload[0];
- const tooltipInfo =
- hoveredLinkIndex !== null
- ? (
- data.links[hoveredLinkIndex] as {
- tooltipInfo?: Array<{
- name: string;
- value: number;
- }>;
- }
- )?.tooltipInfo
- : undefined;
- return (
- <div
- className={css({
- zIndex: 1000,
- pointerEvents: 'none',
- borderRadius: 2,
- boxShadow: '0 1px 6px rgba(0, 0, 0, .20)',
- backgroundColor: theme.menuBackground,
- color: theme.menuItemText,
- padding: 10,
- })}
- >
- <div style={{ lineHeight: 1.4 }}>
- {name && <div style={{ marginBottom: 5 }}>{name}</div>}
- <div
- style={{
- fontFamily: privacyMode
- ? t('Redacted Script')
- : undefined,
- }}
- >
- {format(value, 'financial')}
- </div>
- {tooltipInfo && tooltipInfo.length > 0 && (
+ <div ref={setViewportEl} style={{ width: '100%', height: '100%' }}>
+ <ResponsiveContainer>
+ <Sankey
+ data={data}
+ node={props => (
+ <SankeyNode
+ {...props}
+ containerWidth={width}
+ phase={phase}
+ showPercentages={showPercentages}
+ />
+ )}
+ link={props => (
+ <SankeyLink
+ {...props}
+ containerWidth={width}
+ phase={phase}
+ isHovered={hoveredLinkIndex === props.index}
+ onMouseEnter={() => setHoveredLinkIndex(props.index)}
+ onMouseLeave={() => setHoveredLinkIndex(null)}
+ />
+ )}
+ sort={false}
+ iterations={128}
+ nodePadding={23}
+ width={width}
+ height={height}
+ margin={{
+ left: 0,
+ right: 0,
+ top: 10,
+ bottom: 25,
+ }}
+ >
+ {showTooltip && (
+ <Tooltip
+ content={({ active, payload }) => {
+ if (!active || !payload?.length) return null;
+ const { value = 0, name = '' } = payload[0];
+ const tooltipInfo =
+ hoveredLinkIndex !== null
+ ? (
+ data.links[hoveredLinkIndex] as {
+ tooltipInfo?: Array<{
+ name: string;
+ value: number;
+ }>;
+ }
+ )?.tooltipInfo
+ : undefined;
+ return (
+ <div
+ className={css({
+ zIndex: 1000,
+ pointerEvents: 'none',
+ borderRadius: 2,
+ boxShadow: '0 1px 6px rgba(0, 0, 0, .20)',
+ backgroundColor: theme.menuBackground,
+ color: theme.menuItemText,
+ padding: 10,
+ })}
+ >
+ <div style={{ lineHeight: 1.4 }}>
+ {name && (
+ <div style={{ marginBottom: 5 }}>{name}</div>
+ )}
<div
- style={{ marginTop: 6, fontSize: 11, opacity: 0.7 }}
+ style={{
+ fontFamily: privacyMode
+ ? t('Redacted Script')
+ : undefined,
+ }}
>
- {tooltipInfo.map(item => (
- <div key={item.name}>
- {item.name} (
- <span
- style={{
- fontFamily: privacyMode
- ? t('Redacted Script')
- : undefined,
- }}
- >
- {format(item.value, 'financial')}
- </span>
- )
- </div>
- ))}
+ {format(value, 'financial')}
</div>
- )}
+ {tooltipInfo && tooltipInfo.length > 0 && (
+ <div
+ style={{
+ marginTop: 6,
+ fontSize: 11,
+ opacity: 0.7,
+ }}
+ >
+ {tooltipInfo.map(item => (
+ <div key={item.name}>
+ {item.name} (
+ <span
+ style={{
+ fontFamily: privacyMode
+ ? t('Redacted Script')
+ : undefined,
+ }}
+ >
+ {format(item.value, 'financial')}
+ </span>
+ )
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
</div>
- </div>
- );
- }}
- isAnimationActive={false}
- />
- )}
- </Sankey>
- </ResponsiveContainer>
+ );
+ }}
+ isAnimationActive={false}
+ />
+ )}
+ </Sankey>
+ </ResponsiveContainer>
+ </div>
)}
</Container>
);
diff --git a/packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx b/packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx
index fc5c127b82..479a83778d 100644
--- a/packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/SpendingGraph.tsx
@@ -163,7 +163,7 @@ export function SpendingGraph({
compareTo,
}: SpendingGraphProps) {
const privacyMode = usePrivacyMode();
- const animationProps = useRechartsAnimation({ isAnimationActive: false });
+ const animationProps = useRechartsAnimation({ animationDuration: 1000 });
const balanceTypeOp = 'cumulative';
const format = useFormat();
diff --git a/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx b/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
index a9700fd51e..aef083405f 100644
--- a/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CalendarCard.tsx
@@ -28,9 +28,9 @@ import debounce from 'lodash/debounce';
import { FinancialText } from '#components/FinancialText';
import { PrivacyFilter } from '#components/PrivacyFilter';
+import { CalendarCardSkeleton } from '#components/reports/CalendarCardSkeleton';
import { DateRange } from '#components/reports/DateRange';
import { CalendarGraph } from '#components/reports/graphs/CalendarGraph';
-import { LoadingIndicator } from '#components/reports/LoadingIndicator';
import { ReportCard } from '#components/reports/ReportCard';
import { ReportCardName } from '#components/reports/ReportCardName';
import { calculateTimeRange } from '#components/reports/reportRanges';
@@ -339,7 +339,7 @@ export function CalendarCard({
/>
))
) : (
- <LoadingIndicator />
+ <CalendarCardSkeleton />
)}
</View>
</View>
diff --git a/packages/desktop-client/src/components/reports/reports/SummaryCard.tsx b/packages/desktop-client/src/components/reports/reports/SummaryCard.tsx
index a809e844c6..90bcf0663d 100644
--- a/packages/desktop-client/src/components/reports/reports/SummaryCard.tsx
+++ b/packages/desktop-client/src/components/reports/reports/SummaryCard.tsx
@@ -10,9 +10,9 @@ import type {
} from '@actual-app/core/types/models';
import { DateRange } from '#components/reports/DateRange';
-import { LoadingIndicator } from '#components/reports/LoadingIndicator';
import { ReportCard } from '#components/reports/ReportCard';
import { ReportCardName } from '#components/reports/ReportCardName';
+import { ReportCardValueSkeleton } from '#components/reports/ReportCardValueSkeleton';
import { calculateTimeRange } from '#components/reports/reportRanges';
import { summarySpreadsheet } from '#components/reports/spreadsheets/summary-spreadsheet';
import { SummaryNumber } from '#components/reports/SummaryNumber';
@@ -160,7 +160,7 @@ export function SummaryCard({
animate={isEditing ?? false}
/>
) : (
- <LoadingIndicator />
+ <ReportCardValueSkeleton />
)}
</View>
</View>
diff --git a/packages/desktop-client/src/hooks/useReducedMotion.ts b/packages/desktop-client/src/hooks/useReducedMotion.ts
new file mode 100644
index 0000000000..464d108859
--- /dev/null
+++ b/packages/desktop-client/src/hooks/useReducedMotion.ts
@@ -0,0 +1,21 @@
+import { useSyncExternalStore } from 'react';
+
+import { useIsTestEnv } from './useIsTestEnv';
+
+const QUERY = '(prefers-reduced-motion: reduce)';
+
+function subscribe(callback: () => void) {
+ const mq = window.matchMedia(QUERY);
+ mq.addEventListener('change', callback);
+ return () => mq.removeEventListener('change', callback);
+}
+
+function getSnapshot() {
+ return window.matchMedia(QUERY).matches;
+}
+
+export function useReducedMotion(): boolean {
+ const isTestEnv = useIsTestEnv();
+ const prefersReduced = useSyncExternalStore(subscribe, getSnapshot);
+ return isTestEnv || prefersReduced;
+}
diff --git a/upcoming-release-notes/7907.md b/upcoming-release-notes/7907.md
new file mode 100644
index 0000000000..dec90cc591
--- /dev/null
+++ b/upcoming-release-notes/7907.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [matt-fidd]
+---
+
+Add animations to more reports cards