ThePacielloGroup / CCAe

The Colour Contrast Analyser (CCA) helps you determine the legibility of text and the contrast of visual elements, such as graphical controls and visual indicators.
http://www.paciellogroup.com/resources/contrastanalyser/
GNU General Public License v3.0
468 stars 105 forks source link

Fix "just below" display #315

Closed patrickhlauke closed 9 months ago

patrickhlauke commented 9 months ago

Currently, the "just below" text is displayed at inappropriate points when "decimals" is set to 2 (both in unnecessary cases, and - as seen in the screenshot below - just completely wrong cases, as 2.952 is not below 2.95)

screenshot of CCAe showing the ratio 'just below 2.95:1 (2.952:1)'

It should only show if there's a rounding happening one decimal point below the currently set decimal display, and only if it's just below 3, 4.5, or 7.

This PR adds more nuance to the big if used to decide when to show the "just below" bit.

CCAe with the same colours, but now showing just '2.96:1'

(not sure why it decided that 2.952 actually rounds to 2.96 in this case...but nothing that I touched should have influenced that. EDIT: ah, it's likely this which accounts for the difference in rounding between the last release - first screenshot here - and the latest main branch - second screenshot, with my PR applied - https://github.com/ThePacielloGroup/CCAe/commit/0cee4cc5d00ef114963e0cc716cc28417d4c546d)

patrickhlauke commented 9 months ago

unrelated, but when running this locally, it kept showing me an error when trying to open the preferences

ReferenceError: x is not defined

To get it to run locally, I had to uncomment lines 26 to 29 https://github.com/ThePacielloGroup/CCAe/blob/main/src/menu.js#L26 ... is this intentional somehow?

ferllings commented 9 months ago

unrelated, but when running this locally, it kept showing me an error when trying to open the preferences

ReferenceError: x is not defined

To get it to run locally, I had to uncomment lines 26 to 29 https://github.com/ThePacielloGroup/CCAe/blob/main/src/menu.js#L26 ... is this intentional somehow?

The commented code is intentional, but the error is not :)

ferllings commented 9 months ago

(not sure why it decided that 2.952 actually rounds to 2.96 in this case...but nothing that I touched should have influenced that. EDIT: ah, it's likely this which accounts for the difference in rounding between the last release - first screenshot here - and the latest main branch - second screenshot, with my PR applied - 0cee4cc)

Might be related to my recent modification: https://github.com/ThePacielloGroup/CCAe/commit/0cee4cc5d00ef114963e0cc716cc28417d4c546d

I'll merge and to do some proper testing later, to see what I'm missing.