Comments (4)
That’s a great question. Importing image files doesn’t work with native JavaScript/importmaps/AssetMapper. It’s kind of a thing webpack invented, but I totally understand that we got used to the convenience.
Anyway, the answer is to pass the images as values to the stimulus controller. Is that simple - though I realize if you are rendering this controller frequently, that could be annoying.
i don’t know if it’s worth it, but we could create a system to help with this. The only thing you’re missing if you do the iconUrl: ../… solution is the version hash. AssetMapper dumps a manifest.json file with a map to the versioned filenames (though maybe not in dev), which could be used in JavaScript to find the final name.
Or… we could add something to AssetMapper to actually support importing images… in a similar way to the upcoming CSS support in 6.4. Hmm…
from ux.
Many thanks for your anwser.
I now pass the assets as values, but it becomes less readable. I do not call it many times, so still accepable.
Or… we could add something to AssetMapper to actually support importing images… in a similar way to the upcoming CSS support in 6.4. Hmm…
By "Hmm...", do you mean you have something in mind? Let me know if I can help finding a more elegant solution than using values.
from ux.
Yea, I have something in mind, I just don’t know if it’s a good idea or not :). So for now, let’s stick with values as, like you mentioned, it’s fairly rare.
from ux.
👍
Thanks. I close this for now.
from ux.
Related Issues (20)
- [UX] Live component - form select required not initialized HOT 3
- [LiveComponent] [Form] Sometimes save function doesn't have correct value from the last edited form field HOT 8
- [Autocomplete] Testing an autocomplete HOT 12
- [LiveComponent] Serializer still required
- How to render a component from PHP code? HOT 2
- [TURBO] UX Turbo does not re-render form on error HOT 17
- [LiveComponent] make AsLiveComponent non-final HOT 2
- [LiveComponent] Redirection not working Symfony 7.0.1 live-component 2.13 HOT 4
- [Autocomplete + Live Component] Validation issue when using an autocomplete field in a live component HOT 2
- [LiveComponent] ElementChanges fails with 'DOMException: DOMTokenList.remove: The empty string is not a valid token' if HTML class attribute contains newlines HOT 6
- [Live Component + Autocomplete + Dynamics form] Change rendering problem HOT 3
- [TwigComponent] set anonymous template in a bundle directory HOT 5
- [Docs] Symfony UX not in general symfony search ? HOT 1
- [StimulusBundle] Deprecation after "symfony new --webapp" HOT 4
- [LiveComponent][Documentation] Unclear instructions for Javascript HOT 9
- [Autocomplete] Fetch results with elasticsearch HOT 3
- [UX Live] Wrong display value for loading element show HOT 5
- [Autocomplete] Module build failed @symfony/ux-autocomplete/package.json" could not be found HOT 3
- [LiveComponent] data-loading behaviour not working correctly in child components HOT 7
- [LiveComponent] addCollectionItem don't work when using DTO as source HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ux.