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…
<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.
Or install it from npm and import it in your own script.
npm
npm install @profpowell/screen-saver
Import
import'@profpowell/screen-saver';
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.
No 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.
Themed
bauhaus, memphis, art-deco, brutalist, kawaii
Each is designed for the Vanilla Breeze theme of the same name. See With Vanilla Breeze.
Methods and properties
Member
Purpose
activate(), deactivate()
Start and stop the screen saver from script.
isActive
Read-only. Whether the screen saver is showing.
timeout, effect, speed, background, palette
Mirror 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 effectattribute.
Events
Both events bubble.
Event
Detail
Fires when
screensaver-activate
None
The screen saver starts.
screensaver-deactivate
{ duration }, in milliseconds
The screen saver is dismissed.
CSS custom properties
Property
Default
Purpose
--screen-saver-bg
rgba(0, 0, 0, 0.95)
The backdrop that covers the page. The five themed effects paint their own backdrop over it.
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.
Effects
Follows the theme?
bauhaus, memphis, art-deco, brutalist, kawaii
Yes, always. Shapes, backdrop and text all come from tokens. The paletteattribute makes no difference.
matrix, starfield, ascii-glitch
Yes, in part. The falling characters, the stars and the text use tokens. The backdrop stays dark.
The 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.
Text in most effects, the blocks in brutalist, the stars in starfield
--color-success
The falling characters and the text in matrix
--font-display, --font-sans, --font-mono
The 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.
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
Every effect checks the visitor's reduced-motion setting (prefers-reduced-motion: reduce) when it starts. With that setting on, the screen saver still appears but shows a still picture or a plain backdrop and does not animate. slideshow stays on its first image.
Moving the mouse, pressing a mouse button, pressing any key or touching the screen dismisses the screen saver. Input in the first half second after it starts is ignored, so the movement that started it does not also dismiss it.
Mouse, keyboard, touch, scroll and wheel input all count as activity and restart the idle timer.
The overlay has the dialog role and the label "Screen saver". It is hidden from screen readers until it starts.