From cfb2e265481817c41725eb6b6f6f4e915d4ba7a0 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Thu, 1 Sep 2022 11:11:45 +0200 Subject: SONAR-16894 SONAR-16899 [892238] [892241] * [892238] Link or button text lacks 4.5:1 contrast ratio on hover or focus * [892241] An icon lacks 3 to 1 contrast ratio --- .../src/main/js/components/charts/BubbleChart.tsx | 6 ++--- .../main/js/components/charts/ColorBoxLegend.css | 15 +++++++++++ .../js/components/charts/ColorRatingsLegend.tsx | 29 +++++++++------------- .../charts/__tests__/BubbleChart-test.tsx | 20 ++++++++++++--- .../__snapshots__/BubbleChart-test.tsx.snap | 24 +++++++++--------- 5 files changed, 58 insertions(+), 36 deletions(-) (limited to 'server/sonar-web/src/main/js/components/charts') diff --git a/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx b/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx index f1bc4005a10..bf1f077913f 100644 --- a/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx +++ b/server/sonar-web/src/main/js/components/charts/BubbleChart.tsx @@ -33,7 +33,7 @@ import './BubbleChart.css'; const TICKS_COUNT = 5; interface BubbleItem { - color?: string; + color: { fill: string; stroke: string; hover?: string }; key?: string; data?: T; size: number; @@ -343,7 +343,7 @@ export default class BubbleChart extends React.PureComponent, State> } interface BubbleProps { - color?: string; + color: { fill: string; stroke: string; hover?: string }; onClick?: (ref?: T) => void; data?: T; r: number; @@ -367,7 +367,7 @@ function Bubble(props: BubbleProps) { diff --git a/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.css b/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.css index e9a6cc27297..ea980591587 100644 --- a/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.css +++ b/server/sonar-web/src/main/js/components/charts/ColorBoxLegend.css @@ -22,6 +22,21 @@ justify-content: center; } +.color-box-legend .link-checkbox .color-box-legend-rating { + width: 20px; + height: 20px; + line-height: 20px; + display: inline-block; + border: 1px solid transparent; + border-radius: 20px; + color: var(--blacka87); +} + +.color-box-legend .link-checkbox[aria-checked='false'] .color-box-legend-rating { + background-color: transparent !important; + border-color: transparent !important; +} + .color-box-legend > *:not(:first-child) { margin-left: 24px; } diff --git a/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx b/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx index 21a5f0ba9ee..982d0fea5c6 100644 --- a/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx +++ b/server/sonar-web/src/main/js/components/charts/ColorRatingsLegend.tsx @@ -23,6 +23,7 @@ import Tooltip from '../../components/controls/Tooltip'; import { RATING_COLORS } from '../../helpers/constants'; import { translateWithParameters } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; +import Checkbox from '../controls/Checkbox'; import './ColorBoxLegend.css'; export interface ColorRatingsLegendProps { @@ -44,25 +45,19 @@ export default function ColorRatingsLegend(props: ColorRatingsLegendProps) { 'component_measures.legend.help_x', formatMeasure(rating, 'RATING') )}> - props.onRatingClick(rating)} - role="checkbox" - tabIndex={0}> + props.onRatingClick(rating)}> - + className="color-box-legend-rating little-spacer-left" + style={{ + borderColor: RATING_COLORS[rating - 1].stroke, + backgroundColor: RATING_COLORS[rating - 1].fillTransparent + }}> + {formatMeasure(rating, 'RATING')} - {formatMeasure(rating, 'RATING')} - + ))} diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx index a42768183ab..d6f5b7577c2 100644 --- a/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx +++ b/server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx @@ -59,8 +59,8 @@ it('should display bubbles', () => { it('should render bubble links', () => { const wrapper = shallowRender({ items: [ - { x: 1, y: 10, size: 7 }, - { x: 2, y: 30, size: 5 } + { x: 1, y: 10, size: 7, color: { fill: 'blue', stroke: 'blue' } }, + { x: 2, y: 30, size: 5, color: { fill: 'green', stroke: 'green' } } ] }); wrapper @@ -141,8 +141,20 @@ function shallowRender(props: Partial['pro