Big css utility file

This is a workspace post. It's a working document of my thoughts as I built something or pieced together an idea. It might be unstructured and contain spelling errors. It also might not look good on a small screen. But it could be useful to someone or related to another post, so I'm publishing it as-is.

CSS is hard to write by hand, but I find it easier if I do this:

  1. Use CSS utility classes for prototyping the components and elements.
  2. Re-writing the classes using something like BEM conventions.

It’s easier to go from nothing ⇒ prototype ⇒ complete than to go from zero ⇒ complete.

I’ve been using this which is a big CSS util library I made a while ago. I think it’s based on Tailwind, but I honestly can’t remember. I update it using find-and-replace in Jetbrain’s Goland IDE, which makes it pretty easy. Or I use sed if that fails.

The styles are all classes like flex, text-right, font-sans, text-gray-500, or border-2. There’s no documentation for them. They are well named, and you can search the file yourself if you’re looking for something specific.

Since it’s about 5MB, it’s not great to send the entire thing to the browser, so I use (go install to cut it down.

It lets you use HTML or a “keep” list, like this.

# This is more or less right, and works pretty well for my React code base.
  grep -Eoih '"[^"]*"' */**/*.js \
      | sed -e 's/"//g' \
	  | tr " " "\n" \
	  | sort -u \
	  | awk 'length<26' \
	  | awk 1 ORS=',.'

# Cut your CSS file, keeping what's classes from .html and .js files.
cat main.css \
  | css cut --html="*/**/**.html" --keep="${ALL_CLASSES_FROM_JS}" \
  | css minify \
  | css format --indent=0 \
  > output.css
css | snippets | workspace