Skip to content

Commit

Permalink
Create news page and corresponding scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fscek committed Mar 15, 2024
1 parent dae1957 commit e108547
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 6 deletions.
46 changes: 46 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,52 @@ footer {
z-index: 50;
}

/* news page css */
.news-container {
padding: 20px;
background-color: #fff;
color: #000;
border-radius: 8px; /* softens the edges */
margin: 20px auto; /* centralizes the container */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* subtle shadow for depth */
max-width: 95%; /* width of the news container */
}

.news-container h2 {
text-align: center;
margin-bottom: 20px;
}

/* styling for individual news items */
.news-item {
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid #eee; /* separating news items */
}

.news-item:last-child {
border-bottom: none; /* removing the border from the last item */
}

.news-item h3 {
margin: 0;
color: #D67DB3; /* using the primary color for headlines */
}

.news-item p {
margin: 5px 0 10px; /* spacing around the paragraph */
}

.news-item a {
color: #000000; /* ensuring links are visible */
text-decoration: underline; /* underlining links for clarity */
}

.news-item a:hover {
color: #D67DB3; /* hover effect for links */
}


/* threeJS css - commented out
#threejs-container {
width: 100%;
Expand Down
19 changes: 19 additions & 0 deletions assets/data/news.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"title": "New test",
"date": "2024-03-15",
"content": "Test, This is a very big test<br>A paragraph too small is a paragraph never lived.",
"image": "",
"link": "www.google.com",
"tags": ["Release"]
},
{
"title": "Test 2",
"date": "2024-03-10",
"content": "Test",
"image": "",
"link": "",
"tags": ["Tour"]
}
]

6 changes: 3 additions & 3 deletions assets/js/menu-toggle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function toggleMenu() {
var menuContent = document.getElementById("menuContent");
var overlay = document.getElementById("pageOverlay");
var menuIcon = document.getElementById("menuIcon"); // Ensure this matches your icon's ID
var menuIcon = document.getElementById("menuIcon");

// Reduce opacity to start fade out
menuIcon.style.opacity = 0;
Expand All @@ -11,11 +11,11 @@ function toggleMenu() {
if (menuContent.classList.contains('active')) {
menuContent.classList.remove('active');
overlay.style.display = "none";
menuIcon.src = "assets/images/hamburger-menu-open.png";
menuIcon.src = "/assets/images/hamburger-menu-open.png";
} else {
menuContent.classList.add('active');
overlay.style.display = "block";
menuIcon.src = "assets/images/hamburger-menu-close-D67DB3.png";
menuIcon.src = "/assets/images/hamburger-menu-close-D67DB3.png";
}
// Fade icon back in
menuIcon.style.opacity = 1;
Expand Down
28 changes: 28 additions & 0 deletions assets/js/news-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
fetch('../assets/data/news.json')
.then(response => response.json())
.then(newsItems => {
const newsSection = document.getElementById('news-section');

// clears existing content in the news section
newsSection.innerHTML = '';

newsItems.forEach(item => {
const newsItem = document.createElement('div');
newsItem.className = 'news-item';

let newsContent = `<h3>${item.title}</h3>`;
if (item.image) {
newsContent += `<img src="${item.image}" alt="${item.title}" style="width:100%;max-width:600px;height:auto;">`;
}
newsContent += `<p>${item.date}</p><p>${item.content}</p>`;
if (item.link) {
newsContent += `<a href="${item.link}">Read More</a>`;
}

newsItem.innerHTML = newsContent;
newsSection.appendChild(newsItem);
});
})
.catch(error => {
console.error('Error fetching news:', error);
});
4 changes: 2 additions & 2 deletions assets/js/toggle-bio.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ function toggleBio() {

if (moreText.classList.contains("show")) {
moreText.classList.remove("show");
setTimeout(() => { moreText.style.display = "none"; }, 500); // Ensure display:none is applied after the transition
setTimeout(() => { moreText.style.display = "none"; }, 500); // ensures display:none is applied after the transition
readMoreBtn.innerHTML = "read more";
} else {
moreText.style.display = "block";
setTimeout(() => { moreText.classList.add("show"); }, 10); // Slight delay to ensure display:block is applied before adding opacity
setTimeout(() => { moreText.classList.add("show"); }, 10); // slight delay to ensure display:block is applied before adding opacity
readMoreBtn.innerHTML = "read less";
}
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>szch.me</title>
<title>the home to szch.me</title>
<link rel="icon" type="image/x-icon" href="assets/images/favicon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
Expand Down
51 changes: 51 additions & 0 deletions news/news.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>szch.me news</title>
<link rel="icon" type="image/x-icon" href="../assets/images/favicon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fragment+Mono:ital@0;1&family=Bricolage+Grotesque:opsz,[email protected],200..800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div id="pageOverlay" class="overlay" onclick="toggleMenu()"></div>
<header>
<div class="scrolling_text">
<div class="text">
<span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span>
</div>
<div class="text">
<span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span>
</div>
</div>
<div class="menu-icon" onclick="toggleMenu()">
<img src="../assets/images/hamburger-menu-open.png" alt="Menu open" id="menuIcon">
</div>
<div class="menu-content" id="menuContent">
<span class="close-menu" onclick="toggleMenu()">
<img src="../assets/images/hamburger-menu-close-D67DB3.png" alt="Menu close" style="display:none;" id="closeIcon">
</span>
<ul>
<li><a href="../index.html">take me home</a></li>
<li><a href="./news.html">news</a></li>
<li><a href="../music/music.html">music</a></li>
<li><a href="../visuals/visuals.html">visuals</a></li>
</ul>
</div>
</header>
<main>
<section id="news-section" class="news-container">
<h2 class="display-font">the news</h2>
<!-- news items will be dynamically inserted here from the news.js script and json -->
</section>
</main>
<footer>
<p class="fragment-mono-regular">&copy; 2024 SZCH. All rights reserved.</p>
</footer>
<script src="../assets/js/menu-toggle.js"></script>
<script src="../assets/js/news-script.js"></script>
</body>
</html>

0 comments on commit e108547

Please sign in to comment.