added react layout with header, main and footer

This commit is contained in:
2025-07-22 12:41:55 +02:00
parent b9699bd512
commit cb206c10bb
11 changed files with 206 additions and 176 deletions

View File

@@ -1,44 +1 @@
@import "tailwindcss";
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
@import "tailwindcss";

View File

@@ -1,65 +1,11 @@
import React, { useState } from "react";
import "./App.css";
import Layout from "./layout/layout";
function App() {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
const response = await fetch("http://localhost:5002/api/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username,
password,
}),
});
if (response.ok) {
console.log("Login successful");
// Handle successful login here
} else {
console.log("Login failed");
// Handle login error here
}
} catch (error) {
console.error("Login error:", error);
}
};
return (
<>
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="username">Username:</label>
<input
type="text"
id="username"
name="username"
value={username}
onChange={(e) => setUsername(e.target.value)}
required
/>
</div>
<div>
<label htmlFor="password">Password:</label>
<input
type="password"
id="password"
name="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
/>
</div>
<button type="submit">Login</button>
</form>
</>
<Layout>
<p>Test</p>
</Layout>
);
}

View File

@@ -0,0 +1,22 @@
import React from "react";
const Header: React.FC = () => {
return (
<header className="bg-blue-600 text-white p-4 shadow-md">
<div className="container mx-auto flex justify-between items-center">
<h1 className="text-xl font-bold">Bikelane Web</h1>
<nav>
<ul className="flex space-x-4">
<li>
<a href="" className="hover:underline">
Login
</a>
</li>
</ul>
</nav>
</div>
</header>
);
};
export default Header;

View File

@@ -1,70 +1 @@
@import "tailwindcss";
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

View File

@@ -0,0 +1,20 @@
import React from "react";
import Header from "../components/Header";
type LayoutProps = {
children: React.ReactNode;
};
const Layout: React.FC<LayoutProps> = ({ children }) => {
return (
<div className="flex flex-col min-h-screen bg-gray-100">
<Header />
<main className="flex-1">{children}</main>
<footer className="bg-gray-800 text-white p-4 text-center">
<p>&copy; {new Date().getFullYear()} Bikelane Web</p>
</footer>
</div>
);
};
export default Layout;