forked from gabischool/Week6_JS_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
103 lines (92 loc) · 4.33 KB
/
index.html
File metadata and controls
103 lines (92 loc) · 4.33 KB
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
<!-- DO NOT CHANGE THE HTML -->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gabi News - Latest Technology Updates</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<header class="header">
<div class="header-content">
<div class="header-top">
<div class="header-top-content">
<div class="header-left">
<img src="https://plus.gabischool.com/assets/uploads/gabinews.png" alt="Gabi News Logo" class="logo">
<div class="header-text">
<p>Your Source for the Latest Technology Updates</p>
</div>
</div>
</div>
</div>
<nav class="main-nav">
<div class="nav-links">
<a href="#" data-category="Latest News" class="active">Latest News</a>
<a href="#" data-category="Technology">Technology</a>
<a href="#" data-category="AI & ML">AI & ML</a>
<a href="#" data-category="Web Development">Web Development</a>
<a href="#" data-category="Cyber Security">Cyber Security</a>
</div>
</nav>
</div>
</header>
<!-- News Container -->
<div id="news-container" class="news-container">
<!-- Featured Article -->
<div class="news-grid"></div>
<script type="module">
import { newsData, displayArticles } from './dom_challenges.js';
const newsGrid = document.querySelector('.news-grid');
// Update grid when category changes
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
const category = link.dataset.category;
// Update active state
document.querySelectorAll('.nav-links a').forEach(l => l.classList.remove('active'));
link.classList.add('active');
// Update featured article and grid
displayArticles(category);
// Update grid
const articles = newsData[category].slice(1);
newsGrid.innerHTML = '';
articles.forEach(article => {
newsGrid.innerHTML += `
<article class="news-card">
<img class="news-image" src="${article.image}" alt="${article.title}">
<div class="news-content">
<h2 class="news-title">${article.title}</h2>
<div class="news-date">${article.date}</div>
<p class="news-excerpt">${article.excerpt}</p>
<span class="tag">${article.tag}</span>
</div>
</article>
`;
});
});
});
</script>
</div>
<!-- Initial Articles -->
<div class="news-grid">
<article class="news-card">
<img class="news-image" src="https://images.unsplash.com/photo-1541185933-ef5d8ed016c2" alt="SpaceX Successfully Launches New Satellite Constellation">
<div class="news-content">
<h2 class="news-title">SpaceX Successfully Launches New Satellite Constellation</h2>
<div class="news-date">March 13, 2024</div>
<p class="news-excerpt">Starship completes its most ambitious mission yet, deploying 50 satellites in a single launch and advancing global internet coverage goals.</p>
<span class="tag">Space Tech</span>
</div>
</article>
<article class="news-card">
<img class="news-image" src="https://images.unsplash.com/photo-1592478411213-6153e4ebc07d" alt="Apple Unveils Revolutionary Mixed Reality Device">
<div class="news-content">
<h2 class="news-title">Apple Unveils Revolutionary Mixed Reality Device</h2>
<div class="news-date">March 12, 2024</div>
<p class="news-excerpt">The tech giant's latest hardware release promises to transform how we interact with digital content through advanced spatial computing.</p>
<span class="tag">Hardware</span>
</div>
</article>
</div>
</body>
</html>