2 ms·
I love the ideas here, but honestly the examples are a bit weak here. > Where possible, default to defining style and behaviour with inline HTML attributes bu
by graypegg 3y ago
I love the ideas here, but honestly the examples are a bit weak here.
> Where possible, default to defining style and behaviour with inline HTML attributes
but their example wouldn't work.
<div class="bg-green" onlick="this.classList.add('green')">
should probably be
<div onclick="this.classList.add('bg-green')">
which I think makes it a little more clear how weird this could get if you wanted to add more styles. You just keep growing the params passed to the ClassList add method, in a string. I would personally find
<button></button>
button:active { background: green; }
to be much more readable, but the author seems to imply this is complicated due to their approach of "Locality of Behaviour".
--
> Where libraries are necessary, use libraries that leverage html attributes over libraries built around javascript or custom syntax
I totally agree! But why is your example of a library not built around javascript or a custom syntax feature:
<input type="text" _="on input put me into #output">
<div id="output"></div>
That "on input put me into #output" I think is more jarring that the library shown as the bad example. Even better, this could just be some JS, without a framework at all.
--
> Prefer "naked" HTML to obfuscation layers that compile down to HTML
Their example is to not use Rails ERB tag helpers, in your templates. I don't think this is that big of an issue, these helpers can actually handle a lot of things that will look messy if you use the minimal amount of templating to write them. The example leaves off unique dom ids, turbo tags (very HTML/no JS focused!) and iteration.
- tomrod 3y ago>> Where possible, default to defining style and behaviour with inline HTML attributes This was my critiquing point as well. Style configurations should be separate from actions, with only references linking the two. It's the only way that makes sense for anything meaningful. Yes, I could technically write a python app where all SQL database connections have hardcoded SQL as one one long file, but that is poor practice. This suggested principle seems the same to me.