mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:49:45 +00:00
Подгон слайдера под проекты
This commit is contained in:
1 parent
ec6275a4f2
commit
4591a8b77c
4 files changed
+75
-34
No files matched your search
@@ -12,7 +12,7 @@ export const useResizeObserver = ({
|
||||
parentSelector,
|
||||
childSelector = 'blockquote',
|
||||
onResize = (parent, height) => {
|
||||
parent.style.marginBottom = `calc(${height}px + 2em)`;
|
||||
parent.style.paddingBottom = `calc(${height}px + 2em)`;
|
||||
}
|
||||
}: UseResizeObserverConfig) => {
|
||||
useEffect(() => {
|
||||
|
||||
@@ -32,7 +32,7 @@ interface SliderContextType {
|
||||
export const SliderContext = createContext<SliderContextType>({
|
||||
slideNumber: 0,
|
||||
mediaList: [],
|
||||
goToSlide: () => {},
|
||||
goToSlide: () => { },
|
||||
slidesCount: 0,
|
||||
});
|
||||
|
||||
@@ -91,38 +91,40 @@ function Slider({
|
||||
return (
|
||||
<SliderContext.Provider value={contextValue}>
|
||||
<div className="slider">
|
||||
<Swiper
|
||||
modules={[Navigation, Pagination]}
|
||||
spaceBetween={20}
|
||||
slidesPerView={itemsPerSlide}
|
||||
slidesPerGroup={1}
|
||||
loop={enableButtons}
|
||||
navigation={enableButtons}
|
||||
pagination={{ clickable: enableButtons }}
|
||||
autoplay={
|
||||
autoPlay
|
||||
? { delay: autoPlayTime, disableOnInteraction: false }
|
||||
: false
|
||||
}
|
||||
onSlideChange={(swiper) => setSlideNumber(swiper.activeIndex)}
|
||||
>
|
||||
{filteredMedia.map((media) => (
|
||||
<SwiperSlide
|
||||
key={media.id}
|
||||
className={
|
||||
filteredMedia.length === 1
|
||||
? "swiper-slide single"
|
||||
: "swiper-slide"
|
||||
}
|
||||
>
|
||||
<img
|
||||
src={media.src}
|
||||
alt={`slide-${media.id}`}
|
||||
className="slide-image"
|
||||
/>
|
||||
</SwiperSlide>
|
||||
))}
|
||||
</Swiper>
|
||||
<div className="full-width-container">
|
||||
<Swiper
|
||||
modules={[Navigation, Pagination]}
|
||||
spaceBetween={20}
|
||||
slidesPerView={itemsPerSlide}
|
||||
slidesPerGroup={1}
|
||||
loop={enableButtons}
|
||||
navigation={enableButtons}
|
||||
pagination={{ clickable: enableButtons }}
|
||||
autoplay={
|
||||
autoPlay
|
||||
? { delay: autoPlayTime, disableOnInteraction: false }
|
||||
: false
|
||||
}
|
||||
onSlideChange={(swiper) => setSlideNumber(swiper.activeIndex)}
|
||||
>
|
||||
{filteredMedia.map((media) => (
|
||||
<SwiperSlide
|
||||
key={media.id}
|
||||
className={
|
||||
filteredMedia.length === 1
|
||||
? "swiper-slide single"
|
||||
: "swiper-slide"
|
||||
}
|
||||
>
|
||||
<img
|
||||
src={media.src}
|
||||
alt={`slide-${media.id}`}
|
||||
className="slide-image"
|
||||
/>
|
||||
</SwiperSlide>
|
||||
))}
|
||||
</Swiper>
|
||||
</div>
|
||||
</div>
|
||||
</SliderContext.Provider>
|
||||
);
|
||||
|
||||
@@ -5,6 +5,9 @@ $color-usual: #ACACAC;
|
||||
$border-raduis: 16px;
|
||||
$background-tape: #F5F5F7;
|
||||
|
||||
$swiper-button-size: 48px;
|
||||
$swiper-button-arrow-size: 20px;
|
||||
|
||||
:root {
|
||||
--wp--preset--spacing--10: 5%;
|
||||
--wp--preset--spacing--20: 10%;
|
||||
@@ -50,6 +53,7 @@ $background-tape: #F5F5F7;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
// "Цитаты"
|
||||
.wp-block-pullquote {
|
||||
* {
|
||||
margin-bottom: 0;
|
||||
@@ -72,6 +76,7 @@ $background-tape: #F5F5F7;
|
||||
}
|
||||
}
|
||||
|
||||
// Таблица
|
||||
.table-wrapper {
|
||||
border: 1px solid $table-header-color;
|
||||
border-radius: $border-raduis;
|
||||
@@ -135,4 +140,37 @@ $background-tape: #F5F5F7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// .slider {
|
||||
// position: static;
|
||||
|
||||
// .swiper {
|
||||
// height: 476px;
|
||||
|
||||
// .swiper-wrapper {
|
||||
// align-items: flex-end;
|
||||
// position: absolute;
|
||||
// left: 0;
|
||||
// width: 100%;
|
||||
|
||||
// .swiper-slide {
|
||||
// height: 376px;
|
||||
// width: 376px;
|
||||
// }
|
||||
// }
|
||||
|
||||
// .swiper-button-prev, .swiper-button-next {
|
||||
// top: calc($swiper-button-size / 2);
|
||||
// left: auto;
|
||||
// }
|
||||
|
||||
// .swiper-button-prev {
|
||||
// right: calc($swiper-button-size);
|
||||
// }
|
||||
|
||||
// .swiper-pagination {
|
||||
// display: none;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -18,6 +18,7 @@ export default function WpPost({
|
||||
children,
|
||||
}: WpPostProps) {
|
||||
useResizeObserver({parentSelector: '.wp-block-pullquote'});
|
||||
// useResizeObserver({parentSelector: ".swiper", childSelector: ".swiper-wrapper"});
|
||||
|
||||
return (
|
||||
<div className={post.categories?.includes('projects') ? "project" : ""}>
|
||||
|
||||
Reference in new issue
Block a user