1
Fork 0
mirror of https://github.com/Steffo99/bluelib.git synced 2024-12-22 11:34:21 +00:00

🔧 BREAKING: Change validity from boolean | null to "running" | "ok" | "error" | null

This commit is contained in:
Steffo 2021-09-14 17:09:08 +02:00
parent 069715b5c2
commit 7e7a1c4420
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 7 additions and 14 deletions

View file

@ -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,

View file

@ -21,4 +21,4 @@ export interface BluelibHTMLProps<Element extends HTMLElement> extends BluelibPr
export type InputValue = readonly string[] | string | number | undefined
export type Validity = boolean | null
export type Validity = null | "running" | "ok" | "error"