Skip to content

Commit 62958a8

Browse files
content preloader
1 parent be700fd commit 62958a8

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

content_loader/image.jpg

44.2 KB
Loading

content_loader/index.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Content Placeholder</title>
8+
<link rel="stylesheet" href="./style.css" />
9+
</head>
10+
<body>
11+
<div class="card">
12+
<div class="card-header animated-bg" id="header">&nbsp;</div>
13+
<div class="card-content">
14+
<h3 class="card-title animated-bg animated-bg-text" id="title">
15+
&nbsp;
16+
</h3>
17+
<p class="card-description" id="description">
18+
&nbsp;
19+
<span class="animated-bg animated-bg-text"></span
20+
><span class="animated-bg animated-bg-text"></span
21+
><span class="animated-bg animated-bg-text"></span>
22+
</p>
23+
<div class="author">
24+
<div class="profile-img animated-bg" id="profile_img">&nbsp;</div>
25+
<div class="author-info">
26+
<strong class="animated-bg animated-bg-text" id="name">
27+
&nbsp;</strong
28+
>
29+
<small class="animated-bg animated-bg-text" id="date">
30+
&nbsp;
31+
</small>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
<script src="./script.js"></script>
37+
</body>
38+
</html>

content_loader/script.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const header = document.getElementById('header')
2+
const title = document.getElementById('title')
3+
const description = document.getElementById('description')
4+
const profile_img = document.getElementById('profile_img')
5+
const name = document.getElementById('name')
6+
const date = document.getElementById('date')
7+
8+
const animated_bgs = document.querySelectorAll('.animated-bg')
9+
const animated_bg_texts = document.querySelectorAll('.animated-bg-text')
10+
11+
12+
setTimeout(getData, 2500)
13+
14+
15+
function getData() {
16+
header.innerHTML = ' <img src="./image.jpg" alt="background" />'
17+
18+
title.innerHTML = 'Among Us'
19+
description.innerHTML = 'A very popular game in 2020, where there is an murderer impostor among the crew mates boarded on a space shuttle.'
20+
profile_img.innerHTML = '<img src="https://randomuser.me/api/portraits/men/45.jpg" alt="#" />'
21+
name.innerHTML = 'Ram Purohit'
22+
date.innerHTML = 'Jan 12, 2021'
23+
24+
animated_bgs.forEach(bg => bg.classList.remove('animated-bg'))
25+
animated_bg_texts.forEach(bg => bg.classList.remove('animated-bg-text'))
26+
27+
}
28+

content_loader/style.css

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");
2+
3+
* {
4+
box-sizing: border-box;
5+
}
6+
body {
7+
font-family: "Roboto", sans-serif;
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
justify-content: center;
12+
height: 100vh;
13+
overflow: hidden;
14+
background-color: #ecf0f1;
15+
margin: 0;
16+
}
17+
img {
18+
max-width: 100%;
19+
}
20+
21+
.card {
22+
box-shadow: 0 20px 10px rgba(0, 0, 0, 0.2);
23+
border-radius: 10px;
24+
overflow: hidden;
25+
width: 350px;
26+
}
27+
28+
.card-header {
29+
height: 200px;
30+
}
31+
.card-header img {
32+
object-fit: cover;
33+
height: 100%;
34+
width: 100%;
35+
}
36+
37+
.card-content {
38+
background-color: #fff;
39+
padding: 30px;
40+
}
41+
.card-title {
42+
height: 20px;
43+
margin: 0;
44+
}
45+
46+
.card-description {
47+
color: #777;
48+
margin: 10px 0 20px;
49+
}
50+
51+
.author {
52+
display: flex;
53+
}
54+
.profile-img {
55+
border-radius: 50%;
56+
overflow: hidden;
57+
height: 40px;
58+
width: 40px;
59+
}
60+
61+
.author-info {
62+
display: flex;
63+
flex-direction: column;
64+
justify-content: center;
65+
margin-left: 10px;
66+
width: 100px;
67+
}
68+
69+
.author-info small {
70+
color: #aaa;
71+
margin-top: 5px;
72+
}
73+
74+
/** The Animations for loading **/
75+
76+
.animated-bg {
77+
background-image: linear-gradient(
78+
to right,
79+
#f6f7f8 0%,
80+
#edeef1 10%,
81+
#f6f7f8 20%,
82+
#f6f7f8 100%
83+
);
84+
background-size: 200% 100%;
85+
animation: bgPos 1s linear infinite;
86+
}
87+
88+
.animated-bg-text {
89+
display: inline-block;
90+
margin: 0;
91+
height: 12px;
92+
width: 100%;
93+
}
94+
95+
@keyframes bgPos {
96+
0% {
97+
background-position: 50% 0;
98+
}
99+
100% {
100+
background-position: -150% 0;
101+
}
102+
}

0 commit comments

Comments
 (0)