Skip to content

Commit 19480a8

Browse files
author
unknown
committed
Done
0 parents  commit 19480a8

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Github Users</title>
8+
<link rel="stylesheet" href="./style.css">
9+
</head>
10+
11+
<body>
12+
<div class="container">
13+
<h1>Github Users</h1>
14+
<input type="text" placeholder="Search by username" id="inp">
15+
<div class="users">
16+
17+
</div>
18+
</div>
19+
20+
<script src="./script.js"></script>
21+
</body>
22+
23+
</html>

script.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
let getApi = async () => {
4+
let a = await fetch("https://api.github.com/users");
5+
6+
let data = await a.json();
7+
8+
let users = document.querySelector(".users");
9+
10+
let inp = document.getElementById("inp");
11+
12+
data.map((ele) => {
13+
let box = document.createElement("div");
14+
box.classList.add("box")
15+
box.innerHTML = `
16+
<img src="${ele.avatar_url}" alt="" height="80px" width="80px">
17+
<h1>${ele.login}</h1>
18+
<a href="${ele.html_url}">View Profile</a>`
19+
users.appendChild(box);
20+
21+
inp.addEventListener("keyup", () => {
22+
box.style.display = "none";
23+
if (ele.login.includes(inp.value)) {
24+
box.style.display = "flex";
25+
}
26+
})
27+
28+
29+
})
30+
31+
32+
33+
34+
}
35+
36+
getApi();

style.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
* {
2+
padding: 0%;
3+
margin: 0%;
4+
box-sizing: border-box;
5+
}
6+
7+
.container {
8+
height: 100vh;
9+
overflow: auto;
10+
width: 100vw;
11+
background-color: azure;
12+
border: 1px solid;
13+
display: flex;
14+
flex-direction: column;
15+
align-items: center;
16+
gap: 10px;
17+
}
18+
19+
#inp {
20+
padding: 10px;
21+
height: 30px;
22+
width: 90%;
23+
border-radius: 5px;
24+
border: 2px solid blue;
25+
}
26+
27+
#inp:focus {
28+
border: 2px solid blue;
29+
}
30+
31+
.users {
32+
width: 90%;
33+
display: flex;
34+
align-items: center;
35+
justify-content: center;
36+
flex-wrap: wrap;
37+
gap: 10px;
38+
}
39+
40+
.box {
41+
height: 150px;
42+
gap: 3px;
43+
width: 200px;
44+
background-color: white;
45+
border-radius: 10px;
46+
display: flex;
47+
flex-direction: column;
48+
align-items: center;
49+
box-shadow: 0 0 2px 2px rgb(208, 208, 208);
50+
justify-content: center;
51+
}
52+
53+
img {
54+
border-radius: 50%;
55+
56+
}
57+
58+
.box h1 {
59+
font-size: medium;
60+
}
61+
62+
a {
63+
color: blue;
64+
text-decoration: none;
65+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
66+
font-weight: bold;
67+
}

0 commit comments

Comments
 (0)