mirror of
https://github.com/genemecija/learn-morse-code.git
synced 2025-12-06 07:02:00 +01:00
Challenge word coloring progress
This commit is contained in:
parent
87abb2a222
commit
d707f483ce
|
|
@ -20,7 +20,7 @@ export default React.memo(function ChallengeMode(props) {
|
|||
let morseArray = morseCharBuffer.split('_').filter(l => l !== '')
|
||||
|
||||
let correctCharIndexes = [] // Indexes of correct letters in Challenge Word
|
||||
let incorrectCharIndex = null
|
||||
// let incorrectCharIndex = null
|
||||
let incorrectMorseIndexes = [] // Indexes of incorrect morse characters in morse character buffer
|
||||
|
||||
let offset = 0
|
||||
|
|
@ -45,10 +45,12 @@ export default React.memo(function ChallengeMode(props) {
|
|||
|
||||
if (morseLetter === challengeLetter) {
|
||||
correctCharIndexes.push(index-offset)
|
||||
incorrectCharIndex = null
|
||||
|
||||
document.getElementById('challengeWord').childNodes[index-offset].classList.add('correct')
|
||||
// incorrectCharIndex = null
|
||||
}
|
||||
else {
|
||||
incorrectCharIndex = index-offset
|
||||
// incorrectCharIndex = index-offset
|
||||
incorrectMorseIndexes.push(index)
|
||||
if (incorrectMorseIndexes.length > 0) {
|
||||
setMorseCharBuffer(prev => {
|
||||
|
|
@ -79,6 +81,9 @@ export default React.memo(function ChallengeMode(props) {
|
|||
challengeWordClass = 'correct'
|
||||
setTimeout(() => {
|
||||
setMorseCharBuffer('')
|
||||
morseArray = []
|
||||
incorrectMorseIndexes = []
|
||||
offset = 0
|
||||
}, 800)
|
||||
setTimeout(() => {
|
||||
getNextWord()
|
||||
|
|
@ -88,7 +93,7 @@ export default React.memo(function ChallengeMode(props) {
|
|||
|
||||
return (
|
||||
<>
|
||||
<ChallengeWord className={challengeWordClass} word={word} correctCharIndexes={correctCharIndexes} incorrectCharIndex={incorrectCharIndex} />
|
||||
<ChallengeWord className={challengeWordClass} word={word} />
|
||||
<ChallengeBufferDisplay morseArray={morseArray} incorrectMorseIndexes={incorrectMorseIndexes} />
|
||||
{/* <button onClick={() => console.log(morseCharBuffer)}>morseCharBuffer</button> */}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -4,21 +4,13 @@ export default React.memo(function ChallengeWord(props) {
|
|||
|
||||
let challengeWordClass= props.className
|
||||
const word = props.word
|
||||
const correctCharIndexes = props.correctCharIndexes
|
||||
const incorrectCharIndex = props.incorrectCharIndex
|
||||
|
||||
let challengeLetters = word.split('')
|
||||
|
||||
let spannedWord = challengeLetters.map((letter,index) => {
|
||||
|
||||
let className = 'cLetter'
|
||||
|
||||
if (incorrectCharIndex === index) {
|
||||
className = 'cLetter morseError'
|
||||
} else if (correctCharIndexes.includes(index)) {
|
||||
className = 'cLetter correct'
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<span key={index} className={className} id={"chal"+index}>{letter}</span>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -441,11 +441,9 @@ i[class*="ri-"] {
|
|||
transition: all 300ms ease-in-out;
|
||||
}
|
||||
|
||||
#challengeWord span {
|
||||
#challengeWord .cLetter {
|
||||
padding: 4px;
|
||||
margin: 1px;
|
||||
-webkit-transition: background 100ms ease-in-out;
|
||||
transition: background 100ms ease-in-out;
|
||||
display: -webkit-inline-box;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
|
|
@ -453,9 +451,12 @@ i[class*="ri-"] {
|
|||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
display: inline-block;
|
||||
padding-top: 10px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
#challengeWord span.correct {
|
||||
#challengeWord .cLetter.correct {
|
||||
background: rgba(0, 255, 0, 0.6);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
|
@ -503,6 +504,8 @@ i[class*="ri-"] {
|
|||
text-align: center;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
display: inline-block;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
#morseBufferDisplay #alphanumeric-container #alphanumeric {
|
||||
|
|
@ -599,9 +602,25 @@ i[class*="ri-"] {
|
|||
}
|
||||
|
||||
#challengeBufferDisplay #alphanumeric-container #alphanumeric {
|
||||
font-size: 40px;
|
||||
background-color: transparent;
|
||||
margin-bottom: 10px;
|
||||
height: 50px;
|
||||
font-size: 3rem;
|
||||
font-family: "Courier", monospace;
|
||||
float: right;
|
||||
background: #fdfdfd;
|
||||
margin-left: 3px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 3px;
|
||||
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2), 0px -1px 1px rgba(255, 255, 255, 0.1);
|
||||
box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2), 0px -1px 1px rgba(255, 255, 255, 0.1);
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#challengeBufferDisplay #alphanumeric-container #alphanumeric:first-child {
|
||||
|
|
@ -610,13 +629,14 @@ i[class*="ri-"] {
|
|||
}
|
||||
|
||||
#challengeBufferDisplay #alphanumeric-container #alphanumeric span {
|
||||
display: inline-block;
|
||||
padding: 4px;
|
||||
-webkit-transition: background 100ms ease-in-out;
|
||||
transition: background 100ms ease-in-out;
|
||||
}
|
||||
|
||||
#challengeBufferDisplay #ditDahs {
|
||||
width: 50%;
|
||||
height: 50px;
|
||||
padding-right: 5px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
|
|
@ -628,25 +648,20 @@ i[class*="ri-"] {
|
|||
-webkit-box-pack: center;
|
||||
-ms-flex-pack: center;
|
||||
justify-content: center;
|
||||
font-size: 25px;
|
||||
font-size: 3rem;
|
||||
font-family: "Courier", monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#challengeBufferDisplay #ditDahs span {
|
||||
padding: 4px;
|
||||
padding: 5px;
|
||||
-webkit-transition: background 100ms ease-in-out;
|
||||
transition: background 100ms ease-in-out;
|
||||
}
|
||||
|
||||
#challengeBufferDisplay #ditDahs .ditDah {
|
||||
background: #fdfdfd;
|
||||
height: 40px;
|
||||
width: 30px !important;
|
||||
margin-left: 3px;
|
||||
border-radius: 3px;
|
||||
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.3), 0px -1px 1px white;
|
||||
box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.3), 0px -1px 1px white;
|
||||
-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2), 0px -1px 1px rgba(255, 255, 255, 0.1);
|
||||
box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2), 0px -1px 1px rgba(255, 255, 255, 0.1);
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
|
|
@ -656,6 +671,8 @@ i[class*="ri-"] {
|
|||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
-webkit-transition: all 100ms ease-in-out;
|
||||
transition: all 100ms ease-in-out;
|
||||
}
|
||||
|
||||
.space {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -406,13 +406,16 @@ $button-height: 60px;
|
|||
text-transform: uppercase;
|
||||
transition: all 300ms ease-in-out;
|
||||
|
||||
span {
|
||||
.cLetter {
|
||||
padding: 4px;
|
||||
margin: 1px;
|
||||
transition: background 100ms ease-in-out; //, opacity 100ms ease-in-out;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
line-height: 3rem;
|
||||
display: inline-block;
|
||||
padding-top: 10px;
|
||||
background: transparent;
|
||||
// transition: background 100ms ease-in-out; //, opacity 100ms ease-in-out;
|
||||
|
||||
&.correct {
|
||||
background: rgba(0,255,0,0.6);
|
||||
|
|
@ -467,6 +470,9 @@ $button-height: 60px;
|
|||
text-align: center;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
|
||||
display: inline-block;
|
||||
padding-top: 10px;
|
||||
// border: 1px solid red;
|
||||
|
||||
#alphanumeric {
|
||||
|
|
@ -551,9 +557,26 @@ $button-height: 60px;
|
|||
justify-content: center;
|
||||
|
||||
#alphanumeric {
|
||||
font-size: 40px;
|
||||
background-color: transparent;
|
||||
margin-bottom: 10px;
|
||||
// font-size: 40px;
|
||||
// background-color: transparent;
|
||||
// margin-bottom: 10px;
|
||||
|
||||
height: 50px;
|
||||
// border: 1px solid purple;
|
||||
font-size: 3rem;
|
||||
font-family: $ditDah-font;
|
||||
float: right;
|
||||
|
||||
|
||||
background: #fdfdfd;
|
||||
margin-left: 3px;
|
||||
margin-bottom: 20px;
|
||||
// box-shadow: 0px 1px 0px #000;
|
||||
border-radius: $main-border-radius;
|
||||
box-shadow: $main-box-shadow-dark;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
&:first-child {
|
||||
padding-left: 5px;
|
||||
|
|
@ -562,6 +585,7 @@ $button-height: 60px;
|
|||
}
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
padding: 4px;
|
||||
transition: background 100ms ease-in-out;
|
||||
}
|
||||
|
|
@ -569,32 +593,56 @@ $button-height: 60px;
|
|||
}
|
||||
|
||||
#ditDahs {
|
||||
width: 50%;
|
||||
// width: 50%;
|
||||
// padding-right: 5px;
|
||||
// // border-right: 2px solid #000;
|
||||
// display: flex;
|
||||
// flex-direction: row;
|
||||
// justify-content: center;
|
||||
// font-size: 25px;
|
||||
// font-family: $ditDah-font;
|
||||
// font-weight: bold;
|
||||
|
||||
height: 50px;
|
||||
padding-right: 5px;
|
||||
// border-right: 2px solid #000;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
font-size: 25px;
|
||||
// border: 1px solid purple;
|
||||
font-size: 3rem;
|
||||
font-family: $ditDah-font;
|
||||
font-weight: bold;
|
||||
|
||||
span {
|
||||
padding: 4px;
|
||||
transition: background 100ms ease-in-out;
|
||||
}
|
||||
.ditDah {
|
||||
background: #fdfdfd;
|
||||
|
||||
}
|
||||
span {
|
||||
// background: #fdfdfd;
|
||||
|
||||
// height: 40px;
|
||||
// width: 30px !important;
|
||||
// margin-left: 3px;
|
||||
// // box-shadow: 0px 1px 0px #000;
|
||||
// border-radius: $main-border-radius;
|
||||
// box-shadow: $main-box-shadow-light;
|
||||
// display: flex;
|
||||
// justify-content: center;
|
||||
// align-items: center;
|
||||
|
||||
padding: 5px;
|
||||
transition: background 100ms ease-in-out;
|
||||
background: #fdfdfd;
|
||||
height: 40px;
|
||||
width: 30px !important;
|
||||
// width: 30px !important;
|
||||
margin-left: 3px;
|
||||
// box-shadow: 0px 1px 0px #000;
|
||||
border-radius: $main-border-radius;
|
||||
box-shadow: $main-box-shadow-light;
|
||||
box-shadow: $main-box-shadow-dark;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
transition: all 100ms ease-in-out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue