-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export helper to help appropriately build image styles
- Loading branch information
Showing
3 changed files
with
24 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CSSProperties } from 'react'; | ||
|
||
/** | ||
* Get img style properties to ensure proper rendering within react-roi | ||
* @param style | ||
*/ | ||
export function getTargetImageStyle(style?: CSSProperties): CSSProperties { | ||
return { | ||
// block display so that the container fits the dimensions of the image | ||
display: 'block', | ||
// Pointer events is disabled to prevent the image to be draggable | ||
pointerEvents: 'none', | ||
// Revert any global css rules that can influence the width and height of the image | ||
// e.g. tailwindcss's preflight sets max-width: 100% on any img tag | ||
// The width and height of the target should be their natural values for react-roi to work as expected | ||
maxWidth: 'initial', | ||
maxHeight: 'initial', | ||
...style, | ||
}; | ||
} |