Web Development Reference

Kip Landergren

(Updated: )

My cheat sheet for web development covering CSS and helpful resources.

Contents

CSS Libraries

TailwindCSS

Tailwind CSS Reference

CSS-in-JS

CSS Modules

The gist:

Of note:

emotion

linaria

Panda

styled-components

StyleX

Type-safe style compiler for authoring strict styles in TypeScript / JavaScript.

vanilla-extract

Component Libraries

Base UI (mui/base-ui)

Radix

From README.md:

Radix Primitives is a low-level UI component library with a focus on accessibility, customization and developer experience. You can use these components either as the base layer of your design system, or adopt them incrementally.

I think of Radix as the supplier of unstyled React components to build upon. They have solved common functionality and behavior problems (e.g. “how exactly should a context menu work?”) and can be built upon.

Repository Overview

philosophy.md explains vision and principles
packages/core internal helpers
packages/react components and hooks

Primitives

A primitive component Foo has exports such that:

Foo.Root Root is an alias pointing back to Foo
Foo.Bar1 Bar1 is some descendant component
Foo.Bar2 Bar2 is some descendant component

I believe this is for the DX of always having .Root access the topmost radix-ui component of the module.

Slot

Notes

Resources

shadcn/ui

From the Introduction:

shadcn/ui is a set of beautifully-designed, accessible components and a code distribution platform. Works with your favorite frameworks and AI models. Open Source. Open Code.

This is not a component library. It is how you build your component library.

This latter description is because its goal is to provide components whose source is copied directly into your repository and modified according to your needs.

Notes

The default style has been deprecated. Use the new-york style instead.

Repository Overview

CONTRIBUTING.md includes a repository structure overview
app/www/components React components used in the shadcn-ui website
app/www/registry components to use in your applications
app/www/registry/default (deprecated) the “default” style implementations
app/www/registry/default/ui (deprecated) the “default” tsx component code
app/www/registry/new-york the “new york” style implementations
app/www/registry/new-york/ui the “new york” tsx component code
packages/cli (?? deprecated ??) the old CLI code
packages/shadcn the current CLI code

Resources

Other Libraries

Class Variance Authority (cva)

Structured way of defining JavaScript objects such that className strings can be composed based on defined “variants”. Inspired many CSS-in-JS libraries’ functionality.

PostCSS

a .css file being processed by PostCSS and turned into an abstract syntax tree before being recompiled into a new .css file with changes from plugins applied

Web APIs

IndexedDB

Client-side database implemented in JavaScript.

WindowOrWorkerGlobalScope

Events

Keys

ArrowUp
ArrowDown
ArrowLeft
ArrowRight

Management

onFocus()

Important: there does not appear to be a robust way of determining whether a focus event was initiated by user mouse, user keyboard, or programatic action.

Create a favicon.ico from .png

$ convert public/image.png     \
  \( -clone 0 -resize 16x16 \) \
  \( -clone 0 -resize 24x24 \) \
  \( -clone 0 -resize 32x32 \) \
  \( -clone 0 -resize 48x48 \) \
  \( -clone 0 -resize 64x64 \) \
  -delete 0                    \
  -alpha off                   \
  -colors 256                  \
  ./public/favicon.ico

Resources

Others:

Web Development Terminology

AD
active directory
DMZ
demilitarized zone; referring to subnetwork between an organization’s internal network and untrusted external networks
DOM
Document Object Model; a platform-neutral model for events, aborting activities, and node trees
IdP
identify provider
atomic CSS / atomic styles
one utility class name : one CSS rule. e.g. TailwindCSS’ flex -> display: flex;
client-side
the DOM and JavaScript that runs in the user’s browser
front end web server / UI server
server that serves static assets (JavaScript, CSS, HTML) and may route dynamic requests (other web pages, API calls)
headless component architecture
?? shadcn/ui uses; something something internals are able to be updated without affecting usage but I don’t see how ??
leaf component
the outermost / final descendant of a component tree
polyfill
a piece of code—typically JavaScript—used to provide modern functionality to browsers that do not natively support it
vendor prefix
the browser (vendor) prefix added to CSS rules and JavaScript APIs that enable browser-specific behavior. Note: According to MDN this is being phased out.