From 73380e0883569e1db132e143e7a3fee5714a352b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Sat, 6 Apr 2024 20:40:38 +0000 Subject: [PATCH] Preview/advisors --- src/api/api.ts | 2 +- src/components/App/index.tsx | 38 +++++++++++++++- src/components/App/styles.css | 9 ++++ src/components/pages/AdvisorChat/index.tsx | 20 ++++++++- .../components/AssistantCard/index.tsx | 2 +- .../AssistantCard/styles.module.css | 3 +- src/components/pages/Advisors/index.tsx | 2 +- .../SuccessPaymentPage/index.tsx | 2 +- src/hooks/useSchemeColorByElement.tsx | 30 +++++++++++++ src/services/color-formatter/index.ts | 44 +++++++++++++++++++ 10 files changed, 143 insertions(+), 9 deletions(-) create mode 100644 src/hooks/useSchemeColorByElement.tsx create mode 100644 src/services/color-formatter/index.ts diff --git a/src/api/api.ts b/src/api/api.ts index 547ea56..435efe1 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -26,7 +26,7 @@ import { AIRequestsV2, Assistants, OpenAI, - SinglePayment + SinglePayment, } from './resources' const api = { diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 7103ae9..32c2b4f 100755 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { Routes, Route, @@ -109,6 +109,7 @@ import AdvisorChatPage from "../pages/AdvisorChat"; import PaymentWithEmailPage from "../pages/PaymentWithEmailPage"; import SuccessPaymentPage from "../pages/PaymentWithEmailPage/ResultPayment/SuccessPaymentPage"; import FailPaymentPage from "../pages/PaymentWithEmailPage/ResultPayment/FailPaymentPage"; +import { useSchemeColorByElement } from "@/hooks/useSchemeColorByElement"; import GetInformationPartnerPage from "../pages/GetInformationPartner"; const isProduction = import.meta.env.MODE === "production"; @@ -228,6 +229,26 @@ function App(): JSX.Element { } }, [dispatch]); + // useEffect(() => { + // const motion = window.matchMedia("(prefers-reduced-motion: no-preference)"); + // if (motion.matches) { + // const scheme = document.querySelector('meta[name="theme-color"]'); + // console.log(document.querySelectorAll("section.page")[0]); + // let hue = 0; + // let color; + // const backgroundColor = + // window.getComputedStyle(document.querySelectorAll("section.page")[0]) + // .backgroundColor || "#ffffff"; + // scheme?.setAttribute("content", backgroundColor); + + // setInterval(() => { + // color = `hsl(${(hue += 5)} 50% 30%)`; + // document.body.style.background = color; + // scheme?.setAttribute("content", color); + // }, 50); + // } + // }, []); + return ( }> @@ -550,6 +571,19 @@ function Layout({ setIsSpecialOfferOpen }: LayoutProps): JSX.Element { const changeIsSpecialOfferOpen = () => setIsSpecialOfferOpen(true); const homeConfig = useSelector(selectors.selectHome); const showNavbarFooter = homeConfig.isShowNavbar; + const mainRef = useRef(null); + // console.log( + // mainRef.current?.querySelectorAll("section.page, .page, section") + // ); + useSchemeColorByElement(mainRef.current, "section.page, .page, section", [ + location, + ]); + // useEffect(() => { + // console.log( + // "###$", + // mainRef.current?.querySelectorAll("section.page, .page, section")[0] + // ); + // }, [location]); const birthdate = useSelector(selectors.selectBirthdate); const dataItems = useMemo(() => [birthdate], [birthdate]); @@ -644,7 +678,7 @@ function Layout({ setIsSpecialOfferOpen }: LayoutProps): JSX.Element { )} -
+
{showFooter ?