Night Desk

Paper After Dark

Dark themes usually look like a screen with the lights off. This page tries something older: a sheet of paper on a desk, late at night, with one lamp above it. The paper has grain. The lamp leaves a shadow. The words are set in a book face, and the colours come from Dracula.

Nothing here needs a script. There is one HTML file and one stylesheet. The grain is an SVG noise filter that the stylesheet carries inside itself. The light is two gradients, and the shadow is a stack of box shadows. The fonts are the ones already on your machine.

The palette

Dracula Classic gives you a background, a foreground, and a short list of accents. Each colour has one job on this page.

Token Hex Job
Background#282A36The sheet
Background Dark#21222CCode wells
Background Darker#191A21The desk
Selection#44475ARules and selected text
Foreground#F8F8F2Body text and headings
Comment#6272A4Code comments, the quote rule, the lamp tint
Purple#BD93F9The date line and table heads
Pink#FF79C6The drop cap and keywords
Cyan#8BE9FDLinks, types, and property names
Green#50FA7BInline code and function names
Yellow#F1FA8CQuotes, strings, and the name on the desk
Orange#FFB86CNumbers and parameters
Red#FF5555No job yet. It waits for an error.

How the paper is made

Grain

Two layers of fine noise lie on the sheet, one light and one dark. A third layer is much coarser and makes the tone uneven, as it is in real pulp. All three are the same turbulence filter with different settings, stored as data URIs in custom properties.

.sheet::before {
  background-image: var(--grain-light), var(--grain-dark), var(--mottle);
  background-size: 200px, 260px, 900px;
}

Light

The lamp hangs above the top right corner of the desk. The desk is brighter there, the sheet has a thin highlight on its top edge, and the shadow falls down and to the left. These are three of the six shadow layers:

.sheet {
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.06),     /* lit top edge */
    -2px 3px 4px rgb(0 0 0 / 0.35),            /* contact shadow */
    -40px 60px 120px -20px rgb(0 0 0 / 0.55);  /* long shadow */
}

Code blocks use the opposite trick. An inset shadow under the top lip and a faint highlight under the bottom lip make each block look like a well cut into the paper.

Type

Body text is Georgia at 19 pixels with a line height of 1.65, in a column about 70 characters wide. Code is Menlo or Consolas. Labels are small capitals in the system sans. No font-family names a web font, so the page is complete on the first frame.

Typography exists to honor content.

Robert Bringhurst, The Elements of Typographic Style

Use it

  1. Keep dracula-paper.css next to your page and link it.
  2. Put the text in <main class="sheet">. Give the first paragraph the class opening to get the drop cap.
  3. Colour code with seven classes: kw, fn, num, str, com, typ, and arg.
// Reading time for a post, in minutes.
function readingTime(text, wordsPerMinute = 230) {
  const words = text.trim().split(/\s+/).length;
  if (words === 0) return "nothing to read";
  return Math.ceil(words / wordsPerMinute);
}

readingTime(document.querySelector("article").innerText);

That is the whole theme. Turn the lamp down, and read.