Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

Ambient Pack

Lets a site look slightly like today. The pack resolves a season, a time of day and calendar occasions for the author's place, writes them as attributes on <html>, and maps them to decorative tokens. It never asks for or guesses the visitor's location.

TypeFunctional
Version0.2.0
CSSpacks/ambient.full.css (about 2.8 KB gzipped, icons included)
JSpacks/ambient.core.js (about 3 KB gzipped)
Inline head scriptpacks/ambient.head.js (under 1.25 KB gzipped)
Resolvers for buildspacks/ambient.resolve.js

Season, time of day, weather from a feed you serve, occasions with built-in calendars, tint tokens, motif icons, the visitor opt-out and the preview are in. Animated atmosphere effects are not built yet.

How it works

  1. Configure. The page lists the signals it wants in data-ambient and, optionally, gives a time zone and a calendar in a JSON block.
  2. Resolve. Pure functions turn the clock and the config into a state.
  3. Reflect. The state is written to attributes on <html>: by the inline head script before first paint, then kept current by the module.
  4. Respond. The pack's CSS maps the attributes to tokens. Your CSS and your theme can select on the same attributes.

Ambient adds tokens. It does not change --color-primary, text colours, borders or focus styles, so contrast for text and controls stays the theme's own. Without data-ambient on <html> the pack does nothing.

Demo

Loading

The page is correct at each stage of loading:

StageSetsWithout it
Attributes written by your builddata-season, data-occasion and data-occasion-icon as of build timeNo state; the plain theme
Inline head scriptSeason, time of day and occasions from the clock, and the weather the module cached earlier in the session, before first paint. Removes all state if the visitor opted out.Built values stand until the module runs
ModuleFetches the weather feed once, at idle. Keeps the state current: it wakes at the next boundary and when the tab becomes visible again. Wires the opt-out control.No weather; state is right at load and does not update

The head script must come after #ambient-config. It does not throw, wait on the network or touch layout. With JavaScript off, the attributes your build wrote are used as they are.

Attributes on <html>

AttributeValuesWritten byNotes
data-ambientWord list of signals: season daypart weather occasionAuthorThe opt-in switch. Absent, or off, means the pack does nothing.
data-seasonspring, summer, autumn, winter, or a custom labelPackMeteorological seasons by month.
data-daypartdawn, day, dusk, nightPackDawn and dusk are the 45 minutes either side of sunrise and sunset.
data-weatherclear, cloudy, fog, rain, snow, storm, windPackFrom the weather feed, a pin or a preview. Absent when there is no fresh feed.
data-weather-intensitylight, heavyPackAbsent means moderate.
data-occasionWord list of occasion ids, highest priority first, at most twoPackMatch with ~=, like data-theme.
data-occasion-dayBooleanPackPresent on the day itself, not during the lead-up.
data-occasion-iconAn icon namePackThe icon the active occasion's calendar entry names.
data-ambient-leveltint, motif (default)Authortint turns motif icons off and leaves the colour tokens.
data-ambient-debugBooleanAuthorAllows the ?ambient= preview outside localhost.

The pack writes a state attribute only for a signal you enabled and a value it knows. State attributes are a public contract: select on them freely.

Two attributes go on other elements. data-ambient-surface gives an element, usually <body>, the washed background. data-ambient="off" on any element resets the tokens for that subtree.

Configuration

All keys are optional. Without tz the visitor's own clock is used.

KeyMeaning
tzIANA time zone of the author's place, for example America/Los_Angeles.
hemispherenorth (default) or south, which shifts the season by two.
seasonsA month (1–12) to label map for places without four seasons. Custom labels get no built-in tint; style them yourself.
occasionsDated windows written by a build with expandCalendar(). The head script reads these.
calendarsNames of built-in sets to use: markers, geek, civic-us. Default ["markers"].
calendarYour own entries, added to the built-in sets. An entry with the id of a built-in one replaces it.
feedURL of the weather feed, for example /ambient.json. Without it the pack makes no request.
pinFixes signals for a page: { "season": "winter", "weather": "snow" }.

Calendar rules

Rule formExampleMeaning
Fixed date"10-31"Month and day, every year
Range"12-24..01-01"Inclusive; may wrap the year
Nth weekday"11:4:thu", "5:-1:mon"Fourth Thursday of November; last Monday of May
Day of year"doy:256"The 256th day
Explicit dates{ "dates": ["2026-02-17"] }Movable observances, written by your build

An occasion is active from lead days before its date to trail days after. Active occasions are sorted by priority, then by how near their own day is, and the first two are kept. An entry may name an icon from the icon list.

Built-in calendars

SetOccasion idsDefault
markersnew-year, march-equinox, june-solstice, september-equinox, december-solstice, leap-dayOn
geekweb-birthday, pi-day, css-naked-day, may-the-4th, towel-day, programmers-day, ada-lovelace-dayOff
civic-usUS federal holidays by their statutory names (mlk-day, presidents-day, memorial-day, juneteenth, independence-day, labor-day, columbus-day, veterans-day, thanksgiving, christmas-day, new-year), plus valentines-day and halloweenOff

