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

Implemented Tailwind / Added Forms #48

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/components/App/App.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.App {
background-color: #d0c5b9;
max-height: 100vh;
min-height: 100vh;
display: flex;
flex-direction: column;
font-family: 'Satisfy', cursive;
font-family: "Satisfy", cursive;
justify-content: space-between;
padding-bottom: 5rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a note of this rule for min-height vs max-height and padding bottom bc it's working effectively on my branch with max height and no padding.

}
5 changes: 5 additions & 0 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import Main from '../Main/Main';
import BreadList from '../BreadList/BreadList';
import BreadDetail from '../BreadDetail/BreadDetail';
import Error from "../Error/Error";
import CreateAcctForm from '../CreateAcctForm/CreateAcctForm';
import LoginForm from '../LoginForm/LoginForm';

import './App.css';
import 'leaflet/dist/leaflet.css';

Expand All @@ -17,6 +20,8 @@ function App() {
<Route path="/" element={<Main />} />
<Route path="/breads/:id" element={<BreadList />} />
<Route path="/breads/:id/:breadId" element={<BreadDetail />} />
<Route path="/create-account" element={<CreateAcctForm />} />
<Route path="/login" element={<LoginForm />} />
<Route path="*" element={<Error />} />
</Routes>
</div>
Expand Down
69 changes: 69 additions & 0 deletions src/components/CreateAcctForm/CreateAcctForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.acct-form-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 5rem;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 0.9375rem;
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
padding: 2rem;
margin: 5rem auto 2rem;
width: 90%;
max-width: 25rem;
font-family: "Abel", sans-serif;
gap: 1.25rem;
}

form {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}

.acct-form-container h2 {
text-align: center;
color: #333;
font-family: "Satisfy", cursive;
font-size: 2rem;

}

.acct-form-container input {
border: 2px solid #82aa9f;
border-radius: 5px;
padding: 0.625rem;
font-size: 1rem;
color: #333;
width: 100%;
margin-bottom: 1rem;
}

.acct-form-container input::placeholder {
color: #666;
}

.acct-form-container button {
background-color: #82aa9f;
color: white;
padding: 0.625rem 1.25rem;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.5s ease;
width: 100%;
margin-bottom: 1rem;
}

.acct-form-container button:hover {
background-color: #f0a200;
}

/* Adjustments for larger screens */
@media screen and (min-width: 750px) {
.acct-form-container {
width: 80%;
max-width: 500px;
}
}
49 changes: 49 additions & 0 deletions src/components/CreateAcctForm/CreateAcctForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
import React, { useState } from 'react';
import { NewUser } from "../../apiTypes";
import './CreateAcctForm.css';

function CreateAcctForm() {
const [formData, setFormData] = useState<NewUser>({ name: '', email: '', password: '' })

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target
setFormData({ ...formData, [name]: value })
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
// console.log(formData)
};

return (
<div className="acct-form-container">
<h2>Create Account</h2>
<form onSubmit={handleSubmit}>
<input
type="text"
name="name"
placeholder="Name"
value={formData.name}
onChange={handleChange}
required
/>
<input
type="email"
name="email"
placeholder="Email"
value={formData.email}
onChange={handleChange}
required
/>
<input
type="password"
name="password"
placeholder="Password"
value={formData.password}
onChange={handleChange}
required
/>
<button type="submit">Submit</button>
</form>
</div>
)
}

export default CreateAcctForm;
61 changes: 61 additions & 0 deletions src/components/LoginForm/LoginForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.login-form-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 5rem;
background-color: rgba(255, 255, 255, 0.8);
border-radius: 0.9375rem;
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
padding: 2rem;
margin: 5rem auto 2rem;
width: 90%;
max-width: 25rem;
font-family: 'Abel', sans-serif;
gap: 1.25rem;
}

.login-form-container h2 {
text-align: center;
color: #333;
font-family: 'Satisfy', cursive;
font-size: 2rem;
}

.login-form-container input {
border: 2px solid #82aa9f;
border-radius: 5px;
padding: 0.625rem;
font-size: 1rem;
color: #333;
width: 100%;
margin-bottom: 1rem;
}

.login-form-container input::placeholder {
color: #666;
}

.login-form-container button {
background-color: #82aa9f;
color: white;
padding: 0.625rem 1.25rem;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.5s ease;
width: 100%;
margin-bottom: 1rem;
}

.login-form-container button:hover {
background-color: #f0a200;
}

/* Adjustments for larger screens */
@media screen and (min-width: 750px) {
.login-form-container {
width: 80%;
max-width: 500px;
}
}
44 changes: 43 additions & 1 deletion src/components/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
import React, { useState } from 'react';
import { UserCredentials } from "../../apiTypes";
import { UserCredentials } from "../../apiTypes";
import './LoginForm.css';

function LoginForm() {
const [credentials, setCredentials] = useState<UserCredentials>({ email: '', password: '' });

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
setCredentials({ ...credentials, [name]: value })
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault()
// console.log(credentials)
};

return (
<div className="login-form-container">
<h2>Login</h2>
<form onSubmit={handleSubmit}>
<input
type="email"
name="email"
placeholder="Email"
value={credentials.email}
onChange={handleChange}
required
/>
<input
type="password"
name="password"
placeholder="Password"
value={credentials.password}
onChange={handleChange}
required
/>
<button type="submit">Submit</button>
</form>
</div>
)
}

export default LoginForm;
1 change: 0 additions & 1 deletion src/components/Main/Main.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ body, html {
.map-wrapper >h2 {
font-size: xx-large;
}


}

Expand Down
21 changes: 17 additions & 4 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,39 @@ const Navbar = () => {
const location = useLocation();
const navigate = useNavigate();

const isLoggedIn = false;

const handleBack = () => {
navigate(-1);
};

const isDetailPage = location.pathname.includes('/breads/') && location.pathname.split('/').length > 3;
const isDetailPage = location.pathname.includes('/breads/') && location.pathname.split('/').length >= 3;

return (
<div className="navbar">
<h1>Belongea's Boulangerie</h1>
<h1>
<Link to="/" className="app-title">Belongea's Boulangerie</Link>
</h1>
<div className="nav-links">
{isDetailPage && (
<Link to="#" onClick={handleBack} className="back-link">
Back
</Link>
)}
<Link to="/">Home</Link>
{!isLoggedIn ? (
<>
<Link to="/create-account">Create Account</Link>
<Link to="/login">Login</Link>
</>
) : (
<>
<Link to="/breadbox">BreadBox</Link>
<button onClick={() => console.log('Log out')}>Logout</button>
</>
)}
</div>
</div>
);
};


export default Navbar;