From c7d13cc7f87fd44b9b0261124b4b0b86b98edb68 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 20 Dec 2024 14:54:57 +0300 Subject: [PATCH 1/9] feat: add StartPageMobile --- components/StartPage/StartPage.js | 208 ------------ components/StartPage/StartPageMobile.js | 415 ++++++++++++++++++++++++ pages/[slug].js | 6 +- pages/index.js | 6 +- 4 files changed, 425 insertions(+), 210 deletions(-) create mode 100644 components/StartPage/StartPageMobile.js diff --git a/components/StartPage/StartPage.js b/components/StartPage/StartPage.js index 425bbb34..56cd49fd 100644 --- a/components/StartPage/StartPage.js +++ b/components/StartPage/StartPage.js @@ -19,8 +19,6 @@ import Logo from './Logo' import Partners from './Partners' import PasswordRecovery from './PasswordRecovery' import Reviews from './Reviews' -import SectionBlock from './SectionBlock' -import SectionContainer from './SectionContainer' import Close from 'public/icons/close.svg' import LevelLogo from 'public/icons/level-logo-color.svg' @@ -43,66 +41,12 @@ function StartPage({ defaultContentKey = null }) { const router = useRouter() const [contentKey, setContentKey] = useState(defaultContentKey) - const [showSections, setShowSections] = useState({ - logo: false, - updates: false, - partners: false, - connect: false, - signIn: false, - download: false, - passwordRecovery: false, - }) - - const [blocks, setBlocks] = useState({ - intro: { clicked: false, opacity: 'opacity-0' }, - howItWork: { clicked: false, opacity: 'opacity-0' }, - reviews: { clicked: false, opacity: 'opacity-0' }, - faq: { clicked: false, opacity: 'opacity-0' }, - }) - - useEffect(() => { - if (defaultContentKey) { - setShowSections((prev) => ({ - ...prev, - [defaultContentKey]: true, - })) - } - }, [defaultContentKey]) - - const toggleSection = (section) => { - setShowSections((prev) => { - const isCurrentlyVisible = prev[section] - return { - logo: false, - updates: false, - partners: false, - connect: false, - signIn: false, - download: false, - passwordRecovery: false, - [section]: !isCurrentlyVisible, - } - }) - } - useEffect(() => { if (defaultContentKey) { setContentKey(defaultContentKey) } }, [defaultContentKey]) - useEffect(() => { - if (defaultContentKey) { - setBlocks((prev) => ({ - ...prev, - [defaultContentKey]: { - clicked: true, - opacity: 'opacity-100', - }, - })) - } - }, [defaultContentKey]) - const handleContentClick = async (newContentKey) => { if (defaultContentKey) { await router.replace('/', undefined, { shallow: true, scroll: false }) @@ -256,158 +200,6 @@ function StartPage({ defaultContentKey = null }) { -
-
router.replace(mainLink)}> - } - showSection={showSections.logo} - toggleSection={toggleSection} - isLogo={true} - label={} - /> -
-
- {!showSections.signIn && ( -
- -
- )} -
{ - e.preventDefault() - router.push(`/${contentRoutes['signIn']}`) - }} - className={`cursor-pointer rounded-xl p-5 ${ - showSections.signIn - ? 'col-span-2 bg-th-secondary-10' - : 'bg-slate-550 text-th-text-secondary-100' - }`} - > -

- {showSections.signIn ? t('users:LoginToAccount') : t('users:SignIn')} -

- {showSections.signIn && ( - { - toggleSection( - showSections.signIn && showSections.connect ? 'signIn' : 'connect' - ) - }} - /> - )} -
-
- -
handleContentClick('intro')} - > -
-
- {blocks.intro.clicked ? ( - - ) : ( -

- )} -
-
-
handleContentClick('howItWork')} - > -
-
- {blocks.howItWork.clicked ? ( - - ) : ( -

{t('MainBlocks.HowItWorks')}

- )} -
-
-
handleContentClick('reviews')} - > -
-
- {blocks.reviews.clicked ? ( - - ) : ( -

{t('MainBlocks.Reviews')}

- )} -
-
-
handleContentClick('faq')} - > -
-
- {blocks.faq.clicked ? ( - - ) : ( -

{t('FAQ')}

- )} -
-
- - } - showSection={showSections.partners} - toggleSection={toggleSection} - /> - - - toggleSection('feedback')} />} - showSection={showSections.connect} - toggleSection={toggleSection} - /> - - - -
- -
-
) } diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js new file mode 100644 index 00000000..11b0754a --- /dev/null +++ b/components/StartPage/StartPageMobile.js @@ -0,0 +1,415 @@ +import { useEffect, useState } from 'react' + +import Link from 'next/link' +import { useRouter } from 'next/router' + +import { useTranslation } from 'next-i18next' + +import AboutVersion from 'components/AboutVersion' +import SwitchLocalization from 'components/SwitchLocalization' + +import CookiesAproove from './CookiesAproove' +import Download from './Download' +import Feedback from './Feedback' +import FrequentlyAskedQuestions from './FrequentlyAskedQuestions' +import HowItWorks from './HowItWorks' +import LevelIntro from './LevelIntro' +import Login from './Login' +import Logo from './Logo' +import Partners from './Partners' +import PasswordRecovery from './PasswordRecovery' +import Reviews from './Reviews' +import SectionBlock from './SectionBlock' +import SectionContainer from './SectionContainer' + +import Close from 'public/icons/close.svg' +import LevelLogo from 'public/icons/level-logo-color.svg' + +const contentRoutes = { + signIn: 'sign-in', + connect: 'connect-with-us', + updates: 'updates', + partners: 'partners', + intro: 'what-is-level', + reviews: 'reviews', + howItWork: 'how-it-works', + faq: 'faq', + download: 'download', + logo: 'about', +} + +function StartPageMobile({ defaultContentKey = null }) { + const { t } = useTranslation(['start-page', 'projects', 'users', 'common']) + const router = useRouter() + const [contentKey, setContentKey] = useState(defaultContentKey) + + const [showSections, setShowSections] = useState({ + logo: false, + updates: false, + partners: false, + connect: false, + signIn: false, + download: false, + passwordRecovery: false, + }) + + const [blocks, setBlocks] = useState({ + intro: { clicked: false, opacity: 'opacity-0' }, + howItWork: { clicked: false, opacity: 'opacity-0' }, + reviews: { clicked: false, opacity: 'opacity-0' }, + faq: { clicked: false, opacity: 'opacity-0' }, + }) + + useEffect(() => { + if (defaultContentKey) { + setShowSections((prev) => ({ + ...prev, + [defaultContentKey]: true, + })) + } + }, [defaultContentKey]) + + const toggleSection = (section) => { + setShowSections((prev) => { + const isCurrentlyVisible = prev[section] + return { + logo: false, + updates: false, + partners: false, + connect: false, + signIn: false, + download: false, + passwordRecovery: false, + [section]: !isCurrentlyVisible, + } + }) + } + + useEffect(() => { + if (defaultContentKey) { + setContentKey(defaultContentKey) + } + }, [defaultContentKey]) + + useEffect(() => { + if (defaultContentKey) { + setBlocks((prev) => ({ + ...prev, + [defaultContentKey]: { + clicked: true, + opacity: 'opacity-100', + }, + })) + } + }, [defaultContentKey]) + + const handleContentClick = async (newContentKey) => { + if (defaultContentKey) { + await router.replace('/', undefined, { shallow: true, scroll: false }) + } + if (contentKey === newContentKey) { + setContentKey(null) + } else { + setContentKey(newContentKey) + handleClick(newContentKey) + } + } + + const contentObjects = { + signIn: handleContentClick('connect')} />, + connect: setContentKey(null)} />, + updates: , + partners: , + intro: , + reviews: , + howItWork: , + faq: , + download: , + logo: , + passwordRecovery: , + } + const handleClick = (contentKey) => { + if (contentKey && contentRoutes[contentKey]) { + router.replace(`/${contentRoutes[contentKey]}`, undefined, { + shallow: true, + scroll: false, + }) + } + } + const mainLink = router.pathname === '/' ? `/${contentRoutes['logo']}` : '/' + return ( + <> +
+ + +
+
+
+ + {t('MainBlocks.WhatIsLevel')} + + + {t('MainBlocks.Reviews')} + +
+
+ + {t('MainBlocks.HowItWorks')} + + + + {t('MainBlocks.FAQ')} + +
+
+
+ {contentObjects[contentKey]} + { + setContentKey(null) + if (defaultContentKey) { + router.replace('/', undefined, { shallow: true }) + } + }} + /> +
+
+ + +
+ +
+
+
+
router.replace(mainLink)}> + } + showSection={showSections.logo} + toggleSection={toggleSection} + isLogo={true} + label={} + /> +
+
+ {!showSections.signIn && ( +
+ +
+ )} +
{ + e.preventDefault() + router.push(`/${contentRoutes['signIn']}`) + }} + className={`cursor-pointer rounded-xl p-5 ${ + showSections.signIn + ? 'col-span-2 bg-th-secondary-10' + : 'bg-slate-550 text-th-text-secondary-100' + }`} + > +

