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

marquee-wc

<marquee-wc> scrolls its content at a constant speed, as a replacement for the retired <marquee> tag that pauses when asked and stops for reduced motion. Its modes (named looks such as a stock ticker or a news bar) take their colors, fonts and spacing from Vanilla Breeze tokens.

At a glance

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

Install

From a CDN. The script is all you need: on first load it adds the component's styles to the page.

The package also ships the same styles as a file. Linking it is optional. It is useful when you want the styles in place before the script runs.

Or with npm:

Demo

Six modes on a Vanilla Breeze page. None of them sets a color or a font: surfaces, text and spacing come from the theme tokens.

Usage

A ticker that pauses while the pointer is over it or while keyboard focus is inside it.

A news bar. The label on the left comes from the --marquee-label custom property.

A vertical credit roll. Block content is allowed inside.

Reference

Attributes

AttributeValuesDefaultPurpose
directionleft, right, up, downleftWhich way the content moves.
speedNumber50Pixels per second. The speed stays the same however long the content is.
behaviorloop, slide, alternatelooploop repeats without end, slide moves in once and stops, alternate moves back and forth.
gapCSS lengthSet by the modeSpace between repeats. Overrides --marquee-gap.
pause-on-hoverBooleanoffPauses on hover and while keyboard focus is inside.
play-staterunning, pausedrunningStarts or stops the motion.
autofillBoolean; false to opt outonCopies short content until it fills the visible width, so the loop has no empty stretch.
fadeBooleanoffFades the content out at both edges.
reduced-motionrespect, ignorerespectignore keeps the motion 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-motion modes animate each letter or each word.

Modes

GroupModesWhat they do
Surface themesticker, breaking-news, code-block, screen-saver, credits, dot-matrixStyle the whole strip. screen-saver suits behavior="alternate" and credits suits direction="up".
Letter motionbounce, wave, march, pulse, ransom, pop, spin, rainbow, flip, glitch, leet, blink, chase, invert, decodeSplit the text into letters, or words with unit="word", and animate each one with a small delay while the strip scrolls.

Methods and properties

MemberPurpose
start()Sets play-state="running".
stop()Sets play-state="paused".
toggle()Switches between running and paused.
refresh()Measures the content again. Call it after you change the content with script.
direction, speed, behavior, playState, modeRead-only. The current value of the matching attribute.
axisRead-only. x or y, worked out from direction.

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

Events

All three events bubble and carry no detail.

EventWhen
marquee-startThe marquee starts running.
marquee-pauseThe marquee is paused.
marquee-cycleOne loop completes.

CSS custom properties

PropertyPurpose
--marquee-gapSpace between repeats.
--marquee-fade-sizeWidth of the edge fade when fade is set.
--marquee-bgBackground of the surface themes.
--marquee-fgText color of the surface themes.
--marquee-labelLabel text of breaking-news, as a quoted string. Default 'BREAKING'.

The element sets --marquee-duration and --marquee-cycle-distance itself. Do not set them.

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

With Vanilla Breeze

The component's styles name Vanilla Breeze tokens directly, so a themed page needs no setup.

TokenDrives
--color-surfaceBackground of ticker.
--color-surface-sunkenBackground of code-block.
--color-backgroundBackground of screen-saver, credits and dot-matrix; letter color of invert.
--color-textText of ticker, code-block and credits.
--color-accentText of screen-saver, the lights of dot-matrix, the chips of ransom, and the highlight in pop and chase.
--color-errorBackground of breaking-news.
--color-successText of leet and decode.
--color-text-on-error-auto, --color-text-on-accent-autoText on the breaking-news bar and on ransom chips. These tokens pick black or white to suit the fill.
--font-mono, --font-sans, --font-serifTypeface of each mode: mono for ticker, code-block, dot-matrix, leet and decode; sans for breaking-news, screen-saver and ransom; serif for credits.
--font-size-sText size of ticker and code-block.
--size-xs to --size-3xlGaps, padding and fade widths.
--radius-mCorner radius of code-block.

For each value the styles use the first of these that is set: the --marquee-* property, then the Vanilla Breeze token, then a built-in default. Set the property on one element to change that element only.

All the styles sit in the cascade layer web-components, which is one of Vanilla Breeze's own layers. Theme packs can therefore restyle a marquee, and your unlayered CSS overrides it without !important. Because spacing uses the --size-* scale, marquees grow and shrink with the rest of the page.

marquee-wc or data-effect="marquee"

Vanilla Breeze has a CSS-only scroll, data-effect="marquee". Use it for a plain strip of content with no script. Use marquee-wc when you need the same speed whatever the content length, vertical or back-and-forth motion, automatic filling of short content, pausing while off screen, events, or any of the modes.

Accessibility

↑