Open bennypowers opened 1 year ago
That's a great idea. I'd be more than happy to review a PR for this 😄
Some initial thoughts on naming/structure:
/_pagefind/pagefind-ui.js
script dual purpose and work for both approaches <pagefind-default-ui></pagefind-default-ui>
would be preferable Your naming preferences are fine by me.
About APIs, if it'd be up to me, I'd have the script become a module which exports the constructor but also registers the tag name as a side effect. Changing from a script to w module would be a breaking change, but worth it IMO, so perhaps it's best to vend a script as well, at least initially. Scripts can import modules but only as promises so it might be awkward to try and straddle the fence.
Oh yup that makes sense. I'm pretty firm on no breaking changes, but I'm happy to change the recommended/documented flows. So that sounds good to me! I think anything further could be handled in reviewing a PR 🙂
Looking at the default UI, you'll see that it currently builds out to multiple targets — including a module build that is published to https://www.npmjs.com/package/@pagefind/default-ui, so there's potentially something you could tap into there, or another ESM build for web added, etc.
The
PagefindUI
object is great if someone wants to write javascript, but how much nicer would it be to offer a web component?before:
after:
Options could be exposed as attibutes or children. function options could be set as DOM properties, or modified in events
Would that be an interesting PR to review?