-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow EuiImage to set custom width #3012
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @anishagg17
Can you update the PR summary to include a more full description? Like, what part of the issue this PR addresses, how it was addressed, and what is still left to do?
Also, please strikethrough (~~
) any checklist items that don't apply so we have an accurate picture of work still left to be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the description and summary updates
This doesn't appear to match the description or solve the issue requirements, though. Specifically:
the size prop essentially means "width or height should be set to this, whichever is larger" in any cases when it is not set to original or fullWidth
allow EuiImage to set custom width by allowing size to accept number
With these changes, only height is directly set when giving the size
prop a numeric value. A 2:1 horizontally oriented image, for instance, would be 100px wide when size={50}
. This component would need to do an aspect ratio calculation to accomplish the requirement of "width or height should be set to this, whichever is larger" (or perhaps just also set max-width
to the given size
number)
@snide Am I reading your comments correctly?
I will update it soon |
I have updated the functionality |
@anishagg17 I'm still a bit confused on the intention of this PR. If you intend for this PR to only impact width, we can work with that. If your latest commit intended to restrict height based on aspect ratio, the functionality needs to be revisited. |
Let me recheck for it |
@thompsongl can you please recheck this now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @anishagg17, this does restrict height now also.
Like I mentioned in an earlier comment, this can be done without any JS if we were to "perhaps just also set max-width to the given size number". Rather than use timeouts or ratio calculations, we could use the customStyle
state to set minWidth
and maxWdith
to size
when size
is a number. CSS will correctly size the image with the same restrictions.
Should I update according to this?? |
Jenkins, test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3012/ |
Yes, please. A style-only solution is preferable here to using React lifecycle methods and JS intervals to check DOM sizing attributes. |
now i have used
this fixes it correctly |
@anishagg17 This one got kind of complicated and the docs needed good explanations so I pushed you a PR. anishagg17#3 As mentioned in the summary it:
|
- Moved props docs to comments in component file - Accounting for `style` prop is passed by consumer - Removed extraneous style properties - Updating docs size section
Last 2 properties are required to maintain the aspect ratio otherwise a size x size image is rendered |
Ahh it only happens when the height is greater than the width. This actually brings up a greater question... Should we be increasing the size of the images to fit the "size" given? @snide, Just curious on your thoughts here.... Currently, all the enum sizes (s, m, l, etc...) will force the image to grow to fit that specified width. However, in the current configuration when a I can't really see a benefit of making the image grow to fit the size if the image isn't already atleast that size. This will cause blurry images. |
Jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3012/ |
I agree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about it some more and I think we should just keep the behavior as it is where the sized (s, m, l, etc) images would grow to fit the determined size, but the custom values behave as a maximum and wont grow the image.
The only way I could find to make the latter actually grow the image proportionally is to use object-fill
but then it doesn't work with the shadow we have on the figure
and just gets very messy. So for now, I think this works. I just have some text changes now based on all that.
Haha, thanks @snide. I think we'll leave it for now and circle back but at least the custom sizing won't increase the image size. |
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
Jenkins, test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3012/ |
There's a prettier error most likely due to the accepting of changes in Github.
|
Jenkins, test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3012/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks!
Summary
Fixes : #1554
allow EuiImage to set custom width by allowing size to accept number
Checklist
- [ ] Check against all themes for compatibility in both light and dark modes- [ ] Checked in mobile- [ ] Props have proper autodocs- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes