Skip to content

Commit

Permalink
Update carousel component
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszDziezykNetcentric committed Jul 15, 2024
1 parent 24fb0fd commit c4df21a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 272 deletions.
220 changes: 89 additions & 131 deletions blocks/carousel/carousel.css
Original file line number Diff line number Diff line change
@@ -1,170 +1,128 @@
.carousel .carousel-slides-container {
.carousel-wrapper {
position: relative;
}

.carousel .carousel-slides,
.carousel .carousel-slide-indicators {
list-style: none;
margin: 0;
padding: 0;
}

.carousel .carousel-slides {
display: flex;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;
overflow: scroll clip;
.carousel.swiper-carousel {
width: 100%;
height: 100%;
margin: 32px 0;
overflow: hidden;
}

.carousel .carousel-slides::-webkit-scrollbar {
display: none;
.carousel {
padding-bottom: 28px;
position: relative;
}

.carousel .carousel-slide {
flex: 0 0 100%;
scroll-snap-align: start;
.carousel .swiper-slide {
text-align: left;
font-size: 18px;
display: flex;
flex-direction: column;
flex-direction: row;
gap: 24px;
align-items: flex-start;
justify-content: center;
position: relative;
}

.carousel .swiper-slide img {
display: block;
width: 100%;
min-height: min(40rem, calc(100svh - var(--nav-height)));
height: 100%;
object-fit: cover;
}

.carousel .carousel-slide:has(.carousel-slide-content[data-align="center"]) {
align-items: center;
.carousel .swiper-slide:nth-child(2n + 1) > div:nth-child(1) {
width: 55.8333%;
}

.carousel .carousel-slide:has(.carousel-slide-content[data-align="right"]) {
align-items: flex-end;
.carousel .swiper-slide:nth-child(2n + 1) > div:nth-child(2) {
width: calc(100% - 55.8333%);
text-align: left;
}

.carousel .carousel-slide .carousel-slide-image picture {
position: absolute;
inset: 0;
.carousel .swiper-slide:nth-child(2n) picture {
width: 232px;
display: block;
margin-left: 50px;
}

.carousel .carousel-slide .carousel-slide-image picture > img {
height: 100%;
width: 100%;
object-fit: cover;
.carousel .swiper-slide h2 {
margin-top: 24px;
font-size: 28px;
line-height: 36px;
text-transform: uppercase;
}

.carousel .carousel-slide .carousel-slide-content {
z-index: 1;
padding: 1rem;
margin: 1.5rem 3rem;
color: white;
background-color: rgba(0 0 0 / 50%);
position: relative;
width: var(--slide-content-width, auto);
.carousel .swiper-slide p {
font-size: 16px;
line-height: 24px;
}

.carousel .carousel-slide-indicators {
.carousel .button-container .button {
margin: 0;
display: flex;
justify-content: center;
gap: 0.5rem;
gap: 8px;
align-items: center;
}

.carousel .carousel-slide-indicator button {
width: 1rem;
height: 1rem;
.carousel .button-container .button .icon {
padding: 0;
border-radius: 1rem;
background-color: rgba(0 0 0 / 25%);
}

.carousel .carousel-slide-indicator button:disabled,
.carousel .carousel-slide-indicator button:hover,
.carousel .carousel-slide-indicator button:focus-visible {
background-color: rgba(0 0 0 / 80%);
.carousel-wrapper .swiper-button-next,
.carousel-wrapper .swiper-button-prev {
right: 0;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
background-color: transparent;
color: rgb(0 0 0);
border: 1px solid rgb(0 0 0 / 0%);
width: 2.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
padding: 0;
height: 100%;
top: 0;
margin: 0;
}

.carousel .carousel-slide-indicator span,
.carousel .carousel-navigation-buttons span {
border: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap;
.carousel-wrapper .swiper-button-next {
right: -40px;
}

.carousel .carousel-navigation-buttons {
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0.5rem;
right: 0.5rem;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 1;
.carousel-wrapper .swiper-button-prev {
left: -40px;
}

/* stylelint-disable-next-line no-descending-specificity */
.carousel .carousel-navigation-buttons button {
border-radius: 8px;
margin: 0;
padding: 0;
width: 2rem;
height: 2rem;
position: relative;
background-color: rgba(0 0 0 / 25%);
.carousel-wrapper .swiper-button-next:hover,
.carousel-wrapper .swiper-button-prev:hover {
background-color: rgb(0 0 0 / 8%);
}

.carousel .carousel-navigation-buttons button:hover,
.carousel .carousel-navigation-buttons button:focus-visible {
background-color: rgba(0 0 0 / 80%);
.carousel-wrapper .carousel .swiper-pagination {
top: unset;
left: 50%;
bottom: -28px;
transform: translateX(-50%);
position: relative;
width: 160px;
height: 0.5rem;
display: flex;
-webkit-box-align: center;
align-items: center;
background-color: rgb(0 0 0 / 12%);
border-radius: 6px;
}

.carousel .carousel-navigation-buttons button::after {
display: block;
content: "";
border: 3px white solid;
border-bottom: 0;
border-left: 0;
height: 0.75rem;
width: 0.75rem;
position: absolute;
top: 50%;
left: calc(50% + 3px);
transform: translate(-50%, -50%) rotate(-135deg);
}

.carousel .carousel-navigation-buttons button.slide-next::after {
transform: translate(-50%, -50%) rotate(45deg);
left: calc(50% - 3px);
}

@media (width >= 600px) {
.carousel .carousel-navigation-buttons {
left: 1rem;
right: 1rem;
}

.carousel .carousel-navigation-buttons button {
width: 3rem;
height: 3rem;
}

.carousel .carousel-navigation-buttons button::after {
width: 1rem;
height: 1rem;
}

.carousel .carousel-slide .carousel-slide-content {
--slide-content-width: 50%;

margin: 2.5rem 5rem;
}

.carousel .carousel-slide .carousel-slide-content[data-align="justify"] {
--slide-content-width: auto;
}
.carousel-wrapper .carousel .swiper-pagination-progressbar-fill {
transform: translate3d(0, 0, 0) scaleX(0.2) scaleY(1);
transition-duration: 300ms;
min-width: 6px;
height: 6px;
background: rgb(0 0 0);
border: 0;
border-radius: 6px;
cursor: pointer;
appearance: none;
}
Loading

0 comments on commit c4df21a

Please sign in to comment.