Skip to content

Commit

Permalink
feat(mespapiers): Add RotateImage component
Browse files Browse the repository at this point in the history
  • Loading branch information
Merkur39 committed May 30, 2023
1 parent 7199108 commit 4d8994c
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PropTypes from 'prop-types'
import React, { forwardRef } from 'react'

import { useRotatedImage } from '../../Hooks/useRotatedImage'

const RotateImage = forwardRef(
({ image, onLoaded, rotation, a11n, ...props }, ref) => {
const src = useRotatedImage(image, rotation) ?? {}

return (
<img
ref={ref}
onLoad={onLoaded}
src={src}
style={{ maxWidth: '100%', maxHeight: 'inherit' }}
{...a11n}
{...props}
/>
)
}
)
RotateImage.displayName = 'RotateImage'

RotateImage.propTypes = {
image: PropTypes.string,
onLoaded: PropTypes.func,
rotation: PropTypes.number,
alt: PropTypes.string,
a11n: PropTypes.object
}

RotateImage.defaultProps = {
onLoaded: () => {},
rotation: 0,
alt: '',
a11n: {}
}

export default RotateImage

0 comments on commit 4d8994c

Please sign in to comment.