Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1501 from dxc-technology/rarrojolopez-file-input
File input inside a form improvements
- Loading branch information
Showing
6 changed files
with
59 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
website/screens/components/file-input/code/examples/formFileInput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
DxcFileInput, | ||
DxcInset, | ||
DxcButton, | ||
DxcFlex, | ||
} from "@dxc-technology/halstack-react"; | ||
import { useState } from "react"; | ||
|
||
const code = `() => { | ||
const [files, setFiles] = useState([]); | ||
const handleSubmit = (event) => { | ||
event.preventDefault(); | ||
console.log(files.map((file) => file.file.name)); | ||
}; | ||
const callbackFile = (files) => { | ||
setFiles(files); | ||
}; | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<DxcInset space="2rem"> | ||
<DxcFlex direction="column" gap="2rem"> | ||
<DxcFileInput | ||
label="Select your files" | ||
value={files} | ||
callbackFile={callbackFile} | ||
/> | ||
<DxcButton type="submit" label="Submit" /> | ||
</DxcFlex> | ||
</DxcInset> | ||
</form> | ||
); | ||
}`; | ||
|
||
const scope = { | ||
DxcFileInput, | ||
DxcButton, | ||
DxcInset, | ||
DxcFlex, | ||
useState, | ||
}; | ||
|
||
export default { code, scope }; |