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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 59 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,70 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Практика позиционирования</title>
<link rel="stylesheet" href="styles.css">
</head>

<body>
<!--Верстать тут-->
<div class="container">
<div class="square logo-japan">
<div class="logo-japan__circle"></div>
</div>
<div class="square windows">
<div class="windows__cube windows__cube1"></div>
<div class="windows__cube windows__cube2"></div>
<div class="windows__cube windows__cube3"></div>
<div class="windows__cube windows__cube4"></div>
</div>
</div>

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

<div class="overlay" id="overlay">
<div class="modal">
<h2>Header</h2>
<p>ловииоавиоватоитватдтдвалттлвамлтватлд мыоаозвытлзатвлдыатлдвытдатдвылдтатлдвыатлдвытлдатлд
атлдвыдтлавтлдыатлдвытлдатлдвытлдавтлыдатлвытлдатлвылтатл
атлдывтлдавытлдатлвытлавтлыдатлвылтдатлдвытлалвтыдлатдвытлажыавлта аьвыьджавджыаьдвыьдаджвы
твитлщвпитваитлшатлшлтл тлптлваитлдпптлдитлдптилдпадлитлдпалдт тлптлдватлдватлдптлдватлпдватлдптлдва</p>

<div class="load">
<span class="load-text load-text--black">Loading...</span>
<div class="redbar" id="progressBar">
<span class="load-text load-text--white">Loading...</span>
</div>
</div>

<div class = "accordion">
<div class="accordion_item">
<input type="checkbox" id="section1" class="accordion_checkbox">
<label for="section1" class="accordion_label">Section 1</label>
<div class="accordion_content">
бебебе бабаба
</div>
</div>
<div class="accordion_item">
<input type="checkbox" id="section2" class="accordion_checkbox">
<label for="section2" class="accordion_label">Section 2</label>
<div class="accordion_content">
бебебе бабаба
</div>
</div>
<div class="accordion_item">
<input type="checkbox" id="section3" class="accordion_checkbox">
<label for="section3" class="accordion_label">Section 3ч</label>
<div class="accordion_content">
бебебе бабаба
</div>
</div>
</div>
<button class="close" id="closeBtn">Close</button>
</div>
</div>

<script src="index.js"></script>
</body>

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

const element = document.querySelector('.myElement');
element.style.color = 'red';
element.style.width = '300px';
*/
function closeModal() {
overlay.classList.remove('active');
}

function openModal() {
overlay.classList.add('active');

let startTime = null;
const duration = 3000;

progressBar.style.width = '0%';

function animateProgress(timestamp) {
if (!startTime) startTime = timestamp;
let progress = (timestamp - startTime) / duration;

if (progress > 1) progress = 1;

const easedProgress = Math.sin(progress * (Math.PI / 2));

progressBar.style.width = (easedProgress * 100) + '%';

if (progress < 1) {
window.requestAnimationFrame(animateProgress);
}
}

window.requestAnimationFrame(animateProgress);
}

overlay.onclick = (e) => {
if (e.target === overlay) closeModal();
};

openBtn.onclick = () => openModal();
closeBtn.onclick = () => closeModal();

document.onkeydown = (e) => {
if (e.key === 'Escape' && overlay.classList.contains('active')) {
closeModal();
}
};
161 changes: 161 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
.square {
width: 100px;
height: 100px;
border: 1px solid #000;
box-sizing: border-box;
position: relative;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
}

.logo-japan {
height: 80px;
}

.logo-japan__circle {
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
}

.windows {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}

.windows__cube {
width: 45px;
height: 45px;
}

.windows__cube1 { background-color: orangered; }
.windows__cube2 { background-color: greenyellow; }
.windows__cube3 { background-color: skyblue; }
.windows__cube4 { background-color: yellow; }

.btn {
padding: 12px 24px;
font-size: 16px;
}

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

.overlay.active {
visibility: visible;
opacity: 1;
}

.modal {
width: 640px;
background: white;
border-radius: 4px;
position: relative;
padding: 20px;
}

.close {
padding: 12px 24px;
font-size: 16px;
background-color: #107010;
color: white;
border: none;
cursor: pointer;
}

/* СТИЛИ ПРОГРЕСС-БАРА */
.load {
width: 100%;
height: 30px;
background: gray;
border-radius: 15px;
position: relative;
overflow: hidden;
margin-bottom: 20px;
}

.load-text {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-family: Arial, sans-serif;
pointer-events: none;
}

.load-text--black {
color: black;
z-index: 1;
}

.redbar {
position: absolute;
top: 0;
left: 0;
width: 0%;
height: 100%;
background: red;
z-index: 2;
overflow: hidden;
}

.load-text--white {
color: white;
width: 640px;
}

.accordion_content {
max-height: 0;
overflow: hidden;
background: white;
border-radius: 0 0 20px 20px;
padding: 0 20px;
}

.accordion_item input:checked ~ .accordion_content {
max-height: 300px;
padding: 0 20px 6px 20px;
}

.accordion_item {
margin-bottom: 12px;
border: 1px solid #696969;
border-radius: 6px;
background: #cecece;
}

.accordion_item input {
display: none;
}

.accordion_label::before {
content: ">";
font-size: 14px;
display: inline-block;
width: 20px;
}

.accordion_item input:checked ~ .accordion_label::before {
transform: rotate(90deg);
}