+ {showSections.signIn ? t('users:LoginToAccount') : t('users:SignIn')} +

+ {showSections.signIn && ( + { + toggleSection( + showSections.signIn && showSections.connect ? 'signIn' : 'connect' + ) + }} + /> + )} +
+
+ +
handleContentClick('intro')} + > +
+
+ {blocks.intro.clicked ? ( + + ) : ( +

+ )} +
+
+
handleContentClick('howItWork')} + > +
+
+ {blocks.howItWork.clicked ? ( + + ) : ( +

{t('MainBlocks.HowItWorks')}

+ )} +
+
+
handleContentClick('reviews')} + > +
+
+ {blocks.reviews.clicked ? ( + + ) : ( +

{t('MainBlocks.Reviews')}

+ )} +
+
+
handleContentClick('faq')} + > +
+
+ {blocks.faq.clicked ? ( + + ) : ( +

{t('FAQ')}

+ )} +
+
+ + } + showSection={showSections.partners} + toggleSection={toggleSection} + /> + + + toggleSection('feedback')} />} + showSection={showSections.connect} + toggleSection={toggleSection} + /> + + + +
+ +
+
+ + ) +} + +export default StartPageMobile diff --git a/pages/[slug].js b/pages/[slug].js index b2cbfa70..c45411b4 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next' import HiscoderLink from 'components/StartPage/HiscoderLink' import StartPage from 'components/StartPage/StartPage' +import StartPageMobile from 'components/StartPage/StartPageMobile' import { urlGlobal } from 'utils/openGraph' @@ -115,9 +116,12 @@ const SlugPage = () => { -
+
+
+ +
) diff --git a/pages/index.js b/pages/index.js index e2d1fb38..9fc085d6 100644 --- a/pages/index.js +++ b/pages/index.js @@ -5,6 +5,7 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import HiscoderLink from 'components/StartPage/HiscoderLink' import StartPage from 'components/StartPage/StartPage' +import StartPageMobile from 'components/StartPage/StartPageMobile' import { openGraph, urlGlobal } from '../utils/openGraph' @@ -46,9 +47,12 @@ export default function Home() { -
+
+
+ +
) From 6a1ffed0620637e387240b46e7c6a845679b95f9 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 20 Dec 2024 14:57:56 +0300 Subject: [PATCH 2/9] fix: delete code for desktop version --- components/StartPage/StartPageMobile.js | 134 ------------------------ 1 file changed, 134 deletions(-) diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index 11b0754a..9bb6a744 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -5,11 +5,9 @@ import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' -import AboutVersion from 'components/AboutVersion' import SwitchLocalization from 'components/SwitchLocalization' import CookiesAproove from './CookiesAproove' -import Download from './Download' import Feedback from './Feedback' import FrequentlyAskedQuestions from './FrequentlyAskedQuestions' import HowItWorks from './HowItWorks' @@ -17,12 +15,10 @@ import LevelIntro from './LevelIntro' import Login from './Login' import Logo from './Logo' import Partners from './Partners' -import PasswordRecovery from './PasswordRecovery' import Reviews from './Reviews' import SectionBlock from './SectionBlock' import SectionContainer from './SectionContainer' -import Close from 'public/icons/close.svg' import LevelLogo from 'public/icons/level-logo-color.svg' const contentRoutes = { @@ -115,19 +111,6 @@ function StartPageMobile({ defaultContentKey = null }) { } } - const contentObjects = { - signIn: handleContentClick('connect')} />, - connect: setContentKey(null)} />, - updates: , - partners: , - intro: , - reviews: , - howItWork: , - faq: , - download: , - logo: , - passwordRecovery: , - } const handleClick = (contentKey) => { if (contentKey && contentRoutes[contentKey]) { router.replace(`/${contentRoutes[contentKey]}`, undefined, { @@ -139,123 +122,6 @@ function StartPageMobile({ defaultContentKey = null }) { const mainLink = router.pathname === '/' ? `/${contentRoutes['logo']}` : '/' return ( <> -
- - -
-
-
- - {t('MainBlocks.WhatIsLevel')} - - - {t('MainBlocks.Reviews')} - -
-
- - {t('MainBlocks.HowItWorks')} - - - - {t('MainBlocks.FAQ')} - -
-
-
- {contentObjects[contentKey]} - { - setContentKey(null) - if (defaultContentKey) { - router.replace('/', undefined, { shallow: true }) - } - }} - /> -
-
- - -
- -
-
router.replace(mainLink)}> Date: Fri, 20 Dec 2024 16:12:26 +0300 Subject: [PATCH 3/9] fix: edit show blocks --- components/StartPage/Download.js | 2 +- components/StartPage/SectionBlock.js | 2 +- components/StartPage/SectionContainer.js | 35 +++++++++++++++--------- components/StartPage/StartPageMobile.js | 24 +++++++++++++--- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/components/StartPage/Download.js b/components/StartPage/Download.js index 9654def3..d693eb8e 100644 --- a/components/StartPage/Download.js +++ b/components/StartPage/Download.js @@ -86,7 +86,7 @@ function Download({ t, onClose }) {

{t('common:Download')}

diff --git a/components/StartPage/SectionBlock.js b/components/StartPage/SectionBlock.js index 602e7711..c4fc6746 100644 --- a/components/StartPage/SectionBlock.js +++ b/components/StartPage/SectionBlock.js @@ -31,7 +31,7 @@ function SectionBlock({ className={`relative rounded-xl bg-th-secondary-10 p-5 ${ isLogo ? 'flex justify-center' : 'text-center' }`} - // onClick={handleSectionToggle} + onClick={handleSectionToggle} > {showSection ? content : isLogo ? label :

{label}

} { + // Закрываем текущий блок перед открытием нового + if (!showSections[section]) { + await router.replace('/', undefined, { shallow: true, scroll: false }) + } + + // Переключаем состояние секции + toggleSection({ [section]: !showSections[section] }) + + // Переходим к нужному маршруту + await router.replace(`/${section}`, undefined, { shallow: true, scroll: false }) + } + return (
{!showSections.updates && ( - handleSectionClick('download')} + className={`cursor-pointer rounded-xl bg-th-secondary-10 p-5 ${ showSections.download ? 'col-span-2' : '' }`} > @@ -27,15 +38,13 @@ function SectionContainer({ showSections, toggleSection, t }) { {t('common:Download')}

{showSections.download && } - +
)} {!showSections.download && ( - handleSectionClick('updates')} + className={`cursor-pointer rounded-xl bg-th-secondary-10 p-5 ${ showSections.updates ? 'col-span-2' : '' }`} > @@ -44,7 +53,7 @@ function SectionContainer({ showSections, toggleSection, t }) { ) : ( )} - +
)}
) diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index 9bb6a744..7c00d2dc 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -245,7 +245,15 @@ function StartPageMobile({ defaultContentKey = null }) { )}
- +
+ router.push(contentRoutes['partners'], undefined, { + shallow: true, + scroll: false, + }) + } + > - - +
+
+ router.push(contentRoutes['connect'], undefined, { + shallow: true, + scroll: false, + }) + } + > - +
Date: Fri, 20 Dec 2024 16:45:45 +0300 Subject: [PATCH 4/9] fix: writeToUs separate in StartPage --- components/StartPage/Feedback.js | 124 +++++++++++------------- components/StartPage/StartPage.js | 7 +- components/StartPage/StartPageMobile.js | 9 +- 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/components/StartPage/Feedback.js b/components/StartPage/Feedback.js index 25aba873..23a00103 100644 --- a/components/StartPage/Feedback.js +++ b/components/StartPage/Feedback.js @@ -49,74 +49,68 @@ function Feedback({ onClose }) { } return ( -
- {isConnectWithUsPage && ( -

{t('start-page:WriteToUs')}

- )} - -
e.stopPropagation()}> - - {!isSent ? ( -
- +
e.stopPropagation()}> + + {!isSent ? ( + + - + - + - - {t('users:Send')} - -

- {t('users:ConditionOfConsent')} -

- - ) : ( -
-

{t('users:YourMessageSentThankYou')}

- -
- )} -
+ + {t('users:Send')} + +

+ {t('users:ConditionOfConsent')} +

+ + ) : ( +
+

{t('users:YourMessageSentThankYou')}

+ +
+ )}
) } diff --git a/components/StartPage/StartPage.js b/components/StartPage/StartPage.js index 56cd49fd..ea08ee0f 100644 --- a/components/StartPage/StartPage.js +++ b/components/StartPage/StartPage.js @@ -61,7 +61,12 @@ function StartPage({ defaultContentKey = null }) { const contentObjects = { signIn: handleContentClick('connect')} />, - connect: setContentKey(null)} />, + connect: ( +
+

{t('start-page:WriteToUs')}

+ setContentKey(null)} /> +
+ ), updates: , partners: , intro: , diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index 7c00d2dc..89998e22 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -274,7 +274,14 @@ function StartPageMobile({ defaultContentKey = null }) { toggleSection('feedback')} />} + content={ +
+

+ {t('start-page:WriteToUs')} +

+ toggleSection('feedback')} /> +
+ } showSection={showSections.connect} toggleSection={toggleSection} /> From 920b4b7ac7dd7036368c1a1a77c80e8ca009685b Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 20 Dec 2024 16:55:34 +0300 Subject: [PATCH 5/9] style: edit style for StartPage --- pages/[slug].js | 13 ++++++++----- pages/index.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pages/[slug].js b/pages/[slug].js index c45411b4..c0345b35 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -116,11 +116,14 @@ const SlugPage = () => { -
- -
-
- +
+
+ +
+ +
+ +
diff --git a/pages/index.js b/pages/index.js index 9fc085d6..a7a3b4da 100644 --- a/pages/index.js +++ b/pages/index.js @@ -47,11 +47,14 @@ export default function Home() { -
- -
-
- +
+
+ +
+ +
+ +
From 7e6ad8891cf632734953f9b857e3cae8ff6c5951 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 20 Dec 2024 17:24:56 +0300 Subject: [PATCH 6/9] fix: delete comments --- components/StartPage/SectionContainer.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/StartPage/SectionContainer.js b/components/StartPage/SectionContainer.js index 09df1fd9..c600b16b 100644 --- a/components/StartPage/SectionContainer.js +++ b/components/StartPage/SectionContainer.js @@ -13,15 +13,12 @@ function SectionContainer({ showSections, toggleSection, t }) { } const handleSectionClick = async (section) => { - // Закрываем текущий блок перед открытием нового if (!showSections[section]) { await router.replace('/', undefined, { shallow: true, scroll: false }) } - // Переключаем состояние секции toggleSection({ [section]: !showSections[section] }) - // Переходим к нужному маршруту await router.replace(`/${section}`, undefined, { shallow: true, scroll: false }) } From 35cf211c71de9fb9dff869e00e99888b370d0ed2 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Fri, 20 Dec 2024 18:22:25 +0300 Subject: [PATCH 7/9] fix: edit sectionKey --- components/StartPage/StartPageMobile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index 89998e22..f256bf81 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -255,7 +255,7 @@ function StartPageMobile({ defaultContentKey = null }) { } > } showSection={showSections.partners} @@ -272,7 +272,7 @@ function StartPageMobile({ defaultContentKey = null }) { } > From 35f8d08312994da025fe29b97e9d52606a084049 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Mon, 23 Dec 2024 11:35:17 +0300 Subject: [PATCH 8/9] feat: add & used OneSection component --- components/StartPage/Feedback.js | 25 ++++++- components/StartPage/Logo.js | 24 ++++++- components/StartPage/OneSection.js | 86 +++++++++++++++++++++++++ components/StartPage/Partners.js | 11 +++- components/StartPage/SectionBlock.js | 47 -------------- components/StartPage/StartPageMobile.js | 78 ++++++---------------- 6 files changed, 160 insertions(+), 111 deletions(-) create mode 100644 components/StartPage/OneSection.js delete mode 100644 components/StartPage/SectionBlock.js diff --git a/components/StartPage/Feedback.js b/components/StartPage/Feedback.js index 23a00103..d4a47273 100644 --- a/components/StartPage/Feedback.js +++ b/components/StartPage/Feedback.js @@ -9,7 +9,9 @@ import { toast, Toaster } from 'react-hot-toast' import ButtonLoading from 'components/ButtonLoading' import InputField from 'components/Panel/UI/InputField' -function Feedback({ onClose }) { +import Close from 'public/icons/close.svg' + +function Feedback({ isStartPage, onClose }) { const { t } = useTranslation(['start-page', 'projects', 'users', 'common']) const [feedback, setFeedback] = useState({ name: '', email: '', message: '' }) const [isError, setIsError] = useState(false) @@ -38,6 +40,10 @@ function Feedback({ onClose }) { toast.success(t('YourMessageHasBeenSent')) setIsError(false) setIsSent(true) + + if (isStartPage) { + onClose() + } }) .catch((err) => { console.log({ err }) @@ -51,6 +57,17 @@ function Feedback({ onClose }) { return (
e.stopPropagation()}> + {isStartPage && ( +
{ + onClose() + }} + > + +
+ )} + {!isSent ? (
onClose()} + onClick={() => { + if (!isStartPage) { + onClose() + } + }} > {t('common:Close')} diff --git a/components/StartPage/Logo.js b/components/StartPage/Logo.js index 7288d6aa..7140179d 100644 --- a/components/StartPage/Logo.js +++ b/components/StartPage/Logo.js @@ -1,14 +1,34 @@ +import { useState } from 'react' + import Link from 'next/link' import { useRouter } from 'next/router' +import Close from 'public/icons/close.svg' import GlokasLogo from 'public/icons/glokas-logo.svg' -function Logo({ t }) { +function Logo({ isMobilePage, t }) { const { locale } = useRouter() const isRuLocale = locale === 'ru' + + const [isOpen, setIsOpen] = useState(true) + + const handleClose = () => { + setIsOpen(false) + } + + if (!isOpen) return null + return (
-

{t('LogoHeader')}

+
+

{t('LogoHeader')}

+ {isMobilePage && ( + + )} +
{ + router.replace('/', undefined, { shallow: true, scroll: false }) + toggleSection({ partners: false, connect: false }) + } + + const handleSectionClick = async (section) => { + const sectionKey = + section === 'connect-with-us' ? 'connect' : section === 'about' ? 'logo' : section + + if (showSections[sectionKey]) { + toggleSection({ [sectionKey]: false }) + await router.replace('/', undefined, { shallow: true, scroll: false }) + } else { + await router.replace('/', undefined, { shallow: true, scroll: false }) + toggleSection({ [sectionKey]: true }) + await router.replace(`/${section}`, undefined, { shallow: true, scroll: false }) + } + } + + const renderSectionContent = () => { + if (label === t('Partners')) { + return ( +
handleSectionClick('partners')} + className={`cursor-pointer rounded-xl bg-th-secondary-10 p-5 text-center ${ + showSections.partners ? 'col-span-2' : '' + }`} + > + {!showSections.partners && ( +

{label}

+ )} + {showSections.partners && } +
+ ) + } + + if (label === t('WriteToUs')) { + return ( +
handleSectionClick('connect-with-us')} + className={`cursor-pointer rounded-xl bg-th-secondary-10 p-5 text-center ${ + showSections.connect ? 'col-span-2' : '' + }`} + > +

+ {label} +

+ + {showSections.connect && } +
+ ) + } + + if (label === 'logo') { + return ( +
handleSectionClick('about')} + className={`flex cursor-pointer justify-center rounded-xl bg-th-secondary-10 p-5`} + > + {!showSections.logo &&

{logo}

} + {showSections.logo && } +
+ ) + } + + return null + } + + return ( +
+ {renderSectionContent()} +
+ ) +} + +export default OneSection diff --git a/components/StartPage/Partners.js b/components/StartPage/Partners.js index f1d11851..cf2e660b 100644 --- a/components/StartPage/Partners.js +++ b/components/StartPage/Partners.js @@ -1,6 +1,8 @@ import Image from 'next/image' import Link from 'next/link' +import Close from 'public/icons/close.svg' + const partners = [ { name: 'Unfolding Word', @@ -32,9 +34,14 @@ const partners = [ }, ] -function Partners({ t }) { +function Partners({ t, onClose }) { return ( -
+
+ +

{t('Partners')}

{partners.map((partner) => ( diff --git a/components/StartPage/SectionBlock.js b/components/StartPage/SectionBlock.js deleted file mode 100644 index c4fc6746..00000000 --- a/components/StartPage/SectionBlock.js +++ /dev/null @@ -1,47 +0,0 @@ -import { useRouter } from 'next/router' - -import Close from 'public/icons/close.svg' - -function SectionBlock({ - sectionKey, - label, - content, - showSection, - toggleSection, - isLogo = false, -}) { - const router = useRouter() - - const updateRoute = async () => { - await router.replace('/', undefined, { shallow: true, scroll: false }) - } - - const handleSectionToggle = async () => { - await updateRoute() - toggleSection(sectionKey) - } - - const handleCloseClick = async (e) => { - e.stopPropagation() - await updateRoute() - } - - return ( -
- {showSection ? content : isLogo ? label :

{label}

} - -
- ) -} - -export default SectionBlock diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index f256bf81..11dff076 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -1,6 +1,5 @@ import { useEffect, useState } from 'react' -import Link from 'next/link' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' @@ -8,15 +7,12 @@ import { useTranslation } from 'next-i18next' import SwitchLocalization from 'components/SwitchLocalization' import CookiesAproove from './CookiesAproove' -import Feedback from './Feedback' import FrequentlyAskedQuestions from './FrequentlyAskedQuestions' import HowItWorks from './HowItWorks' import LevelIntro from './LevelIntro' import Login from './Login' -import Logo from './Logo' -import Partners from './Partners' +import OneSection from './OneSection' import Reviews from './Reviews' -import SectionBlock from './SectionBlock' import SectionContainer from './SectionContainer' import LevelLogo from 'public/icons/level-logo-color.svg' @@ -119,20 +115,16 @@ function StartPageMobile({ defaultContentKey = null }) { }) } } - const mainLink = router.pathname === '/' ? `/${contentRoutes['logo']}` : '/' return ( <>
-
router.replace(mainLink)}> - } - showSection={showSections.logo} - toggleSection={toggleSection} - isLogo={true} - label={} - /> -
+ } + toggleSection={toggleSection} + t={t} + />
{!showSections.signIn && (
@@ -245,54 +237,24 @@ function StartPageMobile({ defaultContentKey = null }) { )}
-
- router.push(contentRoutes['partners'], undefined, { - shallow: true, - scroll: false, - }) - } - > - } - showSection={showSections.partners} - toggleSection={toggleSection} - /> -
-
- router.push(contentRoutes['connect'], undefined, { - shallow: true, - scroll: false, - }) - } - > - -

- {t('start-page:WriteToUs')} -

- toggleSection('feedback')} /> -
- } - showSection={showSections.connect} - toggleSection={toggleSection} - /> -
+ + -
From ff0f9c3f414379a02462c4a365274bac97082369 Mon Sep 17 00:00:00 2001 From: DenisArger Date: Mon, 23 Dec 2024 16:36:12 +0300 Subject: [PATCH 9/9] fix: delete fragment --- components/StartPage/StartPageMobile.js | 256 ++++++++++++------------ 1 file changed, 127 insertions(+), 129 deletions(-) diff --git a/components/StartPage/StartPageMobile.js b/components/StartPage/StartPageMobile.js index 11dff076..f4499581 100644 --- a/components/StartPage/StartPageMobile.js +++ b/components/StartPage/StartPageMobile.js @@ -116,150 +116,148 @@ function StartPageMobile({ defaultContentKey = null }) { } } return ( - <> -
- } - toggleSection={toggleSection} - t={t} - /> -
- {!showSections.signIn && ( -
- -
- )} -
{ - e.preventDefault() - router.push(`/${contentRoutes['signIn']}`) - }} - className={`cursor-pointer rounded-xl p-5 ${ - showSections.signIn - ? 'col-span-2 bg-th-secondary-10' - : 'bg-slate-550 text-th-text-secondary-100' - }`} - > -

