Skip to content

Commit fee692a

Browse files
Feat: Add NProgress page loader and fix input box bug
1 parent 6eaf163 commit fee692a

File tree

7 files changed

+45
-12
lines changed

7 files changed

+45
-12
lines changed

index.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<title>GitHub Data Finder</title>
88
<meta name="description" content="Get github users data and information">
99
<meta name="viewport" content="width=device-width, initial-scale=1">
10-
11-
<meta property="og:title" content="">
10+
<meta property="og:title" content="Github Data Finder">
1211
<meta property="og:type" content="">
1312
<meta property="og:url" content="">
1413
<meta property="og:image" content="">
15-
14+
<meta name="theme-color" content="#fafafa">
1615
<link rel="manifest" href="site.webmanifest">
16+
1717
<!-- Place favicon.ico in the root directory -->
1818
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
1919

@@ -25,7 +25,6 @@
2525
<!-- BootStrap Icons CDN -->
2626
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
2727

28-
<meta name="theme-color" content="#fafafa">
2928
</head>
3029

3130
<body>

package-lock.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
"eslint": "^8.57.0",
1818
"parcel-bundler": "^1.12.4",
1919
"prettier": "^3.2.5"
20+
},
21+
"dependencies": {
22+
"nprogress": "^0.2.0"
2023
}
2124
}

scripts/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1+
import NProgress from "nprogress";
2+
import "nprogress/nprogress.css";
3+
14
let form = document.querySelector(".form-control");
25
let username = document.querySelector("#username");
6+
const emptyInput = document.querySelector("#username");
37

48
form.addEventListener("submit", (e) => {
59
e.preventDefault();
610
let value = username.value;
711
fetchGitData(value).then(() => console.log("Data Fetched"));
12+
emptyInput.value = "";
813
});
914

15+
//Disable the NProgress spinner
16+
NProgress.configure({ showSpinner: false });
17+
//Start the progress bar
18+
NProgress.start();
19+
20+
//API Call
1021
async function fetchGitData(username) {
1122
try {
1223
let data = await window.fetch(`https://api.github.com/users/${username}`);
1324
console.log(data);
1425
console.log(data.type);
1526
let finalData = await data.json();
27+
console.log(finalData);
1628
let mainRight = document.getElementById("main-right");
1729
let {
1830
avatar_url,
@@ -83,3 +95,5 @@ async function fetchGitData(username) {
8395
console.log(error);
8496
}
8597
}
98+
//Stop the progress bar
99+
NProgress.done();

scripts/theme.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ let theme = document.getElementById("theme-slider");
33
theme.addEventListener("click", (evt) => {
44
let themeMode = document.body;
55
themeMode.classList.toggle("switch-theme");
6-
})
6+
});

styles/main.css

+4
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,7 @@ body {
543543
.cursor-type {
544544
cursor: pointer;
545545
}
546+
.bar {
547+
background: #6e40c9 !important;
548+
height: 0.14rem !important;
549+
}

styles/theme.css

+12-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
bottom: 0;
3333
background-color: #ffffff;
3434
border: 1px solid #161c26;
35-
transition: .4s;
35+
transition: 0.4s;
3636
}
3737

3838
.slider:before {
@@ -42,21 +42,26 @@
4242
width: 22px;
4343
left: 4px;
4444
bottom: 4px;
45-
background: linear-gradient(180deg, rgba(183, 52, 179, 0.15) 0%, rgba(164, 46, 156, 0) 100%), #6e40c9 !important;
46-
-webkit-transition: .4s;
47-
transition: .4s;
45+
background: linear-gradient(
46+
180deg,
47+
rgba(183, 52, 179, 0.15) 0%,
48+
rgba(164, 46, 156, 0) 100%
49+
),
50+
#6e40c9 !important;
51+
-webkit-transition: 0.4s;
52+
transition: 0.4s;
4853
}
4954

50-
input:checked+.slider {
55+
input:checked + .slider {
5156
background-color: #161c26;
5257
border: 1px solid #f7f7f7;
5358
}
5459

55-
input:focus+.slider {
60+
input:focus + .slider {
5661
box-shadow: 0 0 1px #161c26;
5762
}
5863

59-
input:checked+.slider:before {
64+
input:checked + .slider:before {
6065
transform: translateX(22px);
6166
}
6267

0 commit comments

Comments
 (0)