From 812cf5d624ddb6826412c8d372070ae8e4ffe8ff Mon Sep 17 00:00:00 2001 From: Kakabay Date: Tue, 7 Mar 2023 15:03:02 +0500 Subject: [PATCH 1/3] Search input lang added --- src/components/header/Search.tsx | 79 +++++++++++--------------------- 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/src/components/header/Search.tsx b/src/components/header/Search.tsx index 8a1488c..1e8a972 100644 --- a/src/components/header/Search.tsx +++ b/src/components/header/Search.tsx @@ -1,21 +1,19 @@ // Modules -import { Dispatch, SetStateAction } from "react"; -import { motion } from "framer-motion"; -import { useSelector, useDispatch } from "react-redux"; -import { useNavigate } from "react-router-dom"; -import { useRef } from "react"; +import { Dispatch, SetStateAction } from 'react'; +import { motion } from 'framer-motion'; +import { useSelector, useDispatch } from 'react-redux'; +import { useNavigate } from 'react-router-dom'; +import { useRef } from 'react'; +import { Api } from '../../api/Api'; // Animations -import { - searchMotion, - searchMobileMotion, -} from "../../animations/search.animation"; +import { searchMotion, searchMobileMotion } from '../../animations/search.animation'; // Types -import { RootState } from "../../types/store.types"; +import { RootState } from '../../types/store.types'; // Actions -import { setSearch } from "../../actions/setSearch"; +import { setSearch } from '../../actions/setSearch'; interface IProps { isSmall: boolean; @@ -24,18 +22,20 @@ interface IProps { } const Search = ({ isSmall, isInputFocused, setIsInputFocused }: IProps) => { + const language = new Api('').language; + const onInputChange = (value: string) => { dispatch(setSearch(value)); }; - const searchValue = useSelector( - (state) => state.search.value + const searchValue = useSelector( + (state) => state.search.value, ); // redux const dispatch = useDispatch(); - const inputValue = useSelector( - (state) => state.search.value + const inputValue = useSelector( + (state) => state.search.value, ); const navigate = useNavigate(); @@ -53,29 +53,25 @@ const Search = ({ isSmall, isInputFocused, setIsInputFocused }: IProps) => { } }} variants={searchMobileMotion} - initial={isSmall ? "borderRest" : {}} - animate={isSmall ? (isInputFocused ? "borderActive" : "borderRest") : {}} - > + initial={isSmall ? 'borderRest' : {}} + animate={isSmall ? (isInputFocused ? 'borderActive' : 'borderRest') : {}}> ) => - onInputChange(event.target.value) - } + onChange={(event: React.ChangeEvent) => onInputChange(event.target.value)} onFocus={() => { setIsInputFocused(true); }} onBlur={() => { setIsInputFocused(false); - onInputChange(""); + onInputChange(''); }} /> 0 ? "active" : "rest"} - variants={searchMotion} - > + initial={'rest'} + animate={inputValue.length > 0 ? 'active' : 'rest'} + variants={searchMotion}> { fill="none" xmlns="http://www.w3.org/2000/svg" variants={searchMobileMotion} - initial={isSmall ? "loopRest" : "loopActive"} - animate={ - isSmall - ? isInputFocused - ? "loopActive" - : "loopRest" - : "loopActive" - } - > + initial={isSmall ? 'loopRest' : 'loopActive'} + animate={isSmall ? (isInputFocused ? 'loopActive' : 'loopRest') : 'loopActive'}> { - + - Search + initial={isSmall ? 'placeholderRest' : {}} + animate={isSmall ? (isInputFocused ? 'placeholderActive' : 'placeholderRest') : {}}> + {language === 'EN' ? 'Search' : language === 'RU' ? 'Искать' : 'Gözle'} From 343b5ab6dc1169f51b573d59a1556f946ea33653 Mon Sep 17 00:00:00 2001 From: Kakabay Date: Tue, 7 Mar 2023 15:15:01 +0500 Subject: [PATCH 2/3] categoryes lang added --- src/components/header/Nav.tsx | 88 ++++++++++++-------------- src/components/header/SubNav.tsx | 65 ++++++++----------- src/components/header/SubNavLiMain.tsx | 42 ++++++------ 3 files changed, 87 insertions(+), 108 deletions(-) diff --git a/src/components/header/Nav.tsx b/src/components/header/Nav.tsx index 0b86a58..3cf2706 100644 --- a/src/components/header/Nav.tsx +++ b/src/components/header/Nav.tsx @@ -1,29 +1,29 @@ // Modules -import { useState } from "react"; -import { Link } from "react-router-dom"; -import { motion } from "framer-motion"; -import { Api } from "../../api/Api"; +import { useState } from 'react'; +import { Link } from 'react-router-dom'; +import { motion } from 'framer-motion'; +import { Api } from '../../api/Api'; // Icons -import { ReactComponent as Logo } from "../../assets/icons/logo.svg"; -import { ReactComponent as Instagram } from "../../assets/icons/insta-black.svg"; -import { ReactComponent as Facebook } from "../../assets/icons/fb-black.svg"; -import { ReactComponent as TikTok } from "../../assets/icons/tiktok-black.svg"; +import { ReactComponent as Logo } from '../../assets/icons/logo.svg'; +import { ReactComponent as Instagram } from '../../assets/icons/insta-black.svg'; +import { ReactComponent as Facebook } from '../../assets/icons/fb-black.svg'; +import { ReactComponent as TikTok } from '../../assets/icons/tiktok-black.svg'; // Components -import Search from "./Search"; -import LanguageSelect from "./LanguageSelect"; +import Search from './Search'; +import LanguageSelect from './LanguageSelect'; // Hooks -import useMediaQuery from "../../hooks/useMediaQuery"; +import useMediaQuery from '../../hooks/useMediaQuery'; // Animation -import { searchMobileMotion } from "../../animations/search.animation"; +import { searchMobileMotion } from '../../animations/search.animation'; const Nav = () => { - const isSmall = useMediaQuery("(max-width: 850px)"); + const isSmall = useMediaQuery('(max-width: 850px)'); const [isInputFocused, setIsInputFocused] = useState(false); - const language = new Api("").language; + const language = new Api('').language; return (