diff --git a/src/components/Controls.js b/src/components/Controls.js index 6495859..0e79cb8 100644 --- a/src/components/Controls.js +++ b/src/components/Controls.js @@ -1,5 +1,6 @@ const html = require("./controls.html"); -const css = require("../styles/contols.css"); +const css = require("../styles/controls.css"); +const { getCalendar } = require("../utils/index"); const init = (gameField) => { const controlsEl = document.getElementById("controls"); @@ -10,6 +11,7 @@ const init = (gameField) => { const resetEl = document.getElementById("reset"); const clearEl = document.getElementById("clear"); const canvasEl = document.getElementById("game-field"); + const calendarFormEl = document.getElementById("calendar-form"); const controls = { interval: null, play() { @@ -78,6 +80,11 @@ const init = (gameField) => { const { offsetX, offsetY } = e; controls.updateField(offsetX, offsetY); }); + calendarFormEl.addEventListener("submit", (e) => { + e.preventDefault(); + const user = e.target[0].value; + console.log(getCalendar(user)); + }); return controls; }; diff --git a/src/components/controls.html b/src/components/controls.html index 382b908..12fb9e4 100644 --- a/src/components/controls.html +++ b/src/components/controls.html @@ -11,7 +11,7 @@ value="10" /> -
+
diff --git a/src/styles/contols.css b/src/styles/controls.css similarity index 100% rename from src/styles/contols.css rename to src/styles/controls.css diff --git a/src/utils/index.js b/src/utils/index.js index e2cd2b6..ccca9a6 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,3 +1,34 @@ +const query = (user) => `query { + user (login: "${user}") { + contributionsCollection { + contributionCalendar { + weeks { + contributionDays { + contributionCount + } + } + } + } + } + +}`; + +const options = (user) => ({ + method: "post", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + query: query(user), + }), +}); + +const getCalendar = (user) => { + // return fetch(`https://api.github.com/graphql`, options(user)).then((res) => + // res.json() + // ); +}; + class Stream { constructor(head, next) { this.head = head; @@ -30,4 +61,5 @@ const getNeighbors = (key) => { module.exports = { Stream, getNeighbors, + getCalendar, };