From 4cd7b0199ea2ab7315205b94546dd3781914ce55 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 2 Jun 2026 22:46:24 +0200 Subject: [PATCH] update header fields on typing --- src/components/CustomHeaders.tsx | 32 +++++++++-- src/components/FormField.tsx | 7 +-- src/components/HeaderFields.tsx | 99 ++++++++++++++++++++++++++------ src/hooks/useChessGame.ts | 1 + src/pages/Chessboard.tsx | 11 +++- src/styles/_input.css | 1 + 6 files changed, 123 insertions(+), 28 deletions(-) diff --git a/src/components/CustomHeaders.tsx b/src/components/CustomHeaders.tsx index c206297..f509372 100644 --- a/src/components/CustomHeaders.tsx +++ b/src/components/CustomHeaders.tsx @@ -1,11 +1,13 @@ +import type { ChangeEvent } from "react"; import FormField from "#/components/FormField.tsx"; import type { IHeader } from "#/interfaces.ts"; interface IProps { headers: IHeader; + updateHeaders: (e: ChangeEvent, fieldName: string) => void; } -const CustomHeaders = ({ headers }: IProps) => { +const CustomHeaders = ({ headers, updateHeaders }: IProps) => { return (
@@ -18,10 +20,30 @@ const CustomHeaders = ({ headers }: IProps) => {
- - - - + + + +
diff --git a/src/components/FormField.tsx b/src/components/FormField.tsx index 0f5fdc1..7427e0d 100644 --- a/src/components/FormField.tsx +++ b/src/components/FormField.tsx @@ -1,15 +1,14 @@ -import { useChessGame } from "#/hooks/useChessGame.ts"; +import type { ChangeEvent } from "react"; import type { IHeader } from "#/interfaces.ts"; export interface IFormField { fieldName: string; type: string; headers: IHeader; + updateHeaders: (e: ChangeEvent, fieldName: string) => void; } -const FormField = ({ fieldName, type, headers }: IFormField) => { - const { updateHeaders } = useChessGame(); - +const FormField = ({ fieldName, type, headers, updateHeaders }: IFormField) => { return (
diff --git a/src/styles/_input.css b/src/styles/_input.css index 39f978a..527fa19 100644 --- a/src/styles/_input.css +++ b/src/styles/_input.css @@ -9,6 +9,7 @@ &:focus { outline: none; border-color: var(--accent); + background-color: var(--header-bg); } }