mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 05:09:46 +00:00
Merge branch 'refactoring'
This commit is contained in:
commit
f82b47c042
17 files changed
+252
-179
No files matched your search
@@ -19,8 +19,8 @@ export const fetchMedia = async (): Promise<MediaItem[]> => {
|
|||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
try {
|
try {
|
||||||
// Запрашиваем медиа с указанной страницы
|
// Запрашиваем медиа с указанной страницы
|
||||||
const media = (await wp.media().page(page)) as WPv2.Media[];
|
const media = (await wp.media().page(page)) as WPv2.MediaWithPaging;
|
||||||
console.log('media', media);
|
console.log("media", media);
|
||||||
|
|
||||||
// Преобразуем данные и добавляем в общий массив
|
// Преобразуем данные и добавляем в общий массив
|
||||||
const transformedMedia = media.map(({ id, source_url, alt_text }) => {
|
const transformedMedia = media.map(({ id, source_url, alt_text }) => {
|
||||||
@@ -31,7 +31,6 @@ export const fetchMedia = async (): Promise<MediaItem[]> => {
|
|||||||
|
|
||||||
allMedia = [...allMedia, ...transformedMedia];
|
allMedia = [...allMedia, ...transformedMedia];
|
||||||
|
|
||||||
// Если это последняя страница
|
|
||||||
if (media._paging.totalPages === page) {
|
if (media._paging.totalPages === page) {
|
||||||
hasMore = false;
|
hasMore = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const fetchPosts = async (): Promise<App.PostsResult> => {
|
|||||||
const excerptElement = Parse(post.excerpt.rendered)[0];
|
const excerptElement = Parse(post.excerpt.rendered)[0];
|
||||||
const newLab: App.LabCard = {
|
const newLab: App.LabCard = {
|
||||||
...newPost,
|
...newPost,
|
||||||
preview: image?.src || null,
|
preview: image?.src || undefined,
|
||||||
previewText: (excerptElement as any)?.props?.children || "",
|
previewText: (excerptElement as any)?.props?.children || "",
|
||||||
};
|
};
|
||||||
result.labs[post.id] = newLab;
|
result.labs[post.id] = newLab;
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import "./Field.styles.scss";
|
import "./Field.styles.scss";
|
||||||
import cross from "@/shared/assets/images/cross.svg";
|
import cross from "@/shared/assets/images/cross.svg";
|
||||||
import fileUpload from "@/shared/assets/images/fileUpload.svg";
|
import fileUpload from "@/shared/assets/images/fileUpload.svg";
|
||||||
import { ForwardedRef, forwardRef } from "react";
|
import { ForwardedRef, forwardRef } from "react";
|
||||||
import { UseFormRegisterReturn } from "react-hook-form";
|
import {
|
||||||
|
FieldError,
|
||||||
|
FieldErrorsImpl,
|
||||||
|
Merge,
|
||||||
|
UseFormRegisterReturn,
|
||||||
|
} from "react-hook-form";
|
||||||
type FieldType =
|
type FieldType =
|
||||||
| "text"
|
| "text"
|
||||||
| "email"
|
| "email"
|
||||||
@@ -18,7 +24,11 @@ interface FieldProps {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
fileAttached?: boolean;
|
fileAttached?: boolean;
|
||||||
error?: string;
|
error?:
|
||||||
|
| string
|
||||||
|
| FieldError
|
||||||
|
| Merge<FieldError, FieldErrorsImpl<any>>
|
||||||
|
| undefined;
|
||||||
handleRemoveFile?: () => void;
|
handleRemoveFile?: () => void;
|
||||||
register?: UseFormRegisterReturn;
|
register?: UseFormRegisterReturn;
|
||||||
}
|
}
|
||||||
@@ -27,7 +37,7 @@ const Field = forwardRef(
|
|||||||
(
|
(
|
||||||
{
|
{
|
||||||
type,
|
type,
|
||||||
name,
|
|
||||||
placeholder,
|
placeholder,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
fileAttached = false,
|
fileAttached = false,
|
||||||
@@ -90,7 +100,7 @@ const Field = forwardRef(
|
|||||||
{...register}
|
{...register}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{error && <span className="error-message">{error}</span>}
|
{error && <span className="error-message">{String(error)}</span>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
type Mods = Record<string, boolean | string>;
|
type Mods = Record<string, boolean | string>;
|
||||||
|
|
||||||
export function classNames(
|
export function classNames(
|
||||||
cls: string,
|
cls: string,
|
||||||
mods?: Mods,
|
mods?: Mods,
|
||||||
additional?: string[] | undefined[],
|
additional?: string[] | undefined[]
|
||||||
): string {
|
): string {
|
||||||
if (additional && mods) {
|
if (additional && mods) {
|
||||||
return [
|
return [
|
||||||
cls,
|
cls,
|
||||||
...additional.filter(Boolean),
|
...additional.filter(Boolean),
|
||||||
Object.entries(mods)
|
Object.entries(mods)
|
||||||
.filter(([cls, value]) => Boolean(value))
|
.filter(([value]) => Boolean(value))
|
||||||
.map(([className, value]) => className)
|
.map(([className]) => className)
|
||||||
.join(' '),
|
.join(" "),
|
||||||
].join(' ');
|
].join(" ");
|
||||||
}
|
}
|
||||||
if (additional && !mods) {
|
if (additional && !mods) {
|
||||||
return [cls, ...additional.filter(Boolean)].join(' ');
|
return [cls, ...additional.filter(Boolean)].join(" ");
|
||||||
}
|
}
|
||||||
if (!additional && mods) {
|
if (!additional && mods) {
|
||||||
return [
|
return [
|
||||||
cls,
|
cls,
|
||||||
Object.entries(mods)
|
Object.entries(mods)
|
||||||
.filter(([cls, value]) => Boolean(value))
|
.filter(([value]) => Boolean(value))
|
||||||
.map(([className, value]) => className),
|
.map(([className]) => className),
|
||||||
].join(' ');
|
].join(" ");
|
||||||
}
|
}
|
||||||
return [cls].join(' ');
|
return [cls].join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
classNames('remove-btn', { hovered: true, selectable: true, red: false }, [
|
classNames("remove-btn", { hovered: true, selectable: true, red: false }, [
|
||||||
'pdg',
|
"pdg",
|
||||||
]);
|
]);
|
||||||
Vendored
+33
-13
@@ -19,7 +19,25 @@ declare namespace WPv2 {
|
|||||||
raw: string;
|
raw: string;
|
||||||
rendered: string;
|
rendered: string;
|
||||||
}
|
}
|
||||||
|
export interface PagingInfo {
|
||||||
|
total: number;
|
||||||
|
totalPages: number;
|
||||||
|
links: {
|
||||||
|
next?: string;
|
||||||
|
};
|
||||||
|
next?: {
|
||||||
|
_options: {
|
||||||
|
auth: boolean;
|
||||||
|
endpoint: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
transport: Record<string, any>;
|
||||||
|
_params: Record<string, any>;
|
||||||
|
_supportedMethods: string[];
|
||||||
|
_path: Record<string, any>;
|
||||||
|
};
|
||||||
|
}
|
||||||
export interface Content {
|
export interface Content {
|
||||||
raw: string;
|
raw: string;
|
||||||
rendered: string;
|
rendered: string;
|
||||||
@@ -113,7 +131,9 @@ declare namespace WPv2 {
|
|||||||
class_list: string[];
|
class_list: string[];
|
||||||
_links: Links;
|
_links: Links;
|
||||||
}
|
}
|
||||||
|
export interface MediaWithPaging extends Array<Media> {
|
||||||
|
_paging: PagingInfo;
|
||||||
|
}
|
||||||
export interface Media {
|
export interface Media {
|
||||||
id: number;
|
id: number;
|
||||||
date: string;
|
date: string;
|
||||||
@@ -181,15 +201,15 @@ declare namespace WPv2 {
|
|||||||
offset?: number;
|
offset?: number;
|
||||||
order?: "asc" | "desc";
|
order?: "asc" | "desc";
|
||||||
orderby?:
|
orderby?:
|
||||||
| "author"
|
| "author"
|
||||||
| "date"
|
| "date"
|
||||||
| "id"
|
| "id"
|
||||||
| "include"
|
| "include"
|
||||||
| "modified"
|
| "modified"
|
||||||
| "parent"
|
| "parent"
|
||||||
| "relevance"
|
| "relevance"
|
||||||
| "slug"
|
| "slug"
|
||||||
| "title";
|
| "title";
|
||||||
slug?: string[];
|
slug?: string[];
|
||||||
status?: string[];
|
status?: string[];
|
||||||
}
|
}
|
||||||
@@ -284,11 +304,11 @@ declare namespace App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Card extends WpPost {
|
export interface Card extends WpPost {
|
||||||
preview: string | null;
|
preview?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LabCard extends Card {
|
export interface LabCard extends Card {
|
||||||
previewText: string;
|
previewText?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostsResult {
|
export interface PostsResult {
|
||||||
|
|||||||
@@ -87,11 +87,12 @@ const ProjectsList = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isError) return <div>Ошибка при загрузке данных</div>;
|
if (isError || !projects) return <div>Ошибка при загрузке данных</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.mainContainer}>
|
<div className={styles.mainContainer}>
|
||||||
<CardListTemplate
|
<CardListTemplate
|
||||||
|
//@ts-ignore
|
||||||
items={transformPostsToCardData(projects)}
|
items={transformPostsToCardData(projects)}
|
||||||
variant="project"
|
variant="project"
|
||||||
gridConfig={gridConfig}
|
gridConfig={gridConfig}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export function CategoryPage({ category }: CategoryPageProps) {
|
|||||||
const { data: postsData, isLoading, isError } = usePosts();
|
const { data: postsData, isLoading, isError } = usePosts();
|
||||||
|
|
||||||
const categoryPosts =
|
const categoryPosts =
|
||||||
postsData?.other.filter((post) => post.categories.includes(category)) || [];
|
postsData?.other.filter((post) => post.categories?.includes(category)) ||
|
||||||
|
[];
|
||||||
|
|
||||||
if (isLoading)
|
if (isLoading)
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import MediaContainer from "@/widgets/MediaBlock/MediaContainer";
|
import MediaContainer from "@/widgets/MediaBlock/MediaContainer";
|
||||||
import "./MediaBlock.styles.scss";
|
import "./MediaBlock.styles.scss";
|
||||||
|
import { ReactElement } from "react";
|
||||||
|
|
||||||
function MediaBlock({ images }) {
|
interface MediaBlockProps {
|
||||||
|
images: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function MediaBlock({ images }: MediaBlockProps): ReactElement {
|
||||||
return (
|
return (
|
||||||
<div className="media-block">
|
<div className="media-block">
|
||||||
{images.map((item, index) => (
|
{images.map((item, index) => (
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
function MediaContainer({ src }) {
|
import { ReactElement } from "react";
|
||||||
return (
|
|
||||||
<div className="media-container">
|
interface MediaContainerProps {
|
||||||
<img className="image" alt="" src={src} />
|
src: string;
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MediaContainer;
|
function MediaContainer({ src }: MediaContainerProps): ReactElement {
|
||||||
|
return (
|
||||||
|
<div className="media-container">
|
||||||
|
<img className="image" alt="" src={src} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MediaContainer;
|
||||||
@@ -3,7 +3,6 @@ import Marquee from "react-fast-marquee";
|
|||||||
|
|
||||||
import PartnersLogo from "./PartnersLogo";
|
import PartnersLogo from "./PartnersLogo";
|
||||||
import styles from "./Partners.module.scss";
|
import styles from "./Partners.module.scss";
|
||||||
// import BlockHeading from "@/widgets/BlockHeading";
|
|
||||||
|
|
||||||
// Тип для данных партнёра
|
// Тип для данных партнёра
|
||||||
interface Partner {
|
interface Partner {
|
||||||
@@ -73,28 +72,25 @@ const mock: Partner[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function Partners({ partners = mock }: PartnersProps) {
|
function Partners({ partners = mock }: PartnersProps) {
|
||||||
const [mediaList, setMediaList] = useState<Partner[]>(partners);
|
const [mediaList] = useState<Partner[]>(partners);
|
||||||
const [play, setPlay] = useState(false);
|
const [play, setPlay] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
const updateMediaList = async () => {
|
||||||
const loadData = async () => {
|
// Логика для обновления списка медиа
|
||||||
try {
|
// const newMediaList = await getMedia('partners');
|
||||||
// Эмуляция загрузки данных
|
// setMediaList(newMediaList);
|
||||||
// const newMediaList = await getMedia('partners');
|
|
||||||
// setMediaList(newMediaList);
|
|
||||||
|
|
||||||
// Автозапуск если достаточно элементов
|
|
||||||
if (mediaList.length >= 5) {
|
|
||||||
setPlay(true);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error loading partners data:", error);
|
|
||||||
// Автозапуск с mock-данными
|
|
||||||
setPlay(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadData();
|
// if (newMediaList.length >= 5) {
|
||||||
|
setPlay(true);
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateMediaList();
|
||||||
|
window.addEventListener("resize", updateMediaList);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", updateMediaList);
|
||||||
|
};
|
||||||
}, [mediaList.length]);
|
}, [mediaList.length]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { useEffect, useState, useRef } from "react";
|
import { createContext, useEffect, useState } from "react";
|
||||||
import { Swiper, SwiperSlide } from "swiper/react";
|
import { Swiper, SwiperSlide } from "swiper/react";
|
||||||
import { Pagination } from "swiper/modules";
|
import { Navigation, Pagination } from "swiper/modules";
|
||||||
import { useMedia } from "@/modules/media/hooks/useMedia";
|
import { useMedia } from "@/modules/media/hooks/useMedia";
|
||||||
|
|
||||||
import "swiper/css";
|
import "swiper/css";
|
||||||
|
import "swiper/css/navigation";
|
||||||
import "swiper/css/pagination";
|
import "swiper/css/pagination";
|
||||||
|
|
||||||
import "./Slider.styles.scss";
|
import "./Slider.styles.scss";
|
||||||
|
import { MediaItem } from "@/modules/media/api/get";
|
||||||
import arrow from "../../shared/assets/images/arrow.svg";
|
|
||||||
|
|
||||||
interface SliderProps {
|
interface SliderProps {
|
||||||
autoPlay?: boolean;
|
autoPlay?: boolean;
|
||||||
@@ -17,6 +17,25 @@ interface SliderProps {
|
|||||||
category?: string;
|
category?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the SliderContextType interface to include the missing properties
|
||||||
|
interface SliderContextType {
|
||||||
|
slideNumber: number;
|
||||||
|
mediaList: MediaItem[];
|
||||||
|
setSlideNumber?: (slideNumber: number) => void;
|
||||||
|
goToSlide: (slideNumber: number) => void; // Added for Dot component
|
||||||
|
slidesCount: number; // Added for Dots component
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then in your Slider component, update the context value:
|
||||||
|
|
||||||
|
// Create context with default values
|
||||||
|
export const SliderContext = createContext<SliderContextType>({
|
||||||
|
slideNumber: 0,
|
||||||
|
mediaList: [],
|
||||||
|
goToSlide: () => {},
|
||||||
|
slidesCount: 0,
|
||||||
|
});
|
||||||
|
|
||||||
function Slider({
|
function Slider({
|
||||||
autoPlay = false,
|
autoPlay = false,
|
||||||
autoPlayTime = 3000,
|
autoPlayTime = 3000,
|
||||||
@@ -24,29 +43,33 @@ function Slider({
|
|||||||
category = "gallery",
|
category = "gallery",
|
||||||
}: SliderProps) {
|
}: SliderProps) {
|
||||||
const { data: mediaData, isLoading, isError } = useMedia();
|
const { data: mediaData, isLoading, isError } = useMedia();
|
||||||
const [itemsPerSlide, setItemsPerSlide] = useState(
|
const [itemsPerSlide, setItemsPerSlide] = useState<number>(
|
||||||
window.innerWidth <= 768 ? 1 : 2
|
window.innerWidth <= 768 ? 1 : 2
|
||||||
);
|
);
|
||||||
const [enableButtons, setEnableButtons] = useState(false);
|
const [enableButtons, setEnableButtons] = useState<boolean>(false);
|
||||||
const swiperRef = useRef<any>(null);
|
const [slideNumber, setSlideNumber] = useState<number>(0);
|
||||||
|
|
||||||
const filteredMedia = images
|
// Фильтруем медиа по категории
|
||||||
? images.map((src, id) => ({ id, src }))
|
const filteredMedia: MediaItem[] = images
|
||||||
|
? images.map((src, id) => ({ id, src, category: "", name: "" }))
|
||||||
: mediaData?.filter((media) => media.category === category) || [];
|
: mediaData?.filter((media) => media.category === category) || [];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
const isMobile = window.innerWidth <= 768;
|
setItemsPerSlide(window.innerWidth <= 768 ? 1 : 2);
|
||||||
setItemsPerSlide(isMobile ? 1 : 2);
|
};
|
||||||
|
window.addEventListener("resize", handleResize);
|
||||||
// Показываем стрелки только если слайдов больше 2
|
return () => window.removeEventListener("resize", handleResize);
|
||||||
setEnableButtons(!isMobile && filteredMedia.length > 2);
|
}, []);
|
||||||
};
|
|
||||||
|
useEffect(() => {
|
||||||
window.addEventListener("resize", handleResize);
|
const numberOfSlides = filteredMedia.length;
|
||||||
handleResize(); // сразу вызываем
|
if (numberOfSlides > 2) {
|
||||||
return () => window.removeEventListener("resize", handleResize);
|
setEnableButtons(true);
|
||||||
}, [filteredMedia]);
|
} else if (numberOfSlides === 1) {
|
||||||
|
setItemsPerSlide(1);
|
||||||
|
}
|
||||||
|
}, [filteredMedia]);
|
||||||
|
|
||||||
if (isLoading)
|
if (isLoading)
|
||||||
return (
|
return (
|
||||||
@@ -56,52 +79,52 @@ function Slider({
|
|||||||
);
|
);
|
||||||
if (isError) return <div>Ошибка при загрузке медиа</div>;
|
if (isError) return <div>Ошибка при загрузке медиа</div>;
|
||||||
|
|
||||||
return (
|
// Create context value
|
||||||
<div className={`slider ${enableButtons ? "has-pagination" : ""}`}>
|
const contextValue: SliderContextType = {
|
||||||
{/* Кастомные стрелки */}
|
slideNumber,
|
||||||
{enableButtons && (
|
mediaList: filteredMedia,
|
||||||
<div className="custom-navigation">
|
setSlideNumber,
|
||||||
<button className="custom-prev" onClick={() => swiperRef.current?.slidePrev()}>
|
goToSlide: (slide: number) => setSlideNumber(slide),
|
||||||
<img src={arrow} alt="prev" />
|
slidesCount: filteredMedia.length,
|
||||||
</button>
|
};
|
||||||
<button className="custom-next" onClick={() => swiperRef.current?.slideNext()}>
|
|
||||||
<img src={arrow} alt="next" style={{ transform: "rotate(180deg)" }} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Swiper
|
return (
|
||||||
modules={[Pagination]}
|
<SliderContext.Provider value={contextValue}>
|
||||||
spaceBetween={20}
|
<div className="slider">
|
||||||
slidesPerView={itemsPerSlide}
|
<Swiper
|
||||||
slidesPerGroup={1}
|
modules={[Navigation, Pagination]}
|
||||||
loop={enableButtons}
|
spaceBetween={20}
|
||||||
pagination={{ clickable: enableButtons }}
|
slidesPerView={itemsPerSlide}
|
||||||
autoplay={
|
slidesPerGroup={1}
|
||||||
autoPlay
|
loop={enableButtons}
|
||||||
? { delay: autoPlayTime, disableOnInteraction: false }
|
navigation={enableButtons}
|
||||||
: false
|
pagination={{ clickable: enableButtons }}
|
||||||
}
|
autoplay={
|
||||||
onSwiper={(swiper) => (swiperRef.current = swiper)}
|
autoPlay
|
||||||
>
|
? { delay: autoPlayTime, disableOnInteraction: false }
|
||||||
{filteredMedia.map((media) => (
|
: false
|
||||||
<SwiperSlide
|
}
|
||||||
key={media.id}
|
onSlideChange={(swiper) => setSlideNumber(swiper.activeIndex)}
|
||||||
className={
|
>
|
||||||
filteredMedia.length === 1
|
{filteredMedia.map((media) => (
|
||||||
? "swiper-slide single"
|
<SwiperSlide
|
||||||
: "swiper-slide"
|
key={media.id}
|
||||||
}
|
className={
|
||||||
>
|
filteredMedia.length === 1
|
||||||
<img
|
? "swiper-slide single"
|
||||||
src={media.src}
|
: "swiper-slide"
|
||||||
alt={`slide-${media.id}`}
|
}
|
||||||
className="slide-image"
|
>
|
||||||
/>
|
<img
|
||||||
</SwiperSlide>
|
src={media.src}
|
||||||
))}
|
alt={`slide-${media.id}`}
|
||||||
</Swiper>
|
className="slide-image"
|
||||||
</div>
|
/>
|
||||||
|
</SwiperSlide>
|
||||||
|
))}
|
||||||
|
</Swiper>
|
||||||
|
</div>
|
||||||
|
</SliderContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import React, { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { SliderContext } from "../Slider";
|
import { SliderContext } from "../Slider";
|
||||||
|
|
||||||
import { arrow } from '../../../assets/images';
|
import arrow from "@/shared/assets/images/arrow.svg";
|
||||||
import './Arrows.styles.scss';
|
import "./Arrows.styles.scss";
|
||||||
|
interface ArrowsProps {
|
||||||
function Arrows() {
|
prevSlide: () => void;
|
||||||
const { changeSlide } = useContext(SliderContext);
|
nextSlide: () => void;
|
||||||
|
}
|
||||||
return (
|
export default function Arrows({ prevSlide, nextSlide }: ArrowsProps) {
|
||||||
<div className="arrows">
|
const { mediaList } = useContext(SliderContext);
|
||||||
<div className="arrow left" onClick={() => changeSlide(-1)}>
|
if (mediaList.length <= 1) {
|
||||||
<img src={ arrow } alt="" />
|
return null;
|
||||||
</div>
|
}
|
||||||
<div className="arrow right" onClick={() => changeSlide(1)}>
|
return (
|
||||||
<img src={ arrow } alt="" />
|
<div className="arrows">
|
||||||
</div>
|
<div className="arrow left" onClick={prevSlide}>
|
||||||
</div>
|
<img src={arrow} alt="" />
|
||||||
);
|
</div>
|
||||||
|
<div className="arrow right" onClick={nextSlide}>
|
||||||
|
<img src={arrow} alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Arrows;
|
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
|
|
||||||
import { SliderContext } from "../Slider";
|
import { SliderContext } from "../Slider";
|
||||||
|
import { ReactElement } from "react";
|
||||||
|
|
||||||
function Dot({ number }) {
|
interface DotProps {
|
||||||
|
number: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Dot({ number }: DotProps): ReactElement {
|
||||||
const { goToSlide, slideNumber } = useContext(SliderContext);
|
const { goToSlide, slideNumber } = useContext(SliderContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -13,4 +17,4 @@ function Dot({ number }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Dot;
|
export default Dot;
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
|
|
||||||
import { SliderContext } from "../Slider";
|
import { SliderContext } from "../Slider";
|
||||||
import Dot from "./Dots";
|
import Dot from "./Dot"; // Fixed import - was incorrectly importing from "./Dots"
|
||||||
|
import { ReactElement } from "react";
|
||||||
|
|
||||||
function Dots() {
|
function Dots(): ReactElement {
|
||||||
const { slidesCount } = useContext(SliderContext);
|
const { slidesCount } = useContext(SliderContext);
|
||||||
|
|
||||||
const renderDots = () => {
|
const renderDots = (): ReactElement[] => {
|
||||||
const dots = [];
|
const dots: ReactElement[] = [];
|
||||||
for (let i = 0; i < slidesCount; i++) {
|
for (let i = 0; i < slidesCount; i++) {
|
||||||
dots.push(<Dot key={`dot-${i}`} number={i} />);
|
dots.push(<Dot key={`dot-${i}`} number={i} />);
|
||||||
}
|
}
|
||||||
@@ -18,4 +18,4 @@ function Dots() {
|
|||||||
return <div className="dots">{renderDots()}</div>;
|
return <div className="dots">{renderDots()}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Dots;
|
export default Dots;
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
export default function Slide({ slide }) {
|
interface SlideProps {
|
||||||
|
slide: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Slide({ slide }: SlideProps) {
|
||||||
return (
|
return (
|
||||||
<div className="slide">
|
<div className="slide">
|
||||||
<img src={slide} className="slide-image" />
|
<img src={slide} className="slide-image" alt="Slide" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import Slide from "./Slide";
|
import Slide from "./Slide";
|
||||||
import { SliderContext } from "../Slider";
|
import { SliderContext } from "../Slider";
|
||||||
|
import { MediaItem } from "@/modules/media/api/get";
|
||||||
|
|
||||||
export default function SlidesList() {
|
export default function SlidesList() {
|
||||||
const { slideNumber, mediaList } = useContext(SliderContext);
|
const { slideNumber, mediaList } = useContext(SliderContext);
|
||||||
@@ -10,9 +11,9 @@ export default function SlidesList() {
|
|||||||
className="slide-list"
|
className="slide-list"
|
||||||
style={{ transform: `translateX(-${slideNumber * 100}%)` }}
|
style={{ transform: `translateX(-${slideNumber * 100}%)` }}
|
||||||
>
|
>
|
||||||
{mediaList.map((slide, index) => (
|
{mediaList.map((slide: MediaItem, index: number) => (
|
||||||
<Slide key={index} slide={slide.src} />
|
<Slide key={index} slide={slide.src} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"root":["./src/main.tsx","./src/vite-env.d.ts","./src/app/app.tsx","./src/app/layout/root.tsx","./src/app/providers/router/index.ts","./src/app/providers/router/ui/approuter.tsx","./src/app/types/global.d.ts","./src/modules/index.ts","./src/modules/contact/api/post.ts","./src/modules/contact/hooks/usecontactform.ts","./src/modules/media/api/get.ts","./src/modules/media/hooks/usemedia.ts","./src/modules/news/api/get.ts","./src/modules/news/hooks/usenews.ts","./src/modules/news/hooks/usenewsbyid.ts","./src/modules/posts/api/get.ts","./src/modules/posts/hooks/usepostbyid.ts","./src/modules/posts/hooks/usepostprojects.ts","./src/modules/posts/hooks/useposts.ts","./src/pages/aboutus/aboutus.tsx","./src/pages/aboutus/index.ts","./src/pages/aboutus/types.ts","./src/pages/contact/contact.tsx","./src/pages/contact/index.ts","./src/pages/mainpage/index.tsx","./src/pages/mainpage/ui/mainpage/mainpage.async.tsx","./src/pages/mainpage/ui/mainpage/mainpage.tsx","./src/pages/mainpage/ui/mainpage/mockdata.ts","./src/pages/mainpage/ui/components/gallery/gallery.tsx","./src/pages/mainpage/ui/components/gallery/index.ts","./src/pages/newsitem/newsitem.tsx","./src/pages/notfound/notfoundpage.tsx","./src/pages/wppostpage/wppostpage.tsx","./src/shared/components/card/card.tsx","./src/shared/components/card/types.ts","./src/shared/components/field/field.tsx","./src/shared/components/field/index.ts","./src/shared/api/parsecontent.ts","./src/shared/api/wp-client.ts","./src/shared/config/routeconfig/routeconfig.tsx","./src/shared/lib/elementonscreen/elementonscreen.ts","./src/shared/lib/classnames/classnames.ts","./src/shared/types/app.d.ts","./src/widgets/button/ui/button.tsx","./src/widgets/cardlist/cardlist.tsx","./src/widgets/cardlist/cardlistfunctions.ts","./src/widgets/cardlist/cardlisttemplate.tsx","./src/widgets/cardlist/types.ts","./src/widgets/categorypage/categorypage.tsx","./src/widgets/contactform/contactform.tsx","./src/widgets/contactform/index.ts","./src/widgets/contactform/variables.ts","./src/widgets/contactus/contactus.tsx","./src/widgets/contactus/index.ts","./src/widgets/footer/footer.tsx","./src/widgets/footer/footercontacts.tsx","./src/widgets/footer/footerlink.tsx","./src/widgets/footer/index.ts","./src/widgets/mediablock/mediablock.tsx","./src/widgets/mediablock/index.ts","./src/widgets/mediablock/mediacontainer/mediacontainer.tsx","./src/widgets/mediablock/mediacontainer/index.ts","./src/widgets/navbar/navbar.tsx","./src/widgets/navbar/navbarlink.tsx","./src/widgets/navbar/index.ts","./src/widgets/partners/partners.tsx","./src/widgets/partners/partnerslogo.tsx","./src/widgets/partners/index.ts","./src/widgets/slider/slider.tsx","./src/widgets/slider/components/arrows.tsx","./src/widgets/slider/components/dot.tsx","./src/widgets/slider/components/dots.tsx","./src/widgets/slider/components/slide.tsx","./src/widgets/slider/components/slideslist.tsx","./src/widgets/wppost/pagecontent.tsx","./src/widgets/wppost/pageheader.tsx","./src/widgets/wppost/wppost.tsx","./src/widgets/wppost/index.ts"],"errors":true,"version":"5.8.2"}
|
{"root":["./src/main.tsx","./src/vite-env.d.ts","./src/app/app.tsx","./src/app/layout/root.tsx","./src/app/providers/router/index.ts","./src/app/providers/router/ui/approuter.tsx","./src/app/types/global.d.ts","./src/modules/index.ts","./src/modules/contact/api/post.ts","./src/modules/contact/hooks/usecontactform.ts","./src/modules/media/api/get.ts","./src/modules/media/hooks/usemedia.ts","./src/modules/news/api/get.ts","./src/modules/news/hooks/usenews.ts","./src/modules/news/hooks/usenewsbyid.ts","./src/modules/posts/api/get/fetchpostbyid.ts","./src/modules/posts/api/get/fetchpostprojects.ts","./src/modules/posts/api/get/fetchposts.ts","./src/modules/posts/hooks/usepostbyid.ts","./src/modules/posts/hooks/usepostprojects.ts","./src/modules/posts/hooks/useposts.ts","./src/pages/aboutus/aboutus.tsx","./src/pages/aboutus/index.ts","./src/pages/aboutus/types.ts","./src/pages/contact/contact.tsx","./src/pages/contact/index.ts","./src/pages/mainpage/index.tsx","./src/pages/mainpage/ui/mainpage/mainpage.async.tsx","./src/pages/mainpage/ui/mainpage/mainpage.tsx","./src/pages/mainpage/ui/mainpage/mockdata.ts","./src/pages/mainpage/ui/components/gallery/gallery.tsx","./src/pages/mainpage/ui/components/gallery/index.ts","./src/pages/newsitem/newsitem.tsx","./src/pages/notfound/notfoundpage.tsx","./src/pages/wppostpage/wppostpage.tsx","./src/shared/components/card/card.tsx","./src/shared/components/card/types.ts","./src/shared/components/field/field.tsx","./src/shared/components/field/index.ts","./src/shared/api/parsecontent.ts","./src/shared/api/wp-client.ts","./src/shared/config/routeconfig/routeconfig.tsx","./src/shared/lib/elementonscreen/elementonscreen.ts","./src/shared/lib/classnames/classnames.ts","./src/shared/types/app.d.ts","./src/widgets/button/ui/button.tsx","./src/widgets/cardlist/cardlist.tsx","./src/widgets/cardlist/cardlistfunctions.ts","./src/widgets/cardlist/cardlisttemplate.tsx","./src/widgets/cardlist/types.ts","./src/widgets/categorypage/categorypage.tsx","./src/widgets/contactform/contactform.tsx","./src/widgets/contactform/index.ts","./src/widgets/contactform/variables.ts","./src/widgets/contactus/contactus.tsx","./src/widgets/contactus/index.ts","./src/widgets/footer/footer.tsx","./src/widgets/footer/footercontacts.tsx","./src/widgets/footer/footerlink.tsx","./src/widgets/footer/index.ts","./src/widgets/mediablock/mediablock.tsx","./src/widgets/mediablock/index.ts","./src/widgets/mediablock/mediacontainer/mediacontainer.tsx","./src/widgets/mediablock/mediacontainer/index.ts","./src/widgets/navbar/navbar.tsx","./src/widgets/navbar/navbarlink.tsx","./src/widgets/navbar/index.ts","./src/widgets/partners/partners.tsx","./src/widgets/partners/partnerslogo.tsx","./src/widgets/partners/index.ts","./src/widgets/slider/slider.tsx","./src/widgets/slider/components/arrows.tsx","./src/widgets/slider/components/dot.tsx","./src/widgets/slider/components/dots.tsx","./src/widgets/slider/components/slide.tsx","./src/widgets/slider/components/slideslist.tsx","./src/widgets/wppost/pagecontent.tsx","./src/widgets/wppost/pageheader.tsx","./src/widgets/wppost/wppost.tsx","./src/widgets/wppost/index.ts"],"version":"5.8.2"}
|
||||||
Reference in new issue
Block a user