-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (68 loc) · 2.69 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Skeleton Loader width CSS</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- reference: https://www.freecodecamp.org/news/how-to-build-skeleton-screens-using-css-for-better-user-experience -->
<div class="container">
<div class="card_list">
<template id="card-template">
<a class="card" id="card-link">
<div class="card_header">
<div class="card_header_thumb">
<img class="card_header_img skeleton" id="logo-img" alt="">
</div>
<h3 class="card_title" id="card-title">
<div class="skeleton skeleton_text"></div>
<div class="skeleton skeleton_text"></div>
</h3>
</div>
<div class="card_body">
<div class="card_content" id="card-details">
<div class="skeleton skeleton_text skeleton_text_body"></div>
</div>
<div class="card_content_thumb">
<img class="skeleton" id="cover-img" alt="">
</div>
</div>
<div class="card_footer" id="card-footer">
<div class="skeleton skeleton_text skeleton_footer"></div>
</div>
</a>
</template>
</div>
</div>
<!-- Install ION ICONS via CDN -->
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<script>
const cardList = document.querySelector(".card_list");
const cardTemplate = document.getElementById("card-template");
for (let i = 0; i < 10; i++) {
cardList.append(cardTemplate.content.cloneNode(true));
}
fetch("./data.json")
.then((response) => response.json())
.then((posts) => {
cardList.innerHTML = "";
posts.forEach(post => {
const div = cardTemplate.content.cloneNode(true);
div.getElementById("card-link").href = post.link;
div.getElementById("logo-img").src = post.logoImage;
div.getElementById("card-title").textContent = post.title;
div.getElementById("card-details").textContent = post.details;
div.getElementById("cover-img").src = post.coverImage;
div.getElementById("card-footer").innerHTML = `<ion-icon name="arrow-up"></ion-icon>
<ion-icon name="chatbox-ellipses"></ion-icon>
<ion-icon name="bookmark"></ion-icon>`;
cardList.append(div);
});
})
</script>
</body>
</html>