-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add loadedImageProps and placeholderProps props #46
base: master
Are you sure you want to change the base?
Conversation
f0a3a32
to
9fc73b0
Compare
const props = { | ||
...placeholderProps, | ||
style: { | ||
backgroundImage: loaded ? '' : 'url( ' + placeholderSrc + ')', |
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.
Maybe it will be better to put these styles somewhere in the css, so that it will be enough to pass className
in the placeholderProps
(and merge classes here) to override styles without important
hacks
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.
Also it will simplify applying different styles for different resolutions using media queries
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 taking a look @BilyachenkoOY ! The issue is that we need to read placeholderSrc
from the props, and that can't be done if we move the styles completely to a CSS file. It's true we could keep backgroundImage
in the style
while moving everything else to a CSS file, but I think that would be confusing.
In the case you need to make a lot of modifications to the placeholder style, probably it's a better idea passing a node as the placeholder
prop instead of adding props to the default placeholder. How does that sound?
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 still believe that there should be as few as possible in props and it will be fine if there will be only backgroundImage
+ height&width since it should be as easy as possible to override styles using wrapperClassName
.
As for placeholder
, it will be placed inside this <span>
and is not suitable for all style manipulations.
It is not a big issue to me to add few important
directives to my CSS, so it is up to you
Fixes #31.
Description
loadedImageProps
: it allows passing an object of props that will be applied to the loaded image.placeholderProps
: it allows passing an object of props that will be applied to the placeholder.