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

blink-wc

<blink-wc> makes its content blink, as a replacement for the retired <blink> tag that can be paused and stops for reduced motion. Its modes (named looks such as a neon sign or a terminal cursor) take their colors, fonts and corner radius from Vanilla Breeze tokens.

At a glance

Package@profpowell/blink-wc, version 1.5.2
Elements<blink-wc>
Renders inLight DOM
Sourcegithub.com/ProfPowell/blink-wc
Documentationprofpowell.github.io/blink-wc
LicenceMIT
In Vanilla BreezeNot bundled. Load it yourself.

Install

From a CDN. Load both files: the component renders in the light DOM and the script does not add the styles for you.

Or with npm:

Demo

Six modes on a Vanilla Breeze page. None of them sets a color or a font: both come from the theme tokens.

Usage

With no attributes, the content switches fully on and off once a second. behavior="pulse" fades instead, and count stops it after a set number of blinks.

A mode styles the element as well as animating it.

The letter modes animate each letter in turn. Add unit="word" to animate whole words.

Reference

Attributes

AttributeValuesDefaultPurpose
rateCSS time1sLength of one blink cycle.
behaviorblink, pulse, flicker, stepsblinkblink is a hard on and off, pulse a soft fade, flicker an uneven flutter. steps turns on the step engine described below.
min-opacity0 to 1Set by the modeOpacity of the "off" phase.
countNumberinfiniteBlink this many times, then stop.
stepsNumber, 2 or more2Number of steps in one cycle of the step engine.
step-durationsList of weights, such as 3 1 1EqualHow long each step holds, as shares of the cycle.
step-byelement, letter, wordelementWhether the whole text steps together or each letter or word steps in turn.
pause-on-hoverBooleanoffPauses on hover and while keyboard focus is inside.
play-staterunning, pausedrunningStarts or stops the blinking.
reduced-motionrespect, ignorerespectignore keeps the blinking running even when the reader has asked for reduced motion.
modeA mode namenoneA visual or motion preset. See the list below.
unitletter, wordletterWhether the letter modes animate each letter or each word.

Modes

GroupModesWhat they do
Surface themesneon, crt, terminal, warning, alert, police, vegasStyle the whole element: a glowing sign, a green screen, a block cursor after steady text, an amber or red panel, a red and blue light bar, a gold sign.
Letter motionwave, twinkle, sparkle, rainbow, chase, glitch, cascade, typewriter, zoom, flip3d, swing, shake, heartbeatSplit the text into letters, or words with unit="word", and animate each one with a small delay.
Script-drivenmorse, decodemorse blinks the text out in Morse code with a dot and dash caption. decode runs through random characters, then settles on the real text.
Step modesextrude, collapse, outline, morph, depth, revolveUse the step engine, so each step of the cycle has its own look.

The step engine

A step is one stage of the blink cycle. With behavior="steps", or any step mode, the element moves through its steps during one rate cycle and sets data-step="0", data-step="1" and so on in turn. You style each step with CSS. A plain blink is the two-step case.

Methods and properties

MemberPurpose
start()Sets play-state="running".
stop()Sets play-state="paused".
toggle()Switches between running and paused.
refresh()Renders the content again. Call it after you change the content with script.
rate, behavior, steps, playState, modeRead-only. The current value of the matching attribute.

To change a setting, set the attribute. The element reacts to attribute changes.

Events

All three events bubble and carry no detail.

EventWhen
blink-startThe blinking starts running.
blink-pauseThe blinking is paused.
blink-cycleOne blink completes.

CSS custom properties

PropertyDefaultPurpose
--blink-rate1sLength of one cycle. The element writes this from the rate attribute as an inline style, so change the attribute, not the property.
--blink-min-opacity0Opacity of the "off" phase.
--blink-stagger0.08sDelay between one letter and the next in the letter modes.
--blink-step-ease0sLength of the transition between steps. 0s is a hard cut.
--blink-step-timingeaseTiming function of the transition between steps.
--blink-dot170Length of one Morse dot, in milliseconds.
--blink-bgSet by the modeBackground of the surface themes.
--blink-fgSet by the modeText color of the modes.

The blink-wc documentation shows every mode running and has the full detail.

With Vanilla Breeze

The component's stylesheet names Vanilla Breeze tokens directly, so a themed page needs no setup. Tokens resolve on each element, so light and dark mode both work.

TokenDrives
--color-accentText of neon, extrude, outline and depth; the cursor of terminal and typewriter; the lit letter in chase.
--color-primaryThe shadow block of extrude, and the fallback when no accent is set.
--color-successThe glow color of crt; text of morse and decode.
--color-warningPanel of warning.
--color-errorPanel of alert.
--color-textText of terminal.
--color-surface-sunken, --color-surfaceBackground of terminal.
--font-mono, --font-sansTypeface of each mode: mono for crt, terminal, morse and decode; sans for the other surface themes and extrude.
--radius-mCorner radius of the panels.

For each value the styles use the first of these that is set: the --blink-* property, then the Vanilla Breeze token, then a built-in default. Text on the warning and alert panels is worked out as black or white from the panel color, so it stays readable with any theme and with your own --blink-bg.

All the styles sit in the cascade layer web-components, which is one of Vanilla Breeze's own layers. Theme packs can therefore restyle the component, and your unlayered CSS overrides it without !important.

blink-wc or data-effect="blink"

Vanilla Breeze has a CSS-only blink, data-effect="blink", which stops by itself after about five seconds. Use it to draw the eye to one thing once, with no script. Use blink-wc when you need a themed look, letter-by-letter motion, the step engine, script control or events.

Accessibility

Blinking content is a real hazard for some readers, which is why browsers dropped <blink>. Keep blinking areas small and slow: below about three flashes a second, and never across the whole screen.

↑