Skip to content

Commit

Permalink
added acceptableFileFormat prop to inputImage (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruggero <[email protected]>
  • Loading branch information
sepehr2github and cgero-eth authored Jul 25, 2023
1 parent 13f2506 commit 8bcd5df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- a new variable named acceptableFileFormat added to inputImage Component

## [0.2.7] - 2023-07-24

### Changed
Expand Down
1 change: 1 addition & 0 deletions src/components/input/inputImageSingle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Single.args = {
minDimension: 256,
maxFileSize: 3000000,
onlySquare: true,
acceptableFileFormat: 'image/jpg, image/jpeg, image/png, image/gif',
onError: () =>
alert(
'Please provide a squared image (PNG, SVG, JPG or GIF) with a maximum of 3MB and size between 256px and 2400 px on each side',
Expand Down
7 changes: 6 additions & 1 deletion src/components/input/inputImageSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export type InputImageSingleProps = {
* Passing image src for preview
*/
preview?: string;
/**
* acceptable image formats
*/
acceptableFileFormat?: string;
};

export const InputImageSingle: React.FC<InputImageSingleProps> = ({
Expand All @@ -43,6 +47,7 @@ export const InputImageSingle: React.FC<InputImageSingleProps> = ({
maxFileSize,
onlySquare = false,
preview: previewSrc = '',
acceptableFileFormat = 'image/jpg, image/jpeg, image/png, image/gif, image/svg+xml',
onError,
}) => {
const [loading, setLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -96,7 +101,7 @@ export const InputImageSingle: React.FC<InputImageSingleProps> = ({
} = useDropzone({
onDrop,
...(maxFileSize && { maxSize: maxFileSize }),
accept: 'image/jpg, image/jpeg, image/png, image/gif, image/svg+xml',
accept: acceptableFileFormat,
});

if (loading) {
Expand Down

0 comments on commit 8bcd5df

Please sign in to comment.