diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 887b305..4e4ee8e 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -84,7 +84,7 @@ "value":"dep-6", "label":"DEP 6", "children": [ - { "value": "dep-6-part-a", "label": "Who is respondible for witnessing?" }, + { "value": "dep-6-part-a", "label": "Who is responsible for witnessing?" }, { "value": "dep-6-part-b", "label": "Why should we witness?" }, { "value": "dep-6-part-c", "label": "How do we witness?" } ] diff --git a/public/locales/kn/translation.json b/public/locales/kn/translation.json index ecdbe32..0341ee7 100644 --- a/public/locales/kn/translation.json +++ b/public/locales/kn/translation.json @@ -23,6 +23,17 @@ { "value": "loa", "label": "Lessons on Assurance" + }, + { + "value": "tms60", + "label": "TMS60", + "children": [ + { "value": "tms-60-pack-a", "label": "Living the New Life" }, + { "value": "tms-60-pack-b", "label": "Proclaiming Christ" }, + { "value": "tms-60-pack-c", "label": "Reliance on God's Resources" }, + { "value": "tms-60-pack-d", "label": "Being Christ's Disciple" }, + { "value": "tms-60-pack-e", "label": "Growth in Christlikeness" } + ] } ] } \ No newline at end of file diff --git a/src/VerseValidator.css b/src/VerseValidator.css index c77e727..c08e605 100644 --- a/src/VerseValidator.css +++ b/src/VerseValidator.css @@ -76,8 +76,34 @@ } } -@media (prefers-color-scheme: dark) { - .correct { - background-color: #495749; /* Change the background color as needed */ +@media (prefers-color-scheme: light) { + .partial { + background-color: #dafcff; /* Change the background color as needed */ } } + +@media (prefers-color-scheme: light) { + .incorrect { + background-color: transparent; /* Change the background color as needed */ + } +} + + +@media (prefers-color-scheme: dark) { + .correct { + background-color: #2e5e2e; /* Change the background color as needed */ + } +} + +@media (prefers-color-scheme: dark) { + .partial { + background-color: #004d5c; /* Change the background color as needed */ + } +} + +@media (prefers-color-scheme: dark) { + .incorrect { + background-color: transparent; /* Change the background color as needed */ + } +} + diff --git a/src/VerseValidator.jsx b/src/VerseValidator.jsx index 92f1bf2..0f9fde0 100644 --- a/src/VerseValidator.jsx +++ b/src/VerseValidator.jsx @@ -2,24 +2,28 @@ import { useState } from "react"; import "./VerseValidator.css"; import { StringDiff } from "react-string-diff"; +const STATE = { + INCORRECT: 0, + PARTIAL: 1, + CORRECT: 2, +}; // function to render and handle logic of each of the cells const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse } , toHideReference, t}) => { // useful use of destructuring here const [inputReference, setReference] = useState('') - const [referenceBool, setReferenceBool] = useState(false) + const [referenceBool, setReferenceBool] = useState(STATE.INCORRECT) const [inputChapterTitle, setChapterTitle] = useState('') - const [chapterTitleBool, setChapterTitleBool] = useState(false) + const [chapterTitleBool, setChapterTitleBool] = useState(STATE.INCORRECT) const [inputTitle, setTitle] = useState('') - const [titleBool, setTitleBool] = useState(false) + const [titleBool, setTitleBool] = useState(STATE.INCORRECT) const [inputVerse, setVerse] = useState('') - const [verseBool, setVerseBool] = useState(false) + const [verseBool, setVerseBool] = useState(STATE.INCORRECT) const[hintBool, setHintBool] = useState(false) const[diffBool, setDiffBool] = useState(false) - // function to check correctness of verse input - // so far only perform checking on full spelling of reference names + // function to check correctness of reference input const referenceChange = (e) => { const value = e.target.value; const string1 = String(value) @@ -30,33 +34,27 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse .replace(/\s+/g, "") .toLowerCase() .normalize("NFC"); - const bool = (string1 === string2); + var result = STATE.INCORRECT; // init + if (string1 === string2) { + result = STATE.CORRECT; + } else if (string2.startsWith(string1) & string1 !== "") { + result = STATE.PARTIAL + } else { + result = STATE.INCORRECT + } setReference(value); - setReferenceBool(bool); + setReferenceBool(result); }; - {/* function to check correctness of verse input */} - const verseChange = (e) => { - const value = e.target.value; - let string1 = value; - let string2 = verse; - string1 = String(string1) - .replace(/[\p{P}\p{S}]/gu, "") - .replace(/\s+/g, "") - .toLowerCase() - .normalize("NFC"); - string2 = String(string2) - .replace(/[\p{P}\p{S}]/gu, "") - .replace(/\s+/g, "") - .toLowerCase() - .normalize("NFC"); + const referenceClassName = `reference-box${ + referenceBool === STATE.CORRECT ? " correct" : + referenceBool === STATE.PARTIAL ? " partial" : + " incorrect" + }`; + - const bool = string1 === string2; - setVerse(value); - setVerseBool(bool); - }; {/* function to check correctness of title input */} const titleChange = (e) => { @@ -75,11 +73,24 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse .toLowerCase() .normalize("NFC"); - const bool = string1 === string2; + var result = STATE.INCORRECT; // init + if (string1 === string2) { + result = STATE.CORRECT; + } else if (string2.startsWith(string1) & string1 !== "") { + result = STATE.PARTIAL + } else { + result = STATE.INCORRECT + } setTitle(value); - setTitleBool(bool); + setTitleBool(result); }; + const titleClassName = `chapter-title-box${ + titleBool=== STATE.CORRECT ? " correct" : + titleBool === STATE.PARTIAL ? " partial" : + " incorrect" + }`; + {/* function to check correctness of chapter title input */} @@ -101,26 +112,75 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse .toLowerCase() .normalize("NFC"); - const bool = string1 === string2; + var result = STATE.INCORRECT; // init + if (string1 === string2) { + result = STATE.CORRECT; + } else if (string2.startsWith(string1) & string1 !== "") { + result = STATE.PARTIAL + } else { + result = STATE.INCORRECT + } setChapterTitle(value); - setChapterTitleBool(bool); + setChapterTitleBool(result); + }; + const chapterTitleClassName = `title-box${ + chapterTitleBool=== STATE.CORRECT ? " correct" : + chapterTitleBool === STATE.PARTIAL ? " partial" : + " incorrect" + }`; + + + // check verse input + const verseChange = (e) => { + const value = e.target.value; + let string1 = value; + let string2 = verse; + string1 = String(string1) + .replace(/[\p{P}\p{S}]/gu, "") + .replace(/\s+/g, "") + .toLowerCase() + .normalize("NFC"); + string2 = String(string2) + .replace(/[\p{P}\p{S}]/gu, "") + .replace(/\s+/g, "") + .toLowerCase() + .normalize("NFC"); + + var result = STATE.INCORRECT; // init + if (string1 === string2) { + result = STATE.CORRECT; + } else if (string2.startsWith(string1) & string1 !== "") { + result = STATE.PARTIAL + } else { + result = STATE.INCORRECT + } + + setVerse(value); + setVerseBool(result); }; - const DiffViewer = ({oldValue, newValue}) => { - const string1 = String(oldValue) - .replace(/[\p{P}\p{S}]/gu, "") - .toLowerCase() - .normalize("NFC"); + const verseClassName = `verse-box${ + verseBool === STATE.CORRECT ? " correct" : + verseBool === STATE.PARTIAL ? " partial" : + " incorrect" + }`; - const string2 = String(newValue) - .replace(/[\p{P}\p{S}]/gu, "") - .toLowerCase() - .normalize("NFC"); + // const DiffViewer = ({oldValue, newValue}) => { + // const string1 = String(oldValue) + // .replace(/[\p{P}\p{S}]/gu, "") + // .toLowerCase() + // .normalize("NFC"); - return () - } + + // const string2 = String(newValue) + // .replace(/[\p{P}\p{S}]/gu, "") + // .toLowerCase() + // .normalize("NFC"); + + // return () + // } const DiffViewerStrict = ({oldValue, newValue}) => { const string1 = String(oldValue) @@ -144,7 +204,7 @@ const VerseValidator = ({ element: { pack, title, chapterTitle, reference, verse {t('verse_validator.input_reference')}