-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
204 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,45 @@ | ||
import { RouterProvider, createBrowserRouter } from "react-router-dom" | ||
import { Container } from "@radix-ui/themes" | ||
import "./App.css" | ||
import { ProtectedRoute, GuestRoute } from "./api/router" | ||
import Dashboard from "./components/Dashboard" | ||
import { Layout } from "./components/Layout/Layout" | ||
import Login from "./components/Login" | ||
|
||
interface IProtectedRoutePage { | ||
component: () => JSX.Element | ||
} | ||
|
||
const ProtectedRoutePage: React.FC<IProtectedRoutePage> = ({ component }) => { | ||
return ( | ||
<Layout> | ||
<ProtectedRoute component={component} /> | ||
</Layout> | ||
) | ||
} | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
id: "App", | ||
path: "/", | ||
children: [ | ||
{ | ||
index: true, | ||
Component: () => <ProtectedRoute component={Dashboard} />, | ||
Component: () => <ProtectedRoutePage component={Dashboard} />, | ||
}, | ||
{ | ||
path: "/login", | ||
element: <GuestRoute component={Login} />, | ||
}, | ||
{ | ||
path: "/dashboard", | ||
element: <ProtectedRoute component={Dashboard} />, | ||
element: <ProtectedRoutePage component={Dashboard} />, | ||
}, | ||
], | ||
}, | ||
]) | ||
|
||
function App() { | ||
return ( | ||
<Container align="center"> | ||
<RouterProvider router={router} /> | ||
</Container> | ||
) | ||
return <RouterProvider router={router} /> | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
const Dashboard = () => { | ||
return ( | ||
<div> | ||
<h1>Dashboard</h1> | ||
</div> | ||
) | ||
return <h1>Dashboard</h1> | ||
} | ||
|
||
export default Dashboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.header { | ||
display: flex; | ||
background-color: var(--blue-9); | ||
padding: 10px; | ||
} | ||
|
||
.image-container { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.image-container img { | ||
max-height: 30px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react" | ||
import treylogo from "../../../public/treylogo-navigation.svg" | ||
import Navigation from "../Navigation/Navigation" | ||
import styles from "./Header.module.css" | ||
|
||
export const Header: React.FC = () => { | ||
return ( | ||
<header className={styles["header"]}> | ||
<div className={styles["image-container"]}> | ||
<img src={treylogo} alt="TREY-logo" /> | ||
</div> | ||
<Navigation /> | ||
</header> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react" | ||
import { Container } from "@radix-ui/themes" | ||
import { Header } from "../Header/Header" | ||
|
||
interface ILayout { | ||
children: React.ReactNode | ||
} | ||
|
||
export const Layout: React.FC<ILayout> = ({ children }) => { | ||
return ( | ||
<> | ||
<Header /> | ||
<Container align="center">{children}</Container> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react" | ||
import styles from "./Logincontainer.module.css" | ||
|
||
interface ILoginContainer { | ||
children: React.ReactNode | ||
} | ||
|
||
export const LoginContainer: React.FC<ILoginContainer> = ({ children }) => { | ||
return <div className={styles["login-container"]}>{children}</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
src/web/src/components/LoginContainer/Logincontainer.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.login-container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* reset */ | ||
button, | ||
p { | ||
all: unset; | ||
} | ||
|
||
.navigation { | ||
position: relative; | ||
display: flex; | ||
width: 100%; | ||
z-index: 1; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.navigation-menu-list { | ||
display: flex; | ||
list-style: none; | ||
margin: 0; | ||
} | ||
|
||
.navigation-menu-link { | ||
display: block; | ||
text-decoration: none; | ||
font-size: 16px; | ||
} | ||
.navigation-menu-link[data-active="true"] { | ||
text-decoration: underline; | ||
color: var(--trey-yellow); | ||
} | ||
|
||
.navigation-menu-trigger, | ||
.navigation-menu-link { | ||
padding: 8px 12px; | ||
outline: none; | ||
font-weight: 500; | ||
border-radius: 4px; | ||
color: var(--white); | ||
} | ||
.navigation-menu-trigger:hover, | ||
.navigation-menu-link:hover { | ||
text-decoration: underline; | ||
} | ||
.navigation-menu-trigger:focus, | ||
.navigation-menu-link:focus { | ||
outline: 2px solid var(--blue-focus); | ||
color: var(--trey-yellow); | ||
} | ||
|
||
.navigation-menu-trigger { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
gap: 2px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useLocation } from "react-router-dom" | ||
import * as NavigationMenu from "@radix-ui/react-navigation-menu" | ||
import styles from "./Navigation.module.css" | ||
|
||
const navigationRoutes = [{ name: "Dashboard", href: "/dashboard" }] | ||
|
||
const Navigation = () => { | ||
const location = useLocation() | ||
|
||
return ( | ||
<NavigationMenu.Root className={styles["navigation"]}> | ||
<NavigationMenu.List className={styles["navigation-menu-list"]}> | ||
{navigationRoutes.map((navigationRoute) => { | ||
return ( | ||
<NavigationMenu.Item key={navigationRoute.name}> | ||
<NavigationMenu.Link | ||
data-active={location.pathname === navigationRoute.href} | ||
className={styles["navigation-menu-link"]} | ||
href={navigationRoute.href} | ||
> | ||
{navigationRoute.name} | ||
</NavigationMenu.Link> | ||
</NavigationMenu.Item> | ||
) | ||
})} | ||
</NavigationMenu.List> | ||
<NavigationMenu.List className={styles["navigation-menu-list"]}> | ||
<NavigationMenu.Item> | ||
<NavigationMenu.Trigger className={styles["navigation-menu-trigger"]}> | ||
{"käyttäjä tähän"} | ||
</NavigationMenu.Trigger> | ||
</NavigationMenu.Item> | ||
</NavigationMenu.List> | ||
</NavigationMenu.Root> | ||
) | ||
} | ||
|
||
export default Navigation |
Oops, something went wrong.