From 5ff75eb4adbd7df4ec11192e41a6e05178855395 Mon Sep 17 00:00:00 2001
From: Ismail Cherri
Date: Mon, 9 Sep 2024 14:07:50 +0200
Subject: [PATCH] SONAR-22323 Fix a11y issues on PR overview page
---
.../src/components/CoverageIndicator.tsx | 11 +-
.../src/components/DonutChart.tsx | 32 +-
.../src/components/DuplicationsIndicator.tsx | 11 +-
.../__tests__/CoverageIndicator-test.tsx | 14 +-
.../__tests__/DuplicationsIndicator-test.tsx | 9 +-
.../CoverageIndicator-test.tsx.snap | 112 ++++--
.../DuplicationsIndicator-test.tsx.snap | 340 ++++++++++--------
.../overview/branches/QualityGateStatus.tsx | 2 +-
.../branches/SoftwareImpactMeasureCard.tsx | 9 +-
.../overview/components/AnalysisStatus.tsx | 2 +
.../components/IssueMeasuresCardInner.tsx | 2 +-
.../apps/overview/components/MeasuresCard.tsx | 2 +-
.../components/MeasuresCardPercent.tsx | 4 +-
.../__tests__/MeasureIndicator-test.tsx | 6 +-
.../MeasureIndicator-test.tsx.snap | 51 +--
.../resources/org/sonar/l10n/core.properties | 1 +
16 files changed, 352 insertions(+), 256 deletions(-)
diff --git a/server/sonar-web/design-system/src/components/CoverageIndicator.tsx b/server/sonar-web/design-system/src/components/CoverageIndicator.tsx
index 9eeb58479b7..a6eb05c1009 100644
--- a/server/sonar-web/design-system/src/components/CoverageIndicator.tsx
+++ b/server/sonar-web/design-system/src/components/CoverageIndicator.tsx
@@ -28,17 +28,23 @@ const FULL_PERCENT = 100;
const PAD_ANGLE = 0.1;
export interface CoverageIndicatorProps {
+ 'aria-hidden'?: boolean | 'true' | 'false';
+ 'aria-label'?: string;
size?: 'xs' | 'sm' | 'md';
value?: number | string;
}
-export function CoverageIndicator({ size = 'sm', value }: CoverageIndicatorProps) {
+export function CoverageIndicator({
+ size = 'sm',
+ value,
+ ...rest
+}: Readonly) {
const theme = useTheme();
const width = SIZE_TO_WIDTH_MAPPING[size];
const thickness = SIZE_TO_THICKNESS_MAPPING[size];
if (value === undefined) {
- return ;
+ return ;
}
const themeRed = themeColor('coverageRed')({ theme });
@@ -64,6 +70,7 @@ export function CoverageIndicator({ size = 'sm', value }: CoverageIndicatorProps
padAngle={padAngle}
thickness={thickness}
width={width}
+ {...rest}
/>
);
}
diff --git a/server/sonar-web/design-system/src/components/DonutChart.tsx b/server/sonar-web/design-system/src/components/DonutChart.tsx
index 14c4ec3782b..4fc1e638445 100644
--- a/server/sonar-web/design-system/src/components/DonutChart.tsx
+++ b/server/sonar-web/design-system/src/components/DonutChart.tsx
@@ -25,6 +25,8 @@ export interface DataPoint {
}
export interface DonutChartProps {
+ 'aria-hidden'?: boolean | 'true' | 'false';
+ 'aria-label'?: string;
cornerRadius?: number;
data: DataPoint[];
height: number;
@@ -35,8 +37,18 @@ export interface DonutChartProps {
width: number;
}
-export function DonutChart(props: DonutChartProps) {
- const { height, cornerRadius, minPercent = 0, padding = [0, 0, 0, 0], width } = props;
+export function DonutChart(props: Readonly) {
+ const {
+ height,
+ cornerRadius,
+ minPercent = 0,
+ padding = [0, 0, 0, 0],
+ width,
+ padAngle,
+ data,
+ thickness,
+ ...rest
+ } = props;
const availableWidth = width - padding[1] - padding[3];
const availableHeight = height - padding[0] - padding[2];
@@ -44,31 +56,31 @@ export function DonutChart(props: DonutChartProps) {
const size = Math.min(availableWidth, availableHeight);
const radius = Math.floor(size / 2);
- const total = props.data.reduce((acc, d) => acc + d.value, 0);
+ const total = data.reduce((acc, d) => acc + d.value, 0);
const pie = d3Pie()
.sort(null)
.value((d) => Math.max(d.value, (total / 100) * minPercent));
- if (props.padAngle !== undefined) {
- pie.padAngle(props.padAngle);
+ if (padAngle !== undefined) {
+ pie.padAngle(padAngle);
}
- const sectors = pie(props.data).map((d, i) => {
+ const sectors = pie(data).map((d, i) => {
return (
);
});
return (
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+