Solstice and equinox dates are the usual ones, not astronomical calculations. Religious and cultural observances are not built in: add them as your own entries, with explicit dates for the movable ones.

The head script reads only dated windows (occasions), which a build writes. On a page that gives no occasions, the module fetches packs/ambient.resolve.js once and applies occasions after load.

Weather feed

Weather comes from one URL that you serve, named by feed in the config. The pack knows nothing about weather providers and the visitor's browser contacts only your site. Add weather to data-ambient to use it.

FieldMeaning
vSchema version, 1. Anything else is ignored.
asOfISO time of the observation. Required.
ttlSeconds the observation is good for. Default 1800.
weather, intensityValues of data-weather and data-weather-intensity. An unknown value is dropped.
tempCCarried in Ambient.state.tempC for your own use, such as a status line. It has no attribute and no styling.
sunrise, sunsetHH:MM in the place. They replace the fixed sun times for dawn and dusk.
attributionFor you to show; the pack does not read it.

Producing the feed

Anything that can write that JSON will do: a Worker, a serverless function or a scheduled build. The resolver file has two helpers for Open-Meteo, which needs no key. Your coordinates stay in the producer and never reach a page.

Open-Meteo's data is CC BY 4.0, so show the attribution somewhere on your site, and its free tier is for non-commercial use: check the terms for your case. For another provider, map its conditions to the vocabulary above; mapWeatherCode(code, windKmh) does that for WMO codes.

Tokens

TokenSet byUse
--color-ambientDerivedDecorative marks, ornaments, chart accents
--color-ambient-surfaceDerivedPage background, through data-ambient-surface
--ambient-hueSeasonAbsolute oklch hue of the season colour
--ambient-chromaWeatherChroma multiplier, 0.6 to 1.1
--ambient-warmthTime of dayShare of a warm hue mixed in at dawn and dusk
--ambient-washWeatherShare of the accent in the surface, at most 4%
--ambient-blendThemeShare of the theme's primary kept in a season colour (default 25%)

A season has a hue of its own: winter is a cool blue-grey, spring a soft green, summer a clear blue, autumn a warm brown. The season colour takes its lightness from the theme's primary and keeps a share of it, so it still belongs to the theme. Without a season, --color-ambient is the theme's primary, adjusted by weather and time of day.

At night the surface is left alone on a light page and washed at 4% on a dark one. The time of day never changes the visitor's light or dark mode.

The treatments reset under forced colours and in print. Token changes transition over 600 ms, and not at all under reduced motion.

Motifs

A motif is a small static icon that appears only where you place a slot. The current icon is --ambient-icon, chosen in this order: the occasion's icon, then the weather, then the season. It is drawn as a mask filled with --color-ambient.

SlotMarkupResult
Inline mark<span data-ambient-slot="mark" aria-hidden="true"></span>The current icon at 1em. Empty, and no space taken, when there is no icon.
Rule ornament<hr data-ornament data-ambient-slot>The ornament becomes the current icon. With no state the rule keeps its normal ornament.
Surface<body data-ambient-surface>The background uses --color-ambient-surface.
Your own[data-ambient-slot="name"]Unstyled hook for site CSS.

Icon names: snowflake, sprout, sun, leaf, moon, cloud, drops, fog, wind, storm, sparkles, cake, heart, ghost, star, flag, pi, gift. Each is also a token, --ambient-icon-name, so site CSS can use one directly. They come from the Lucide set.

Seasons give a snowflake, sprout, sun or leaf. Weather gives a sun (a moon on a clear night), cloud, fog, drops, storm, snowflake or wind. Motifs are hidden in forced colours and in print, and with data-ambient-level="tint". Add aria-hidden="true" to a mark: it carries no information.

JavaScript API

The pure resolvers are in packs/ambient.resolve.js and have no DOM access: resolveSeason(date, config), resolveDaypart(date, config, sun), resolveOccasions(date, calendar, config), calendarFor(config), expandCalendar(calendar, years), mapWeatherCode(code, windKmh), and for the feed readFeed(feed), feedFresh(feed, nowMs), openMeteoUrl(place) and feedFromOpenMeteo(data, options).

Visitor control and preview

The module wires any [data-ambient-toggle] button or checkbox and keeps aria-pressed or checked in step. <settings-panel> shows the same switch in its Environment section on a page that uses the pack. The choice is one localStorage key, vb-ambient.

To preview a state, add ?ambient=winter,night,snow,halloween to the URL. It is honoured only on localhost or when <html> carries data-ambient-debug.

Privacy

The pack sets no cookie and never asks for location. It makes no network request unless you name a weather feed, and then one request to that URL per session and ttl; by default that is your own site, so the browser contacts no third party. It stores two things: the visitor's opt-out in localStorage and the last feed in sessionStorage. The season and time are the author's, by the configured time zone, which is why a visitor elsewhere sees the author's evening and not a guess about their own.

When to Use

Load the ambient pack on a personal or editorial site where a returning reader should notice the site feels like today. Leave it out where colour carries meaning that must not drift, such as a data dashboard with a fixed palette.

↑