From fa5a39e6eb1abf797d5ec73bbb59146e27318388 Mon Sep 17 00:00:00 2001 From: GuiTavs7 <7tavs7@gmail.com> Date: Thu, 7 Nov 2024 19:44:57 -0300 Subject: [PATCH] update scripts --- src/css/styles.css | 2 +- src/scripts/objects/screen.js | 30 ++++++++++++++++-------------- src/scripts/services/events.js | 3 ++- src/scripts/variables.js | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/css/styles.css b/src/css/styles.css index 9077205..e5ef20b 100644 --- a/src/css/styles.css +++ b/src/css/styles.css @@ -240,6 +240,6 @@ main { .container .profile-data .events ul li a:hover{ background-color:hotpink; color: #fff; - padding: 5px; + padding: 3px; border-radius: 7px; } \ No newline at end of file diff --git a/src/scripts/objects/screen.js b/src/scripts/objects/screen.js index b02b776..0a7e8e1 100644 --- a/src/scripts/objects/screen.js +++ b/src/scripts/objects/screen.js @@ -36,10 +36,10 @@ const screen = { ${repo.name}
-

🍴 ${repo.forks_count}

-

🌟 ${repo.stargazers_count}

-

👀 ${repo.watchers_count}

-

💻 ${repo.language}

+

🍴 ${repo.forks_count ?? "Sem forks 😢"}

+

🌟 ${repo.stargazers_count ?? "Sem estrelas 😢"}

+

👀 ${repo.watchers_count ?? "Sem observadores 😢"}

+

💻 ${repo.language ?? "Sem linguagem 😢"}

@@ -58,18 +58,20 @@ const screen = { let eventsItens = "" - user.events.filter(event => event.type === "CreateEvent" || event.type === "PushEvent").forEach(event => { - - if (event.type === "PushEvent"){ - eventsItens += `
  • ${event.repo.name} - ${event.payload.commits.slice(-1)[0].message}
  • `; - console.log(eventsItens); + user.events.forEach(event =>{ + if(event.type === "PushEvent"){ + eventsItens += `
  • + ${event.repo.name} +

    -- ${event.payload.commits[0].message}

    +
  • ` } - - else if (event.type === "CreateEvent"){ - eventsItens += `
  • Create ${event.payload.ref_type} (Sem mensagem de commit!)
  • `; + else{ + eventsItens += `
  • + ${event.repo.name} +

    -- Criado um ${event.payload.ref_type}

    +
  • ` } - - }); + }) if (eventsItens){ this.userProfile.innerHTML += `
    diff --git a/src/scripts/services/events.js b/src/scripts/services/events.js index 09c475e..4b5adad 100644 --- a/src/scripts/services/events.js +++ b/src/scripts/services/events.js @@ -4,7 +4,8 @@ import { baseUrl, eventsQuantity } from "../variables.js"; async function getEvents(userName){ const response = await fetch(`${baseUrl}/${userName}/events?per_page=${eventsQuantity}`); - return await response.json(); + const events = await response.json(); + return events.filter(element => element.type === "CreateEvent" || element.type === "PushEvent").slice(0,eventsQuantity); } export { getEvents }; \ No newline at end of file diff --git a/src/scripts/variables.js b/src/scripts/variables.js index 7d457ac..adade29 100644 --- a/src/scripts/variables.js +++ b/src/scripts/variables.js @@ -1,5 +1,5 @@ const baseUrl = "https://api.github.com/users"; -const repositoriesQuantity = 16; -const eventsQuantity = 16; +const repositoriesQuantity = 24; +const eventsQuantity = 24; export {baseUrl, repositoriesQuantity, eventsQuantity}; \ No newline at end of file