summaryrefslogtreecommitdiffstats
path: root/client/src/login
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /client/src/login
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'client/src/login')
-rw-r--r--client/src/login/data/texts.js0
-rw-r--r--client/src/login/jsx/App.jsx39
-rw-r--r--client/src/login/jsx/LoginPanel.jsx80
-rw-r--r--client/src/login/scss/_loginPanel.scss43
-rw-r--r--client/src/login/scss/index.scss8
5 files changed, 170 insertions, 0 deletions
diff --git a/client/src/login/data/texts.js b/client/src/login/data/texts.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client/src/login/data/texts.js
diff --git a/client/src/login/jsx/App.jsx b/client/src/login/jsx/App.jsx
new file mode 100644
index 0000000..a0109dd
--- /dev/null
+++ b/client/src/login/jsx/App.jsx
@@ -0,0 +1,39 @@
+import React, { useState } from 'react';
+import ReactDOM from 'react-dom';
+
+import "../scss/index.scss";
+
+import texts from '../../common/data/texts.js';
+import TopBar from '../../common/jsx/TopBar.jsx';
+import Info from '../../common/jsx/Info.jsx';
+import LoginPanel from './LoginPanel.jsx';
+
+const App = () => {
+ const [lang, setLang] = useState('en');
+ const [info, setInfo] = useState('login-info');
+ const [hover, setHover] = useState('');
+ const [user, setUser] = useState(null);
+ const t = (key) => texts[lang][key] || texts['en'][key];
+
+ return (
+ <div className="main">
+ <TopBar
+ lang={lang}
+ setLang={setLang}
+ setHover={setHover}
+ t={t}
+ />
+ <LoginPanel
+ setUser={setUser}
+ t={t}
+ />
+ <Info
+ info={info}
+ hover={hover}
+ t={t}
+ />
+ </div>
+ )
+};
+
+ReactDOM.render(<App />, document.getElementById('app'));
diff --git a/client/src/login/jsx/LoginPanel.jsx b/client/src/login/jsx/LoginPanel.jsx
new file mode 100644
index 0000000..296dc0e
--- /dev/null
+++ b/client/src/login/jsx/LoginPanel.jsx
@@ -0,0 +1,80 @@
+import React, {useState, useEffect} from 'react';
+
+const LoginPanel = ({setUser, t}) => {
+ const [username, setUsername] = useState('');
+ const [password, setPassword] = useState('');
+ const [active, setActive] = useState(false);
+
+ useEffect(() => {
+ if (username.length > 4 && password.length > 4) {
+ setActive(true);
+ } else {
+ setActive(false);
+ }
+ }, [username, password])
+
+ const usernameValidation = (e) => {
+ const value = e.target.value;
+ const regex = /^[0-9a-zA-Z]+$/;
+
+ if ((value.length < 20 && value.match(regex)) || value === "") {
+ setUsername(value);
+ }
+ };
+
+ const passwordValidation = (e) => {
+ e.target.value.length < 20 && setPassword(e.target.value);
+ };
+
+ const submit = (e) => {
+ e.preventDefault();
+ if (username === 'admin' && password === 'admin') {
+ setUser('admin');
+ }
+ }
+
+ return (
+ <div className="login-panel">
+ <form className="login-panel__form" onSubmit={submit}>
+ <p className="login-panel__header">
+ {t('login-to-admin')}
+ </p>
+ <div className="text-input">
+ <input
+ onChange={usernameValidation}
+ placeholder={t('user')}
+ id="admin-user-name"
+ name="admin-user-name"
+ type="text"
+ className="text-input-field"
+ value={username}
+ />
+ <label htmlFor="admin-user-name" className="text-input-label">{t('user')}</label>
+ </div>
+ <div className="text-input">
+ <input
+ onChange={passwordValidation}
+ placeholder={t('password')}
+ id="admin-password"
+ name="admin-password"
+ type="password"
+ className="text-input-field"
+ value={password}
+ />
+ <label htmlFor="admin-password" className="text-input-label">
+ {t('password')}
+ </label>
+ </div>
+ <div>
+ <input
+ type="submit"
+ className={`login-panel__button${active ? ' active' : ''}`}
+ value={t('login')}
+ />
+ </div>
+ </form>
+ </div>
+ );
+};
+
+export default LoginPanel;
diff --git a/client/src/login/scss/_loginPanel.scss b/client/src/login/scss/_loginPanel.scss
new file mode 100644
index 0000000..8afb066
--- /dev/null
+++ b/client/src/login/scss/_loginPanel.scss
@@ -0,0 +1,43 @@
+.login-panel {
+ text-align: center;
+
+ &__form {
+ display: inline-block;
+ }
+
+ &__header {
+ color: white;
+ font-size: 2em;
+ margin-bottom: 4em;
+ }
+
+ &__button {
+ display: inline-block;
+ color: $text-inactive;
+ background: $background;
+ font-size: 1.25em;
+ border-radius: 1em;
+ border: 2px solid $text-inactive;
+ padding: .5em 1.5em;
+ margin: 0 auto;
+ transition: .3s color, .3s background;
+ cursor: pointer;
+
+ &:hover {
+ background: $text-inactive;
+ color: $background;
+ }
+
+ &.active {
+ background: $background;
+ color: $text-selected;
+ border: 2px solid $text-selected;
+
+ &:hover {
+ background: $text-selected;
+ color: $background;
+ }
+ }
+ }
+
+}
diff --git a/client/src/login/scss/index.scss b/client/src/login/scss/index.scss
new file mode 100644
index 0000000..6a7eb52
--- /dev/null
+++ b/client/src/login/scss/index.scss
@@ -0,0 +1,8 @@
+@import '../../common/scss/reset';
+@import '../../common/scss/colors';
+@import '../../common/scss/globals';
+@import '../../common/scss/forms';
+@import '../../common/scss/main';
+@import '../../common/scss/info';
+@import '../../common/scss/topBar';
+@import 'loginPanel';