toxi, to CSS
@toxi@mastodon.thi.ng avatar

Today's features a major update for the https://thi.ng/meta-css toolchain, a data-driven codegen for creating custom modular CSS frameworks, incl. transpiler, bundler, dev/watch mode...

The new version supports callable parametric templates, which not only help to reduce the overall API surface (i.e. the total number of rules) of a generated CSS framework, but also enable advanced operations like those shown in the attached images (e.g. declarations of CSS color variables (in rgb, hsl, lch, or oklch modes) and pure CSS color per-color-channel adjustments...).

Also new, is added support for documentation metadata for all generative CSS class & template specs (incl. template params). Parts of the readme are generated from these embedded docs and the next version will include a new CLI command to generate Markdown files from/for these CSS docs...

The readme for this package is already pretty detailed by now and should cover most important patterns and usage (incl. the new template features). Take a look (also the examples linked from the readme)!

https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/README.md

Transpiled resulting CSS of the MetaCSS declerations in the previous image, showing the expanded variable definitions and calculations to create the derived color... CSS source code: :root { --link-color-luma: 80%; --link-color-chroma: 100%; --link-color-hue: 0; --link-color-alpha: 1; --link-color: oklch( var(--link-color-luma) var(--link-color-chroma) var(--link-color-hue) / var(--link-color-alpha) ); } a:link, a:visited { color: var(--link-color); } a:hover { color: oklch( calc(var(--link-color-luma) * 1) calc(var(--link-color-chroma) * 0.8) calc(var(--link-color-hue) + 180) / calc(var(--link-color-alpha) * 1) ); }

toxi, to CSS
@toxi@mastodon.thi.ng avatar

Some previews of recent updates/additions:

  1. The declarative & fully typed CLI arg parser https://thi.ng/args now has a nice cliApp() wrapper (also largely declarative), supporting multiple sub-commands (with shared and command-specific args/options), automated usage generation, https://no-color.org support/detection. Still doing more testing with various CLI tools of mine (from which this all has been extracted), but planning to release in next couple of days...

  2. People who've been following the project will know that for years I've been a big fan of Tachyons CSS[1], which is pretty much used for all ~150 examples in the repo. As nice as it is, it's also unmaintained by now and there're various more modern features missing (e.g. grids) and there're also general issues with the overall approach. Switching to Tailwind would mean having to install a whole boatload of additional tooling so is anathema and also doesn't address some of the features I've been wanting to explore: E.g. Generating entire CSS frameworks from a bunch of wildly combinatorial rules, options & lookup tables, keeping literally everything customizable, combinable and purely data-driven (i.e. generated from a JSON file). Similar to Tachyons CSS, these custom generated frameworks are based on standalone CSS utility classes (hence the original particle-inspired naming). However, I'm aiming for a different usage and instead of assigning them directly to an HTML element's class attrib, here we can assign them to (nested) CSS selectors to define fully inlined declarations. The additional killer feature is that each of these classes can be prefixed with an arbitrary number of freely defined media queries and thus making it trivial to add additional responsive/accesible features and without requiring megabytes of raw CSS to cover the combinatorial explosion!

For the past few days I've been trialling this new approach and I very much like where this is going... Take a look at the basic example in the new https://thi.ng/meta-css package & readme. I will also write more about this in coming days. All in all, it's another example where code generation and a domain specific language approach is super powerful again... limits of my world and such...

Also, speaking of bloatware (earlier above), the entire toolchain (incl. CLI & all dependent packages) is a mere 21KB (minified) and it already can do a ton!

Excerpt screenshot of the thi.ng/meta-css readme (link in the toot), explaining basic tool usage and showing the compact MetaCSS source code
Excerpt screenshot of the thi.ng/meta-css readme (link in the toot) showing the final generated CSS output (approx. 80 lines)

toxi,
@toxi@mastodon.thi.ng avatar

Just updated & simplified the https://thi.ng/meta-css tooling to also use JSON as interim representation for the generated CSS framework definitions. The metacss convert command now also acts as bundler, deduplicating CSS selectors, combining rules and media query criterias from multiple meta-stylesheets and optionally including arbitrary CSS (e.g. normalize.css as a sane starting point). More features since yesterday, but total tool bundle size (incl. all deps) has shrunk to 19KB!

I've updated the readme with an expanded example and updated instructions (should you want to try it out, even though it's still pre-release...):

https://thi.ng/meta-css

Next step: Add file watching and auto-regeneration. This should be pretty easy, thanks to Bun's built-in file watcher API:

https://bun.sh/guides/read-file/watch

schizanon, to webdev
@schizanon@mas.to avatar

What's the best static site builder for people who make #websites with #wysiwyg tools so they think that can't build websites?

#webDev #staticSite #html #css #web

schizanon,
@schizanon@mas.to avatar
schizanon, to random
@schizanon@mas.to avatar

Why is it ALWAYS such a pain in the ass to register a for a with a build-time .

Nobody ever considers this use-case when they design these things and we end up with some hacky workaround with tons of caveats.

schizanon,
@schizanon@mas.to avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines