←back to thread

69 points jdkoeck | 4 comments | | HN request time: 0.001s | source
Show context
maxloh ◴[] No.44437012[source]
I don't understand why Svelte isn't even mentioned. Its syntax is more readable for me.

  <div>
    {#each colors as color, i}
      <button
        style="background: {color}"
        aria-label={color}
        aria-current={selected === color}
        onclick={() => selected = color}
      >
        {i + 1}
      </button>
    {/each}
  </div>
replies(4): >>44437120 #>>44437268 #>>44437428 #>>44437574 #
1. roywiggins ◴[] No.44437268[source]
I'm somewhat partial to Alpine, which sort of crams it into html.

    <div x-data="{ open: false }">
        <button @click="open = true">Expand</button>
 
        <span x-show="open">
            Content...
        </span>
    </div>
replies(1): >>44437434 #
2. cluckindan ◴[] No.44437434[source]
x-anything is just painful like Angular. UI state is better off being non-declarative, otherwise the builtin behaviors become a limit and unmaintainable workarounds ensue.

Nobody wants to express complex conditions all around the UI when derived state can be handled in a single store.

replies(1): >>44440147 #
3. roywiggins ◴[] No.44440147[source]
You can drive an entire Alpine app through a class, which works fine- the class handles all the behavior and the x- tags are mostly wiring up events to methods, and state to visible behavior. But it definitely doesn't take that big an app before you start to get a bit cramped.

I think I'm fond of it because I've never grown to love html-in-js. Sometimes you definitely need that, but for apps that are simple enough that you don't, I find Alpine is just nice to use. No build steps at all, every editor knows how to color html, etc.

It probably shouldn't become a web standard though.

replies(1): >>44446053 #
4. cluckindan ◴[] No.44446053{3}[source]
You could get pretty far with a global event handler on the body tag, as most UI events bubble up. Write up an interface for registering sub-handlers from component js files and you get template-behaviour colocation, and any DOM subtree mutation no longer requires event rebinding.