Skip to content

Commit 5262ab5

Browse files
committed
Added new masonory page, and themes
1 parent 531a262 commit 5262ab5

File tree

3 files changed

+140
-231
lines changed

3 files changed

+140
-231
lines changed

script.js

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ document.addEventListener('DOMContentLoaded', function() {
33
const backToTopBtn = document.getElementById('backToTopBtn');
44
const darkModeToggle = document.getElementById('darkModeToggle');
55
const body = document.body;
6+
const projectsSection = document.getElementById('projects');
67

78
// Smooth scrolling
89
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
@@ -16,13 +17,22 @@ document.addEventListener('DOMContentLoaded', function() {
1617

1718
// Sticky navbar effect
1819
window.onscroll = function() {
19-
if (window.pageYOffset > 100) {
20+
const scrollTop = window.pageYOffset;
21+
22+
if (scrollTop > 100) {
2023
navbar.classList.add('scrolled');
2124
backToTopBtn.style.display = 'block';
2225
} else {
2326
navbar.classList.remove('scrolled');
2427
backToTopBtn.style.display = 'none';
2528
}
29+
30+
// Change navbar background color dynamically based on scroll position
31+
if (scrollTop > 300) {
32+
navbar.style.backgroundColor = 'rgba(21, 21, 21, 0.95)';
33+
} else {
34+
navbar.style.backgroundColor = '';
35+
}
2636
};
2737

2838
// Back to top button functionality
@@ -33,24 +43,56 @@ document.addEventListener('DOMContentLoaded', function() {
3343
// Dark mode toggle functionality
3444
darkModeToggle.addEventListener('click', function() {
3545
body.classList.toggle('dark-mode');
46+
updateLocalStorageForDarkMode();
3647
});
3748

38-
// Scroll animations for content sections
39-
const contentSections = document.querySelectorAll('.content-section');
49+
// Set dark mode based on local storage
50+
function setDarkModeFromLocalStorage() {
51+
const isDarkMode = localStorage.getItem('dark-mode') === 'true';
52+
if (isDarkMode) {
53+
body.classList.add('dark-mode');
54+
} else {
55+
body.classList.remove('dark-mode');
56+
}
57+
}
4058

41-
const observerOptions = {
42-
threshold: 0.1,
43-
};
59+
function updateLocalStorageForDarkMode() {
60+
const isDarkMode = body.classList.contains('dark-mode');
61+
localStorage.setItem('dark-mode', isDarkMode);
62+
}
4463

45-
const observer = new IntersectionObserver(entries => {
46-
entries.forEach(entry => {
47-
if (entry.isIntersecting) {
48-
entry.target.classList.add('fade-in');
49-
}
64+
// Initialize dark mode setting
65+
setDarkModeFromLocalStorage();
66+
67+
// Fetch and display GitHub projects
68+
fetch('https://api.github.com/users/hasnocool/repos')
69+
.then(response => response.json())
70+
.then(data => {
71+
displayProjects(data);
72+
})
73+
.catch(error => {
74+
console.error('Error fetching GitHub projects:', error);
5075
});
51-
}, observerOptions);
5276

53-
contentSections.forEach(section => {
54-
observer.observe(section);
55-
});
77+
function displayProjects(repos) {
78+
repos.forEach(repo => {
79+
const repoItem = document.createElement('div');
80+
repoItem.classList.add('masonry-item');
81+
repoItem.innerHTML = `
82+
<h3>${repo.name}</h3>
83+
<p>${repo.description || 'No description available.'}</p>
84+
<a href="${repo.html_url}" target="_blank">View Repository</a>
85+
`;
86+
projectsSection.appendChild(repoItem);
87+
});
88+
}
89+
90+
// Masonry layout update on window resize
91+
const masonry = document.getElementById('projects');
92+
function updateMasonryLayout() {
93+
masonry.style.columnCount = Math.floor(window.innerWidth / 300);
94+
}
95+
96+
window.addEventListener('resize', updateMasonryLayout);
97+
updateMasonryLayout(); // Initial call
5698
});

styles-Default.css

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)