Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] User Login #93

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions front-end/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand Down
25 changes: 6 additions & 19 deletions front-end/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { RouterProvider } from 'react-router-dom';
import Router from './routes';


function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<>
<RouterProvider router={Router} />
</>
);
}

Expand Down
110 changes: 110 additions & 0 deletions front-end/src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";

const Container = styled.div`
display: flex;
height: 100vh;
width: 100vw;
background-color: #191C24;
align-items: center;
justify-content: center;
`
const LoginContainer = styled.div`
display: flex;
align-items: center;
width: 33.3%;
height: 50%;
flex-flow: column;
justify-content: center;
`
const Icon = styled.span`
font-family: 'Material Icons';
font-size: 64px;
color: #DAB783;
`
const Header = styled.h1`
font-size: 40px;
color: #DAB783;
font-weight: medium;
margin: unset;
margin-bottom: 8px;
font-family: 'PlayFair Display';
`;

const InputField = styled.input`
width: 97%;
border-width: 2px;
border-color: #DAB783;
border-radius: 8px;
background-color: #272F38;
color: #DAB783;
font-size: 16px;
padding: 5px;
margin-top: 16px;

`

const LoginButton = styled.button`
width: 100%;
background-color: #DAB783;
border-radius: 50px;
border-width: 0;
font-size: 16px;
font-weight: bold;
color: #191C24;
padding: 5px;
margin-top: 24px;
justify-content: center;

:hover {
background-color: #d6bc98;
cursor: pointer;
}
`

const RegisterButton = styled.button`
width: 100%;
background-color: #DAB783;
border-radius: 50px;
border-color: #DAB783;
background-color: #191C24;
font-size: 16px;
font-weight: bold;
color: #DAB783;
padding: 5px;
margin-top: 16px;
justify-content: center;

:hover {
background-color: #272F38;
cursor: pointer;
}

`
const LoginPage = () => {

const [userName, setUserName] = useState<string>('');
const [password, setPassword] = useState<string>('');

const navigate = useNavigate();

const login = () => {
console.log(userName + ' ' + password);
}

return (
<Container>
<LoginContainer>
<Icon>sports_bar</Icon>
<Header>CopoCheio</Header>
<InputField placeholder="Nome de usuário" value={userName} onChange={(e) => { setUserName(e.target.value) }} />
<InputField placeholder="Senha" value={password} type='password' onChange={(e) => { setPassword(e.target.value) }} />
<LoginButton onClick={login}>Login</LoginButton>
<RegisterButton onClick={() => { navigate('/cadastro') }}>Cadastrar</RegisterButton>
</LoginContainer>
</Container>
);
}

export default LoginPage;
17 changes: 17 additions & 0 deletions front-end/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createBrowserRouter, Navigate } from "react-router-dom";
import LoginPage from "./pages/LoginPage";

const Router = createBrowserRouter([
{
path: '*',
element: <Navigate to='/login' replace />
}, {
path: '/login',
element: <LoginPage></LoginPage>
}, {
path: '/cadastro',
element: <h1>Hello, world!</h1>
}
])

export default Router;