Show HN: I started building yet another CSS framework (eternityforest.github.io)
So, I took all the good parts of my current CSS, replaced the bad parts with things I liked from the most popular frameworks, then extracted it as a standalone library.
The whole thing is 17.5kb, without minifying or removing comments.
It starts with classless styles for semantic html. There is a very small set of about 5 components(The intent is to basically build everything with mostly just windows, cards, and toolbars), and a mix of high and low level utilities.
There's a 12 column grid(not a real CSS grid, trying to keep it all flexbox all the time, it's just simplegrid pared down even more), a very small collection of sizing primitives.
I don't like the whole w-1 through w-100 stuff with hundreds of classes, instead, I use heights from the Highly Composite Number sequence, that you probably already know from somewhere or other(1,2,4,6,12,24, 36, 48, 60).
For widths, instead of exact fixed widths, I have w-sm-full and w-sm-half. The semantics of it is "About the full width of a phone screen, but the theme can fudge it a bit".
The reasoning is that most of the time, I'm designing things to collapse down to a long string of 1 phonewidth cards, might as well have a class for it.
I use zero media queries, except for a single desktop-only class. Nothing in markup should have to think about mobile vs desktop.
This isn't even v0.1 yet, there are still bugs, but the skeleton is there, and I'm posting now to hopefully get some feedback early, so I can fix anything before it's hard to fix.
10 comments
[ 2.8 ms ] story [ 34.5 ms ] threadGoing even further, just tweaking with style= and writing inline css instead of the single value configuration classes.
If it’s just because it’s a fun challenge, also good :)
My set of utility classes is mostly for things where the content or the layout inherently suggests some of the styling, but I'd rather do the actual visual details with semantic selectors.
Almost all my utility classes have to do with layout or sizing, and a lot of those are still as semantic as possible. .margin adds "some" amount of margin, but a theme can choose how much.
This is meant to run lighting and puzzles for themed events and escape rooms, so it's useful to be able to completely change fonts and colors without touching markup.
Bootstrap was the one I spent the most time looking into, but I didn't like how the markup winds up really bloated, and you have to apply classes to basically every tag, and how they don't make use of HTML5 semantic elements.
Using button class="button" seems a little excessive for a ~50k line total project, maybe it makes more sense if you're building the next Trello or GitHub!
If you're "in control" of the interface, and accessibility isn't a concern, have you considered just "making up" your UI elements? Like an old-school version of custom components [0]. If semantics is what you're after, and if you're running the UI in a browser kiosk mode, why limit yourself to HTML5?
[0]: https://codepen.io/spdustin/pen/VwgmXWw
Mostly-semantic is a lot easier though, "There should be padding on this" is a big step up from "I'm specifying exactly 6px right here in the markup".
On doing some digging it seems AVIF not being supported in Edge might be the issue, shoulda thought more about that demo image!
I should probably do more testing on FF too, since it's derived from internal tools that never got used outside of Chrome.