Minimal Svelte example #297
-
Would be great if the docs had sth similar to #97 for Svelte. Maybe as a |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
I should clarify that I'm particularly interested in a SvelteKit example (which is probably what most people building with Svelte will be using). |
Beta Was this translation helpful? Give feedback.
-
Hi there, thanks for opening the issue! I made a gist with a Svelte example a few months ago. Maybe for now we can link the Gist in the Vite section as you mentioned – happy to accept a PR!
Big fan of Svelte/SvelteKit here! To clarify: Svelte is a component framework, and SvelteKit is an app framework – kind of like Next.js, Nuxt, or Remix. I'm not sure what SvelteKit with Jupyter Widgets would look like because the two don't exactly fit together conceptually. Many of the problems it solves don't apply to Widget context. From the docs:
SvelteKit owns both the client and server, and with Jupyter Widgets the "server" is Jupyter kernel (not a JavaScript runtime), so really you just want/need the client-side framework (e.g., Svelte, Vue, or React). |
Beta Was this translation helpful? Give feedback.
-
Yeah I was just thinking of an example that shows where |
Beta Was this translation helpful? Give feedback.
-
FYI, I just updated the Gist to be up-to-date with the latest changes in anywidget.
No worries. I guess I'm not as familiar with using SvelteKit to author packages (al-la Generally speaking, the happy path to creating widgets is when the widget front-end code is minimal and focuses on connecting a JS API to the widget If you have a sufficiently complex idea for a widget, then using SvelteKit to build a separate JS package that you connect in a widget could be a good option. This also means that your SvelteKit package is re-usable outside of the widget context as well. No hard rules, just an observation. |
Beta Was this translation helpful? Give feedback.
-
Thanks for clarifying! Perhaps I should do the same and explain my goal. I'd like to make all components in https://elementari.janosh.dev Python-accessible in VS Code's Interactive Window and Jupyter. Ideally, there'd be a Python wrapper for each component under an from elementari import Structure3d
from pymatgen.core import Lattice, Structure
struct = Structure(
lattice=Lattice.cubic(3),
species=("Fe", "Fe"),
coords=((0, 0, 0), (0.5, 0.5, 0.5)),
)
Structure3d(struct) which should give me this sort of output in a notebook cell: Same for the Btw, happy to submit a PR with any doc improvements we agree on like the link to your gist. |
Beta Was this translation helpful? Give feedback.
-
Ah interesting. I think my recommendation would be to package Packaging this way would make it relatively straightforward to then connect your library exports (valid JavaScript) with Python. |
Beta Was this translation helpful? Give feedback.
-
Feel free to open a PR to add Svelte example to the docs! Going to close for now. |
Beta Was this translation helpful? Give feedback.
-
You might find the |
Beta Was this translation helpful? Give feedback.
Hi there, thanks for opening the issue! I made a gist with a Svelte example a few months ago.
Maybe for now we can link the Gist in the Vite section as you mentioned – happy to accept a PR!
Big fan of Svelte/SvelteKit here!
To clarify: Svelte is a component framework, and SvelteKit is an app framework – kind of like Next.js, Nuxt, or Remix. I'm not sure what SvelteKit with Jupyter Widgets would look like because the two don't exactly fit together conceptually.
Many of the problems it solves don't apply to Widget context. From the docs: