Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Добавляет рецепт слайдера #5364

Merged
merged 37 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1c4c0e1
Добавляет рецепт слайдера,исправленный
AnnaBaraulina Jun 4, 2024
dd87cf8
Update recipes/slider/demos/slider-demo/index.html
AnnaBaraulina Jun 7, 2024
025fd85
Update recipes/slider/demos/slider-demo/index.html
AnnaBaraulina Jun 7, 2024
fd2ec69
Update recipes/slider/demos/slider-demo/index.html
AnnaBaraulina Jun 7, 2024
b48795e
Update recipes/slider/demos/slider-demo/index.html
AnnaBaraulina Jun 7, 2024
7c8d6b9
добавляет размеры слайдов, убирает rotate
AnnaBaraulina Jun 7, 2024
d6775f3
добавляет коммит после всех исправлений и разрешения конфликта изменений
AnnaBaraulina Jun 7, 2024
7f7d6a9
Первый заход с редактированием
TatianaFokina Jun 7, 2024
f735e0c
Форматирует демку
TatianaFokina Jun 7, 2024
c9ea6f3
Я сказала ФОРМАТИРУЕТ демку
TatianaFokina Jun 7, 2024
306c970
Форматирует пример кода
TatianaFokina Jun 7, 2024
41312e4
Чинит разметку
skorobaeus Jun 10, 2024
e24dbd8
Сжимает картинки
skorobaeus Jun 10, 2024
ccbcb8c
Твикает стили
skorobaeus Jun 10, 2024
e88bbfd
Приносит исправленную демку
TatianaFokina Jun 24, 2024
fd7bf3d
Находит упущенное
TatianaFokina Jun 24, 2024
ca9a73b
Добавляет описание картинок, выносит const
TatianaFokina Jul 4, 2024
6da6215
Начинает актуализировать примеры
TatianaFokina Jul 4, 2024
c79e919
Продолжает актуализировать примеры
TatianaFokina Jul 4, 2024
aae936b
Доредачивает вступление, HTML и семантику
TatianaFokina Jul 5, 2024
4082821
Удаляет пробел в конце строки
TatianaFokina Jul 5, 2024
d7620e2
Чинит
TatianaFokina Jul 5, 2024
6cd6dc9
Принимает правки от Алёны
TatianaFokina Jul 8, 2024
1e72c9f
Вносит новые правки в текст
TatianaFokina Jul 8, 2024
3ed92bc
Добавляет тип к кнопкам в демке
TatianaFokina Jul 8, 2024
e235768
Обновляет индекс раздела
TatianaFokina Jul 8, 2024
82b356c
Форматирует JS в демке
TatianaFokina Jul 8, 2024
b45d682
Удаляет лишние пробелы
TatianaFokina Jul 8, 2024
0fb4eff
Форматирует JS в тексте
TatianaFokina Jul 8, 2024
dd27f15
меняет стили на логические
AnnaBaraulina Jul 14, 2024
4583cc1
Актуализирует примеры в тексте
TatianaFokina Jul 16, 2024
b75a38c
Принимает правки от Алёны
TatianaFokina Jul 22, 2024
0c7490c
Убирает ненужное `user-select`
TatianaFokina Jul 22, 2024
cf3a897
Убирает `user-select` из примера
TatianaFokina Jul 22, 2024
c758985
Merge branch 'main' into recipes-slider
TatianaFokina Jul 22, 2024
6c8eaff
Избавляется от мигания
TatianaFokina Jul 22, 2024
2384f52
Актуализирует примеры
TatianaFokina Jul 22, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions recipes/slider/demos/slider-demo/images/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
216 changes: 216 additions & 0 deletions recipes/slider/demos/slider-demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
<!DOCTYPE html>
<html lang="ru">

<head>
<title>Пример слайдера — Слайдер — Дока</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&display=swap">
<style>
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html {
color-scheme: dark;
}

body {
min-height: 100vh;
padding: 50px;
display: flex;
align-items: center;
justify-content: center;
background-color: #18191C;
color: #FFFFFF;
font-family: "Roboto", sans-serif;
}

h3 {
margin: 15px auto 25px;
font-size: 24px;
line-height: 26px;

}

@media (max-width: 768px) {
body {
padding: 30px;
}
}

.button_type_radio {
background-color: transparent;
margin: 0;
padding: 0;
width: 15px;
height: 15px;
border-radius: 50%;
border: 1px solid #FFFFFF;
margin-right: 12px;
}

.button_type_radio.active {
background-color: #C56FFF;
}

.prev-button,
.next-button {
position: absolute;
top: 65%;
transform: translateY(-50%);
background: transparent;
border: none;
cursor: pointer;
width: 40px;
height: auto;
}

.prev-button {
left: -40px;
transform: rotate(45deg);
transform-origin: center;
}

