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

Custom image per alert type #120

Closed
lucianomlima opened this issue Mar 3, 2018 · 11 comments
Closed

Custom image per alert type #120

lucianomlima opened this issue Mar 3, 2018 · 11 comments

Comments

@lucianomlima
Copy link
Contributor

Turns possible to user set an image for an alert type. Example: custom images for error and success alerts.
Can be new props or an options param for alertWithType method.

@testshallpass testshallpass changed the title [Feature Request] Custom image per alert type Custom image per alert type Mar 4, 2018
@testshallpass
Copy link
Owner

@lucianomlima If you want you can use imageSrc prop and pass custom type to change the image in the alert.

@lucianomlima
Copy link
Contributor Author

I know... I use custom type but it would be interesting to be able to have custom image for alert types.

@testshallpass
Copy link
Owner

true something like the errorImageSrc, etc, it would make it a bit easier. I welcome a PR.

@lucianomlima
Copy link
Contributor Author

I can help with PR but I'm not familiar with TDD and this can reduce coverage for this component.

@testshallpass
Copy link
Owner

No worries on the testing I will follow up with a tiny patch on that end. Also, thanks.

@lucianomlima
Copy link
Contributor Author

Ok! I try to send a PR

@lucianomlima
Copy link
Contributor Author

  getSourceForType(type) {
    switch (type) {
      case 'info':
        return this.props.infoImageSrc || require('./assets/info.png');
      case 'warn':
        return this.props.warnImageSrc || require('./assets/warn.png');
      case 'error':
        return this.props.errorImageSrc || require('./assets/error.png');
      case 'success':
        return this.props.successImageSrc || require('./assets/success.png');
      default:
        return this.props.imageSrc;
    }
  }

This is good for you?

@testshallpass
Copy link
Owner

It's good but can be taken a small step further with the props as the return and the defaultProps is the asset. And so: return this.props.infoImageSrc

@lucianomlima
Copy link
Contributor Author

Ok. I did change. What I have to put for default in Readme for these new props?

@testshallpass
Copy link
Owner

testshallpass commented Mar 4, 2018

Basically, infoImageSrc would be require('./assets/info.png'); and etc. See cancelBtnImageSrc prop.

@chhornponleu
Copy link

This feature should support version 2.x as well

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

No branches or pull requests

3 participants