Initial app code, no webpack
- Pre-webpack version of our simple app - One app.js file with all the code - Bootstrap included via CDS, no SASS or customization - Single SVG included in assets folder
This commit is contained in:
commit
b96a9dbce0
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
1
assets/webpack.svg
Normal file
1
assets/webpack.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3046.7 875.7"><path fill="#FFF" d="M387 0l387 218.9v437.9L387 875.7 0 656.8V218.9L387 0z"/><path fill="#8ED6FB" d="M704.9 641.7L399.8 814.3V679.9l190.1-104.6 115 66.4zm20.9-18.9V261.9l-111.6 64.5v232l111.6 64.4zM67.9 641.7L373 814.3V679.9L182.8 575.3 67.9 641.7zM47 622.8V261.9l111.6 64.5v232L47 622.8zm13.1-384.3L373 61.5v129.9L172.5 301.7l-1.6.9-110.8-64.1zm652.6 0l-312.9-177v129.9l200.5 110.2 1.6.9 110.8-64z"/><path fill="#1C78C0" d="M373 649.3L185.4 546.1V341.8L373 450.1v199.2zm26.8 0l187.6-103.1V341.8L399.8 450.1v199.2zM198.1 318.2l188.3-103.5 188.3 103.5-188.3 108.7-188.3-108.7z"/><path fill="#F5FAFA" d="M1164.3 576.3h82.5l84.1-280.2h-80.4l-49.8 198.8-53.1-198.8H1078l-53.6 198.8-49.3-198.8h-80.4l83.6 280.2h82.5l52-179.5 51.5 179.5zM1335.2 437c0 84.1 57.3 146.3 147.4 146.3 69.7 0 107.2-41.8 117.9-61.6l-48.8-37c-8 11.8-30 34.3-68.1 34.3-41.3 0-71.3-26.8-72.9-64.3H1608c.5-5.4.5-10.7.5-16.1 0-91.6-49.3-149.5-136.1-149.5-79.9 0-137.2 63.2-137.2 147.9zm77.7-30.6c3.2-32.1 25.7-56.8 60.6-56.8 33.8 0 58.4 22.5 60 56.8h-120.6zm223.5 169.9h69.7v-28.9c7.5 9.1 35.4 35.9 83.1 35.9 80.4 0 137.2-60.5 137.2-146.8 0-86.8-52.5-147.3-132.9-147.3-48.2 0-76.1 26.8-83.1 36.4V188.9h-73.9v387.4h-.1zm71.8-139.3c0-52.5 31.1-82.5 71.8-82.5 42.9 0 71.8 33.8 71.8 82.5 0 49.8-30 80.9-71.8 80.9-45 0-71.8-36.5-71.8-80.9zm247 239.5h73.9V547.3c7 9.1 34.8 35.9 83.1 35.9 80.4 0 132.9-60.5 132.9-147.3 0-85.7-56.8-146.8-137.2-146.8-47.7 0-75.6 26.8-83.1 36.4V296h-69.7v380.5h.1zm71.8-241.1c0-44.5 26.8-80.9 71.8-80.9 41.8 0 71.8 31.1 71.8 80.9 0 48.8-28.9 82.5-71.8 82.5-40.7 0-71.8-30-71.8-82.5zm231.5 54.1c0 58.9 48.2 93.8 105 93.8 32.2 0 53.6-9.6 68.1-25.2l4.8 18.2h65.4V398.9c0-62.7-26.8-109.8-116.8-109.8-42.9 0-85.2 16.1-110.4 33.2l27.9 50.4a165.2 165.2 0 0 1 74.5-19.8c32.7 0 50.9 16.6 50.9 41.3v18.2c-10.2-7-32.2-15.5-60.6-15.5-65.4-.1-108.8 37.4-108.8 92.6zm73.9-2.2c0-23 19.8-39.1 48.2-39.1s48.8 14.5 48.8 39.1c0 23.6-20.4 38.6-48.2 38.6s-48.8-15.5-48.8-38.6zm348.9 30.6c-46.6 0-79.8-33.8-79.8-81.4 0-45 29.5-82 77.2-82a95.2 95.2 0 0 1 65.4 26.8l20.9-62.2a142.6 142.6 0 0 0-88.4-30c-85.2 0-149 62.7-149 147.9s62.2 146.3 149.5 146.3a141 141 0 0 0 87.3-30l-19.8-60.5c-12.4 10.1-34.9 25.1-63.3 25.1zm110.9 58.4h73.9V431.6l93.8 144.7h86.8L2940.6 423l98.6-127h-83.1l-90 117.9v-225h-73.9v387.4z"/></svg>
|
After Width: | Height: | Size: 2.3 KiB |
43
index.html
Normal file
43
index.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
||||||
|
/>
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
|
||||||
|
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
/>
|
||||||
|
<title>Webpack Demo</title>
|
||||||
|
</head>
|
||||||
|
<body class="container">
|
||||||
|
<h1 class="text-center mt-5">
|
||||||
|
Welcome!
|
||||||
|
</h1>
|
||||||
|
<div class="alert alert-danger" id="error" role="alert"></div>
|
||||||
|
<div class="row mt-5">
|
||||||
|
<div class="col">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" id="numberOne" class="form-control" />
|
||||||
|
<div class="input-group-append input-group-prepend">
|
||||||
|
<span class="input-group-text">+</span>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="numberTwo" class="form-control" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<button id="addValues" class="btn btn-primary">Add Values</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card mt-5">
|
||||||
|
<div class="card-body">The result is: <span id="result"></span></div>
|
||||||
|
</div>
|
||||||
|
<img src="./assets/webpack.svg" />
|
||||||
|
</body>
|
||||||
|
<script src="./src/app.js"></script>
|
||||||
|
</html>
|
44
src/app.js
Normal file
44
src/app.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
const numberOneInput = document.getElementById("numberOne");
|
||||||
|
const numberTwoInput = document.getElementById("numberTwo");
|
||||||
|
const addValuesButton = document.getElementById("addValues");
|
||||||
|
const resultDiv = document.getElementById("result");
|
||||||
|
const errorBox = document.getElementById("error");
|
||||||
|
|
||||||
|
const parseInputs = (...input) => {
|
||||||
|
return input.map(str => parseInt(str));
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputsAreValid = (...input) => {
|
||||||
|
return input.every(num => typeof num === "number" && !isNaN(num));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAdditionError = (inputs, numbers) => {
|
||||||
|
const fullMessage = inputs.reduce((message, str, index) => {
|
||||||
|
if (inputsAreValid(numbers[index])) {
|
||||||
|
return message + "";
|
||||||
|
} else {
|
||||||
|
return message + `${str} is not a number. `;
|
||||||
|
}
|
||||||
|
}, "Please enter two valid numbers! ");
|
||||||
|
|
||||||
|
errorBox.classList.remove("invisible");
|
||||||
|
errorBox.innerText = fullMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
const hideErrors = () => {
|
||||||
|
errorBox.classList.add("invisible");
|
||||||
|
};
|
||||||
|
|
||||||
|
hideErrors();
|
||||||
|
addValuesButton.addEventListener("click", () => {
|
||||||
|
hideErrors();
|
||||||
|
const inputs = [numberOneInput.value, numberTwoInput.value];
|
||||||
|
const parsedInputs = parseInputs(...inputs);
|
||||||
|
if (inputsAreValid(...parsedInputs)) {
|
||||||
|
const [numA, numB] = parsedInputs;
|
||||||
|
resultDiv.innerText = numA + numB;
|
||||||
|
} else {
|
||||||
|
resultDiv.innerText = "";
|
||||||
|
handleAdditionError(inputs, parsedInputs);
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user