Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4-js_basics_Allocene #194

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions homeworks/artur.kobyliatsky_Allocene/4-basics/basics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const calculateButton = document.querySelector('#calculate');
const resultBlock = document.querySelector('#result');

calculateButton.addEventListener('click', () => {
const num1 = Number(document.querySelector('#num1').value);
const num2 = Number(document.querySelector('#num2').value);

const sum = num1 + num2;
const sum1 = num1 - num2;
const sum2 = num1 * num2;
const sum3 = num1 / num2;
const sum4 = num1 % num2;
const sum5 = num1 ** num2;

resultBlock.innerHTML = `
<table>
<thead>
<tr>
<th>Operation</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td>Addition</td>
<td>${num1} + ${num2} = ${sum}</td>
</tr>
<tr>
<td>Subtraction</td>
<td>${num1} - ${num2} = ${sum1}</td>
</tr>
<tr>
<td>Multiplication</td>
<td>${num1} * ${num2} = ${sum2}</td>
</tr>
<tr>
<td>Division</td>
<td>${num1} / ${num2} = ${sum3}</td>
</tr>
<tr>
<td>Obtaining the remainder from division</td>
<td>${num1} % ${num2} = ${sum4}</td>
</tr>
<tr>
<td>Exponentiation</td>
<td>${num1} ** ${num2} = ${sum5}</td>
</tr>
</tbody>
</table>
`;
});
38 changes: 38 additions & 0 deletions homeworks/artur.kobyliatsky_Allocene/4-basics/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/b3adce1055.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./style.css">
<title>JS</title>
</head>

<body>
<main class="main">
<h1 class="main__heading">Basic math operation</h1>
<div class="main__operation">
<div class="numbers">
<div class="number1">
<label for="num1" class="label">Enter number 1</label>
<input type="number" name="num1" id="num1" title="num1" min="-100" max="100" class="inp"
required>
</div>
<div class="number2">
<label for="num2" class="label">Enter number 2</label>
<input type="number" name="num2" id="num2" title="num2" min="-100" max="100" class="inp"
required>
</div>
</div>
<button type="button" class="button" id="calculate">Calculate</button>
<div id="result"></div>
</div>
</main>
<script src="./basics.js"></script>
</body>

</html>
110 changes: 110 additions & 0 deletions homeworks/artur.kobyliatsky_Allocene/4-basics/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
body {
height: 100%;
font-family: "Roboto", sans-serif;
margin: 0;
}

.main {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
}

.main__heading {
margin-top: 25px;
color: #221F1F;
font-size: 48px;
line-height: 32px;
font-weight: 700;
}

.main__operation {
display: flex;
align-items: center;
flex-direction: column;
width: 90%;
}

.numbers {
display: flex;
flex-direction: row;
gap: 60px;
margin-bottom: 25px;
}

.number1 {
display: flex;
flex-direction: column;
}

.number2 {
display: flex;
flex-direction: column;
}

.label {
font-size: 22px;
font-weight: 600;
}

.inp {
height: 40px;
width: 150px;
font-size: 24px;
margin-top: 22px;
border-radius: 6px;
outline: 0;
border: solid .6px #A9A9A9;
padding-left: 19px;
}

.inp:focus {
border-bottom: solid 6px #EF4934;
}

.inp::placeholder {
font-size: 14px;
font-weight: 400;
line-height: 21px;
letter-spacing: 0;
text-align: left;
}

.button {
height: 44px;
width: 406px;
font-size: 24px;
border-radius: 6px;
margin-bottom: 25px;
outline: 0;
border: 0;
color: #FFF;
background-color: #EF4934;
transition: background-color .2s ease-in-out;
}

.button:hover {
background-color: #CD412F;
}

table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}

th {
background-color: rgba(204, 59, 59, .516);
}

td,
th {
border: 1px solid #EF4934;
text-align: left;
padding: 8px;
}

tr:nth-child(even) {
background-color: rgba(204, 59, 59, .3);
}