Jayce's Lab

A site whose colours change every 7 hours

The whole colour scheme of this site changes every 7 hours. Move from the blog to the chat at the same moment and you see the same colours.

Why no server is needed

The palette number is computed from the clock.

const PERIOD = 7 * 60 * 60; // 25,200 seconds
const slot = Math.floor(Date.now() / 1000 / PERIOD);
document.documentElement.dataset.palette = slot % 6;

UNIX time is the same everywhere, so every visitor and every page line up automatically. Because 7 and 24 are coprime, the change happens at a different hour each day, and the six palettes complete a cycle every 42 hours.

Colours only through variables

Every screen uses only variables such as --c-bg, --c-text and --c-a1. A palette is just a set of values for those variables, so adding one never touches the page code. The pixel illustrations are painted with the same variables, so they change too.

Accessibility

Each time a palette is added, text contrast is calculated automatically and the build stops if anything falls below WCAG AA (4.5:1). With reduced motion the colour transition is disabled, and without JavaScript the default palette is used.

Tags

Related projects