forked from BeehiveCommunity/Frontend_Mentor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
108 lines (95 loc) · 3.76 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"use strict";
// Correct projects numbering (Removed duplicate "23" key)
const projects = [
{ name: "01-Community-Card", tags: ["HTML", "CSS"] },
{ name: "02-qr-code-component", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "03-social-proof", tags: ["HTML", "CSS"] },
{ name: "04-nft-project", tags: ["HTML", "CSS"] },
{ name: "05-intractive-rating", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "06-product-preview", tags: ["HTML", "CSS"] },
{ name: "07-fylo-two-column-layout", tags: ["HTML", "CSS"] },
{ name: "08-profile-card", tags: ["HTML", "CSS"] },
{ name: "09-clipboard-landing-page", tags: ["HTML", "CSS"] },
{ name: "10-three-column-card", tags: ["HTML", "CSS"] },
{ name: "11-Order-summery-component", tags: ["HTML", "CSS"] },
{ name: "12-Huddle-comm-page", tags: ["HTML", "CSS"] },
{ name: "13-stat-preview-card", tags: ["HTML", "CSS"] },
{ name: "14-Huddle-landing-page", tags: ["HTML", "CSS"] },
{ name: "15-Article-Preview", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "16-base-apparel-coming-soon", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "17-advice-generator-app", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "18-chat-app-css-illustration", tags: ["HTML", "CSS"] },
{ name: "19-news-homepage", tags: ["HTML", "CSS"] },
{ name: "20-testimonials-grid-section", tags: ["HTML", "CSS"] },
{ name: "21-ecommerce-product-page", tags: ["HTML", "CSS", "JavaScript"] },
{ name: "22-Weather-App", tags: ["HTML", "CSS", "JavaScript", "API"] },
{ name: "23-joke-generator", tags: ["HTML", "CSS", "JavaScript", "API"] },
{ name: "24-login-signup" }
];
// Menu toggle functionality
const menuToggle = document.querySelector(".menu-toggle");
const navbarFunction = document.querySelector(".navbar-function");
if (menuToggle && navbarFunction) {
menuToggle.addEventListener("click", () => {
navbarFunction.classList.toggle("active"); // Toggle class to show/hide nav
});
}
// Populate the list of projects dynamically
const list = document.getElementById("list");
if (list) {
projects.forEach(({ name }, i) => {
const listItem = document.createElement("li");
const tags = projects[i].tags
? projects[i].tags.map((tag) => `<span class="tag">${tag}</span>`).join(" ")
: "";
listItem.innerHTML = `
<a href="./${name}/index.html" target="_blank">
<img src="./${name}/design/desktop-design.jpg" alt="${name}" />
<p>${i + 1}. ${formatProjectName(name)}</p>
<div class="tags">Technologies: ${tags}</div>
</a>
<div class="links-container" target="_blank">
<a href="./${name}/index.html" class="blue">
<i class="fas fa-eye"></i>
</a>
</div>
`;
list.appendChild(listItem);
});
}
function formatProjectName(name) {
return name
.split("-")
.splice(1)
.map((word) => word[0].toUpperCase() + word.slice(1))
.join(" ");
}
// FAQs Section Script
const accordions = document.querySelectorAll(".accordion");
accordions.forEach((accordion) => {
accordion.addEventListener("click", function () {
this.classList.toggle("active");
var panel = this.nextElementSibling;
// Toggle the panel's maxHeight for smooth expand/collapse
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
});
// Smooth scroll-to-top button
const btn = document.querySelector(".scroll-up-btn");
if (btn) {
btn.addEventListener("click", () => {
document.documentElement.scrollTo({
top: 0,
behavior: "smooth"
});
});
}
// GSAP Animations
if (typeof gsap !== "undefined") {
gsap.from(".navbar", { opacity: 0, y: -50, duration: 1.5, ease: "power2.out" });
gsap.from(".footer", { opacity: 0, y: 50, duration: 1.5, ease: "power2.out", delay: 0.5 });
}