From 0566b637c96c9b8cb1bb515507c6bf012c3f0187 Mon Sep 17 00:00:00 2001 From: Nate Ferrell Date: Mon, 30 Sep 2024 03:36:20 -0500 Subject: [PATCH] feat: #comment updated layout --- src/components/DeviceCustomizationForm.tsx | 139 +++++++-------------- src/components/EditDeviceForm.tsx | 4 +- 2 files changed, 49 insertions(+), 94 deletions(-) diff --git a/src/components/DeviceCustomizationForm.tsx b/src/components/DeviceCustomizationForm.tsx index 2ee9d47..ae1ed4a 100644 --- a/src/components/DeviceCustomizationForm.tsx +++ b/src/components/DeviceCustomizationForm.tsx @@ -1,15 +1,12 @@ -// src/components/DeviceCustomizationForm.tsx - import React, { useState } from "react"; import { Device, Port } from "../types/devices"; +import * as Form from "@radix-ui/react-form"; interface DeviceCustomizationFormProps { - onAddDevice: (device: Omit) => void; + onAddDevice?: (device: Omit) => void; } -const DeviceCustomizationForm: React.FC = ({ - onAddDevice, -}) => { +const DeviceCustomizationForm: React.FC = () => { const [name, setName] = useState(""); const [type, setType] = useState(""); const [gridSize, setGridSize] = useState(100); @@ -38,107 +35,65 @@ const DeviceCustomizationForm: React.FC = ({ ]); }; - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - onAddDevice({ - name, - type, - gridSize, - inputs, - outputs, - position: { x: gridSize, y: gridSize }, - }); - // Reset form - setName(""); - setType(""); - setGridSize(100); - setInputs([]); - setOutputs([]); - }; - return ( -
-
- - setName(e.target.value)} - required - className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" - /> -
-
- - setType(e.target.value)} - required - className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" - /> -
-
- - setGridSize(Number(e.target.value))} - required - min="100" - max="2000" - className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" - /> -
-
+ + + setGridSize(Number(e.target.value))} + className="p-2 border border-gray-300 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100" + /> + + + +
-
-

- Inputs: {inputs.length} -

-

- Outputs: {outputs.length} -

-
- - + ); }; diff --git a/src/components/EditDeviceForm.tsx b/src/components/EditDeviceForm.tsx index be0c58a..326b266 100644 --- a/src/components/EditDeviceForm.tsx +++ b/src/components/EditDeviceForm.tsx @@ -101,8 +101,8 @@ const EditDeviceForm: React.FC = ({ value={gridSize} onChange={(e) => setGridSize(Number(e.target.value))} required - min="10" - max="100" + min="100" + max="2000" className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" />