From 4a9cf28660ed3b7e02952d02035978d1d4ad3e7e Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Wed, 9 Dec 2020 23:26:30 +0100 Subject: add creator 2nd step & onKeyPress helper --- client/src/admin/jsx/MainScreen.jsx | 22 ++++++++++++-- client/src/admin/jsx/creator/Creator.jsx | 6 ++-- client/src/admin/jsx/creator/Step1.jsx | 51 ++++++++++++++++++++++++++------ client/src/admin/jsx/creator/Step2.jsx | 32 ++++++++++++++++++++ 4 files changed, 97 insertions(+), 14 deletions(-) create mode 100644 client/src/admin/jsx/creator/Step2.jsx (limited to 'client/src/admin/jsx') diff --git a/client/src/admin/jsx/MainScreen.jsx b/client/src/admin/jsx/MainScreen.jsx index ea2def5..8808dc5 100644 --- a/client/src/admin/jsx/MainScreen.jsx +++ b/client/src/admin/jsx/MainScreen.jsx @@ -1,5 +1,6 @@ import React, { Fragment } from 'react'; import { WithHover, t, goTo } from '../hocs'; +import { onKeyPress } from '../helpers' const MainScreen = ({ projects }) => (
@@ -7,16 +8,31 @@ const MainScreen = ({ projects }) => (
{ !projects.length && ( -

{ t('edit-current-project') }

+

+ { t('edit-current-project') } +

)} { !projects.length && ( -

{ t('show-saved-projects') }

+

+ { t('show-saved-projects') } +

)} -

+

{ t('create-new-project') }

diff --git a/client/src/admin/jsx/creator/Creator.jsx b/client/src/admin/jsx/creator/Creator.jsx index 896235e..fa552b3 100644 --- a/client/src/admin/jsx/creator/Creator.jsx +++ b/client/src/admin/jsx/creator/Creator.jsx @@ -1,15 +1,17 @@ import React, { useState } from 'react'; import Step1 from './Step1'; +import Step2 from './Step2'; import { t, goTo } from '../../hocs'; const Creator = ({projects}) => { const [step, setStep] = useState('step1'); + const [data, setData] = useState({}); switch(step) { case 'step1': - return ; + return ; case 'step2': - return null; + return ; default: return null; } diff --git a/client/src/admin/jsx/creator/Step1.jsx b/client/src/admin/jsx/creator/Step1.jsx index 647661e..3e2e05d 100644 --- a/client/src/admin/jsx/creator/Step1.jsx +++ b/client/src/admin/jsx/creator/Step1.jsx @@ -1,11 +1,23 @@ import React, { useState } from 'react'; import { WithHover, t, goTo } from '../../hocs'; +import { onKeyPress } from '../../helpers' -const Step1 = () => { - const [websiteTitle, setWebsiteTitle] = useState(''); - const [websiteDescription, setWebsiteDescription] = useState(''); +const Step1 = ({ setStep, data, setData }) => { + const [websiteTitle, setWebsiteTitle] = useState(data.websiteTitle || ''); + const [websiteDescription, setWebsiteDescription] = useState(data.websiteDescription || ''); const isNextActive = websiteTitle.length > 2 && websiteDescription.length > 2 ? 'active' : ''; + const uploadFavicon = () => ( + console.log('this will upload favicon') + ) + + const handleNext = () => { + if (isNextActive) { + setData({ ...data, websiteTitle, websiteDescription }); + setStep('step2'); + } + } + return (
{ t('main-information') }
@@ -21,7 +33,9 @@ const Step1 = () => { className="text-input-field" value={websiteTitle} /> - +
@@ -32,16 +46,25 @@ const Step1 = () => { onChange={e => setWebsiteDescription(e.target.value)} id="website-description" name="website-description" - placeholder={t('website-description')}> + placeholder={t('website-description')} + value={websiteDescription} + > - +
-
+
+
+
{t('upload-favicon')} @@ -50,12 +73,22 @@ const Step1 = () => {
-
+
{t('cancel')}
-
+
{t('next')}
diff --git a/client/src/admin/jsx/creator/Step2.jsx b/client/src/admin/jsx/creator/Step2.jsx new file mode 100644 index 0000000..d8ce009 --- /dev/null +++ b/client/src/admin/jsx/creator/Step2.jsx @@ -0,0 +1,32 @@ +import React from 'react'; +import { WithHover, t } from '../../hocs'; + +const Step2 = ({ setStep, data, setData }) => { + console.log(data) + const isNextActive = () => {} + const handleNext = () => {} + + return ( +
+
{ t('website-sections') }
+ +
+ +
setStep('step1')} className="creator__btns-cancel"> + {t('back')} +
+
+ +
+ {t('next')} +
+
+
+
+ ) +} + +export default Step2; -- cgit v1.2.3