jsx working

This commit is contained in:
C4illin 2024-05-19 00:07:56 +02:00
parent 0f0bc6c4e5
commit a68046ecd6
19 changed files with 814 additions and 458 deletions

13
src/components/base.tsx Normal file
View file

@ -0,0 +1,13 @@
export const BaseHtml = ({ children, title = "ConvertX" }) => (
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{title}</title>
<link rel="stylesheet" href="/pico.lime.min.css" />
<link rel="stylesheet" href="/style.css" />
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
</head>
<body>{children}</body>
</html>
);

49
src/components/header.tsx Normal file
View file

@ -0,0 +1,49 @@
export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
let rightNav: JSX.Element;
if (loggedIn) {
rightNav = (
<ul>
<li>
<a href="/results">History</a>
</li>
<li>
<a href="/logout">Logout</a>
</li>
</ul>
);
} else {
rightNav = (
<ul>
<li>
<a href="/login">Login</a>
</li>
<li>
<a href="/register">Register</a>
</li>
</ul>
);
}
return (
<header class="container-fluid">
<nav>
<ul>
<li>
<strong>
<a
href="/"
style={{
textDecoration: "none",
color: "inherit",
}}
>
ConvertX
</a>
</strong>
</li>
</ul>
{rightNav}
</nav>
</header>
);
};