PricingBlog

How to locally use custom elements

  • sinsayato-1445829486879965324

    Emilien

    3 months 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

    3 months 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

    3 months 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

    3 months ago

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

    Lucas G

    3 months 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

    3 months 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

    3 months 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

    3 months 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?
  • erikbeus-1446059148813799515

    Erik Beuschau

    3 months ago

    Let me get back to you later today on this 👍
  • erikbeus-1446138022247792793

    Erik Beuschau

    3 months ago

    I currently have a PR in review that should enable this 🙏 I'll keep you posted when it's ready
  • sinsayato-1446165125726994504

    Emilien

    3 months ago

    Thank you very much! I'll wait until it's merged to test all this 😮
    👍1
  • Tod-1446165128079867944

    Tod

    3 months ago

    Great job @Emilien! Your contribution to the Nordcraft Community just made you advance to Community Level 2! 🌲
  • erikbeus-1446464050186682569

    Erik Beuschau

    3 months ago

    It has been merged now, but we have not released it in an actual release yet. You can still try it out if you want 👍
    💪1
  • sinsayato-1446901059544154213

    Emilien

    3 months ago

    i will try it thank you