From 245ab840baf1926ef2c03a8965fce85012887d92 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 16 May 2023 01:23:44 -0300 Subject: one form left --- .../src/handlers/InputChoiceStacked.tsx | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 packages/exchange-backoffice-ui/src/handlers/InputChoiceStacked.tsx (limited to 'packages/exchange-backoffice-ui/src/handlers/InputChoiceStacked.tsx') diff --git a/packages/exchange-backoffice-ui/src/handlers/InputChoiceStacked.tsx b/packages/exchange-backoffice-ui/src/handlers/InputChoiceStacked.tsx new file mode 100644 index 000000000..b19a0d82e --- /dev/null +++ b/packages/exchange-backoffice-ui/src/handlers/InputChoiceStacked.tsx @@ -0,0 +1,93 @@ +import { TranslatedString } from "@gnu-taler/taler-util"; +import { Fragment, VNode, h } from "preact"; +import { LabelWithTooltipMaybeRequired, UIFormProps } from "./InputLine.js"; +import { useField } from "./useField.js"; + +export interface Choice { + label: TranslatedString; + description?: TranslatedString; + value: string; +} + +export function InputChoiceStacked( + props: { + choices: Choice[]; + } & UIFormProps, +): VNode { + const { + choices, + name, + label, + tooltip, + placeholder, + required, + before, + after, + converter, + } = props; + const { value, onChange, state, isDirty } = useField<{ + [s: string]: undefined | string; + }>(name); + if (state.hidden) { + return ; + } + + return ( +
+ +
+
+ {choices.map((choice) => { + let clazz = + "border relative block cursor-pointer rounded-lg bg-white px-6 py-4 shadow-sm focus:outline-none sm:flex sm:justify-between"; + if (choice.value === value) { + clazz += + " border-transparent border-indigo-600 ring-2 ring-indigo-600"; + } else { + clazz += " border-gray-300"; + } + return ( + + ); + })} +
+
+
+ ); +} -- cgit v1.2.3