From: Ismail Cherri
Date: Mon, 9 Sep 2024 12:07:50 +0000 (+0200)
Subject: SONAR-22323 Fix a11y issues on PR overview page
X-Git-Tag: 10.7.0.96327~131
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ff75eb4adbd7df4ec11192e41a6e05178855395;p=sonarqube.git
SONAR-22323 Fix a11y issues on PR overview page
---
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 (
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+