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

border-wc

<border-wc> draws one of 34 decorative border effects around its content, using SVG, canvas or layered CSS that a plain border cannot produce. It names no Vanilla Breeze tokens itself: it uses the text color and corner radius it inherits, and you pass theme tokens in through its custom properties.

At a glance

Package@profpowell/border-wc, version 0.3.1
Elements<border-wc>
Renders inLight DOM. The effect is added as an extra child of the element.
Sourcegithub.com/ProfPowell/border-wc
Documentationprofpowell.github.io/border-wc
LicenceMIT
In Vanilla BreezeNot bundled. Load it yourself.

Install

From a CDN. The package has no stylesheet to load. Each effect is a separate file that the element fetches the first time it is used.

To apply effects with a data-border-effect attribute and no wrapper element, load the binder instead.

Or with npm:

Both entry points do nothing when imported on a server, so a framework that renders on the server can bundle them.

Demo

Six effects on a Vanilla Breeze page. One CSS rule gives every border the theme's primary color and medium corner radius.

Usage

Wrap content in the element and name an effect. Add animate to make the effect move.

Some effects have variants, chosen with mode.

With the binder loaded, put the effect on an existing element. Set its options with custom properties.

Reference

Attributes

AttributeValuesDefaultPurpose
effectAn effect namenoneWhich border to draw. An unknown name draws nothing.
colorAny CSS colorcurrentColorColor of the strokes or particles. A few effects, such as neon and ticket, use a color of their own when this is left at the default.
thicknessNumber of pixels2Stroke width.
speedNumber of milliseconds1000Length of the animation.
radiusNumber of pixelsThe element's own computed border-radiusCorner radius of the drawn border.
animateBooleanoffPlays the effect's entrance or looping animation.
modeDepends on the effectDepends on the effectA variant of the effect. neon accepts synthwave; barber accepts warning, candy and racing; marquee accepts chase, sparkle and random.
motionauto, reduce, forceautoauto follows the reader's reduced-motion setting. reduce always draws a still border. force always animates.
triggertime, scrolltimeFor draw only: reveal the border on a timer, or as the element scrolls into view.
eagerBooleanoffApply the effect as soon as the element is added. By default the element waits until it is within 200 pixels of the viewport, and removes the effect again when it leaves.

Effects

GroupEffects
Modern CSSaurora, barber, chroma, wings, ants
Energylightning, neon, glitch, hud
Retro and craftascii, stitching, typewriter
Patternbarbed-wire, rope, scallop, scoop, zigzag, wave, deco, memphis, opart
Erasbrutalist, aqua
Trippypsychedelic, plasma, gooey
Marquee lightssparks, marquee
Decoration attached to the boxwashi, filmstrip, ticket, bunting
Originalssquiggle, draw

Attribute binder

The binder applies the same 34 effects to any element that carries data-border-effect, and watches the page for elements that are added, changed or removed. The attribute may hold several space-separated values; the binder uses the first one it knows and ignores the rest. Options come from the --border-wc-* custom properties.

The module also exports bindBorderEffects(root), which scans a subtree on demand, and stopWatching(), which stops the binder from reacting to later page changes.

Methods and properties

MemberPurpose
effectGets or sets the effect attribute.
refresh()Reads the attributes and custom properties again and redraws the effect. Call it after you change a custom property.

Events

Events are dispatched on the element and do not bubble.

EventDetailWhen
border-wc:effect-applied{ effect }An effect has been drawn.
border-wc:error{ error }An effect threw an error while being drawn.

CSS custom properties

PropertyPurpose
--border-wc-colorSame as color.
--border-wc-thicknessSame as thickness. A number, with or without px.
--border-wc-speedSame as speed. A number of milliseconds.
--border-wc-radiusSame as radius.
--washi-blendBlend mode of the washi tape strips. Default multiply. Use normal on dark surfaces, where multiply nearly erases the tape.

The border-wc API reference has the full detail, and the playground shows every effect running.

With Vanilla Breeze

border-wc does not name any Vanilla Breeze token. It picks up the theme through three things it reads from the page.

What it readsWhere Vanilla Breeze sets itDrives
The inherited text color (currentColor)--color-text, or whatever color applies to the elementDefault stroke color.
The element's computed border-radiusAny rule you write, for example with --radius-mDefault corner radius of the drawn border.
data-motion-reduced on <html>The Vanilla Breeze motion settingStill borders in place of animated ones.

For color, thickness, speed and radius the element uses the first of these that has a value: the --border-wc-* property, then the attribute, then the built-in default. To follow the theme, point the properties at Vanilla Breeze tokens, for all borders or for one.

The element reads these values when it draws the effect. If a theme switch changes them, call refresh() to redraw.

border-wc or data-border-effect

Vanilla Breeze has its own CSS-only data-border-effect attribute with six values: spin, pulse, march, hue-cycle, breathe and trace. Use those for light, always-on motion that needs no script. Use border-wc when you need an effect that CSS alone cannot draw.

The two share the attribute without conflict. The border-wc binder ignores the six Vanilla Breeze values, and Vanilla Breeze's CSS has no rules for the 34 border-wc names.

Accessibility

↑