add iqball header on all pages

pull/107/head
maxime 1 year ago
parent 9014a0e154
commit 87ddaacd97

@ -1,6 +1,7 @@
import { BrowserRouter, Route, Routes } from "react-router-dom" import { BrowserRouter, Route, Routes } from "react-router-dom"
import loadable from "@loadable/component" import loadable from "@loadable/component"
import { Header } from "./pages/template/Header.tsx"
const HomePage = loadable(() => import("./pages/HomePage.tsx")) const HomePage = loadable(() => import("./pages/HomePage.tsx"))
@ -15,9 +16,12 @@ const Editor = loadable(() => import("./pages/Editor.tsx"))
export default function App() { export default function App() {
return ( return (
<div style={{ height: "100vh", width: "100vw" }}> <div style={{ height: "100vh", width: "100vw" }}>
<BrowserRouter> <BrowserRouter>
<Header/>
<Routes> <Routes>
<Route path={"/"} element={<HomePage />} /> <Route path={"/"} element={<HomePage />} />
<Route path={"/login"} element={<LoginPage />} /> <Route path={"/login"} element={<LoginPage />} />
@ -29,7 +33,6 @@ export default function App() {
<Route path={"/tactic/new/plain"} element={<Editor courtType={"PLAIN"} />} /> <Route path={"/tactic/new/plain"} element={<Editor courtType={"PLAIN"} />} />
<Route path={"/tactic/new/half"} element={<Editor courtType={"HALF"} />} /> <Route path={"/tactic/new/half"} element={<Editor courtType={"HALF"} />} />
<Route path={"*"} element={<NotFoundPage />} /> <Route path={"*"} element={<NotFoundPage />} />
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>

@ -1,25 +1,26 @@
:root { :root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5; line-height: 1.5;
font-weight: 400; font-weight: 400;
color-scheme: light dark; color-scheme: light dark;
font-synthesis: none; font-synthesis: none;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
body { body {
margin: 0; margin: 0;
display: flex; display: flex;
place-items: center; place-items: center;
overflow-x: hidden;
} }
h1 { h1 {
font-size: 3.2em; font-size: 3.2em;
line-height: 1.1; line-height: 1.1;
} }

@ -22,10 +22,7 @@ import { PlayerPiece } from "../components/editor/PlayerPiece"
import { Tactic, TacticComponent, TacticContent } from "../model/tactic/Tactic" import { Tactic, TacticComponent, TacticContent } from "../model/tactic/Tactic"
import { fetchAPI } from "../Fetcher" import { fetchAPI } from "../Fetcher"
import SavingState, { import SavingState, { SaveState, SaveStates } from "../components/editor/SavingState"
SaveState,
SaveStates,
} from "../components/editor/SavingState"
import { BALL_TYPE } from "../model/tactic/CourtObjects" import { BALL_TYPE } from "../model/tactic/CourtObjects"
import { CourtAction } from "../components/editor/CourtAction" import { CourtAction } from "../components/editor/CourtAction"
@ -42,32 +39,16 @@ import {
removeBall, removeBall,
updateComponent, updateComponent,
} from "../editor/TacticContentDomains" } from "../editor/TacticContentDomains"
import { import { BallState, Player, PlayerInfo, PlayerLike, PlayerTeam } from "../model/tactic/Player"
BallState,
Player,
PlayerInfo,
PlayerLike,
PlayerTeam,
} from "../model/tactic/Player"
import { RackedCourtObject, RackedPlayer } from "../editor/RackedItems" import { RackedCourtObject, RackedPlayer } from "../editor/RackedItems"
import CourtPlayer from "../components/editor/CourtPlayer" import CourtPlayer from "../components/editor/CourtPlayer"
import { import { createAction, getActionKind, isActionValid, removeAction } from "../editor/ActionsDomains"
createAction,
getActionKind,
isActionValid,
removeAction,
} from "../editor/ActionsDomains"
import ArrowAction from "../components/actions/ArrowAction" import ArrowAction from "../components/actions/ArrowAction"
import { middlePos, Pos, ratioWithinBase } from "../geo/Pos" import { middlePos, Pos, ratioWithinBase } from "../geo/Pos"
import { Action, ActionKind } from "../model/tactic/Action" import { Action, ActionKind } from "../model/tactic/Action"
import BallAction from "../components/actions/BallAction" import BallAction from "../components/actions/BallAction"
import { import { changePlayerBallState, getOrigin, removePlayer } from "../editor/PlayerDomains"
changePlayerBallState,
getOrigin,
removePlayer,
} from "../editor/PlayerDomains"
import { CourtBall } from "../components/editor/CourtBall" import { CourtBall } from "../components/editor/CourtBall"
import { BASE } from "../Constants"
const ERROR_STYLE: CSSProperties = { const ERROR_STYLE: CSSProperties = {
borderColor: "red", borderColor: "red",
@ -439,9 +420,6 @@ function EditorView({
return ( return (
<div id="main-div"> <div id="main-div">
<div id="topbar-div"> <div id="topbar-div">
<button onClick={() => (location.pathname = BASE + "/")}>
Home
</button>
<div id="topbar-left"> <div id="topbar-left">
<SavingState state={saveState} /> <SavingState state={saveState} />
</div> </div>

@ -1,7 +1,6 @@
import "../style/home/home.css" import "../style/home/home.css"
// import AccountSvg from "../assets/account.svg?react" // import AccountSvg from "../assets/account.svg?react"
import { Header } from "./template/Header"
import { BASE } from "../Constants" import { BASE } from "../Constants"
import { getSession } from "../api/session.ts" import { getSession } from "../api/session.ts"
import { fetchAPIGet, redirect } from "../Fetcher.ts" import { fetchAPIGet, redirect } from "../Fetcher.ts"
@ -26,7 +25,7 @@ interface Team {
export default function HomePage() { export default function HomePage() {
type UserDataResponse = {user?: User, tactics: Tactic[], teams: Team[]} type UserDataResponse = {user?: User, tactics: Tactic[], teams: Team[]}
const [{ user, tactics, teams }, setInfo] = useState<UserDataResponse>({tactics: [], teams: []}) const [{tactics, teams }, setInfo] = useState<UserDataResponse>({tactics: [], teams: []})
useLayoutEffect(() => { useLayoutEffect(() => {
@ -46,26 +45,21 @@ export default function HomePage() {
}, []) }, [])
console.log(user)
const lastTactics = tactics!.sort((a, b) => a.creationDate.getMilliseconds() - b.creationDate.getMilliseconds()).slice(0, 5) const lastTactics = tactics!.sort((a, b) => a.creationDate.getMilliseconds() - b.creationDate.getMilliseconds()).slice(0, 5)
return <Home teams={teams!} allTactics={tactics!} lastTactics={lastTactics} username={user?.name ?? ""} /> return <Home teams={teams!} allTactics={tactics!} lastTactics={lastTactics}/>
} }
function Home({ function Home({
lastTactics, lastTactics,
allTactics, allTactics,
teams, teams,
username,
}: { }: {
lastTactics: Tactic[] lastTactics: Tactic[]
allTactics: Tactic[] allTactics: Tactic[]
teams: Team[] teams: Team[]
username: string
}) { }) {
return ( return (
<div id="main"> <div id="main">
<Header username={username} />
<Body <Body
lastTactics={lastTactics} lastTactics={lastTactics}
allTactics={allTactics} allTactics={allTactics}

@ -1,24 +1,42 @@
import { BASE } from "../../Constants" import { BASE } from "../../Constants"
import accountSvg from "../../assets/account.svg" import accountSvg from "../../assets/account.svg"
import "../../style/template/header.css"
import { useEffect, useState } from "react"
import { fetchAPIGet } from "../../Fetcher.ts"
import { getSession } from "../../api/session.ts"
/** /**
* *
* @param param0 username * @param param0 username
* @returns Header * @returns Header
*/ */
export function Header({ username }: { username: string }) { export function Header() {
const [username, setUsername] = useState("")
useEffect(() => {
async function getUsername() {
const response = await fetchAPIGet("user", getSession())
//TODO check if the response is ok and handle errors
const {name} = await response.json()
setUsername(name)
}
getUsername()
}, [])
return ( return (
<div id="header"> <div id="header">
<div id="header-left"></div> <div id="header-left"></div>
<div id="header-center"> <div id="header-center">
<h1 <p
id="iqball" id="iqball"
className="clickable" className="clickable"
onClick={() => { onClick={() => {
location.pathname = BASE + "/" location.pathname = BASE + "/"
}}> }}>
<span id="IQ">IQ</span> IQBall
<span id="Ball">Ball</span> </p>
</h1>
</div> </div>
<div id="header-right"> <div id="header-right">
<div className="clickable" id="clickable-header-right"> <div className="clickable" id="clickable-header-right">

@ -5,7 +5,9 @@
body { body {
/* background-color: #303030; */ /* background-color: #303030; */
overflow-x: hidden;
} }
#main { #main {
/* margin-left : 10%; /* margin-left : 10%;
margin-right: 10%; */ margin-right: 10%; */

@ -1,49 +1,49 @@
#header { #header {
text-align: center; text-align: center;
background-color: var(--home-main-color); background-color: var(--home-main-color);
margin: 0px; margin: 0;
/* border : var(--accent-color) 1px solid; */
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
justify-content: space-between;
font-family: var(--font-title); font-family: var(--font-title);
/* border-radius: 0.75cap; */
height: 50px;
} }
#img-account { #img-account {
width: 100%;
cursor: pointer; cursor: pointer;
} }
#header-right, #header-left, #header-right, #header-center {
#header-left { width: 100%;
width: 10%;
/* border: yellow 2px solid; */
} }
#header-right { #header-right {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: end;
} }
#username { #username {
color: var(--main-contrast-color); color: var(--main-contrast-color);
margin: 0; margin-left: 10px;
} }
#clickable-header-right:hover #username { #clickable-header-right:hover #username {
color: var(--accent-color); color: var(--accent-color);
} }
#header-center {
width: 80%;
}
#clickable-header-right { #clickable-header-right {
width: 40%;
border-radius: 1cap; border-radius: 1cap;
padding: 2%; padding: 2%;
margin-right: 20px;
display: flex;
align-items: center;
justify-content: space-evenly;
} }
#clickable-header-right:hover { #clickable-header-right:hover {
@ -54,12 +54,10 @@
cursor: pointer; cursor: pointer;
} }
#img-account {
width: 100%;
}
#iqball { #iqball {
margin: 0;
color: var(--accent-color); color: var(--accent-color);
font-weight: bold; font-weight: bold;
font-size: 45px; font-size: 35px;
} }

Loading…
Cancel
Save