- {showSections.signIn ? t('users:LoginToAccount') : t('users:SignIn')} -

- {showSections.signIn && ( - { - toggleSection( - showSections.signIn && showSections.connect ? 'signIn' : 'connect' - ) - }} - /> - )} +
+ } + toggleSection={toggleSection} + t={t} + /> +
+ {!showSections.signIn && ( +
+
-
- + )}
{ + e.preventDefault() + router.push(`/${contentRoutes['signIn']}`) + }} + className={`cursor-pointer rounded-xl p-5 ${ + showSections.signIn + ? 'col-span-2 bg-th-secondary-10' + : 'bg-slate-550 text-th-text-secondary-100' }`} - onClick={() => handleContentClick('intro')} > -
-
- {blocks.intro.clicked ? ( - - ) : ( -

- )} -
+

+ {showSections.signIn ? t('users:LoginToAccount') : t('users:SignIn')} +

+ {showSections.signIn && ( + { + toggleSection( + showSections.signIn && showSections.connect ? 'signIn' : 'connect' + ) + }} + /> + )}
+
+ +
handleContentClick('intro')} + >
handleContentClick('howItWork')} - > -
-
- {blocks.howItWork.clicked ? ( - - ) : ( -

{t('MainBlocks.HowItWorks')}

- )} -
+ >
+
+ {blocks.intro.clicked ? ( + + ) : ( +

+ )}
+
+
handleContentClick('howItWork')} + >
handleContentClick('reviews')} - > -
-
- {blocks.reviews.clicked ? ( - - ) : ( -

{t('MainBlocks.Reviews')}

- )} -
+ >
+
+ {blocks.howItWork.clicked ? ( + + ) : ( +

{t('MainBlocks.HowItWorks')}

+ )}
+
+
handleContentClick('reviews')} + >
handleContentClick('faq')} - > -
-
- {blocks.faq.clicked ? ( - - ) : ( -

{t('FAQ')}

- )} -
+ >
+
+ {blocks.reviews.clicked ? ( + + ) : ( +

{t('MainBlocks.Reviews')}

+ )}
- - - -
- +
+
handleContentClick('faq')} + > +
+
+ {blocks.faq.clicked ? ( + + ) : ( +

{t('FAQ')}

+ )}
-
- +
+ + + +
+ +
+ ) }