Medium’s CSS is actually pretty f***ing good.

The best at drawing pictures of myself

In the beginning (some history)

  • everything nested under a .profile-page class, with zero reusable components (also ~almost~ everything is prefixed with .profile)
  • super generic variable names like @link-color which weren’t scoped to anything, but presumably only to be used in profile-page.less
  • deep nesting (.profile-page .profile-posts .home-post-summary .home-post-collection-image img is an actual selector being generated below — super rough on perf)
  • no image spriting
  • no z-index scale, no font scale, no color scale, no scalesss…
https://gist.github.com/fat/a4af78882d0003d2345e

The 1st Project: OMG Images

The 2nd Project: Scales

https://gist.github.com/fat/1f6da6b3bd0311a1f8a0

The 3rd Project: New Style Guide

  • Limit LESS to variables and mixins (no nesting, guards, extend, etc.) — while these language features ~can~ be powerful, we found that inexperienced LESS developers often got in trouble with them fairly easily. We also just preferred the visual aesthetic of pure CSS (and the consistency it afforded) and wanted to move our codebase as far in that direction as reasonable.
  • Classes and IDs are lowercase with words separated by a dash — this is how most of us had been writing CSS at the time with Bootstrap, Skeleton, Ratchet, etc. And we thought it made sense to do the same here. Another reason is it followed the naming conventions set forth by the CSS language itself, i.e. border-radius-top-left, etc.
  • Prefer components over page level styles — we wanted our front end to feel like library code, and began to break files like profile.less into smaller more focused files like button.less, dialog.less, tooltip.less, etc.
https://gist.github.com/fat/b27700946c777adacdf4

The 4th Project: Identifying the Future

People were confused. And what’s worse, they were thinking they were writing CSS really well, when in reality they weren’t.

  1. Introduce new CSS variable, mixin, and classname semantics to avoid run-on classnames and improve readability
  2. Move us off of LESS and onto Rework for more powerful mixin support and a syntax even closer to vanilla CSS
  3. Add tooling around CSS performance (load time, fps, layout time, etc) — to make it easier to track style changes and regressions over time

The 5th Project: Semantics

  • .js- prefixed class names for elements being relied upon for javascript selectors
  • .u- prefixed class name for single purpose utility classes like .u-underline, .u-capitalize, etc.
  • Introduction of meaningful hypens and camelCase — to underscore the separation between component, descendant components, and modifiers
  • .is- prefixed classes for stateful classes (often toggled by js) like .is-disabled
  • New CSS variable semantics: [property]-[value]--[component]
  • Mixins reduced to polyfills only and prefixed with .m-
https://gist.github.com/fat/a47b882eb5f84293c4ed

X Project: The future?

PS

computer loser / captioned co-founder (captioned.com)

Love podcasts or audiobooks? Learn on the go with our new app.

fat

fat

computer loser / captioned co-founder (captioned.com)

More from Medium

Welcome to Marvia, an island for Heroes

Working From Home — An Examination of Changes in Perceived Spaces

NEXTYPE is an integrated application ecosystem among game, NFT and DeFi that can be cross-chain…

Are You a Coach Seeking to Establish Credibility and Showcase Your Expertise in Your Niche?