Skip to content

Commit

Permalink
score, fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-markin committed Jun 27, 2024
1 parent ee8bcac commit 2d93a71
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 16 deletions.
24 changes: 16 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
</div>
<main class="container" id="content">
<section id="create-vocabulary">
<h1>Learn words every day</h1>
<button onclick="startLearn()" type="button">Start learn</button>
<h1>Learn words</h1>
<div class="card start">
<p>learn dev words</p>
<button onclick="startLearn()" type="button">Start learn</button>
</div>

<!-- <label>Your vocabulary</label>
<form>
<textarea id="vocabulary" rows="20"></textarea>
Expand All @@ -35,12 +39,16 @@ <h2>How is the word translated?</h2>
class="giphy-embed"
allowfullscreen
></iframe>
<p id="current-word"></p>
<div id="suggestions"></div>
<br>
<br>
<a href="#" id="next-word" onclick="learnWord()">Next word</a>

<div class="card">
<p id="current-word"></p>
</div>
<div class="progress">
<span id="score"></span>
<a href="#" id="next-word" onclick="learnWord()">Next word</a>
</div>
<div class="card">
<div id="suggestions"></div>
</div>
</section>
</main>

Expand Down
60 changes: 54 additions & 6 deletions src/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
font-family: "Roboto Mono";
src: url("../fonst/RobotoMono-Regular.ttf");
}
html {
max-width: 800px;
display: block;
margin-left: auto;
margin-right: auto;
}

body {
font-family: "Roboto Mono", monospace;
background: #333131;
font-size: 20px;
background: #1b1b1b;
margin: 0 20px;
}
.container {
color: whitesmoke;
Expand All @@ -23,34 +32,73 @@ iframe {
button {
font-size: 25px;
}

.progress {
display: flex;
justify-content: space-between;
align-items: center;
}
#score {
padding-left: 2em;
}
#next-word {
color: gray;
font-size: 0.8em;
text-decoration: none;
color: #7f7f7f;
}

#vocabulary {
padding: 0;
width: 100%;
}
.start {
height: 300px;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}

#learn-word {
display: none;
}

.card {
background-color: #333131;
border-radius: 15px;
margin: 20px 0;
}

#current-word {
font-size: 30px;
font-size: 1.4em;
text-align: center;
font-weight: 700;
padding: 20px 20px;
margin: 0;
}

#suggestions {
padding: 20px 0;
/* padding: 20px 0; */
display: flex;
flex-direction: column;
}

#suggestions button {
margin: 10px 10px 0 0;
/* margin: 10px 10px 0 0; */
margin: 2px;
border-radius: 6px;
padding-left: 30px;
text-align: left;
background-color: transparent;
border: 0;
color: whitesmoke;
padding: 10px;
padding-left: 2em;
border-radius: 15px;
margin: 0;
font-size: 1em;
}

/* preloader */
#preloader {
position: fixed;
top: 0;
Expand Down
9 changes: 7 additions & 2 deletions src/js/learn.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ function startLearn() {

const currentWordElement = document.getElementById("current-word");
const suggestionsElement = document.getElementById("suggestions");
const scoreElement = document.getElementById("score");

let currentWordIndex;
let currentWord;
let score = 0;

function learnWord() {
preloader.style.display = "flex";
Expand All @@ -93,6 +95,7 @@ function learnWord() {
currentWord = vocabulary[currentWordIndex];
// console.log("current word", currentWord);
currentWordElement.innerHTML = currentWord.en;
scoreElement.innerHTML = `&#128077; ${score}`;

suggest();
loadMeme();
Expand Down Expand Up @@ -124,7 +127,7 @@ function suggest() {
const suggestionElement = document.createElement("button");
suggestionElement.innerHTML = suggestion.ru;
suggestionElement.onclick = function () {
suggestionElement.style.backgroundColor = "red";
suggestionElement.style.backgroundColor = "#7f5353";
};
// console.log(suggestionElement.outerHTML);
suggestionsElement.appendChild(suggestionElement);
Expand All @@ -133,9 +136,11 @@ function suggest() {
const suggestionElement = document.createElement("button");
suggestionElement.innerHTML = currentWord.ru;
suggestionElement.onclick = function () {
suggestionElement.style.backgroundColor = "green";
suggestionElement.style.backgroundColor = "#548354";
setTimeout(learnWord, 500);
score += 1;
};


suggestionsElement.appendChild(suggestionElement);
}
Expand Down

0 comments on commit 2d93a71

Please sign in to comment.