From 95b81fe265a11f7b213104541abc75505a935d5a Mon Sep 17 00:00:00 2001 From: sara Date: Tue, 7 May 2024 13:54:50 -0300 Subject: [PATCH] style: checkbox component --- web/app/components/Button.tsx | 4 +- web/app/components/Input.tsx | 37 +++++++ .../Configurations/Configurations.tsx | 48 +++++++- .../Validations/Configurations/ContextTab.tsx | 4 +- .../Validations/Configurations/Tabs.tsx | 49 --------- .../Validations/Configurations/UITab.tsx | 104 +++++------------- web/app/routes/tx.tsx | 4 +- 7 files changed, 110 insertions(+), 140 deletions(-) delete mode 100644 web/app/components/Validations/Configurations/Tabs.tsx diff --git a/web/app/components/Button.tsx b/web/app/components/Button.tsx index 255ba5c..cdd2a40 100644 --- a/web/app/components/Button.tsx +++ b/web/app/components/Button.tsx @@ -1,13 +1,13 @@ import { ButtonHTMLAttributes } from "react"; interface ButtonProps extends ButtonHTMLAttributes { - type: "submit" | "button"; + type?: "submit" | "button"; className?: string; color?: "blue" | "pink"; } export const Button = ({ - type, + type = "button", children, className: customClassName, color = "blue", diff --git a/web/app/components/Input.tsx b/web/app/components/Input.tsx index 2b1a775..31f4c6d 100644 --- a/web/app/components/Input.tsx +++ b/web/app/components/Input.tsx @@ -4,6 +4,8 @@ interface InputProps extends InputHTMLAttributes { name: string; className?: string; inputSize?: "small" | "medium"; + label?: string; + isCheckbox?: boolean; } export const Input = ({ @@ -16,7 +18,42 @@ export const Input = ({ placeholder, className: customClassName, inputSize = "medium", + label, + isCheckbox = false, + checked, }: InputProps) => { + if (isCheckbox) { + return ( +
+ +
+ +
+
+ ); + } return ( void; @@ -9,6 +10,11 @@ interface ConfigsModalProps { } export function ConfigsModal({ closeModal, latestParams }: ConfigsModalProps) { + const tabs: TabType[] = [TabNames.Context, TabNames.UI_Options]; + const [selected, setSelected] = useState(TabNames.Context); + + const changeSelected = (tab: TabType) => () => setSelected(tab); + // To close config modal on esc press useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { @@ -35,10 +41,42 @@ export function ConfigsModal({ closeModal, latestParams }: ConfigsModalProps) { > + - +
+
+ {tabs.map((tab) => ( + + ))} +
+
+
+ +
+ +
+ +
+
+
diff --git a/web/app/components/Validations/Configurations/Tabs.tsx b/web/app/components/Validations/Configurations/Tabs.tsx deleted file mode 100644 index 6760b50..0000000 --- a/web/app/components/Validations/Configurations/Tabs.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { useState } from "react"; -import { Button } from "~/components/Button"; -import { IProtocolParam, TabNames, TabType } from "~/interfaces"; -import { ContextTab } from "./ContextTab"; -import { UITab } from "./UITab"; - -export const Tabs = ({ - latestParams, -}: { - latestParams: IProtocolParam[] | undefined; -}) => { - const tabs: TabType[] = [TabNames.Context, TabNames.UI_Options]; - const [selected, setSelected] = useState(TabNames.Context); - - const changeSelected = (tab: TabType) => () => setSelected(tab); - - return ( -
-
- {tabs.map((tab) => ( - - ))} -
-
-
- -
- -
- -
-
-
- ); -}; diff --git a/web/app/components/Validations/Configurations/UITab.tsx b/web/app/components/Validations/Configurations/UITab.tsx index 270183f..197fb09 100644 --- a/web/app/components/Validations/Configurations/UITab.tsx +++ b/web/app/components/Validations/Configurations/UITab.tsx @@ -1,5 +1,6 @@ import { useLocation, useNavigate } from "@remix-run/react"; import { useContext } from "react"; +import { Input } from "~/components/Input"; import { ValidationsContext } from "~/contexts/validations.context"; import { SearchParams } from "~/utils"; @@ -51,37 +52,14 @@ export const UITab = () => {
Select validations to show
{validations.map((validation, index, arr) => (
-
- -
-
- -
-
-
+ {index !== arr.length - 1 &&
}
))} @@ -89,54 +67,22 @@ export const UITab = () => {
Others
-
- -
-
- -
-
-
-
- -
-
- -
-
-
+ +
); diff --git a/web/app/routes/tx.tsx b/web/app/routes/tx.tsx index 2a63409..ad2b137 100644 --- a/web/app/routes/tx.tsx +++ b/web/app/routes/tx.tsx @@ -23,6 +23,7 @@ import { exampleCbor, formDataToContext, initialProtPps, + logCuriosity, paramsParser, } from "~/utils"; import SettingsIcon from "../../public/settings.svg"; @@ -151,7 +152,7 @@ export default function Index() { } }, [initData, context.selectedNetwork]); - // if (data) logCuriosity(data); + if (data) logCuriosity(data); const era: EraType = data?.era || Eras.Babbage; @@ -179,7 +180,6 @@ export default function Index() { />