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
Loading…
Add table
Add a link
Reference in a new issue