-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #42469 from dominictb/fix/40751
fix: customize size behavior of image component
- Loading branch information
Showing
3 changed files
with
53 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, {createContext} from 'react'; | ||
|
||
type ImageBehaviorContextValue = { | ||
/** | ||
* Determine whether or not to set the aspect ratio of the container div based on the image's aspect ratio. | ||
*/ | ||
shouldSetAspectRatioInStyle: boolean; | ||
}; | ||
|
||
const ImageBehaviorContext = createContext<ImageBehaviorContextValue>({ | ||
shouldSetAspectRatioInStyle: true, | ||
}); | ||
|
||
function ImageBehaviorContextProvider({children, ...value}: {children: React.ReactNode} & ImageBehaviorContextValue) { | ||
return <ImageBehaviorContext.Provider value={value}>{children}</ImageBehaviorContext.Provider>; | ||
} | ||
|
||
export {ImageBehaviorContext, ImageBehaviorContextProvider}; |
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