<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<title>GitHub API</title>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>

<body>
  <div id="particles-js"></div>
  <div style="display: flex; justify-content: center">
    <div class="svg-container">
      <img src="https://pub-c1de1cb456e74d6bbbee111ba9e6c757.r2.dev/ghrps.svg" alt="OC Logo">
    </div>
  </div>
  <center><a class="github-button" href="https://github.com/sudo-self/user-repos" data-color-scheme="no-preference: light; light: light; dark: light;" data-icon="octicon-star" data-size="large" aria-label="Star sudo-self/user-repos on GitHub">Star</a>
    <p class="light-grey-text">gh api /octocat</p>

    <div class="svg-container">
      <img src="https://pub-c1de1cb456e74d6bbbee111ba9e6c757.r2.dev/oc.gif" alt="OC Logo" width="100">
    </div>

    <form id="gitHubForm" class="form-inline mx-auto mt-3" style="max-width: 280px">
      <input id="usernameInput" class="form-control mb-2 mr-sm-2" type="text" name="username" placeholder="username">
      <button type="submit" class="btn btn-charcoal-grey mb-2">Search</button>
    </form>

    <ul id="userRepos" class="list-group mx-auto mb-5" style="max-width: 500px; overflow-y: auto"></ul>

    <div id="footer">
      <a href="https://sudo-self.github.io/user-repos/">sudo-self.github.io/user-repos</a>
    </div>
    <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
    <script src="app.js"></script>
body {
  background-image: url("https://pub-c1de1cb456e74d6bbbee111ba9e6c757.r2.dev/11.png");
  background-size: cover;
  background-repeat: repeat-y;
}

.btn-charcoal-grey {
  background-color: #444;
  border-color: #fff;
  border: 2px solid;
  color: white;
}

.btn-charcoal-grey:hover {
  background-color: #333;
  border-color: #fff;
}

.github-button {
  background-color: #ccc;
  border: 2px solid white;
}

body,
.svg-container,
.form-inline,
#userRepos,
#footer {
  text-align: center;
}

body {
  background-color: #f5f5f5;
}

#userRepos {
  height: 300px;
  overflow-y: auto;
}

#footer {
  margin-top: 20px;
  color: green;
  font-size: small;
}

.light-grey-text {
  color: #fff;
}

#footer a {
  color: #28a745;
}

#particles-js {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
}

.svg-container img {
  max-width: 100%;
  height: auto;
}
window.onload = function () {
  particlesJS("particles-js", {
    particles: {
      number: {
        value: 80,
        density: {
          enable: true,
          value_area: 800
        }
      },
      color: {
        value: "#ffffff"
      },
      shape: {
        type: "circle",
        stroke: {
          width: 0,
          color: "#000000"
        },
        polygon: {
          nb_sides: 5
        },
        image: {
          src: "img/github.svg",
          width: 100,
          height: 100
        }
      },
      opacity: {
        value: 0.5,
        random: false,
        anim: {
          enable: false,
          speed: 1,
          opacity_min: 0.1,
          sync: false
        }
      },
      size: {
        value: 3,
        random: true,
        anim: {
          enable: false,
          speed: 40,
          size_min: 0.1,
          sync: false
        }
      },
      line_linked: {
        enable: true,
        distance: 150,
        color: "#ffffff",
        opacity: 0.4,
        width: 1
      },
      move: {
        enable: true,
        speed: 6,
        direction: "none",
        random: false,
        straight: false,
        out_mode: "out",
        bounce: false,
        attract: {
          enable: false,
          rotateX: 600,
          rotateY: 1200
        }
      }
    },
    interactivity: {
      detect_on: "canvas",
      events: {
        onhover: {
          enable: true,
          mode: "repulse"
        },
        onclick: {
          enable: true,
          mode: "push"
        },
        resize: true
      },
      modes: {
        grab: {
          distance: 400,
          line_linked: {
            opacity: 1
          }
        },
        bubble: {
          distance: 400,
          size: 40,
          duration: 2,
          opacity: 8,
          speed: 3
        },
        repulse: {
          distance: 200,
          duration: 0.4
        },
        push: {
          particles_nb: 4
        },
        remove: {
          particles_nb: 2
        }
      }
    },
    retina_detect: true
  });
};
document
  .getElementById("gitHubForm")
  .addEventListener("submit", function (event) {
    event.preventDefault();
    var username = document.getElementById("usernameInput").value;
    fetch(`https://api.github.com/users/${username}/repos`)
      .then((response) => response.json())
      .then((data) => {
        var userRepos = document.getElementById("userRepos");
        userRepos.innerHTML = "";
        if (data.length === 0) {
          var li = document.createElement("li");
          li.classList.add("list-group-item");
          li.textContent = "No repositories found.";
          userRepos.appendChild(li);
        } else {
          data.forEach((repo) => {
            var li = document.createElement("li");
            li.classList.add("list-group-item");
            li.innerHTML = `
                            <p><strong>Repo:</strong> ${repo.name}</p>
                            <p><strong>Description:</strong> ${
                              repo.description || "No description"
                            }</p>
                            <p><strong>URL:</strong> <a href="${
                              repo.html_url
                            }">${repo.html_url}</a></p>
                        `;
            userRepos.appendChild(li);
          });
        }
      })
      .catch((error) => console.error("Error:", error));
  });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.