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

screen-saver

<screen-saver> covers the page with an animated effect after the visitor has been idle for a set time, and goes away when they move the mouse or press a key. Five of its 17 effects are drawn in the colors and typefaces of the matching Vanilla Breeze theme, and others can use theme colors on request.

At a glance

Package@profpowell/screen-saver 1.1.1
Elements<screen-saver>
Renders inShadow DOM
DependenciesNone. One effect, tunnel, downloads the Three.js 3D library from unpkg the first time it runs.
Sourcegithub.com/ProfPowell/screen-saver
Documentationprofpowell.github.io/screen-saver
LicenceMIT
In Vanilla BreezeNot bundled. Load it yourself.

Install

Load the component from a CDN with one script tag.

Or install it from npm and import it in your own script.

Demo

Each demo is a Vanilla Breeze page with one theme applied and the matching effect. The screen saver starts as soon as the demo loads. Move the pointer over a demo to dismiss it, then hold still for two seconds to bring it back.

Bauhaus

Memphis

Art deco

Brutalist

Kawaii

Usage

Put one <screen-saver> anywhere in the page. It takes no space until it starts, then covers the whole viewport. The text inside the element is the text the effect shows.

Pair a themed effect with its Vanilla Breeze theme. The effect takes its colors and typeface from the theme.

Add palette="theme" to make an effect that normally cycles through rainbow colors use the theme's colors.

Start and stop it from script, and listen for its events.

Reference

Attributes

AttributeValuesDefaultPurpose
timeoutNumber of seconds180How long the visitor must be idle before the screen saver starts.
effectAn effect name from the table belowbounce3dThe effect to show. An unknown name shows bounce3d.
speedNumber1Multiplies the animation speed. 2 is twice as fast.
backgroundA CSS color, or an image URLNoneThe backdrop behind the effect. A value that starts with http, / or data: is used as an image.
paletterainbow, themerainbowWith theme, effects that pick colors in script use Vanilla Breeze color tokens.

The 17 effects, in groups:

GroupEffectsNotes
Textbounce3d, matrix, ascii-glitchBuilt around the text inside the element. With no text they show the site's host name.
Classicstarfield, plasma, fireworks, bubbles, pipes, mystifyDrawn on a canvas. No text needed.
Scenestunnel, slideshow, snowNo text needed. slideshow reads data-images (a comma-separated list of URLs), data-duration and data-transition (milliseconds, default 5000 and 1000). snow reads data-background (an image URL), data-snowflakes (default 200) and data-wind.
Themedbauhaus, memphis, art-deco, brutalist, kawaiiEach is designed for the Vanilla Breeze theme of the same name. See With Vanilla Breeze.

Methods and properties

MemberPurpose
activate(), deactivate()Start and stop the screen saver from script.
isActiveRead-only. Whether the screen saver is showing.
timeout, effect, speed, background, paletteMirror the attributes of the same name. Changing effect or palette while the screen saver is showing switches at once.
ScreenSaver.registerEffect(name, effectClass)Static. Adds your own effect, a class that extends the exported Effect class, under a name you can use in the effect attribute.

Events

Both events bubble.

EventDetailFires when
screensaver-activateNoneThe screen saver starts.
screensaver-deactivate{ duration }, in millisecondsThe screen saver is dismissed.

CSS custom properties

PropertyDefaultPurpose
--screen-saver-bgrgba(0, 0, 0, 0.95)The backdrop that covers the page. The five themed effects paint their own backdrop over it.
--screen-saver-text-colorDepends on the effectColor of the text.
--screen-saver-font-familyDepends on the effectTypeface of the text.
--screen-saver-font-size4remSize of the text.
--screen-saver-z-index999999Stacking order of the overlay.

See the screen-saver documentation for the full detail.

With Vanilla Breeze

The effects read Vanilla Breeze tokens at the moment the screen saver starts. Custom properties inherit into the shadow DOM, so no setup is needed. How much of the theme an effect picks up depends on the effect.

EffectsFollows the theme?
bauhaus, memphis, art-deco, brutalist, kawaiiYes, always. Shapes, backdrop and text all come from tokens. The palette attribute makes no difference.
matrix, starfield, ascii-glitchYes, in part. The falling characters, the stars and the text use tokens. The backdrop stays dark.
bounce3d, fireworks, bubbles, pipes, mystify, plasma, tunnelOnly with palette="theme". Without it they use built-in rainbow colors.
slideshow, snowNo. They show images or their own scene. Only the optional text uses tokens.

The tokens and what they drive:

TokenDrives
--color-primary, --color-accent, --color-success, --color-warning, --color-info, --color-errorThe color set for memphis, and for bounce3d, fireworks, bubbles, pipes and mystify with palette="theme". bauhaus and art-deco each use three of them. plasma and tunnel use the first one or two.
--color-primary-subtle, --color-accent-subtle, --color-success-subtleThe pastel shapes in kawaii
--color-backgroundThe backdrop of the five themed effects
--color-textText in most effects, the blocks in brutalist, the stars in starfield
--color-successThe falling characters and the text in matrix
--font-display, --font-sans, --font-monoThe typeface of the text. Most effects use the display face. brutalist and ascii-glitch use the monospace face.

The fallback order for text color and typeface is: the --screen-saver-* property if you set it, then the Vanilla Breeze token, then a built-in default. --screen-saver-bg, --screen-saver-font-size and --screen-saver-z-index have no Vanilla Breeze token behind them. Without Vanilla Breeze the built-in defaults apply.

Recommended theme pairings

EffectVanilla Breeze themeNeeds text?
bauhausbauhausYes
memphismemphisNo
art-decoart-decoYes
brutalistbrutalistYes
kawaiikawaiiNo

An effect that needs text shows the site's host name when the element is empty. The other 12 effects work with any theme.

Accessibility

↑