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/Feedback.js b/components/StartPage/Feedback.js index 25aba873..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 }) @@ -49,74 +55,83 @@ function Feedback({ onClose }) { } return ( -
- {isConnectWithUsPage && ( -

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

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

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

- - ) : ( -
-

{t('users:YourMessageSentThankYou')}

- -
- )} -
+ {!isSent ? ( +
+ + + + + + + + {t('users:Send')} + +

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

+ + ) : ( +
+

{t('users:YourMessageSentThankYou')}

+ +
+ )}
) } 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 602e7711..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/SectionContainer.js b/components/StartPage/SectionContainer.js index 3b335a92..c600b16b 100644 --- a/components/StartPage/SectionContainer.js +++ b/components/StartPage/SectionContainer.js @@ -1,4 +1,3 @@ -import Link from 'next/link' import { useRouter } from 'next/router' import AboutVersion from 'components/AboutVersion' @@ -12,14 +11,23 @@ function SectionContainer({ showSections, toggleSection, t }) { router.replace('/', undefined, { shallow: true, scroll: false }) toggleSection({ download: false, updates: false }) } + + 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 }) + } + return (
{!showSections.updates && ( - handleSectionClick('download')} + className={`cursor-pointer rounded-xl bg-th-secondary-10 p-5 ${ showSections.download ? 'col-span-2' : '' }`} > @@ -27,15 +35,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 +50,7 @@ function SectionContainer({ showSections, toggleSection, t }) { ) : ( )} - +
)}
) diff --git a/components/StartPage/StartPage.js b/components/StartPage/StartPage.js index 425bbb34..ea08ee0f 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 }) @@ -117,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: , @@ -256,158 +205,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..f4499581 --- /dev/null +++ b/components/StartPage/StartPageMobile.js @@ -0,0 +1,264 @@ +import { useEffect, useState } from 'react' + +import { useRouter } from 'next/router' + +import { useTranslation } from 'next-i18next' + +import SwitchLocalization from 'components/SwitchLocalization' + +import CookiesAproove from './CookiesAproove' +import FrequentlyAskedQuestions from './FrequentlyAskedQuestions' +import HowItWorks from './HowItWorks' +import LevelIntro from './LevelIntro' +import Login from './Login' +import OneSection from './OneSection' +import Reviews from './Reviews' +import SectionContainer from './SectionContainer' + +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 handleClick = (contentKey) => { + if (contentKey && contentRoutes[contentKey]) { + router.replace(`/${contentRoutes[contentKey]}`, undefined, { + shallow: true, + scroll: false, + }) + } + } + 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' + ) + }} + /> + )} +
+
+ +
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')}

+ )} +
+
+ + + +
+ +
+
+ ) +} + +export default StartPageMobile diff --git a/pages/[slug].js b/pages/[slug].js index b2cbfa70..c0345b35 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,8 +116,14 @@ const SlugPage = () => { -
- +
+
+ +
+ +
+ +
diff --git a/pages/index.js b/pages/index.js index e2d1fb38..a7a3b4da 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,8 +47,14 @@ export default function Home() { -
- +
+
+ +
+ +
+ +