TahaSh / swapy

✨ A framework-agnostic tool that converts any layout into a drag-to-swap one with just a few lines of code https://swapy.tahazsh.com/
MIT License
5.86k stars 114 forks source link

feat: web components #42

Closed itsjavi closed 1 month ago

itsjavi commented 1 month ago

Swapy is very cool and it seems like the perfect candidate to become a Web Component have you considered that?

A simple API like this could automatically initialize it:

<swapy onSwap="console.log">
  <div class="dropzone-1" data-swapy-slot="1">
    <div class="draggable-a" data-swapy-item="a">
      <!-- Your content for 'a' goes here -->
    </div>
  </div>
  <div class="dropzone-2" data-swapy-slot="2">
    <div class="draggable-b" data-swapy-item="b">
      <!-- Your content for 'b' goes here -->
    </div>
  </div>
</swapy>
TahaSh commented 1 month ago

Hi @itsjavi, thank you! I'm not planning on creating a web component wrapper for it, but it's something I might consider in the future. Thanks for the suggestion!