-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
is there a way to load static file like png or ttf in a custom dash component plugin package? #96
Comments
Hm good question. Does the solution in #71 work for you? |
Er, it wouldn't really if you're writing your own bundle. The Dash component bundles only include CSS and JS bundles (see e.g. https://github.com/plotly/dash-core-components/blob/master/dash_core_components/__init__.py#L15-L43). We could also include a way to specify the image assets of the bundle / package as well. |
yep, i've find that there are only two kinds of dist config(js and css) which makes hard to write components like icon on top of other react library. |
@chriddyp are there any plans to look into this? would you accept a PR that implements it? i need to serve map files for my components and an assortment of static resources such as fonts and icons. |
@yunake - I'm not planning on looking into this in the immediate future. I would accept a PR that would add this. This will likely be added to the https://github.com/plotly/dash-components-archetype repository. If possible, a little write up (in a github issue) on the general approach of how this would be accomplished would be really helpful for me and others before the PR gets submitted. |
Great! |
actually, since packages can be egg files and even pex, send_from_directory won't cut it - something like this might be more appropriate, with a pregenerated set of files+urls (for security) - this is what i currently use in my workaround: from pkg_resources import resource_stream
flask.send_file(
resource_stream(component_name, os.path.join(static_dir, resource_url)),
attachment_filename=os.path.basename(resource_url)
) |
I'm also hitting the need for something like this. I want to add static files to a component, in this case I want to add a JS file to |
Companion to PR plotly#96 -- forgot to regen
Companion to PR plotly#96 -- forgot to regen
Also hitting this issue when trying to add an icon to a search box. Since it's a component library which is only used internally by one project, I can work around it by duplicating the icon in the project's assets folder, but that's really an ugly workaround and also not feasible for everyone I think. |
Companion to PR #96 -- forgot to regen
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
I'm writting my own dash components on top of dash & react-semantic-ui.
just find that it's hard to use the icon in dash, cause most react lib pack png files(and many others like ttf) for the icon.
The text was updated successfully, but these errors were encountered: