Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Aljullu
Copy link
Owner

@Aljullu Aljullu commented Jul 27, 2019

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.

@Aljullu Aljullu self-assigned this Jul 27, 2019
@Aljullu Aljullu changed the title Add loadedImageProps prop Add loadedImageProps and placeholderProps props Aug 7, 2019
const props = {
...placeholderProps,
style: {
backgroundImage: loaded ? '' : 'url( ' + placeholderSrc + ')',

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

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

Copy link
Owner Author

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?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support styles applied to the img after loading
2 participants