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:
parent
069715b5c2
commit
7e7a1c4420
2 changed files with 7 additions and 14 deletions
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue