-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-react): FileUploader - Support for crop image #DS-954
- Loading branch information
1 parent
9249910
commit 13c1241
Showing
9 changed files
with
100 additions
and
22 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
25 changes: 23 additions & 2 deletions
25
packages/web-react/src/components/FileUploader/AttachmentImagePreview.tsx
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 |
---|---|---|
@@ -1,20 +1,41 @@ | ||
import React from 'react'; | ||
import { FileQueueValueMetaType } from '../../types/fileUploader'; | ||
import { useFileUploaderStyleProps } from './useFileUploaderStyleProps'; | ||
import { IMAGE_DIMENSION } from './constants'; | ||
|
||
type AttachmentImagePreviewProps = { | ||
label: string; | ||
imagePreview: string; | ||
meta?: FileQueueValueMetaType; | ||
}; | ||
|
||
const AttachmentImagePreview = ({ label, imagePreview }: AttachmentImagePreviewProps) => { | ||
const AttachmentImagePreview = ({ label, imagePreview, meta }: AttachmentImagePreviewProps) => { | ||
const { classProps } = useFileUploaderStyleProps(); | ||
|
||
// TODO: Add CSS styles for crop | ||
const { x, y, width, height } = meta || {}; | ||
console.log('x:', x, 'y:', y, 'width:', width, 'height:', height); | ||
|
||
return ( | ||
<span className={classProps.attachment.image}> | ||
<img src={imagePreview} width={IMAGE_DIMENSION} height={IMAGE_DIMENSION} alt={label} /> | ||
<img | ||
src={imagePreview} | ||
width={IMAGE_DIMENSION} | ||
height={IMAGE_DIMENSION} | ||
alt={label} | ||
style={{ | ||
'--file-uploader-attachment-image-top': `-${y}px`, | ||
'--file-uploader-attachment-image-left': `-${x}px`, | ||
'--file-uploader-attachment-image-width': `${width}px`, | ||
'--file-uploader-attachment-image-height': `${height}px`, | ||
}} | ||
/> | ||
</span> | ||
); | ||
}; | ||
|
||
AttachmentImagePreview.defaultProps = { | ||
meta: undefined, | ||
}; | ||
|
||
export default AttachmentImagePreview; |
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
28 changes: 26 additions & 2 deletions
28
packages/web-react/src/components/FileUploader/useFileUploaderAttachment.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
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