Open adamjarling opened 1 year ago
Adam has it so you can import it into a React component and is close to getting it working in a Vanilla JS project.
Do we want to bundle react with it? UV has umd build include with a script tag. umd script can then be hosted on a CDN.
Not a good idea to include react in the umd bundle but this would mean the user needs to import the react.
There is also a vite related package called react to web component.
This is the one we are going to try first:
Another option would be to ship with preact instead of react for a web component (avoids having to require user to include React OR conflicts with 2 versions of react on the page).
Unfortunately for this I had to fork the preact-custom-element library. https://github.com/digirati-co-uk/iiif-canvas-panel/tree/main/packages/preact-custom-element
But the build options are here: https://github.com/digirati-co-uk/iiif-canvas-panel/blob/main/packages/canvas-panel/esbuild.mjs
ESBuild in this case, but could be made to work with Vite I'm sure. The main thing are overwriting the packages listed there.
Un assigning myself from this... sounds like @stephenwf has a better pattern for implementing vanilla JS. Moving onto React features, but happy to come back to this later if need be.
Ben has volunteered to document this use case in the iiif-commons repo. Should this go in:
https://github.com/IIIF-Commons/thumbnail-panel/tree/main/docs
For now: https://github.com/IIIF-Commons/common-docs/tree/main/docs/thumbnail-panel directly in here would be good.
Still some questions about the common docs, so things will probably change soon with it.
@glenrobson This is somewhat already documented here and may be a solid start for Ben: https://github.com/IIIF-Commons/thumbnail-panel/blob/main/docs/basic-usage.md
Notes
This provides a user not using
React
the ability to still use the Thumbnail component.Done looks like
npm
under the@iiif
organization. @iiif/thumbnail-panel<script src="..path-to-thumbnail"></script>