From 4d642e312ed728ad51c454d1e2a0b7bb350fc174 Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Sun, 6 Dec 2020 23:49:13 +0100 Subject: first creator page --- client/src/admin/jsx/App.jsx | 8 ++-- client/src/admin/jsx/Info.jsx | 10 ----- client/src/admin/jsx/LangSwitch.jsx | 42 ------------------- client/src/admin/jsx/MainScreen.jsx | 6 ++- client/src/admin/jsx/TopBar.jsx | 35 ---------------- client/src/admin/jsx/User.jsx | 39 ----------------- client/src/admin/jsx/creator/Creator.jsx | 18 ++++++++ client/src/admin/jsx/creator/Step1.jsx | 67 ++++++++++++++++++++++++++++++ client/src/admin/jsx/layout/Info.jsx | 10 +++++ client/src/admin/jsx/layout/LangSwitch.jsx | 42 +++++++++++++++++++ client/src/admin/jsx/layout/TopBar.jsx | 35 ++++++++++++++++ client/src/admin/jsx/layout/UserSwitch.jsx | 39 +++++++++++++++++ 12 files changed, 220 insertions(+), 131 deletions(-) delete mode 100644 client/src/admin/jsx/Info.jsx delete mode 100644 client/src/admin/jsx/LangSwitch.jsx delete mode 100644 client/src/admin/jsx/TopBar.jsx delete mode 100644 client/src/admin/jsx/User.jsx create mode 100644 client/src/admin/jsx/creator/Creator.jsx create mode 100644 client/src/admin/jsx/creator/Step1.jsx create mode 100644 client/src/admin/jsx/layout/Info.jsx create mode 100644 client/src/admin/jsx/layout/LangSwitch.jsx create mode 100644 client/src/admin/jsx/layout/TopBar.jsx create mode 100644 client/src/admin/jsx/layout/UserSwitch.jsx (limited to 'client/src/admin/jsx') diff --git a/client/src/admin/jsx/App.jsx b/client/src/admin/jsx/App.jsx index 1bb224f..cb82e90 100644 --- a/client/src/admin/jsx/App.jsx +++ b/client/src/admin/jsx/App.jsx @@ -3,9 +3,10 @@ import ReactDOM from 'react-dom'; import "../scss/index.scss"; -import TopBar from './TopBar.jsx'; -import Info from './Info.jsx'; +import TopBar from './layout/TopBar.jsx'; +import Info from './layout/Info.jsx'; import MainScreen from './MainScreen.jsx'; +import Creator from './creator/Creator.jsx'; import Context from '../context'; import { defaultLanguage } from '../data/translations'; import { getUser, setDbLang } from '../api'; @@ -33,11 +34,12 @@ const App = () => { }, [user]); return ( - +
{ view === 'main' && } + { view === 'creator' && }
diff --git a/client/src/admin/jsx/Info.jsx b/client/src/admin/jsx/Info.jsx deleted file mode 100644 index 75294e1..0000000 --- a/client/src/admin/jsx/Info.jsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { t } from '../hocs'; - -const Info = ({ info, hover }) => ( -

- { hover ? t(hover) : t(info) } -

-); - -export default Info; diff --git a/client/src/admin/jsx/LangSwitch.jsx b/client/src/admin/jsx/LangSwitch.jsx deleted file mode 100644 index 2494bef..0000000 --- a/client/src/admin/jsx/LangSwitch.jsx +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import { WithHover } from '../hocs'; -import { languages } from '../data/translations.js' - -const LangSwitch = ({ lang, setLang, opened, setOpened}) => { - const handleSetLang = (key) => { - setLang(key); - setOpened(false); - }; - - return ( -
- - setOpened(opened !== 'lang' ? 'lang' : false)} - > - {lang} - - { - opened === 'lang' && ( -
- { - languages.map(key => key !== lang && ( - handleSetLang(key)} - > - {key} - - )) - } -
- ) - } -
-
- ); -}; - -export default LangSwitch; diff --git a/client/src/admin/jsx/MainScreen.jsx b/client/src/admin/jsx/MainScreen.jsx index 3d65384..ea2def5 100644 --- a/client/src/admin/jsx/MainScreen.jsx +++ b/client/src/admin/jsx/MainScreen.jsx @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { WithHover, t } from '../hocs'; +import { WithHover, t, goTo } from '../hocs'; const MainScreen = ({ projects }) => (
@@ -16,7 +16,9 @@ const MainScreen = ({ projects }) => ( )} -

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

+

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

diff --git a/client/src/admin/jsx/TopBar.jsx b/client/src/admin/jsx/TopBar.jsx deleted file mode 100644 index e9be676..0000000 --- a/client/src/admin/jsx/TopBar.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, {useState} from 'react'; -import LangSwitch from './LangSwitch.jsx'; -import User from './User.jsx'; - -const TopBar = ({ user, setUser, lang, setLang }) => { - const [opened, setOpened] = useState(false); - - return ( -
- { opened !== false && ( -
setOpened(false)} - /> - )} - - { user && ( - - ) - } -
- ); -}; - -export default TopBar; diff --git a/client/src/admin/jsx/User.jsx b/client/src/admin/jsx/User.jsx deleted file mode 100644 index eb596bf..0000000 --- a/client/src/admin/jsx/User.jsx +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import { WithHover, t } from '../hocs'; -import { logout } from '../api'; - -const User = ({ user, setUser, opened, setOpened }) => { - const handleLogout = () => { - setOpened(false); - logout(); - }; - const handleChangePass = () => { setOpened(false) }; - const handleRemoveUser = () => { setOpened(false) }; - - return ( -
- - setOpened(opened !== 'user' ? 'user' : false)} - > - {user.email} - - { - opened === 'user' && ( -
- - {t('logout')} - - - {t('user-settings')} - -
- ) - } -
-
- ); -}; - -export default User; diff --git a/client/src/admin/jsx/creator/Creator.jsx b/client/src/admin/jsx/creator/Creator.jsx new file mode 100644 index 0000000..896235e --- /dev/null +++ b/client/src/admin/jsx/creator/Creator.jsx @@ -0,0 +1,18 @@ +import React, { useState } from 'react'; +import Step1 from './Step1'; +import { t, goTo } from '../../hocs'; + +const Creator = ({projects}) => { + const [step, setStep] = useState('step1'); + + switch(step) { + case 'step1': + return ; + case 'step2': + return null; + default: + return null; + } +}; + +export default Creator; diff --git a/client/src/admin/jsx/creator/Step1.jsx b/client/src/admin/jsx/creator/Step1.jsx new file mode 100644 index 0000000..647661e --- /dev/null +++ b/client/src/admin/jsx/creator/Step1.jsx @@ -0,0 +1,67 @@ +import React, { useState } from 'react'; +import { WithHover, t, goTo } from '../../hocs'; + +const Step1 = () => { + const [websiteTitle, setWebsiteTitle] = useState(''); + const [websiteDescription, setWebsiteDescription] = useState(''); + const isNextActive = websiteTitle.length > 2 && websiteDescription.length > 2 ? 'active' : ''; + + return ( +
+
{ t('main-information') }
+
+ +
+ setWebsiteTitle(e.target.value)} + placeholder={t('website-title')} + id="website-title" + name="website-title" + type="text" + className="text-input-field" + value={websiteTitle} + /> + +
+
+
+
+ +
+ + +
+
+
+
+
+ +
+
+
+ + {t('upload-favicon')} + +
+
+
+ +
+ {t('cancel')} +
+
+ +
+ {t('next')} +
+
+
+
+ ) +}; + +export default Step1; diff --git a/client/src/admin/jsx/layout/Info.jsx b/client/src/admin/jsx/layout/Info.jsx new file mode 100644 index 0000000..0ea8686 --- /dev/null +++ b/client/src/admin/jsx/layout/Info.jsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { t } from '../../hocs'; + +const Info = ({ info, hover }) => ( +

+ { hover ? t(hover) : t(info) } +

+); + +export default Info; diff --git a/client/src/admin/jsx/layout/LangSwitch.jsx b/client/src/admin/jsx/layout/LangSwitch.jsx new file mode 100644 index 0000000..684d432 --- /dev/null +++ b/client/src/admin/jsx/layout/LangSwitch.jsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { WithHover } from '../../hocs'; +import { languages } from '../../data/translations.js' + +const LangSwitch = ({ lang, setLang, opened, setOpened}) => { + const handleSetLang = (key) => { + setLang(key); + setOpened(false); + }; + + return ( +
+ + setOpened(opened !== 'lang' ? 'lang' : false)} + > + {lang} + + { + opened === 'lang' && ( +
+ { + languages.map(key => key !== lang && ( + handleSetLang(key)} + > + {key} + + )) + } +
+ ) + } +
+
+ ); +}; + +export default LangSwitch; diff --git a/client/src/admin/jsx/layout/TopBar.jsx b/client/src/admin/jsx/layout/TopBar.jsx new file mode 100644 index 0000000..b6564f7 --- /dev/null +++ b/client/src/admin/jsx/layout/TopBar.jsx @@ -0,0 +1,35 @@ +import React, {useState} from 'react'; +import LangSwitch from './LangSwitch.jsx'; +import UserSwitch from './UserSwitch.jsx'; + +const TopBar = ({ user, setUser, lang, setLang }) => { + const [opened, setOpened] = useState(false); + + return ( +
+ { opened !== false && ( +
setOpened(false)} + /> + )} + + { user && ( + + ) + } +
+ ); +}; + +export default TopBar; diff --git a/client/src/admin/jsx/layout/UserSwitch.jsx b/client/src/admin/jsx/layout/UserSwitch.jsx new file mode 100644 index 0000000..403783c --- /dev/null +++ b/client/src/admin/jsx/layout/UserSwitch.jsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { WithHover, t } from '../../hocs'; +import { logout } from '../../api'; + +const User = ({ user, setUser, opened, setOpened }) => { + const handleLogout = () => { + setOpened(false); + logout(); + }; + const handleChangePass = () => { setOpened(false) }; + const handleRemoveUser = () => { setOpened(false) }; + + return ( +
+ + setOpened(opened !== 'user' ? 'user' : false)} + > + {user.email} + + { + opened === 'user' && ( +
+ + {t('logout')} + + + {t('user-settings')} + +
+ ) + } +
+
+ ); +}; + +export default User; -- cgit v1.2.3