Convert LayerCake.svelte lib to Svelte 5 - #331
Conversation
|
On |
8b28a9d to
960a203
Compare
|
Maybe we can handle |
|
I've never liked how the LayerCake component has all of this code for x, y, z and r even if the user hasn't defined those. It would be nice if things were more dynamic where it looked at whether those accessors were set and then created properties as a result. I'm not sure if this will work with Svelte's reactivity but just putting it out there. |
Ya that makes sense. |
Not sure if it's possible to do everything without stores, but with or without stores maybe it's possible to be more dynamic with the context. You wrote earlier that it likely would look like |
|
We should pick this back up. If we keep stores, then we probably can't have it be more dynamic but I'd have to look into it. I had originally thought stores were going away but I think they aren't? If they remain, then can keep our destructured props from the layercake context. There is some new stuff around createContext that maybe would be helpful such as adding type hints? |
|
Yes, the |
|
Here is an attempt to convert the It seems to be the recommended way, from https://svelte.dev/docs/kit/state-management#Using-state-and-stores-with-context
I think it makes the The basic approach I used is to store original prop values or derived variables ( The import in a child component is then const { data, xGet, yGet, xScale, yScale } = $derived(getLayerCakeContext());for using them as Alternatively, one could them import them as const context = getLayerCakeContext()for using them as It would be a breaking change but updating user's components could likely be done with search and replace or a migration script. |
|
For the shared context I used a I think it would be nice to keep the downloadable components with JSDoc so that they can be dropped in any project. |
As discussed in #329