feat: implement functional slider with Swiper.js
- Add Swiper.js via CDN for carousel functionality - Restructure excerpts section: 6 individual slides instead of 2 grouped slides - Implement responsive behavior: 3 slides per view on desktop, 1 on mobile - Add infinite loop navigation with prev/next buttons and pagination bullets - Create custom styles in _section_4-excerpts.scss (no Swiper CSS) - Add script.js with Swiper configuration and responsive breakpoints Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
96c52e7e96
commit
3dc3a8c6e3
5 changed files with 323 additions and 79 deletions
|
|
@ -10,6 +10,7 @@ section#excerpts {
|
|||
text-align: center;
|
||||
width: min(80%, 41.875rem);
|
||||
margin-bottom: 3rem;
|
||||
|
||||
.label {
|
||||
font-weight: 400;
|
||||
font-size: var(--font-size-s);
|
||||
|
|
@ -22,44 +23,135 @@ section#excerpts {
|
|||
}
|
||||
}
|
||||
|
||||
.slider {
|
||||
// Swiper container (styles de base requis par Swiper.js)
|
||||
.swiper {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
padding-bottom: 5rem; // Espace pour pagination
|
||||
overflow: hidden; // REQUIS : cache les slides hors viewport
|
||||
}
|
||||
|
||||
.swiper-wrapper {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
position: relative; // REQUIS pour les transforms
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
transition-property: transform; // REQUIS pour les animations
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.slide {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
.swiper-slide {
|
||||
flex-shrink: 0; // REQUIS : empêche la compression des slides
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
|
||||
.item {
|
||||
width: 13.125rem;
|
||||
.label {
|
||||
@include label-spaced;
|
||||
}
|
||||
.text {
|
||||
font-size: var(--font-size-m);
|
||||
line-height: 140%;
|
||||
margin-bottom: 8rem;
|
||||
}
|
||||
.item {
|
||||
width: 13.125rem;
|
||||
|
||||
.label {
|
||||
@include label-spaced;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: var(--font-size-m);
|
||||
line-height: 140%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.controls {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
// Navigation buttons (prev/next arrows)
|
||||
.swiper-button-prev,
|
||||
.swiper-button-next {
|
||||
z-index: 1;
|
||||
bottom: 0;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
position: absolute;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
|
||||
.bullets {
|
||||
display: flex;
|
||||
.bullet {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: 100%;
|
||||
background-color: #fff;
|
||||
margin: 0.2rem;
|
||||
&::after {
|
||||
display: none; // Cache les flèches par défaut de Swiper
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-button-prev {
|
||||
background-image: url('/assets/svg/arrow-left.svg');
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.swiper-button-next {
|
||||
background-image: url('/assets/svg/arrow-right.svg');
|
||||
right: 0;
|
||||
}
|
||||
|
||||
// Pagination (bullets)
|
||||
.swiper-pagination {
|
||||
bottom: 0.5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.swiper-pagination-bullet {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: 100%;
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
opacity: 1;
|
||||
transition: background-color 250ms ease, transform 250ms ease;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
padding: 0;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-pagination-bullet-active {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
// Mobile responsive
|
||||
@media (max-width: 768px) {
|
||||
padding: 4rem 2rem;
|
||||
|
||||
header {
|
||||
margin-bottom: 2rem;
|
||||
|
||||
.title {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-slide {
|
||||
.item {
|
||||
width: 100%;
|
||||
max-width: 20rem;
|
||||
text-align: center;
|
||||
|
||||
.text {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-button-prev,
|
||||
.swiper-button-next {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,45 +328,118 @@ section#excerpts header .title {
|
|||
font-weight: 700;
|
||||
letter-spacing: 5%;
|
||||
}
|
||||
section#excerpts .slider {
|
||||
section#excerpts .swiper {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
position: relative;
|
||||
padding-bottom: 5rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
section#excerpts .slider .slide {
|
||||
width: 100%;
|
||||
section#excerpts .swiper-wrapper {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
transition-property: transform;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
section#excerpts .slider .slide .item {
|
||||
section#excerpts .swiper-slide {
|
||||
flex-shrink: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}
|
||||
section#excerpts .swiper-slide .item {
|
||||
width: 13.125rem;
|
||||
}
|
||||
section#excerpts .slider .slide .item .label {
|
||||
section#excerpts .swiper-slide .item .label {
|
||||
font-size: 0.625rem;
|
||||
text-transform: uppercase;
|
||||
font-weight: 400;
|
||||
opacity: 0.8;
|
||||
margin-bottom: 0.7rem;
|
||||
}
|
||||
section#excerpts .slider .slide .item .text {
|
||||
section#excerpts .swiper-slide .item .text {
|
||||
font-size: var(--font-size-m);
|
||||
line-height: 140%;
|
||||
margin-bottom: 8rem;
|
||||
}
|
||||
section#excerpts .controls {
|
||||
section#excerpts .swiper-button-prev,
|
||||
section#excerpts .swiper-button-next {
|
||||
z-index: 1;
|
||||
bottom: 0;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
position: absolute;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
section#excerpts .swiper-button-prev::after,
|
||||
section#excerpts .swiper-button-next::after {
|
||||
display: none;
|
||||
}
|
||||
section#excerpts .swiper-button-prev {
|
||||
background-image: url("/assets/svg/arrow-left.svg");
|
||||
left: 0;
|
||||
}
|
||||
section#excerpts .swiper-button-next {
|
||||
background-image: url("/assets/svg/arrow-right.svg");
|
||||
right: 0;
|
||||
}
|
||||
section#excerpts .swiper-pagination {
|
||||
bottom: 0.5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
section#excerpts .controls .bullets {
|
||||
display: flex;
|
||||
}
|
||||
section#excerpts .controls .bullets .bullet {
|
||||
section#excerpts .swiper-pagination-bullet {
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: 100%;
|
||||
background-color: rgba(255, 255, 255, 0.4);
|
||||
opacity: 1;
|
||||
transition: background-color 250ms ease, transform 250ms ease;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
section#excerpts .swiper-pagination-bullet:hover {
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
section#excerpts .swiper-pagination-bullet-active {
|
||||
background-color: #fff;
|
||||
margin: 0.2rem;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
section#excerpts {
|
||||
padding: 4rem 2rem;
|
||||
}
|
||||
section#excerpts header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
section#excerpts header .title {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
section#excerpts .swiper-slide .item {
|
||||
width: 100%;
|
||||
max-width: 20rem;
|
||||
text-align: center;
|
||||
}
|
||||
section#excerpts .swiper-slide .item .text {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
section#excerpts .swiper-button-prev,
|
||||
section#excerpts .swiper-button-next {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
section#handles {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
44
assets/js/script.js
Normal file
44
assets/js/script.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const excerptSwiper = new Swiper('.excerpts-swiper', {
|
||||
// Slides visibles et groupement
|
||||
slidesPerView: 3,
|
||||
slidesPerGroup: 3,
|
||||
spaceBetween: 30,
|
||||
|
||||
// Infinite loop
|
||||
loop: true,
|
||||
|
||||
// Navigation arrows
|
||||
navigation: {
|
||||
nextEl: '.swiper-button-next',
|
||||
prevEl: '.swiper-button-prev',
|
||||
},
|
||||
|
||||
// Pagination bullets
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true,
|
||||
dynamicBullets: false,
|
||||
},
|
||||
|
||||
// Transitions
|
||||
speed: 400,
|
||||
effect: 'slide',
|
||||
|
||||
// Responsive breakpoints
|
||||
breakpoints: {
|
||||
// Mobile : <= 768px
|
||||
0: {
|
||||
slidesPerView: 1,
|
||||
slidesPerGroup: 1,
|
||||
spaceBetween: 20,
|
||||
},
|
||||
// Desktop : > 768px
|
||||
769: {
|
||||
slidesPerView: 3,
|
||||
slidesPerGroup: 3,
|
||||
spaceBetween: 30,
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
101
index.html
101
index.html
|
|
@ -138,43 +138,76 @@
|
|||
Le réel traversé appelle un mot pour ne pas mourir
|
||||
</h3>
|
||||
</header>
|
||||
<div class="slider">
|
||||
<div class="slide">
|
||||
<div class="item">
|
||||
<p class="label">Prologue</p>
|
||||
<p class="text">
|
||||
Le réel est un seuil.<br />
|
||||
On entre, ou pas.
|
||||
</p>
|
||||
<div class="swiper excerpts-swiper">
|
||||
<div class="swiper-wrapper">
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">Prologue</p>
|
||||
<p class="text">
|
||||
Le réel est un seuil.<br />
|
||||
On entre, ou pas.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<p class="label">La peur</p>
|
||||
<p class="text">
|
||||
Le réel est là, à portée de main. La peur est son odeur.
|
||||
</p>
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">La peur</p>
|
||||
<p class="text">
|
||||
Le réel est là, à portée de main. La peur est son odeur.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<p class="label">L'apprentissage</p>
|
||||
<p class="text">
|
||||
On ne devient pas Einstein en le lisant, ni Picasso en le
|
||||
regardant.<br />
|
||||
<br />
|
||||
Ça sauve presque.
|
||||
</p>
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">L'apprentissage</p>
|
||||
<p class="text">
|
||||
On ne devient pas Einstein en le lisant, ni Picasso en le
|
||||
regardant.<br />
|
||||
<br />
|
||||
Ça sauve presque.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">Le temps</p>
|
||||
<p class="text">
|
||||
Les dernières secondes<br />
|
||||
ne sont pas du rebut.<br />
|
||||
<br />
|
||||
Elles ramassent tout.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">La dépression</p>
|
||||
<p class="text">
|
||||
La dépression est un effondrement de la traversabilité.<br />
|
||||
<br />
|
||||
C'est une plante qui ne meurt pas sur n'importe quel sol.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="swiper-slide">
|
||||
<div class="item">
|
||||
<p class="label">Le tissu du monde</p>
|
||||
<p class="text">
|
||||
Un seul amour,<br />
|
||||
pleinement porté,<br />
|
||||
suffit à ce que la<br />
|
||||
totalité ne chute pas.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<button class="prev">
|
||||
<img src="/assets/svg/arrow-left.svg" alt="flèche précédente" />
|
||||
</button>
|
||||
<ul class="bullets">
|
||||
<li><button class="bullet"></button></li>
|
||||
<li><button class="bullet"></button></li>
|
||||
</ul>
|
||||
<button class="next">
|
||||
<img src="/assets/svg/arrow-right.svg" alt="flèche suivante" />
|
||||
</button>
|
||||
|
||||
<!-- Navigation arrows -->
|
||||
<div class="swiper-button-prev"></div>
|
||||
<div class="swiper-button-next"></div>
|
||||
|
||||
<!-- Pagination bullets -->
|
||||
<div class="swiper-pagination"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -438,5 +471,7 @@
|
|||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
|
||||
<script src="/assets/js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue