Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Sep 12, 2024
1 parent caee6c1 commit ea6da8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export namespace InputProps {
>;
style?: CSSProperties;
/** Default: "default" */
state?: "success" | "error" | "default";
state?: "success" | "error" | "info" | "default";
/** The message won't be displayed if state is "default" */
stateRelatedMessage?: ReactNode;
addon?: ReactNode;
Expand Down Expand Up @@ -149,9 +149,11 @@ export const Input = memo(
return "fr-input--error";
case "success":
return "fr-input--valid";
case "info":
case "default":
return undefined;
}
assert<Equals<typeof state, never>>();
})()
),
classes.nativeInputOrTextArea
Expand Down Expand Up @@ -191,7 +193,10 @@ export const Input = memo(
return "fr-error-text";
case "success":
return "fr-valid-text";
case "info":
return "fr-info-text";
}
assert<Equals<typeof state, never>>();
})()
),
classes.message
Expand Down
8 changes: 7 additions & 1 deletion stories/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { meta, getStory } = getStoryFactory({
},
"state": {
"options": (() => {
const options = ["default", "success", "error"] as const;
const options = ["default", "success", "info", "error"] as const;

assert<Equals<typeof options[number] | undefined, InputProps["state"]>>();

Expand Down Expand Up @@ -84,6 +84,12 @@ export const WithSuccessMessage = getStory({
"stateRelatedMessage": "Texte de validation"
});

export const WithInfoMessage = getStory({
"label": "Label champs de saisie",
"state": "info",
"stateRelatedMessage": "Info text"
});

export const Disabled = getStory({
"label": "Label champs de saisie",
"disabled": true
Expand Down

0 comments on commit ea6da8d

Please sign in to comment.