Skip to content
The Chat Archive
o1-mini-2024-09-12· OpenAI WildChat-4.8M (AI2)

так, смотри, мне нужно исправить проблему. при переходе между страницами, к примеру…

  1. User

    так, смотри, мне нужно исправить проблему. при переходе между страницами, к примеру /index и /articles через navbar, у меян есть эффект анимации затухания страницы и затем новая страница появляется. но перед тем, как текущая страница затухает, она поднимается вверх, мне нужно это убрать. т.е. текущая страница должна оставатсья на месте, а новая страница должна появлятсья сверху. где и что нужно изменить.

    // src/pages/_app.tsx

    import React, { useEffect } from 'react'; import Head from 'next/head'; import '@/styles/globals.css'; import { ThemeProvider } from 'next-themes'; import type { AppProps } from 'next/app'; import { Inter } from 'next/font/google'; import Script from 'next/script'; import Layout from '@/components/Layout'; import { useRouter } from 'next/router'; import { AnimatePresence, motion } from 'framer-motion';

    const inter = Inter({ subsets: ['latin'], variable: '--font-inter', });

    export default function App({ Component, pageProps }: AppProps) { const router = useRouter();

    useEffect(() => { if ('scrollRestoration' in window.history) { window.history.scrollRestoration = 'manual'; } }, []);

    const currentPathname = router.pathname;

    return ( <main className={${inter.variable} font-sans relative}> <motion.div key={currentPathname} initial={{ opacity: 0, y: 0 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0 }} transition={{ duration: 0.5, ease: 'easeInOut' }} > <Component {...pageProps} /> </motion.div>

          <Script
            id="lhc-widget-script"
            strategy="afterInteractive"
            dangerouslySetInnerHTML={{
              __html: `
                var LHC_API = LHC_API||{};
                LHC_API.args = {
                  mode: 'widget',
                  lhc_base_url: 'https://xn----7sbabnedajkp5ap8aokkew.xn--p1ai/index.php/',
                  wheight: 450,
                  wwidth: 350,
                  pheight: 520,
                  pwidth: 500,
                  domain: 'xn--80aajcuv3afm.xn--p1ai',
                  leaveamessage: true,
                  department: ["1"],
                  theme: "9",
                  check_messages: false,
                  lang: 'rus/'
                };
                (function() {
                  var po = document.createElement('script');
                  po.type = 'text/javascript';
                  po.setAttribute("crossorigin", "anonymous");
                  po.async = true;
                  var date = new Date();
                  po.src = 'https://xn----7sbabnedajkp5ap8aokkew.xn--p1ai/design/defaulttheme/js/widgetv2/index.js?' + ("" + date.getFullYear() + date.getMonth() + date.getDate());
                  var s = document.getElementsByTagName('script')[0];
                  s.parentNode.insertBefore(po, s);
                })();
              `,
            }}
          />
        </Layout>
      </ThemeProvider>
    </main>
    

    ); }

    // src/components/Articles.tsx

    import React, { useState, useMemo } from "react"; import Image from "next/image"; import Link from "next/link"; import { motion } from "framer-motion"; import { MagnifyingGlassIcon, ChevronDownIcon, } from "@heroicons/react/24/solid";

    const categories = [ { name: "Все", value: "Все" }, { name: "Установка ПО", value: "Установка ПО" }, { name: "Оборудование", value: "Оборудование" }, { name: "Советы", value: "Советы" }, { name: "Общее", value: "Общее" }, { name: "Ошибки", value: "Ошибки" }, ];

    const blogPosts = [ { title: "Как справиться с ошибкой при открытии архива", image: "/images/blog/post1.jpg", excerpt: "Узнайте, как справиться с наиболее частыми ошибками при открытии архивов.", link: "/articles/errors/archive", category: "Ошибки", keywords: ["ошибки архива", "проблемы с архивом", "ошибка открытия архива", "архив"], }, { title: "Инструкция по установке Autocom 2021", image: "/images/blog/post1.jpg", excerpt: "Полноценная, подробная инструкция по установке программного обеспечения.", link: "/articles/software/autocom2021", category: "Установка ПО", keywords: ["установка ПО", "Autocom 2021", "инструкция"], }, ];

    export default function Blog() { const [selectedCategory, setSelectedCategory] = useState("Все"); const [searchTerm, setSearchTerm] = useState(""); const [currentPage, setCurrentPage] = useState(1); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const [isSearchOpen, setIsSearchOpen] = useState(false);

    const postsPerPage = 8;

    const filteredPosts = useMemo(() => { const filteredByCategory = selectedCategory === "Все" ? blogPosts : blogPosts.filter((post) => post.category === selectedCategory); return filteredByCategory.filter( (post) => post.title.toLowerCase().includes(searchTerm.toLowerCase()) || post.excerpt.toLowerCase().includes(searchTerm.toLowerCase()) ); }, [selectedCategory, searchTerm]);

    const paginatedPosts = useMemo(() => { const startIndex = (currentPage - 1) * postsPerPage; return filteredPosts.slice(startIndex, startIndex + postsPerPage); }, [currentPage, filteredPosts]);

    const totalPages = Math.ceil(filteredPosts.length / postsPerPage);

    const handlePageChange = (page: number) => { setCurrentPage(page); };

    return ( {/* Заголовок */} <motion.h2 className="text-4xl font-extrabold text-center text-black dark:text-white" initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.6 }} > Статьи 💻 </motion.h2> <motion.p className="pt-6 text-lg max-w-2xl text-center m-auto text-gray-700 dark:text-gray-300" initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 0.3, duration: 0.6 }} > В этом разделе вы можете найти статьи и решения по программному обеспечению. </motion.p>

      {/* Mobile Menu */}
      <div className="lg:hidden flex flex-col items-center pt-4">
        <motion.div
          className="bg-gray-100 dark:bg-gray-800 p-4 rounded-lg shadow-md w-full max-w-xs"
          layout
        >
          <div className="flex items-center justify-between">
            <motion.button
              className="px-4 py-2 bg-gray-200 dark:bg-gray-700 text-black dark:text-white rounded-full flex items-center justify-between w-full"
              onClick={() => {
                setIsMobileMenuOpen((prev) => !prev);
                if (isSearchOpen) setIsSearchOpen(false);
              }}
              aria-expanded={isMobileMenuOpen}
              aria-label="Выберите категорию"
              whileHover={{ scale: 1.05 }}
              whileTap={{ scale: 0.95 }}
            >
              <span>{selectedCategory}</span>
              <motion.div
                animate={{ rotate: isMobileMenuOpen ? 180 : 0 }}
                transition={{ duration: 0.2 }}
              >
                <ChevronDownIcon className="w-5 h-5" />
              </motion.div>
            </motion.button>
            <motion.button
              className="ml-4 px-4 py-2 bg-gray-200 dark:bg-gray-700 text-black dark:text-white rounded-full shadow"
              onClick={() => {
                setIsSearchOpen((prev) => !prev);
                if (isMobileMenuOpen) setIsMobileMenuOpen(false);
              }}
              aria-label="Поиск"
              whileHover={{ scale: 1.05 }}
              whileTap={{ scale: 0.95 }}
            >
              <MagnifyingGlassIcon className="w-6 h-6" />
            </motion.button>
          </div>
    
          {/* Dropdown */}
          <motion.ul
            className="bg-gray-100 dark:bg-gray-800 rounded-lg overflow-hidden text-center m-0 p-0 list-none"
            initial={false}
            animate={
              isMobileMenuOpen
                ? { opacity: 1, height: "auto", marginTop: "1rem" }
                : { opacity: 0, height: 0, marginTop: 0 }
            }
            transition={{ duration: 0.3 }}
          >
            {categories.map((category, index) => (
              <li
                key={category.value}
                className={`text-black dark:text-white px-4 py-2 leading-tight hover:bg-gray-200 dark:hover:bg-gray-700 cursor-pointer ${
                  index === 0 ? "rounded-t-lg" : ""
                } ${
                  index === categories.length - 1 ? "rounded-b-lg" : ""
                }`}
                onClick={() => {
                  setSelectedCategory(category.value);
                  setIsMobileMenuOpen(false);
                }}
              >
                {category.name}
              </li>
            ))}
          </motion.ul>
    
          {/* Search Bar */}
          <motion.div
            className="overflow-hidden w-full"
            initial={false}
            animate={
              isSearchOpen
                ? { opacity: 1, height: "auto", marginTop: "1rem" }
                : { opacity: 0, height: 0, marginTop: 0 }
            }
            transition={{ duration: 0.3 }}
          >
            <input
              type="text"
              placeholder="Поиск..."
              id="mobile-search"
              value={searchTerm}
              onChange={(e) => {
                setSearchTerm(e.target.value);
                setCurrentPage(1);
              }}
              className="w-full px-4 py-2 border-none focus:outline-none bg-gray-100 dark:bg-gray-700 dark:text-white rounded-lg"
            />
          </motion.div>
        </motion.div>
      </div>
    
      {/* Desktop Filters and Search */}
      <div className="hidden lg:block max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 mt-8">
        <div className="max-w-max mx-auto flex flex-wrap items-center bg-gray-100 dark:bg-gray-800 p-2 rounded-lg shadow space-x-4">
          <div className="flex flex-wrap gap-2">
            {categories.map((category) => (
              <motion.button
                key={category.value}
                onClick={() => {
                  setSelectedCategory(category.value);
                  setCurrentPage(1);
                }}
                className={`px-4 py-2 rounded-full text-sm font-medium transition-colors duration-300 ${
                  selectedCategory === category.value
                    ? "bg-red-500 text-white shadow-lg"
                    : "bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"
                }`}
                whileHover={{ scale: 1.05 }}
                whileTap={{ scale: 0.95 }}
              >
                {category.name}
              </motion.button>
            ))}
          </div>
          <div className="w-full sm:w-auto mt-4 sm:mt-0">
            <input
              type="text"
              placeholder="Поиск..."
              id="desktop-search"
              value={searchTerm}
              onChange={(e) => {
                setSearchTerm(e.target.value);
                setCurrentPage(1);
              }}
              className="w-full sm:w-64 px-4 py-2 border border-gray-300 dark:border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 dark:bg-gray-700 dark:text-white"
            />
          </div>
        </div>
      </div>
    
      {/* Карточки статей */}
      <motion.div
        className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-16 pb-16 grid md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-16"
        initial="hidden"
        animate="visible"
        variants={{
          hidden: {},
          visible: {
            transition: {
              staggerChildren: 0.1,
            },
          },
        }}
      >
        {paginatedPosts.map(({ title, image, excerpt, link }) => (
          <motion.div
            key={title}
            className="relative rounded-2xl p-6 bg-white dark:bg-gray-800 shadow-md hover:shadow-xl transition-shadow duration-300 flex flex-col border border-gray-300 dark:border-gray-700"
            variants={{
              hidden: { opacity: 0, y: 20 },
              visible: { opacity: 1, y: 0 },
            }}
            whileHover={{ scale: 1.02 }}
          >
            {/* Изображение */}
            <Link href={link}>
              <div className="relative h-48 mb-4 rounded-lg overflow-hidden">
                <Image
                  src={image}
                  alt={title}
                  layout="fill"
                  objectFit="cover"
                  className="w-full h-full"
                />
              </div>
            </Link>
    
            {/* Заголовок */}
            <h3 className="text-xl font-extrabold text-black dark:text-white mb-2 line-clamp-3">{title}</h3>
            {/* Описание */}
            <p className="text-gray-700 dark:text-gray-300 flex-grow line-clamp-5 mb-4">{excerpt}</p>
            {/* Кнопка */}
            <Link href={link}>
              <motion.button
                className="w-full px-4 py-2 bg-red-500 text-white rounded-lg shadow hover:bg-red-600 transition-colors duration-300"
                whileHover={{ scale: 1.05 }}
                whileTap={{ scale: 0.95 }}
              >
                Читать далее
              </motion.button>
            </Link>
          </motion.div>
        ))}
      </motion.div>
    
      {/* Пагинация */}
      {totalPages > 1 && (
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-16 flex justify-center items-center space-x-2">
          <button
            onClick={() => handlePageChange(currentPage - 1)}
            disabled={currentPage === 1}
            className={`px-3 py-1 rounded-md text-sm font-medium ${
              currentPage === 1
                ? "bg-gray-300 text-gray-500 cursor-not-allowed"
                : "bg-red-500 text-white hover:bg-red-600"
            } transition-colors duration-300`}
          >
            Предыдущая
          </button>
          {Array.from({ length: totalPages }, (_, index) => index + 1).map((number) => (
            <button
              key={number}
              onClick={() => handlePageChange(number)}
              className={`px-3 py-1 rounded-md text-sm font-medium ${
                currentPage === number
                  ? "bg-red-600 text-white"
                  : "bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600"
              } transition-colors duration-300`}
            >
              {number}
            </button>
          ))}
          <button
            onClick={() => handlePageChange(currentPage + 1)}
            disabled={currentPage === totalPages}
            className={`px-3 py-1 rounded-md text-sm font-medium ${
              currentPage === totalPages
                ? "bg-gray-300 text-gray-500 cursor-not-allowed"
                : "bg-red-500 text-white hover:bg-red-600"
            } transition-colors duration-300`}
          >
            Следующая
          </button>
        </div>
      )}
    </div>
    

    ); }

    // src/components/Hero.tsx

    import { FC } from "react"; import Image from "next/image"; import Link from "next/link";

    export const Hero: FC = () => { return ( Добро пожаловать в SmartDiag 👋

          <p className="text-base sm:text-lg dark:text-neutral-400 mx-auto lg:mx-0">
            Здесь вы найдёте всё необходимое программное обеспечение для
            диагностики и обслуживания вашего автомобиля. Мы предлагаем
            высококачественное и надёжное оборудование, которое поможет вам
            быстро и эффективно провести анализ и ремонт вашего авто. Мы уверены,
            что техническое обслуживание автомобиля может быть простым и
            доступным для каждого.
          </p>
    
          <div className="flex flex-col items-center gap-4 mb-6 sm:flex-row sm:justify-center lg:justify-start">
            <div className="bg-gradient-to-r from-[#ff4b2b] to-[#ff416c] text-white rounded-full py-3 px-6 text-base font-medium items-center group shadow-lg transform transition-transform duration-300 mx-auto sm:mx-0 inline-block hover:scale-105">
              <Link href="/soft" className="flex items-center whitespace-nowrap">
                Программы для приборов
                <svg
                  className="w-5 h-5 ml-2 transform group-hover:rotate-180 transition-transform duration-1000"
                  xmlns="http://www.w3.org/2000/svg"
                  fill="currentColor"
                  viewBox="0 0 32 32"
                >
                  <path d="M29 11.756h-1.526c-0.109-0.295-0.229-0.584-0.361-0.87l1.087-1.076c0.441-0.389 0.717-0.956 0.717-1.587 0-0.545-0.206-1.042-0.545-1.417l0.002 0.002-3.178-3.178c-0.373-0.338-0.87-0.544-1.415-0.544-0.632 0-1.199 0.278-1.587 0.718l-0.002 0.002-1.081 1.080c-0.285-0.131-0.573-0.251-0.868-0.36l0.008-1.526c0.003-0.042 0.005-0.091 0.005-0.141 0-1.128-0.884-2.049-1.997-2.109l-0.005-0h-4.496c-1.119 0.059-2.004 0.981-2.004 2.11 0 0.049 0.002 0.098 0.005 0.147l-0-0.007v1.524c-0.295 0.109-0.584 0.229-0.87 0.361l-1.074-1.084c-0.389-0.443-0.957-0.722-1.589-0.722-0.545 0-1.042 0.206-1.416 0.545l0.002-0.002-3.179 3.179c-0.338 0.373-0.544 0.87-0.544 1.415 0 0.633 0.278 1.2 0.719 1.587l0.002 0.002 1.078 1.079c-0.132 0.287-0.252 0.576-0.362 0.872l-1.525-0.007c-0.042-0.003-0.091-0.005-0.14-0.005-1.128 0-2.050 0.885-2.11 1.998l-0 0.005v4.495c0.059 1.119 0.982 2.005 2.111 2.005 0.049 0 0.098-0.002 0.146-0.005l-0.007 0h1.525c0.109 0.295 0.229 0.584 0.361 0.87l-1.084 1.071c-0.443 0.39-0.721 0.958-0.721 1.592 0 0.545 0.206 1.043 0.545 1.418l-0.002-0.002 3.179 3.178c0.339 0.337 0.806 0.545 1.322 0.545 0.007 0 0.014-0 0.021-0h-0.001c0.653-0.013 1.24-0.287 1.662-0.722l0.001-0.001 1.079-1.079c0.287 0.132 0.577 0.252 0.873 0.362l-0.007 1.524c-0.003 0.042-0.005 0.091-0.005 0.14 0 1.128 0.885 2.050 1.998 2.11l0.005 0h4.496c1.118-0.060 2.003-0.981 2.003-2.109 0-0.050-0.002-0.099-0.005-0.147l0 0.007v-1.526c0.296-0.11 0.585-0.23 0.872-0.362l1.069 1.079c0.423 0.435 1.009 0.709 1.66 0.723l0.002 0h0.002c0.006 0 0.014 0 0.021 0 0.515 0 0.982-0.207 1.323-0.541l3.177-3.177c0.335-0.339 0.541-0.805 0.541-1.32 0-0.009-0-0.018-0-0.028l0 0.001c-0.013-0.651-0.285-1.236-0.718-1.658l-0.001-0-1.080-1.081c0.131-0.285 0.251-0.573 0.36-0.868l1.525 0.007c0.042 0.003 0.090 0.005 0.139 0.005 1.129 0 2.051-0.885 2.11-1.999l0-0.005v-4.495c-0.060-1.119-0.981-2.004-2.11-2.004-0.049 0-0.098 0.002-0.147 0.005l0.007-0zM28.75 17.749l-2.162-0.011c-0.026 0-0.048 0.013-0.074 0.015-0.093 0.009-0.179 0.026-0.261 0.053l0.008-0.002c-0.31 0.068-0.565 0.263-0.711 0.527l-0.003 0.005c-0.048 0.071-0.091 0.152-0.124 0.238l-0.003 0.008c-0.008 0.024-0.027 0.041-0.034 0.066-0.23 0.804-0.527 1.503-0.898 2.155l0.025-0.048c-0.014 0.025-0.013 0.054-0.026 0.080-0.029 0.063-0.053 0.138-0.071 0.215l-0.001 0.008c-0.023 0.072-0.040 0.156-0.048 0.242l-0 0.005c-0.002 0.027-0.004 0.058-0.004 0.089 0 0.209 0.061 0.404 0.166 0.568l-0.003-0.004c0.045 0.088 0.096 0.163 0.154 0.232l-0.001-0.002c0.017 0.019 0.022 0.043 0.040 0.061l1.529 1.531-2.469 2.467-1.516-1.529c-0.020-0.021-0.048-0.027-0.069-0.046-0.060-0.050-0.128-0.096-0.2-0.135l-0.006-0.003c-0.195-0.109-0.429-0.173-0.677-0.173-0.002 0-0.004 0-0.006 0h0c-0.076 0.008-0.145 0.022-0.211 0.040l0.009-0.002c-0.102 0.020-0.192 0.050-0.276 0.089l0.007-0.003c-0.022 0.011-0.047 0.010-0.069 0.022-0.606 0.346-1.307 0.644-2.043 0.859l-0.070 0.017c-0.027 0.008-0.045 0.027-0.071 0.037-0.084 0.033-0.157 0.071-0.224 0.116l0.004-0.003c-0.075 0.041-0.139 0.085-0.199 0.135l0.002-0.002c-0.053 0.052-0.102 0.11-0.145 0.171l-0.003 0.004c-0.103 0.113-0.176 0.254-0.206 0.411l-0.001 0.005c-0.024 0.074-0.043 0.16-0.051 0.249l-0 0.005c-0.002 0.026-0.015 0.048-0.015 0.075l-0.001 2.162h-3.491l0.011-2.156c0-0.028-0.014-0.052-0.016-0.079-0.008-0.092-0.026-0.177-0.052-0.258l0.002 0.008c-0.068-0.313-0.265-0.57-0.531-0.717l-0.006-0.003c-0.070-0.047-0.15-0.089-0.235-0.122l-0.008-0.003c-0.024-0.008-0.042-0.027-0.067-0.034-0.806-0.23-1.507-0.528-2.161-0.9l0.048 0.025c-0.023-0.013-0.050-0.012-0.073-0.023-0.072-0.033-0.156-0.061-0.244-0.079l-0.008-0.001c-0.092-0.029-0.198-0.045-0.308-0.045-0.221 0-0.426 0.066-0.597 0.18l0.004-0.002c-0.076 0.040-0.141 0.084-0.201 0.134l0.002-0.002c-0.021 0.019-0.048 0.025-0.068 0.045l-1.529 1.529-2.47-2.469 1.532-1.516c0.020-0.020 0.027-0.047 0.045-0.067 0.053-0.063 0.101-0.134 0.142-0.209l0.003-0.006c0.037-0.058 0.071-0.124 0.099-0.194l0.003-0.008c0.038-0.14 0.062-0.301 0.066-0.467l0-0.003c-0.008-0.083-0.023-0.158-0.044-0.231l0.002 0.009c-0.020-0.094-0.047-0.177-0.083-0.255l0.003 0.007c-0.012-0.025-0.011-0.052-0.025-0.076-0.347-0.605-0.645-1.305-0.858-2.041l-0.017-0.068c-0.007-0.026-0.027-0.045-0.036-0.070-0.034-0.086-0.072-0.16-0.118-0.228l0.003 0.005c-0.040-0.074-0.084-0.138-0.133-0.197l0.002 0.002c-0.052-0.053-0.109-0.101-0.169-0.144l-0.004-0.003c-0.060-0.051-0.128-0.097-0.2-0.136l-0.006-0.003c-0.057-0.026-0.126-0.049-0.196-0.066l-0.008-0.002c-0.077-0.026-0.167-0.045-0.259-0.053l-0.005-0c-0.026-0.002-0.047-0.015-0.073-0.015l-2.162-0.001v-3.492l2.162 0.011c0.16-0.002 0.311-0.035 0.45-0.092l-0.008 0.003c0.054-0.024 0.099-0.048 0.142-0.075l-0.005 0.003c0.090-0.047 0.168-0.1 0.239-0.16l-0.002 0.001c0.043-0.039 0.082-0.079 0.118-0.122l0.002-0.002c0.056-0.065 0.106-0.138 0.147-0.215l0.003-0.007c0.027-0.047 0.054-0.102 0.076-0.159l0.003-0.008c0.010-0.028 0.029-0.050 0.037-0.078 0.23-0.805 0.527-1.506 0.899-2.159l-0.025 0.048c0.014-0.024 0.013-0.052 0.025-0.076 0.031-0.067 0.057-0.147 0.075-0.229l0.001-0.008c0.020-0.086 0.032-0.185 0.032-0.287 0-0.317-0.113-0.607-0.3-0.834l0.002 0.002c-0.017-0.020-0.023-0.045-0.042-0.063l-1.527-1.529 2.469-2.469 1.518 1.531c0.055 0.045 0.116 0.087 0.180 0.122l0.006 0.003c0.042 0.033 0.089 0.065 0.138 0.094l0.006 0.003c0.160 0.088 0.350 0.142 0.551 0.148l0.002 0 0.005 0.001c0.012 0 0.023-0.009 0.034-0.009 0.186-0.008 0.359-0.056 0.513-0.135l-0.007 0.003c0.022-0.011 0.047-0.006 0.070-0.018 0.605-0.346 1.305-0.645 2.041-0.858l0.069-0.017c0.025-0.007 0.042-0.026 0.066-0.034 0.084-0.033 0.163-0.076 0.236-0.125l-0.004 0.003c0.069-0.038 0.128-0.079 0.183-0.124l-0.002 0.002c0.058-0.056 0.110-0.117 0.156-0.183l0.003-0.004c0.046-0.056 0.089-0.119 0.126-0.185l0.003-0.006c0.028-0.062 0.053-0.135 0.070-0.210l0.002-0.008c0.024-0.073 0.042-0.158 0.050-0.247l0-0.005c0.002-0.027 0.015-0.049 0.015-0.076l0.001-2.162h3.491l-0.011 2.156c0-0.028 0.014-0.051 0.015-0.079 0.008-0.093 0.026-0.178 0.052-0.260l-0.002 0.008c0.019-0.084 0.044-0.157 0.075-0.227l-0.003 0.008c0.040 0.073 0.082 0.136 0.130 0.194l-0.002-0.002c0.048 0.070 0.101 0.131 0.158 0.187l0 0c0.053 0.044 0.112 0.084 0.174 0.120l0.006 0.003c0.068 0.046 0.147 0.087 0.230 0.119l0.008 0.003c0.025 0.009 0.043 0.028 0.069 0.035 0.804 0.229 1.503 0.527 2.155 0.899l-0.047-0.025c0.022 0.012 0.046 0.007 0.068 0.018 0.147 0.076 0.320 0.124 0.503 0.132l0.003 0c0.012 0 0.024 0.009 0.036 0.009l0.028-0.008c0.193-0.008 0.372-0.059 0.531-0.143l-0.007 0.003c0.059-0.033 0.109-0.066 0.156-0.104l-0.003 0.002c0.068-0.037 0.127-0.076 0.181-0.120l-0.002 0.002 1.531-1.528 2.469 2.470-1.531 1.516c-0.020 0.020-0.027 0.047-0.046 0.068-0.053 0.063-0.101 0.134-0.142 0.209l0.003 0.006c-0.084 0.123-0.138 0.272-0.148 0.434l-0 0.002c-0.013 0.056-0.020 0.121-0.020 0.187 0 0.097 0.016 0.190 0.045 0.277l-0.002-0.006c0.020 0.094 0.047 0.176 0.083 0.254l-0.003-0.007c0.012 0.025 0.011 0.053 0.025 0.078 0.347 0.604 0.645 1.303 0.858 2.038l0.017 0.068c0.008 0.030 0.028 0.052 0.038 0.080 0.024 0.062 0.049 0.113 0.077 0.163l-0.003-0.006c0.211 0.397 0.619 0.665 1.090 0.674l0.001 0 2.162 0.001zM16 10.75c-2.899 0-5.25 2.351-5.25 5.25s2.351 5.25 5.25 5.25c2.899 0 5.25-2.351 5.25-5.25v0c-0.004-2.898-2.352-5.246-5.25-5.25h-0zM16 18.75c-1.519 0-2.75-1.231-2.75-2.75s1.231-2.75 2.75-2.75c1.519 0 2.75 1.231 2.75 2.75v0c-0.002 1.518-1.232 2.748-2.75 2.75h-0z"></path>
                </svg>
              </Link>
            </div>
    
            <div className="bg-black text-white rounded-full py-3 px-6 text-base font-medium items-center group shadow-lg transform transition-transform duration-300 hover:scale-105 hover:bg-gray-800 hover:bg-opacity-90 mx-auto sm:mx-0 inline-block">
              <Link href="/contact" className="flex items-center whitespace-nowrap">
                Обратная связь
              </Link>
            </div>
          </div>
        </div>
    
        <div className="hidden lg:flex items-center justify-center lg:w-1/2">
          <Image
            src="/images/hero/hero.svg"
            alt="Иллюстрация, представляющая диагностику автомобиля"
            title="Диагностическое оборудование для вашего автомобиля"
            width={512}
            height={331}
            quality={75}
            sizes="100vw"
            priority
            className="w-full h-auto"
          />
        </div>
      </div>
    </section>
    

    ); };

    // src/pages/articles.tsx

    import Head from "next/head"; import Articles from "../components/Articles";

    const ArticlesPage: React.FC = () => { return ( <> {/* Мета-теги для SEO /} Статьи - SmartDiag {/ Дополнительные мета-теги можно добавить по необходимости */}

      {/* Компонент Статей */}
      <Articles />
    </>
    

    ); };

    export default ArticlesPage;

    // src/pages/index.tsx

    import { Hero } from "../components/Hero"; import Head from "next/head";

    export default function Home() { return ( <> {/* Мета-теги для поисковых систем */} SmartDiag - Ваш проводник в мире автодиагностики

      {/* Компоненты страницы */}
      <Hero />
    </>
    

    ); }

  2. Assistant

    Понимаю вашу задачу. Вы хотите, чтобы при переходе между страницами текущая страница просто затухала без перемещения вверх, а новая страница появлялась сверху. Для достижения этого необходимо внести некоторые изменения в анимации, определённые в вашем файле src/pages/_app.tsx.

    Причина проблемы

    В текущей конфигурации анимации framer-motion в вашем motion.div реализовано следующее:

    <motion.div
      key={currentPathname}
      initial={{ opacity: 0, y: 0 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0 }}
      transition={{ duration: 0.5, ease: 'easeInOut' }}
    >
      <Component {...pageProps} />
    </motion.div>
    

    Проблема заключается в том, что при выходе (exit) анимации не была явно определена позиция по y. Это может привести к непредсказуемым видам анимации, включая нежелательное движение вверх.

    Решение

    Чтобы предотвратить перемещение текущей страницы вверх при её выходе, нужно явно задать значение y: 0 в анимации выхода (exit). Кроме того, для создания эффекта появления новой страницы сверху, можно задать исходное положение (initial) новой страницы с небольшим смещением по y.

    Вот как можно изменить ваш код:

    1. Обновите анимации в motion.div в файле src/pages/_app.tsx:
    // src/pages/_app.tsx
    
    import React, { useEffect } from 'react';
    import Head from 'next/head';
    import '@/styles/globals.css';
    import { ThemeProvider } from 'next-themes';
    import type { AppProps } from 'next/app';
    import { Inter } from 'next/font/google';
    import Script from 'next/script';
    import Layout from '@/components/Layout';
    import { useRouter } from 'next/router';
    import { AnimatePresence, motion } from 'framer-motion';
    
    const inter = Inter({
      subsets: ['latin'],
      variable: '--font-inter',
    });
    
    export default function App({ Component, pageProps }: AppProps) {
      const router = useRouter();
    
      useEffect(() => {
        if ('scrollRestoration' in window.history) {
          window.history.scrollRestoration = 'manual';
        }
      }, []);
    
      const currentPathname = router.pathname;
    
      return (
        <main className={`${inter.variable} font-sans relative`}>
          <Head>
            <meta name="viewport" content="width=device-width, initial-scale=1" />
          </Head>
          <ThemeProvider attribute="class">
            <Layout>
              <AnimatePresence mode="wait" initial={false}>
                <motion.div
                  key={currentPathname}
                  initial={{ opacity: 0, y: 50 }}    // Начальное положение новой страницы выше
                  animate={{ opacity: 1, y: 0 }}
                  exit={{ opacity: 0, y: 0 }}         // Текущая страница просто затухает без смещения
                  transition={{ duration: 0.5, ease: 'easeInOut' }}
                >
                  <Component {...pageProps} />
                </motion.div>
              </AnimatePresence>
    
              <Script
                id="lhc-widget-script"
                strategy="afterInteractive"
                dangerouslySetInnerHTML={{
                  __html: `
                    // Ваш скрипт
                  `,
                }}
              />
            </Layout>
          </ThemeProvider>
        </main>
      );
    }
    

    Объяснение изменений:

    1. initial: Мы задали y: 50, чтобы новая страница начинала анимацию немного выше и перемещалась вниз к своему нормальному положению. Это создаст эффект появления страницы сверху.

    2. exit: Добавили y: 0, чтобы текущая страница при выходе не перемещалась по вертикали, а только затухала.

    3. AnimatePresence: Добавили initial={false}, чтобы предотвратить анимацию при первоначальной загрузке страницы.

    Дополнительные рекомендации

    • Проверка дочерних компонентов: Убедитесь, что внутри ваших страниц (например, в Articles.tsx или Hero.tsx) нет дополнительных анимаций, которые могут влиять на общую анимацию страницы. Если есть, убедитесь, что они не добавляют ненужных смещений по y.

    • Использование вариаций: Для более сложных анимаций вы можете использовать variants и управлять ими централизованно, чтобы избежать конфликтов между анимациями родительских и дочерних компонентов.

    Пример с использованием variants

    Если вы хотите более гибко управлять анимациями, можно использовать variants. Вот пример, как это можно сделать:

    // src/pages/_app.tsx
    
    const pageVariants = {
      initial: {
        opacity: 0,
        y: 50,
      },
      animate: {
        opacity: 1,
        y: 0,
      },
      exit: {
        opacity: 0,
        y: 0,
      },
    };
    
    export default function App({ Component, pageProps }: AppProps) {
      // ... остальной код
    
      return (
        // ... остальной код
        <AnimatePresence mode="wait" initial={false}>
          <motion.div
            key={currentPathname}
            variants={pageVariants}
            initial="initial"
            animate="animate"
            exit="exit"
            transition={{ duration: 0.5, ease: 'easeInOut' }}
          >
            <Component {...pageProps} />
          </motion.div>
        </AnimatePresence>
        // ... остальной код
      );
    }
    

    Этот подход позволяет централизованно управлять анимациями и делает код более читаемым и поддерживаемым.

    Заключение

    Внесенные изменения позволят текущей странице просто затухать без перемещения, а новая страница будет плавно появляться снизу. Это создаст более плавный и предсказуемый эффект перехода между страницами.

    Если после этих изменений проблема сохраняется, убедитесь, что другие части вашего кода (например, анимации внутри страниц) не влияют на общее поведение. При необходимости предоставьте дополнительную информацию или примеры, и я помогу вам более детально разобраться.