Pricing Blog

How to locally use custom elements

  • sinsayato-1445829486879965324

    Emilien

    14 hours ago

    Hello, I am currently testing Nordcraft locally and wanted to know if it is possible to use custom elements when self-hosting a project. I see that it was possible at one point, because there is an example in examples/custom-element on GitHub. But how can this be done now?
  • lucasg-1445834747610661009

    Lucas G

    14 hours ago

    You still can
  • When you add an event to an element just type in the name of it
  • 1445834933561196614-image.png
  • sinsayato-1445837251840839792

    Emilien

    14 hours ago

    Sorry, I meant custom element, not custom event! 🥹
    One that I can use like this:
    <toddle-counter>
    <script
    type="module"
    src="http://localhost:3030/.toddle/custom-element/counter.js"
    ></script>
    <strong>This text should be replaced by a counter component</strong>
    </toddle-counter>
  • lucasg-1445838260810022962

    Lucas G

    14 hours ago

    How exactly are you trying to use it?
  • Custom elements are basically non-standard HTML tags
  • 1445838455979511990-image.png
  • lucasg-1445839465280045056

    Lucas G

    14 hours ago

    You can add that script to any element though, it wouldn't have to be a custom element unless you're trying to target it from something else. Could also probably just give it an element id
  • sinsayato-1446031780875341824

    Emilien

    1hour ago

    I'm not sure we're talking about the same thing. I'm referring to the concept of creating web components/widgets in Nordcraft as you can see on my screenshot.

    I call it a custom element because that's what it seems to be called on the GitHub repository.
    1446031780351049768-image.png
  • sinsayato-1446032240428584991

    Emilien

    1hour ago

    I'm trying to use the same system but locally. Except that instead of putting https://project.toddle.site/.toddle/custom-element/MyForm.js, you would need to put localhost:8989/.toddle/custom-element/MyForm.js.
  • sinsayato-1446033347716452454

    Emilien

    1hour ago

    I saw a commit made by @Erik Beuschau called “Add support for serving custom elements (#81)” earlier this year that seems to add the ability to do this. But the project has changed since then, and I'm wondering if it's still possible to do it today and, if so, how?