Skip to content

Commit

Permalink
[fix] "just below" display (PR ThePacielloGroup#315)
Browse files Browse the repository at this point in the history
Fix "just below" display
  • Loading branch information
ferllings committed Oct 11, 2023
2 parents 4e5099a + 872a3a7 commit 617164f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/CCAcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class CCAController {
levelAAA: this.sharedObject['general.levelAAA'],
raw: cr,
rounded: crr,
rounding: rounding,
}
const def = ['achromatopsia', 'achromatomaly', 'protanopia', 'protanomaly', 'deuteranopia', 'deuteranomaly', 'tritanopia', 'tritanomaly']
def.forEach(key => {
Expand Down
4 changes: 3 additions & 1 deletion src/views/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,11 @@ function applyContrastRatio(contrastRatio) {

let cr = contrastRatio.raw
let crr = contrastRatio.rounded.toLocaleString(i18n.lang)
let r = contrastRatio.rounding
// toLocalString removes trailing zero and use the correct decimal separator, based on the app select lang.
contrastRatioString = `${crr}:1`
if ((cr >= 6.95 && cr < 7) || (cr >= 4.45 && cr < 4.5) || (cr >= 2.95 && cr < 3)) {
if (((r == 1) && ((cr >= 6.95 && cr < 7) || (cr >= 4.45 && cr < 4.5) || (cr >= 2.95 && cr < 3))) ||
((r == 2) && ((cr >= 6.995 && cr < 7) || (cr >= 4.495 && cr < 4.5) || (cr >= 2.995 && cr < 3)))) {
let crr3 = cr.toLocaleString(i18n.lang)
contrastRatioString = `<span class="smaller">${i18n["just below"]} </span>${crr}:1<span class="smaller"> (${crr3}:1)</span>`
}
Expand Down

0 comments on commit 617164f

Please sign in to comment.