diff --git a/todoblue/src/app/board/[board]/BoardHeader.module.css b/todoblue/src/app/board/[board]/BoardHeader.module.css index ae48cc2..c7e1a64 100644 --- a/todoblue/src/app/board/[board]/BoardHeader.module.css +++ b/todoblue/src/app/board/[board]/BoardHeader.module.css @@ -27,7 +27,7 @@ } } -.boardButtons { +.buttonsArea { width: auto; min-width: unset; @@ -35,34 +35,24 @@ gap: 4px; } -.boardButtonsLeft { - grid-area: left; - justify-self: start; -} - -.boardButtonsRight { - grid-area: right; - justify-self: end; -} - -.boardTitle { +.titleArea { grid-area: title; height: 80px; } -.boardTitle div { +.titleDisplay { padding-top: 0.125em; padding-right: 0.75ex; padding-left: 0.75ex; padding-bottom: calc(0.125em + 2px); } -.boardTitle input { +.titleInput { text-align: center; width: 100%; } -.boardButtons button { +.buttonsArea button { display: inline-flex; justify-content: center; align-items: center; @@ -77,3 +67,13 @@ width: 36px; height: 36px; } + +.leftButtonsArea { + grid-area: left; + justify-self: start; +} + +.rightButtonsArea { + grid-area: right; + justify-self: end; +} diff --git a/todoblue/src/app/board/[board]/BoardHeader.tsx b/todoblue/src/app/board/[board]/BoardHeader.tsx index 4099187..44f90db 100644 --- a/todoblue/src/app/board/[board]/BoardHeader.tsx +++ b/todoblue/src/app/board/[board]/BoardHeader.tsx @@ -1,3 +1,5 @@ +import {useRouter} from "next/navigation" +import {ReactNode, useCallback} from "react" import style from "./BoardHeader.module.css" import {useManagedBoard} from "@/app/board/[board]/BoardManager" import {faArrowDownWideShort, faHouse, faPencil, faTableColumns} from "@fortawesome/free-solid-svg-icons" @@ -6,35 +8,126 @@ import cn from "classnames" export function BoardHeader() { - const {title, isEditingTitle, editTitle, setEditTitle, toggleEditingTitle, nextGrouper, nextSorter, websocketState} = useManagedBoard(); - - const isReady = websocketState === WebSocket.OPEN + const {isEditingTitle} = useManagedBoard(); return (
-
- - -
-

- {isEditingTitle ? - setEditTitle(e.target.value)} value={editTitle}/> - : -
{title}
- } -

-
- - -
+ + {isEditingTitle ? : } + + + + + + + + +
) } + +function TitleArea({children}: {children: ReactNode}) { + return ( +

+ {children} +

+ ) +} + +function TitleInput() { + const {editTitle, setEditTitle} = useManagedBoard() + + return ( + setEditTitle(e.target.value)} + value={editTitle} + /> + ) +} + +function TitleDisplay() { + const {title} = useManagedBoard() + + return ( +
+ {title} +
+ ) +} + +function LeftButtonsArea({children}: {children: ReactNode}) { + return ( +
+ {children} +
+ ) +} + +function HomeButton() { + const router = useRouter() + const goHome = useCallback(() => router.push("/"), [router]) + + return ( + + ) +} + +function EditTitleButton() { + const {websocketState, toggleEditingTitle} = useManagedBoard() + + if(websocketState != WebSocket.OPEN) { + return null; + } + + return ( + + ) +} + +function RightButtonsArea({children}: {children: ReactNode}) { + return ( +
+ {children} +
+ ) +} + +function CycleGroupButton() { + const {websocketState, nextGrouper} = useManagedBoard() + + if(websocketState != WebSocket.OPEN) { + return null; + } + + return ( + + ) +} + +function CycleSortButton() { + const {websocketState, nextSorter} = useManagedBoard() + + if(websocketState != WebSocket.OPEN) { + return null; + } + + return ( + + ) +}