.next-button {
right: -40px;
transform: rotate(-45deg);
transform-origin: center;

}

.slideImg {
width: 450px;
height: 225px;
object-fit: cover;
}

.slider {
display: flex;
flex-direction: column;
align-items: center;
max-width: 450px;
width: 100%;
position: relative;
}

.slide {
text-align: center;
width: 100%;
}

[aria-label="Design patterns"]:focus {
outline: 2px solid #C56FFF;
outline-offset: 6px;
}
</style>
</head>

<body>
<div class="slider" tabindex="0" role="region" aria-roledescription="Content Slider" aria-label="Design patterns">
<div class="controls" role="group" aria-label="Slide controls">
<button class="button button_type_radio" tabindex="0" aria-disabled="true" aria-label="show slide 1 of 4">
</button>
<button class="button button_type_radio" tabindex="0" aria-disabled="false" aria-label="show slide 2 of 4">
</button>
<button class="button button_type_radio" tabindex="0" aria-disabled="false" aria-label="show slide 3 of 4">
</button>
<button class="button button_type_radio" tabindex="0" aria-disabled="false" aria-label="show slide 4 of 4">
</button>
<button aria-label="show previous slide" class="button prev-button">
<img class="prev-button" src="./images/arrow-down.svg">
</button>
<button aria-label="show next slide" class="button next-button">
<img class="next-button" src="./images/arrow-down.svg">
</button>
</div>
<div class='slide' role="group" aria-roledescription="Slide" aria-labelledby="First design pattern"
id="carousel-item-1">
<h3 id="carousel-item-1__heading">Паттерн "Лето"</h3>
<h3 id="carousel-item-1__heading">Паттерн «Лето»</h3>
<img class="slideImg" src="./images/IMG_1945.JPG">
</div>
<div class='slide' hidden role="group" aria-roledescription="Slide" aria-labelledby="Second design pattern"
id="carousel-item-2">
<h3 id="carousel-item-2__heading">Паттерн "Цветочное поле"</h3>
<h3 id="carousel-item-2__heading">Паттерн «Цветочное поле»</h3>
<img class="slideImg" src="./images/IMG_1946.JPG">
</div>
<div class='slide' hidden role="group" aria-roledescription="Slide" aria-labelledby="Third design pattern"
id="carousel-item-3">
<h3 id="carousel-item-3__heading">"Паттерн Лиловый"
</h3>
<h3 id="carousel-item-3__heading">Паттерн «Лиловый»</h3>
<img class="slideImg" src="./images/IMG_1947.JPG">
TatianaFokina marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div class='slide' hidden role="group" aria-roledescription="Slide" aria-labelledby="Third design pattern"
id="carousel-item-4">
<h3 id="Fourth design pattern">"Паттерн Алый"</h3>
id="carousel-item-3">
<h3 id="Fourth design pattern">Паттерн «Алый»</h3>
<img class="slideImg" src="./images/IMG_1948.JPG">
</div>
</div>
</main>
skorobaeus marked this conversation as resolved.
Show resolved Hide resolved
<script>
document.addEventListener("DOMContentLoaded", function () {
const slider = document.querySelector('.slider');
const slides = slider.querySelectorAll('.slide');
const controlButtons = document.querySelectorAll('.button');
let currentSlide = 0;

function updateSlider() {
slides.forEach(slide => slide.hidden = true);
controlButtons.forEach(btn => btn.setAttribute('aria-disabled', false));

slides[currentSlide].hidden = false;

controlButtons[currentSlide].setAttribute('aria-disabled', true)

slider.querySelectorAll('.button_type_radio').forEach((controller, index) => {
if (index === currentSlide) {
controller.classList.add('active');
} else {
controller.classList.remove('active');
}
});
controlButtons[controlButtons.length - 2].setAttribute('aria-disabled', currentSlide === 0 ? "true" : "false");
controlButtons[controlButtons.length - 1].setAttribute('aria-disabled', currentSlide === slides.length - 1 ? "true" : "false");
}
controlButtons.forEach((button, index) => {
button.addEventListener('click', () => {
if (index < slides.length) {
currentSlide = index;
updateSlider();
} else {
if (button.getAttribute('aria-label') === "show previous slide" && currentSlide > 0) {
currentSlide--;
} else if (button.getAttribute('aria-label') === "show next slide" && currentSlide < slides.length - 1) {
currentSlide++;
}
updateSlider();
}
});
});
document.addEventListener('keydown', function (event) {
if (event.key === 'ArrowLeft' && currentSlide > 0) {
currentSlide--;
updateSlider();
} else if (event.key === 'ArrowRight' && currentSlide < slides.length - 1) {
currentSlide++;
updateSlider();
}
});

updateSlider();
});
</script>
</body>

</html>
Loading
Loading