Skip to content

Commit

Permalink
Restructured Header
Browse files Browse the repository at this point in the history
  • Loading branch information
n1kPLV committed Sep 19, 2023
1 parent 45b58e6 commit 33c4d42
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Website/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BACKEND_URI="http://127.0.0.1:8080"
BACKEND_URI="http://localhost:8080"
4 changes: 2 additions & 2 deletions Website/src/app/components/base_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./globals.css";
import Header from "@/app/components/header";
import Footer from "@/app/components/footer";
import Header from "@/app/components/layout/header";
import Footer from "@/app/components/layout/footer";
import React from "react";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
"use client";

import Link from "next/link";
import { useContext } from "react";
import { UsernameContext } from "@/app/components/username-provider";
import Link from "next/link";

/**
* The header for the web page
* A component showing the name of the currently logged-in user, with a logout link,
* or a login link if the user is not logged-in.
*/
export default function Header() {
export function CurrentUser({ className }: { className?: string }) {
const username = useContext(UsernameContext);

return (
<header className={"flex flex-row w-full flex-initial justify-items-center p-2"}>
<div>
<Link href={"/"}>RailTrail Admin interface</Link>
</div>
<div className={"grow"} />
<>
{username ? (
<div>
<div className={className}>
Hello {username} &ndash;{" "}
<Link href={"/logout"} prefetch={false}>
Logout
</Link>
</div>
) : (
<div>
<div className={className}>
<Link href={"/login"}>Login</Link>
</div>
)}
</header>
</>
);
}
File renamed without changes.
25 changes: 25 additions & 0 deletions Website/src/app/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Link from "next/link";
import { CurrentUser } from "@/app/components/layout/currentUser";

/**
* The header for the web page
*/
export default function Header() {
return (
<header
className={
"flex flex-row w-full justify-items-center justify-around p-2 flex-wrap bg-white dark:bg-slate-800"
}>
<div className={"mr-auto"}>
<Link href={"/"}>RailTrail Verwaltung</Link>
</div>
<CurrentUser className={"ml-auto sm:order-last"} />
{/* Force a line break for small devices */}
<div className={"w-full sm:hidden"} />

<div>Foo</div>
<div>Bar</div>
<div>Baz</div>
</header>
);
}
2 changes: 1 addition & 1 deletion Website/src/app/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useRouter } from "next/navigation";
import { FormEventHandler, PropsWithChildren, Suspense, useEffect, useRef, useState } from "react";

import Footer from "@/app/components/footer";
import Footer from "@/app/components/layout/footer";
import { ErrorMessage } from "@/app/management/components/errorMessage";

/**
Expand Down
2 changes: 1 addition & 1 deletion Website/src/app/components/track_selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Dispatch, FormEventHandler, PropsWithChildren, useEffect, useRef, useState } from "react";

import Footer from "@/app/components/footer";
import Footer from "@/app/components/layout/footer";
import useSWR from "swr";
import { setCookie } from "cookies-next";
import { inter } from "@/utils/common";
Expand Down

0 comments on commit 33c4d42

Please sign in to comment.