-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
52 lines (44 loc) · 2 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
document.addEventListener('DOMContentLoaded', function() {
AOS.init();
const menuIcon = document.querySelector('.menu-icon');
const navOverlay = document.querySelector('.nav-overlay');
const navLinks = document.querySelectorAll('.nav-menu a');
menuIcon.addEventListener('click', function() {
this.classList.toggle('active');
navOverlay.classList.toggle('active');
});
navLinks.forEach(link => {
link.addEventListener('click', function() {
menuIcon.classList.remove('active');
navOverlay.classList.remove('active');
});
});
const searchInput = document.querySelector('.search-bar input');
const searchButton = document.querySelector('.search-bar button');
const componentCards = document.querySelectorAll('.component-card');
const noResults = document.getElementById('no-results');
function performSearch() {
const searchTerm = searchInput.value.toLowerCase();
let resultsFound = false;
componentCards.forEach(card => {
const cardText = card.textContent.toLowerCase();
if (cardText.includes(searchTerm)) {
card.style.display = 'block';
resultsFound = true;
} else {
card.style.display = 'none';
}
});
if (resultsFound) {
noResults.style.display = 'none';
} else {
noResults.style.display = 'block';
}
}
searchButton.addEventListener('click', performSearch);
searchInput.addEventListener('keyup', function(event) {
if (event.key === 'Enter') {
performSearch();
}
});
});