From 7e7a1c44201e5c899539ff5811571ffce62df7ff Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 14 Sep 2021 17:09:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20BREAKING:=20Change=20validity=20?= =?UTF-8?q?from=20`boolean=20|=20null`=20to=20`"running"=20|=20"ok"=20|=20?= =?UTF-8?q?"error"=20|=20null`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/forms/FormPair.tsx | 19 ++++++------------- src/types.ts | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/components/forms/FormPair.tsx b/src/components/forms/FormPair.tsx index a2ffa5c..72ed94d 100644 --- a/src/components/forms/FormPair.tsx +++ b/src/components/forms/FormPair.tsx @@ -22,23 +22,16 @@ export function FormPair({id, label, input, validity, bluelibClassNames, customC id = UUID.v4() } - let validityClass - // If the input is valid - if(validity === true) { + let validityClass = "" + if(validity === "running") { + validityClass = "color-yellow" + } + else if(validity === "ok") { validityClass = "color-lime" } - // If the input is invalid - else if(validity === false) { + else if(validity === "error") { validityClass = "color-red" } - // If the input has no validity - else if(validity === null) { - validityClass = "" - } - // If no validity has been passed - else { - validityClass = "" - } label = React.cloneElement(label, { htmlFor: id, diff --git a/src/types.ts b/src/types.ts index 58cdcb9..4fb31ad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,4 +21,4 @@ export interface BluelibHTMLProps extends BluelibPr export type InputValue = readonly string[] | string | number | undefined -export type Validity = boolean | null +export type Validity = null | "running" | "ok" | "error"