From 64e3705669e7c12b8013704654f17cf8eaf659d4 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 25 May 2023 18:08:20 -0300 Subject: cases, account details and new-form screen --- .../src/handlers/InputChoiceHorizontal.tsx | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 packages/exchange-backoffice-ui/src/handlers/InputChoiceHorizontal.tsx (limited to 'packages/exchange-backoffice-ui/src/handlers/InputChoiceHorizontal.tsx') diff --git a/packages/exchange-backoffice-ui/src/handlers/InputChoiceHorizontal.tsx b/packages/exchange-backoffice-ui/src/handlers/InputChoiceHorizontal.tsx new file mode 100644 index 000000000..fdee35447 --- /dev/null +++ b/packages/exchange-backoffice-ui/src/handlers/InputChoiceHorizontal.tsx @@ -0,0 +1,86 @@ +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; + value: V; +} + +export function InputChoiceHorizontal( + props: { + choices: Choice[]; + } & UIFormProps, +): VNode { + const { + choices, + name, + label, + tooltip, + help, + placeholder, + required, + before, + after, + converter, + } = props; + const { value, onChange, state, isDirty } = useField(name); + if (state.hidden) { + return ; + } + + return ( +
+ +
+
+ {choices.map((choice, idx) => { + const isFirst = idx === 0; + const isLast = idx === choices.length - 1; + let clazz = + "relative inline-flex items-center px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 focus:z-10"; + if (choice.value === value) { + clazz += + " text-white bg-indigo-600 hover:bg-indigo-500 ring-2 ring-indigo-600 hover:ring-indigo-500"; + } else { + clazz += " hover:bg-gray-100 border-gray-300"; + } + if (isFirst) { + clazz += " rounded-l-md"; + } else { + clazz += " -ml-px"; + } + if (isLast) { + clazz += " rounded-r-md"; + } + return ( + + ); + })} +
+
+ {help && ( +

+ {help} +

+ )} +
+ ); +} -- cgit v1.2.3