Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!--Верстать тут-->
<script src="index.js"></script>

<button id="openModal">Открыть модальное окно</button>

<div class="overlay" id="overlay">
<div class="modal">
<button class="close" id="closeModal">&times;</button>
<h2>Загрузка</h2>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
<div class="progress-text" id="progressText">Loading...</div>
</div>

</div>
</div>

<div class='wraper'>
<div class='logo logomiky'>
<div class='gibball'></div>
<div class='leftball'></div>
<div class='rightball'></div>
</div>

<div class='logo logojapan'>
<div class='redball'></div>
<div class='redball'></div>
</div>
</div>

<script src="index.js"></script>
</body>
</html>
57 changes: 51 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
/*
Изменить элементу цвет и ширину можно вот так:
const openBtn = document.querySelector('#openModal');
const closeBtn = document.querySelector('#closeModal');
const overlay = document.querySelector('#overlay');

const element = document.querySelector('.myElement');
element.style.color = 'red';
element.style.width = '300px';
*/
const progressBar = document.querySelector('#progressBar');
const progressText = document.querySelector('#progressText');

let progress = 0;
let interval;

function startProgress() {
progress = 0;
progressBar.style.width = '0%';

const duration = 3000;
const fps = 60;
const intervalTime = 1000 / fps;
const step = 100 / (duration / intervalTime);

interval = setInterval(() => {
progress += step;

if (progress >= 100) {
progress = 100;
clearInterval(interval);
}
progressBar.style.width = progress + '%';
if (progress > 50) {
progressText.style.color = 'white';
} else {
progressText.style.color = 'black';
}

}, intervalTime);
}

openBtn.addEventListener('click', () => {
overlay.style.display = 'flex';
startProgress();
});

closeBtn.addEventListener('click', () => {
overlay.style.display = 'none';
clearInterval(interval);
});

overlay.addEventListener('click', (e) => {
if (e.target === overlay) {
overlay.style.display = 'none';
clearInterval(interval);
}
});
133 changes: 133 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
body {
margin: 0;
padding: 20px;
background-color: darkgrey;
}

#openModal {
margin-bottom: 20px;
padding: 10px 15px;
font-size: 16px;
cursor: pointer;
}

.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: none;
justify-content: center;
align-items: center;
}

.modal {
width: 640px;
max-width: 90%;
background: white;
padding: 20px;
border-radius: 8px;
position: relative;
}

.close {
position: absolute;
top: 10px;
right: 10px;

background: none;
border: none;
font-size: 24px;
cursor: pointer;
}

.progress {
position: relative;
width: 100%;
height: 40px;
background: #ccc;
border-radius: 6px;
overflow: hidden;
margin-top: 20px;
}

.progress-bar {
height: 100%;
width: 0%;
background: red;
transition: width 0.03s linear;
}

.progress-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

font-weight: bold;
color: black;
pointer-events: none;
}

.wraper {
display: flex;
gap: 20px;
}

.logo {
width: 100px;
height: 100px;
position: relative;
overflow: hidden;
}

.logomiky .gibball {
width: 60px;
height: 60px;
background: black;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -20%);
}

.logomiky .leftball {
width: 31px;
height: 31px;
background: black;
border-radius: 50%;
position: absolute;
top: 18px;
left: 10px;
}

.logomiky .rightball {
width: 31px;
height: 31px;
background: black;
border-radius: 50%;
position: absolute;
top: 18px;
right: 10px;
}

.logojapan {
background: white;
display: flex;
justify-content: center;
align-items: center;
}

.logojapan .redball {
width: 50px;
height: 50px;
background: red;
border-radius: 50%;
}

.logojapan .redball:last-child {
display: none;
}