Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type UploadProps = {
hint?: string;
/** @default false */
multiple?: boolean;
label?: ReactNode;
/** @default "default" */
state?: "success" | "error" | "default";
/** The message won't be displayed if state is "default" */
Expand All @@ -31,6 +32,7 @@ export const Upload = memo(
disabled = false,
hint = t("hint"),
multiple = false,
label = multiple ? t("add files") : t("add file"),
state = "default",
stateRelatedMessage,
nativeInputProps = {},
Expand Down Expand Up @@ -71,7 +73,7 @@ export const Upload = memo(
ref={ref}
>
<label className={fr.cx("fr-label")} aria-disabled={disabled} htmlFor={inputId}>
{t("add_files")}
{label}
<span className={fr.cx("fr-hint-text")}>{hint}</span>
</label>
<input
Expand Down Expand Up @@ -116,7 +118,8 @@ const { useTranslation, addUploadTranslations } = createComponentI18nApi({
"componentName": symToStr({ Upload }),
"frMessages": {
/* spell-checker: disable */
"add_files": "Ajouter des fichiers",
"add file": "Ajouter un fichier",
"add files": "Ajouter des fichiers",
"hint": "Taille maximale : 500 Mo. Formats supportés : jpg, png, pdf. Plusieurs fichiers possibles."
/* spell-checker: enable */
}
Expand All @@ -125,7 +128,8 @@ const { useTranslation, addUploadTranslations } = createComponentI18nApi({
addUploadTranslations({
lang: "en",
messages: {
"add_files": "Add files",
"add file": "Add file",
"add files": "Add files",
"hint": "Maximum size : 500 Mo. Supported formats : jpg, png, pdf. Many files possible."
}
});
9 changes: 9 additions & 0 deletions stories/Upload.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const { meta, getStory } = getStoryFactory({
"disabled": {
"control": { "type": "boolean" }
},
"label": {
"description": "By default : Ajouter un fichier / des fichiers",
"control": { "type": "text" }
},
"state": {
"options": (() => {
const options = ["default", "success", "error"] as const;
Expand Down Expand Up @@ -44,6 +48,7 @@ const { meta, getStory } = getStoryFactory({
export default meta;

export const Default = getStory({
"label": undefined,
"hint": "Texte de description",
"state": "default",
"stateRelatedMessage": "Text de validation / d'explication de l'erreur",
Expand Down Expand Up @@ -73,3 +78,7 @@ export const WithHint = getStory({
export const Multiple = getStory({
"multiple": true
});

export const WithCustomLabel = getStory({
"label": "Téléversez votre image de profil"
});