diff --git a/.gitignore b/.gitignore index 76add87..a44058c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store node_modules dist \ No newline at end of file diff --git a/index.html b/index.html index 667710d..204e0eb 100644 --- a/index.html +++ b/index.html @@ -39,10 +39,5 @@ - - - - - diff --git a/src/app/alert.service.js b/src/app/alert.service.js index 12a8e08..fd572a9 100644 --- a/src/app/alert.service.js +++ b/src/app/alert.service.js @@ -1,4 +1,5 @@ -class AlertService { +import { inputsAreValid } from "./utils/inputs-are-valid"; +export class AlertService { constructor() { this.errorBox = document.getElementById("error"); } diff --git a/src/app/app.js b/src/app/app.js index 6980a4b..53afdc7 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -1,6 +1,6 @@ -const alertService = new AlertService(); -const componentService = new ComponentService(); -const run = (alertService, componentService) => { +import { inputsAreValid } from "./utils/inputs-are-valid"; +import { parseInputs } from "./utils/parse-inputs"; +export const run = (alertService, componentService) => { alertService.hideErrors(); componentService.onClick(() => { @@ -16,4 +16,3 @@ const run = (alertService, componentService) => { } }); }; -run(alertService, componentService); diff --git a/src/app/component.service.js b/src/app/component.service.js index 62e8512..47764a5 100644 --- a/src/app/component.service.js +++ b/src/app/component.service.js @@ -1,4 +1,4 @@ -class ComponentService { +export class ComponentService { constructor() { this.numberOneInput = document.getElementById("numberOne"); this.numberTwoInput = document.getElementById("numberTwo"); diff --git a/src/app/utils/inputs-are-valid.js b/src/app/utils/inputs-are-valid.js index c5c83b2..ea9531e 100644 --- a/src/app/utils/inputs-are-valid.js +++ b/src/app/utils/inputs-are-valid.js @@ -1,3 +1,3 @@ -const inputsAreValid = (...input) => { +export const inputsAreValid = (...input) => { return input.every(num => typeof num === "number" && !isNaN(num)); }; diff --git a/src/app/utils/parse-inputs.js b/src/app/utils/parse-inputs.js index c22d4b2..48b161f 100644 --- a/src/app/utils/parse-inputs.js +++ b/src/app/utils/parse-inputs.js @@ -1,3 +1,3 @@ -const parseInputs = (...input) => { +export const parseInputs = (...input) => { return input.map(str => parseInt(str)); }; diff --git a/src/index.js b/src/index.js index 025ac3f..096a834 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,6 @@ -alert("HELLO FROM WEBPACK!"); +import { run } from "./app/app"; +import { AlertService } from "./app/alert.service"; +import { ComponentService } from "./app/component.service"; +const alertService = new AlertService(); +const componentService = new ComponentService(); +run(alertService, componentService);