Open alanbsmith opened 3 days ago
We would still need to figure out how to elegantly handle setting the base URL for various consumers and environments
If we assumed the base URL was always the same it could go in the CKR provider.
One downside with background images is you don't get the same callbacks you get with <img>
tag. e.g. onerror
and onload
@vibdev Yeah, it could be an img
tag and use src
instead. 🤔
Is there any desire to make it a <Picture />
element so we could serve different graphics depending on media queries?
Also one other thought is, this might be a really good use case for web components, there is no reactivity so might fit.
🚀 Feature Proposal
Create a new Graphic component that pulls SVGs from a URL instead of injecting the graphic as inner HTML within the component.
Motivation
__dangerouslySetInnerHTML
We could also refactor the existing Graphic component, but I think it's a better idea to add this to
canvas-kit-preview-react
and allow consumers to adjust over time. Adding a new component would also allow us to roll this out to teams sooner.Example
The API could look something like this:
Under the hood, we would use set the
imageName
as a CSS var in our stencil and pass it along to thebackgroundImage
.Open to discussion on this. 😄