As an example, here's how you can make a vstack with grid.
vstack {
display:grid;
}
It's ridiculously simple and clean, works with all the elements without extra wrappers, no margins, no cleaning up trailing spaces, etc... add spacing class using "grid-gap" and it's the near perfect solution.The hstack example is more complicated, because you simply have to choose widths, there is no getting around this, even with flexbox. (unless you want to totally give up control of the layout to "auto".)
The spacing classes are clever, and I may adopt some of this method. (I use grid gap, I only have 2 sizes) With the "Spacers" example, a width of 1fr works using grid.
Flex beats grid with some natural overflow capabilities (row wrap), but other than that, flex is not great for this kind of thing.
Since there's only a few examples, I suspect this person will be adding more in the future.
Edit: For declarative things like this, I think there should be one assumption. I use vertical in web interfaces. This means one less option to remember. (ie, by default everything is vertical)
Edit2: With an unknown number of items, flex is probably preferable for horizontal items for simple columns. But that is only if you don't care about the widths of the columns too much as well.
The benefit of an assumption like "everything by default is vertical", then the few people without grid support, but with flex, will have a "mostly" ok display.
Also, it's not hard to have a fallback to flex for horizontal items. (the only place it would really matter)
Don't mean to bash the poster, I just think it's interesting in the "everything old is new again" vain.
Edit: they also have a lot of intrinsic layout behavior that can be difficult to predict once you start getting into more complex layouts than header, sidebar, and footer.
If you use them for layout, you're not respecting the semantic meaning of tags.
> Why were tables declared evil? > Granted, we develop for a fixed screen width.
Personally, I was always more disturbed by the anti-semanticism of the layout use of tables. But I guess at some point the web developer community just really stopped caring about such issues. Or at least that's my takeaway of the common atrocity of style attributes on individual elements that css-in-js approaches frequently produce.
So I for one like this super-compact and simple language, it's good for making simple interfaces quickly. It's unlikely to break in subtle ways on mobile, or so I hope.
Internally a solution like this may use CSS grids, flexbox, or any new hotness that makes thing easier to implement.
Of course this is going to get ugly, or outright break, if used at a large enough scale. But very often you manifestly do not have a large scale, and never going to.
I think the project is neat. It certainly is an opinionated way of doing a layout and it reads quite nicely. If CSS classes were provided as an alternative I think the project might have more adopters.
Good work :)
I agree with you, I think this is clean and easy to use.
Personally, I've stuck with Bootstrap for quite awhile now. It's not perfect but it's pretty good, well documented, and I work to keep it simple. So I don't really use a lot of what Bootstrap does and that's why this project appeals to me.
In a prior life I developed a slew of XUL apps, including a full-suite medical record system and billing system. It had its quirks, but for a developer-heavy (and design-light) firm it was a great way to build standard, predictable, and accessible UIs.
Maybe we need to introduce HTML transpilers now :)
The main advantage I see is the ability to extend HTML to have layout/templating functions, building up a simple DSL for frontend devs and editors. Since the target userbase is already familiar with HTML syntax, it's easy to learn and gives them "super powers" - for example, an <include> tag that imports another HTML file/partial.
Another use case I've used in a number of sites/applications: chaining a Markdown parser, an HTML transpiler, and a React renderer for the HTML "AST". Among other things, it renders internal links <a> as <Link> components of the router.
And the rabbit hole goes deep: the XML/HTML syntax is actually able to represent "programs" in a Lisp-like manner. If the angle brackets are too noisy, one can use Jade/Pug syntax to generate the same AST.
In the end, the traspiler should render the result in standards-compliant HTML. This Pylon project doesn't transpile anything, so the result contains undefined tags which the browser treats as HTMLUnknownElement [0]. The bottom line though, is that it works - and I've seen numerous projects in the wild taking advantage of this behavior.
I'd also like to mention the posthtml project [1]. I haven't used it myself, but a generic HTML transpiler has great potential in my opinion.
[0] https://developer.mozilla.org/en-US/docs/Web/API/HTMLUnknown...
XML was always a poor man's s-expression.
And for all the sins of SGML, tags lend themselves beautifully to templating because they can represent code as data just as Lisp does.
It’s very hard to remember and unintuitive. My guess is something to do with responsiveness?
To me, alignX and alignY (with an align shorthand) are always clear. And the amount of times I’m changing between the two is nearly 0 so far in a large app.
That said for pure layout stuff I actually think that this library is cool. <view> is totally fine.
<py-view> (or a sexier prefix) would even be valid HTML
But it does look nice :)
I understand how that it can feel familiar to Swift devs, and also realized by reading the source that the upside of using unknown tags means they don't have any base style that you'd have to override.
But really, you're breaking all HTML semantics and your markup is not accessible. It could work as a set of React/Vue/Whatever components or even Web components (probably the best way to achieve what you're trying to do), but as bare HTML it doesn't.
The spec allows custom elements[0] and pretty much requires this behaviour.
> you're breaking all HTML semantics and your markup is not accessible.
Calling the markup non-accessible is defensible[1], but it doesn't break HTML semantics in any way.
[0] https://html.spec.whatwg.org/multipage/custom-elements.html#...
[1] though it wouldn't be more accessible as a stack of divs and the custom element can be aria-tagged[2], in the browsers supporting it it's also possible to use customised elements but here there's little of interest
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#...
https://html.spec.whatwg.org/multipage/custom-elements.html#...
<list>
<hstack spacing=s>
<div class="icon"></div>
<text>Westminster</text>
<spacer></spacer>
<text>0.5 miles</text>
</hstack>
....
It is more complex then it needs to be, it puts the styling into into the html, it kills all semantic meaning and pollutes the global namespace of element names.It should be:
<my-cities>
<my-city>
<city-name>Westminster</city-name>
<city-distance>0.5 miles</city-distance>
</my-city>
....
And then simply style the custom attributes to your liking via css. If these "primitives" would use classnames instead of element names, their styles could be added like this: <my-cities class=pylon-list>
<my-city class=pylon-hstack>
<city-name>Westminster</city-name>
<city-distance>0.5 miles</city-distance>
</my-city>
....https://html.spec.whatwg.org/multipage/custom-elements.html#...
Browsers usually treat undefined nonstandard elements as span-like (flow elements), not div-like (block elements) by default.