mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 03:19:45 +00:00
изменила контактную форму, доработала навбар, партнёры
This commit is contained in:
1 parent
79fc2eeb98
commit
d24fecd5e4
25 files changed
+620
-236
No files matched your search
@@ -98,6 +98,7 @@
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: filter 0.3s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.title {
|
||||
|
||||
@@ -3,27 +3,23 @@ $icon-size: 24px;
|
||||
$color-file-button: rgb(7, 42, 200);
|
||||
|
||||
.contact-form {
|
||||
padding: 20px 22px;
|
||||
padding: 1.3rem 32px;
|
||||
border-radius: 16px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: $bg-form;
|
||||
margin-top: 20px;
|
||||
align-items: flex-start;
|
||||
|
||||
h2 {
|
||||
margin-top: 0;
|
||||
min-width: 400px;
|
||||
font-size: 28px;
|
||||
font-weight: 500;
|
||||
line-height: 44px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: 20px;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
.smart-captcha {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.inputs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -41,7 +37,6 @@ $color-file-button: rgb(7, 42, 200);
|
||||
padding: 12px 16px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
}
|
||||
@@ -50,6 +45,7 @@ $color-file-button: rgb(7, 42, 200);
|
||||
height: 300px;
|
||||
line-height: 30px;
|
||||
resize: none;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
height: 200px;
|
||||
}
|
||||
@@ -77,16 +73,21 @@ $color-file-button: rgb(7, 42, 200);
|
||||
|
||||
.upload-file-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
background: none;
|
||||
border: none; // Убрана рамка
|
||||
padding: 0;
|
||||
|
||||
.icon {
|
||||
filter: invert(15%) sepia(100%) saturate(2861%) hue-rotate(229deg)
|
||||
brightness(93%) contrast(120%);
|
||||
filter: invert(15%) sepia(100%) saturate(2861%) hue-rotate(229deg) brightness(93%) contrast(120%);
|
||||
}
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
font-size: 18px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
@@ -118,7 +119,7 @@ $color-file-button: rgb(7, 42, 200);
|
||||
}
|
||||
}
|
||||
|
||||
.file-input input:focus + .upload-file-btn {
|
||||
.file-input input:focus+.upload-file-btn {
|
||||
outline: -webkit-focus-ring-color auto 1px;
|
||||
}
|
||||
|
||||
@@ -126,11 +127,31 @@ $color-file-button: rgb(7, 42, 200);
|
||||
.submit {
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
|
||||
padding: 12px;
|
||||
font-size: 18px;
|
||||
line-height: normal;
|
||||
margin-top: 0;
|
||||
|
||||
&:disabled {
|
||||
background-color: #aaaaaa;
|
||||
color: dimgrey;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.agree-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px; // Расстояние между чекбоксом и текстом
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox-container {
|
||||
margin-top: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
@@ -17,13 +17,16 @@ import {
|
||||
const formSchema = z.object({
|
||||
name: z.string().min(1, "Обязательное поле"),
|
||||
email: z.string().email("Некорректный email. Пример 123@sfedu.ru"),
|
||||
phone: z.string()
|
||||
.min(1, "Обязательное поле")
|
||||
.regex(/^\+7\s?\(?\d{3}\)?\s?\d{3}[-.\s]?\d{2}[-.\s]?\d{2}$/, "Некорректный номер телефона"),
|
||||
message: z.string().min(1, "Обязательное поле"),
|
||||
file: z
|
||||
.any() // Используем `any`, чтобы избежать ошибки типа
|
||||
.any()
|
||||
.optional()
|
||||
.nullable()
|
||||
.refine(
|
||||
(file) => !file || file.length === 0 || file instanceof File, // Проверяем, что это File, если значение есть
|
||||
(file) => !file || file.length === 0 || file instanceof File,
|
||||
"Файл должен быть экземпляром File"
|
||||
)
|
||||
.refine(
|
||||
@@ -37,6 +40,7 @@ const formSchema = z.object({
|
||||
)
|
||||
.transform((value) => value ?? undefined),
|
||||
captcha: z.string().min(1, "Требуется проверка капчи"),
|
||||
agree: z.boolean().refine(val => val, "Необходимо согласие на обработку данных"),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
@@ -55,9 +59,11 @@ function ContactForm() {
|
||||
defaultValues: {
|
||||
name: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
message: "",
|
||||
file: undefined,
|
||||
captcha: "",
|
||||
agree: false,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -65,7 +71,31 @@ function ContactForm() {
|
||||
|
||||
const file = watch("file");
|
||||
const fileAttached = !!file && file instanceof File;
|
||||
console.log(file);
|
||||
const agree = watch("agree");
|
||||
|
||||
const handlePhoneChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let value = e.target.value.replace(/\D/g, '');
|
||||
|
||||
if (value.length === 0 || value === '7') {
|
||||
setValue("phone", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.length === 1) {
|
||||
value = `+7 ${value}`;
|
||||
} else if (value.length <= 4) {
|
||||
value = `+7 (${value.slice(1)}`;
|
||||
} else if (value.length <= 7) {
|
||||
value = `+7 (${value.slice(1, 4)}) ${value.slice(4)}`;
|
||||
} else if (value.length <= 9) {
|
||||
value = `+7 (${value.slice(1, 4)}) ${value.slice(4, 7)}-${value.slice(7)}`;
|
||||
} else {
|
||||
value = `+7 (${value.slice(1, 4)}) ${value.slice(4, 7)}-${value.slice(7, 9)}-${value.slice(9, 11)}`;
|
||||
}
|
||||
|
||||
setValue("phone", value, { shouldValidate: true });
|
||||
};
|
||||
|
||||
const handleFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const selectedFile = e.target.files?.[0];
|
||||
setValue("file", selectedFile || undefined, { shouldValidate: true });
|
||||
@@ -87,12 +117,18 @@ function ContactForm() {
|
||||
setValue("captcha", "");
|
||||
}, [setValue]);
|
||||
|
||||
const handleAgreeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setValue("agree", e.target.checked, { shouldValidate: true });
|
||||
};
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
const formData = new FormData();
|
||||
formData.append("name", data.name);
|
||||
formData.append("email", data.email);
|
||||
formData.append("phone", data.phone);
|
||||
formData.append("message", data.message);
|
||||
formData.append("captcha", data.captcha);
|
||||
formData.append("agree", data.agree.toString());
|
||||
|
||||
if (data.file instanceof File) {
|
||||
formData.append("file", data.file);
|
||||
@@ -133,6 +169,16 @@ function ContactForm() {
|
||||
register={register("email")}
|
||||
error={errors.email?.message}
|
||||
/>
|
||||
<Field
|
||||
type="tel"
|
||||
name="phone"
|
||||
placeholder="+7 (___) ___-__-__"
|
||||
disabled={isSubmitting || isPending}
|
||||
register={register("phone", {
|
||||
onChange: handlePhoneChange,
|
||||
})}
|
||||
error={errors.phone?.message}
|
||||
/>
|
||||
<Field
|
||||
type="textarea"
|
||||
name="message"
|
||||
@@ -141,7 +187,6 @@ function ContactForm() {
|
||||
register={register("message")}
|
||||
error={errors.message?.message}
|
||||
/>
|
||||
|
||||
<Field
|
||||
type="file"
|
||||
name="file"
|
||||
@@ -153,12 +198,25 @@ function ContactForm() {
|
||||
})}
|
||||
error={errors.file?.message}
|
||||
/>
|
||||
<div className="checkbox-container">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="agree"
|
||||
disabled={isSubmitting || isPending}
|
||||
{...register("agree")}
|
||||
onChange={handleAgreeChange}
|
||||
/>
|
||||
<label htmlFor="agree">
|
||||
Я согласен с <a href="https://www.study.sfedu.ru/privacypolicy?ysclid=m8anp507sz44008873" target="_blank" rel="noopener noreferrer">обработкой персональных данных</a>
|
||||
</label>
|
||||
{errors.agree && <span className="error-message">{errors.agree.message}</span>}
|
||||
</div>
|
||||
<div className="submit-container">
|
||||
{watch("captcha") ? (
|
||||
<Field
|
||||
type="submit"
|
||||
name="submit"
|
||||
disabled={isSubmitting || isPending}
|
||||
disabled={isSubmitting || isPending || !agree}
|
||||
/>
|
||||
) : (
|
||||
<div className="captcha-container">
|
||||
@@ -175,4 +233,4 @@ function ContactForm() {
|
||||
);
|
||||
}
|
||||
|
||||
export default ContactForm;
|
||||
export default ContactForm;
|
||||
@@ -8,6 +8,7 @@
|
||||
.half {
|
||||
flex: 1 1 50%;
|
||||
width: 100%;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
|
||||
@@ -7,8 +7,8 @@ function ContactUs() {
|
||||
<br />
|
||||
<div className="block" id="contact-us">
|
||||
<h1 className="half">
|
||||
Нужна помощь?
|
||||
<br /> Команда способных IT-специалистов готова вам помочь!
|
||||
Есть вопросы?
|
||||
<br /> Команда способных<br />IT-специалистов готова<br />вам помочь!
|
||||
</h1>
|
||||
<ContactForm />
|
||||
</div>
|
||||
|
||||
@@ -11,130 +11,121 @@
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
transition: transform 0.3s ease-out, height 0.3s ease-out,
|
||||
background-color 0.8s ease-out;
|
||||
transition: transform 0.3s ease-out, height 0.3s ease-out, background-color 0.8s ease-out;
|
||||
|
||||
&.hidden {
|
||||
transform: translateY(-110%); // Убираем navbar вверх
|
||||
transform: translateY(-110%); // Убираем navbar вверх
|
||||
}
|
||||
|
||||
&:not(.hidden) {
|
||||
transform: translateY(0); // Показываем navbar
|
||||
transform: translateY(0); // Показываем navbar
|
||||
}
|
||||
|
||||
&.transparent {
|
||||
background-color: transparent !important;
|
||||
transition: none;
|
||||
background-color: transparent !important;
|
||||
transition: none;
|
||||
|
||||
.bar .nav-link {
|
||||
color: $text-secondary;
|
||||
.bar .nav-link {
|
||||
color: $text-secondary;
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
color: black;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
color: black;
|
||||
.burger .line {
|
||||
background-color: #ffffff;
|
||||
&.open {
|
||||
background-color: #072ac8; // Синий цвет, когда меню открыто
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.burger .line {
|
||||
background-color: #ffffff;
|
||||
|
||||
&.open {
|
||||
background-color: #072ac8; // Синий цвет, когда меню открыто
|
||||
}
|
||||
.logo {
|
||||
filter: brightness(0) invert(1);
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
filter: brightness(0) invert(1);
|
||||
}
|
||||
}
|
||||
|
||||
.nav-link:has(> .logo) {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
|
||||
.logo {
|
||||
width: $navbar-logo-height;
|
||||
height: auto;
|
||||
}
|
||||
.logo {
|
||||
width: $navbar-logo-height;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.nav-link {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
letter-spacing: 0em;
|
||||
padding: 0.25em;
|
||||
margin-left: 40px;
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
.nav-link {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
letter-spacing: 0em;
|
||||
padding: .25em;
|
||||
margin-left: 40px;
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
|
||||
.nav-link::after {
|
||||
background: $text-secondary;
|
||||
}
|
||||
.nav-link::after {
|
||||
background: $text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
// height: $navbar-height;
|
||||
// padding: $navbar-padding-tb 5%;
|
||||
height: $navbar-height;
|
||||
padding: $navbar-padding-tb 5%;
|
||||
|
||||
// .nav-link:has(> .logo) .logo {
|
||||
// width: $navbar-logo-mini-height;
|
||||
// }
|
||||
|
||||
.bar {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background-color: white;
|
||||
width: 50%;
|
||||
height: 200vh;
|
||||
z-index: 9;
|
||||
padding: 60px 0px;
|
||||
|
||||
&.open {
|
||||
display: flex;
|
||||
.nav-link:has(> .logo) .logo {
|
||||
width: $navbar-logo-mini-height;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
padding: 10px 5px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
.bar {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background-color: white;
|
||||
width: 50%;
|
||||
height: 200vh;
|
||||
z-index: 9;
|
||||
padding: 60px 0px;
|
||||
|
||||
.burger {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 10;
|
||||
&.open {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 25px;
|
||||
height: 3px;
|
||||
background-color: #072ac8;
|
||||
margin: 4px 0;
|
||||
transition: all 0.3s ease;
|
||||
.nav-link {
|
||||
padding: 10px 5px;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.burger {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 10;
|
||||
|
||||
.line {
|
||||
width: 25px;
|
||||
height: 3px;
|
||||
background-color: #072ac8;
|
||||
margin: 4px 0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
height: $navbar-height;
|
||||
padding: $navbar-padding-tb 5%;
|
||||
|
||||
.nav-link:has(> .logo) .logo {
|
||||
width: $navbar-logo-mini-height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import NavbarLink from "./NavbarLink";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
import logo from "@/shared/assets/images/sсb_blue.svg";
|
||||
import "./Navbar.styles.scss";
|
||||
@@ -50,6 +51,9 @@ function Navbar({ links = mock }: NavbarProps) {
|
||||
const [navbarHidden, setNavbarHidden] = useState(false); // true = спрятан, false = виден
|
||||
const [lastScrollTop, setLastScrollTop] = useState(0);
|
||||
const THRESHOLD = 400; // navbar не скрывается в первые 400px
|
||||
const [isTransparent, setIsTransparent] = useState(true);
|
||||
const [scrolledOnce, setScrolledOnce] = useState(false);
|
||||
const location = useLocation(); // отслеживаем путь
|
||||
|
||||
const toggleMenu = () => {
|
||||
setIsOpen(!isOpen);
|
||||
@@ -59,6 +63,17 @@ function Navbar({ links = mock }: NavbarProps) {
|
||||
setIsOpen(false); // Закрываем меню при клике на ссылку
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (location.pathname === "/") {
|
||||
setIsTransparent(true);
|
||||
setScrolledOnce(false);
|
||||
window.scrollTo(0, 0);
|
||||
} else {
|
||||
setIsTransparent(false);
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
|
||||
// Для навбара
|
||||
useEffect(() => {
|
||||
const navbar = document.getElementById("navbar");
|
||||
@@ -73,25 +88,43 @@ function Navbar({ links = mock }: NavbarProps) {
|
||||
const handleScroll = () => {
|
||||
const currentScrollTop = window.pageYOffset;
|
||||
|
||||
if (currentScrollTop <= THRESHOLD) {
|
||||
setNavbarHidden(false);
|
||||
} else {
|
||||
if (currentScrollTop > lastScrollTop) {
|
||||
setNavbarHidden(true);
|
||||
} else {
|
||||
if (!isOpen) {
|
||||
if (currentScrollTop <= THRESHOLD) {
|
||||
setNavbarHidden(false);
|
||||
} else {
|
||||
if (currentScrollTop > lastScrollTop) {
|
||||
setNavbarHidden(true);
|
||||
} else {
|
||||
setNavbarHidden(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Прозрачность исчезает при первом скролле на главной
|
||||
if (
|
||||
location.pathname === "/" &&
|
||||
!scrolledOnce &&
|
||||
currentScrollTop > 50
|
||||
) {
|
||||
setIsTransparent(false);
|
||||
setScrolledOnce(true);
|
||||
}
|
||||
|
||||
setLastScrollTop(currentScrollTop);
|
||||
};
|
||||
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
return () => window.removeEventListener("scroll", handleScroll);
|
||||
}, [lastScrollTop]);
|
||||
}, [lastScrollTop, scrolledOnce, location.pathname, isOpen]);
|
||||
|
||||
|
||||
return (
|
||||
<div id="navbar">
|
||||
<div
|
||||
id="navbar"
|
||||
className={`${isTransparent ? "transparent" : ""} ${navbarHidden ? "hidden" : ""
|
||||
}`}
|
||||
>
|
||||
|
||||
<NavbarLink className="logo-container" link={{ to: "/" }}>
|
||||
<img src={logo} className="logo" alt="SCB logo" />
|
||||
</NavbarLink>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#numbers {
|
||||
img {
|
||||
pointer-events: none;
|
||||
}
|
||||
label {
|
||||
font-size: 20px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.blocks {
|
||||
padding: 24px;
|
||||
background-color: #f7f5f5;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.gap01 {
|
||||
gap: 32px;
|
||||
}
|
||||
|
||||
.visible {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.visible {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
label {
|
||||
font-size: 14px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.blocks {
|
||||
padding: 10px;
|
||||
background-color: transparent;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gap01 {
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import "./Numbers.styles.scss";
|
||||
import { ten, twenty, thirty, Illustration } from '../../shared/assets/images/numbers';
|
||||
|
||||
const Numbers = () => {
|
||||
|
||||
return (
|
||||
<div className="block" id="numbers" style={{ marginBottom: "48px" }}>
|
||||
<h2 className="title">СКБ «КИТ» в цифрах"</h2>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "24px" }}>
|
||||
<div className="gap01" style={{ display: "flex", flexDirection: "column" }}>
|
||||
<div className='blocks'>
|
||||
<img src={ten} alt="10" />
|
||||
<label>лет успешной работы</label>
|
||||
</div>
|
||||
<div className='blocks'>
|
||||
<img src={twenty} alt="20+" />
|
||||
<label>сотрудников</label>
|
||||
</div>
|
||||
<div className='blocks'>
|
||||
<img src={thirty} alt="30+" />
|
||||
<label>выполненных проектов</label>
|
||||
</div>
|
||||
</div>
|
||||
<div className="gap01" style={{ display: "flex", flexDirection: "column" }}>
|
||||
<div className='blocks'>
|
||||
<img src={ten} alt="10" />
|
||||
<label>лет успешной работы</label>
|
||||
</div>
|
||||
<div className='blocks'>
|
||||
<img src={twenty} alt="20+" />
|
||||
<label>сотрудников</label>
|
||||
</div>
|
||||
<div className='blocks'>
|
||||
<img src={thirty} alt="30+" />
|
||||
<label>выполненных проектов</label>
|
||||
</div>
|
||||
</div>
|
||||
<img className="visible" src={Illustration} alt="Illustration" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Numbers;
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from './Numbers';
|
||||
@@ -1,5 +1,5 @@
|
||||
$block-height: 150px;
|
||||
$logo-size: 150px;
|
||||
$block-height: 200px;
|
||||
$logo-size: 200px;
|
||||
|
||||
#partners {
|
||||
margin-left: 0;
|
||||
@@ -31,6 +31,11 @@ $logo-size: 150px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.rfm-marquee {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.partner {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Marquee from "react-fast-marquee";
|
||||
|
||||
import PartnersLogo from "./PartnersLogo";
|
||||
import styles from "./Partners.module.scss";
|
||||
import BlockHeading from "@/widgets/BlockHeading";
|
||||
// import BlockHeading from "@/widgets/BlockHeading";
|
||||
|
||||
// Тип для данных партнёра
|
||||
interface Partner {
|
||||
@@ -74,20 +74,28 @@ const mock: Partner[] = [
|
||||
|
||||
function Partners({ partners = mock }: PartnersProps) {
|
||||
const [mediaList, setMediaList] = useState<Partner[]>(partners);
|
||||
|
||||
const updateMediaList = async () => {
|
||||
// Логика для обновления списка медиа
|
||||
// const newMediaList = await getMedia('partners');
|
||||
// setMediaList(newMediaList);
|
||||
};
|
||||
const [play, setPlay] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
updateMediaList();
|
||||
window.addEventListener("resize", updateMediaList);
|
||||
return () => {
|
||||
window.removeEventListener("resize", updateMediaList);
|
||||
const loadData = async () => {
|
||||
try {
|
||||
// Эмуляция загрузки данных
|
||||
// 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();
|
||||
}, [mediaList.length]);
|
||||
|
||||
return (
|
||||
<div className={styles.block} id={styles.partners}>
|
||||
@@ -98,8 +106,10 @@ function Partners({ partners = mock }: PartnersProps) {
|
||||
<Marquee
|
||||
gradient={false}
|
||||
pauseOnHover={false}
|
||||
play={play}
|
||||
speed={80}
|
||||
className={styles.marquee}
|
||||
autoFill={play}
|
||||
>
|
||||
{mediaList.map((item, index) => (
|
||||
<div key={index} className={styles.partner}>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 50vh;
|
||||
height: 48vh;
|
||||
bottom: 10px;
|
||||
|
||||
.slide-image {
|
||||
@@ -16,7 +16,7 @@
|
||||
height: auto;
|
||||
height: 350px;
|
||||
object-fit: cover;
|
||||
object-position: center center;
|
||||
object-position: center center; //
|
||||
border-radius: 8px;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -42,8 +42,20 @@
|
||||
}
|
||||
|
||||
/* стрелки */
|
||||
.swiper-button-prev,
|
||||
.swiper-button-next {
|
||||
/* Кастомные стрелки */
|
||||
.custom-navigation {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 100%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.custom-prev,
|
||||
.custom-next {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: white;
|
||||
@@ -53,27 +65,63 @@
|
||||
align-items: center;
|
||||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
|
||||
cursor: pointer;
|
||||
font-size: 24px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
&::after {
|
||||
font-size: 18px;
|
||||
font-weight: 1000;
|
||||
color: black;
|
||||
.custom-prev {
|
||||
margin-left: -70px;
|
||||
@media (max-width: 768px) {
|
||||
margin-left: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Позиционирование стрелок */
|
||||
.swiper-button-prev {
|
||||
left: 5px;
|
||||
|
||||
.custom-next {
|
||||
margin-right: -70px;
|
||||
@media (max-width: 768px) {
|
||||
left: 0px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-button-next {
|
||||
right: 5px;
|
||||
.slider.news {
|
||||
.swiper-slide {
|
||||
opacity: 0.5;
|
||||
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
|
||||
height: 65vh;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
right: 0px;
|
||||
.slide-image {
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
opacity: 1;
|
||||
transition: none;
|
||||
height: 48vh;
|
||||
.slide-image {
|
||||
height: 350px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-slide-active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&.no-animation .swiper-slide {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.swiper-wrapper:has(.swiper-slide.single) {
|
||||
justify-content: center !important;
|
||||
}
|
||||
.swiper-slide-prev,
|
||||
.swiper-slide-next {
|
||||
opacity: 0.7;
|
||||
transform: scale(0.9);
|
||||
@media (max-width: 768px) {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import { Swiper, SwiperSlide } from "swiper/react";
|
||||
import { Navigation, Pagination } from "swiper/modules";
|
||||
import { Pagination } from "swiper/modules";
|
||||
import { useMedia } from "@/modules/media/hooks/useMedia";
|
||||
|
||||
import "swiper/css";
|
||||
import "swiper/css/navigation";
|
||||
import "swiper/css/pagination";
|
||||
|
||||
import "./Slider.styles.scss";
|
||||
|
||||
import arrow from "../../shared/assets/images/arrow.svg";
|
||||
|
||||
interface SliderProps {
|
||||
autoPlay?: boolean;
|
||||
autoPlayTime?: number;
|
||||
@@ -27,28 +28,25 @@ function Slider({
|
||||
window.innerWidth <= 768 ? 1 : 2
|
||||
);
|
||||
const [enableButtons, setEnableButtons] = useState(false);
|
||||
const swiperRef = useRef<any>(null);
|
||||
|
||||
// Фильтруем медиа по категории
|
||||
const filteredMedia = images
|
||||
? images.map((src, id) => ({ id, src }))
|
||||
: mediaData?.filter((media) => media.category === category) || [];
|
||||
console.log(mediaData);
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setItemsPerSlide(window.innerWidth <= 768 ? 1 : 2);
|
||||
};
|
||||
window.addEventListener("resize", handleResize);
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const numberOfSlides = filteredMedia.length;
|
||||
if (numberOfSlides > 2) {
|
||||
setEnableButtons(true);
|
||||
} else if (numberOfSlides === 1) {
|
||||
setItemsPerSlide(1);
|
||||
}
|
||||
}, [filteredMedia]);
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
setItemsPerSlide(isMobile ? 1 : 2);
|
||||
|
||||
// Показываем стрелки только если слайдов больше 2
|
||||
setEnableButtons(!isMobile && filteredMedia.length > 2);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
handleResize(); // сразу вызываем
|
||||
return () => window.removeEventListener("resize", handleResize);
|
||||
}, [filteredMedia]);
|
||||
|
||||
if (isLoading)
|
||||
return (
|
||||
@@ -60,19 +58,31 @@ function Slider({
|
||||
|
||||
return (
|
||||
<div className="slider">
|
||||
{/* Кастомные стрелки */}
|
||||
{enableButtons && (
|
||||
<div className="custom-navigation">
|
||||
<button className="custom-prev" onClick={() => swiperRef.current?.slidePrev()}>
|
||||
<img src={arrow} alt="prev" />
|
||||
</button>
|
||||
<button className="custom-next" onClick={() => swiperRef.current?.slideNext()}>
|
||||
<img src={arrow} alt="next" style={{ transform: "rotate(180deg)" }} />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Swiper
|
||||
modules={[Navigation, Pagination]}
|
||||
modules={[Pagination]}
|
||||
spaceBetween={20}
|
||||
slidesPerView={itemsPerSlide}
|
||||
slidesPerGroup={1}
|
||||
loop={enableButtons}
|
||||
navigation={enableButtons}
|
||||
pagination={{ clickable: enableButtons }}
|
||||
autoplay={
|
||||
autoPlay
|
||||
? { delay: autoPlayTime, disableOnInteraction: false }
|
||||
: false
|
||||
}
|
||||
onSwiper={(swiper) => (swiperRef.current = swiper)}
|
||||
>
|
||||
{filteredMedia.map((media) => (
|
||||
<SwiperSlide
|
||||
|
||||
Reference in new issue
Block a user