Skip to content

Commit 0fb419f

Browse files
committed
Bugfix Copied texts
1 parent 57f92d5 commit 0fb419f

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "color-contrast-bookmarklet",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "color contrast checker bookmarklet",
55
"main": "dist/bookmarklet.js",
66
"scripts": {

src/bookmarklet.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
largeTextAA: 'Large or bold text AA',
5252
largeTextAAA: 'Large or bold text AAA',
5353
nonTextAA: 'Non-text elements AA',
54-
clipboardTextPassed: 'For {contentType}, the selected foreground colour ({foregroundColor}) and background colour ({backgroundColor}) result in a contrast of {contrastValue} for {label}, which corresponds to the required minimum contrast ratio of {requiredContrast}:1.',
55-
clipboardTextFailed: 'For {contentType}, the selected foreground colour ({foregroundColor}) and background colour ({backgroundColor}) result in a contrast of {contrastValue} for {label} instead of the required minimum contrast ratio of {requiredContrast}:1.'
54+
clipboardTextPassed: "The color combination of forground color $foregroundColor$ and background color $backgroundColor$ has a contrast ratio of $contrastValue$ : 1. The required contrast ratio of $contrastValue$ for level $label$ on $contentType$ is passed.",
55+
clipboardTextFailed: "The color combination of forground color $foregroundColor$ and background color $backgroundColor$ has a contrast ratio of $contrastValue$ : 1. For level $label$ on $contentType$ a minimum contrast of $requiredContrast$ : 1 is required.",
56+
5657
}
5758
},
5859
de: {
@@ -76,7 +77,7 @@
7677
nonText: 'Nicht-Textbasierte-Inhalte',
7778
nonTextLabel: 'Visualisierung für nicht-textbasierte Inhalte',
7879
applyButton: 'Übernehmen',
79-
colorAriaLive: 'Die ausgewählte farbe ist',
80+
colorAriaLive: 'Die ausgewählte Farbe ist',
8081
successIconLabel: 'bestanden',
8182
failedIconLabel: 'fehlgeschlagen',
8283
infoIconLabel: 'Hinweis',
@@ -96,7 +97,7 @@
9697
},
9798
errorMessage: 'Bitte geben Sie einen validen Farbwert ein.',
9899
copyMessage: {
99-
regularText: 'regulären Text',
100+
regularText: 'regulärem Text',
100101
largeText: 'großen und fetten Text',
101102
nonText: 'nicht-textbasierte-Inhalte',
102103
template: 'in Zwischenablage kopiert',
@@ -105,12 +106,12 @@
105106
largeTextAA: 'Großer oder fetter Text AA',
106107
largeTextAAA: 'Großer oder fetter Text AAA',
107108
nonTextAA: 'Nicht-Textbasierte-Inhalte AA',
108-
clipboardTextPassed: 'Für {contentType} ergibt sich mit der gewählten Vordergrundfarbe ({foregroundColor}) und Hintergrundfarbe ({backgroundColor}) ein Kontrast von {contrastValue} für {label}, was dem geforderten Mindestkontrastverhältnis von {requiredContrast}:1 entspricht.',
109-
clipboardTextFailed: 'Für {contentType} ergibt sich mit der gewählten Vordergrundfarbe ({foregroundColor}) und Hintergrundfarbe ({backgroundColor}) ein Kontrast von {contrastValue} für {label}, anstelle des geforderten Mindestkontrastverhältnis von {requiredContrast}:1.'
109+
clipboardTextPassed: "Die Farbkombination aus Vordergrundfarbe $foregroundColor$ und Hintergrundfarbe $backgroundColor$ hat ein Kontrastverhältnis von $contrastValue$ : 1. Das erforderliche Kontrastverhältnis von mindestens $requiredContrast$ : 1 für Level $label$ bei $contentType$ ist damit erfüllt.",
110+
clipboardTextFailed: "Die Farbkombination aus Vordergrundfarbe $foregroundColor$ und Hintergrundfarbe $backgroundColor$ hat ein Kontrastverhältnis von $contrastValue$ : 1. Für Level $label$ ist bei $contentType$ ein Kontrastverhältnis von mindestens $requiredContrast$ : 1 erforderlich.",
110111
}
111112
}
112113
};
113-
114+
console.log(translationDictionary);
114115
// default color values
115116
const defaultForegroundColor = '#323130';
116117
const defaultBackgroundColor = '#cdece8';
@@ -1087,8 +1088,10 @@
10871088
level: level,
10881089
requiredContrast: requiredRatio
10891090
}
1090-
const clipboardText = currentContrastRatio >= requiredRatio ? translations.copyMessage.clipboardTextPassed.replace(/{(.*?)}/g, (_, key) => copyTemplateData[key] || '') : translations.copyMessage.clipboardTextFailed.replace(/{(.*?)}/g, (_, key) => copyTemplateData[key] || '');
1091-
1091+
const clipboardText =
1092+
currentContrastRatio >= (typeof(requiredRatio) === "string" ? parseFloat(requiredRatio.replace(",", ".")) : requiredRatio)
1093+
? translations.copyMessage.clipboardTextPassed.replace(/\$(.*?)\$/g, (_, key) => copyTemplateData[key] || '')
1094+
: translations.copyMessage.clipboardTextFailed.replace(/\$(.*?)\$/g, (_, key) => copyTemplateData[key] || '');
10921095
const button = event.currentTarget;
10931096
const textToCopy = button.getAttribute('data-text');
10941097

0 commit comments

Comments
 (0)