Skip to content

Docs menu // site/fx

[ SDK ] /docs/sdk/fx

site/fx

One-shot effects. They play once and leave no state behind.

import
import fx from "site/fx"

Functions#

SignatureDescription
fn glitch(ms: i64) -> voidRGB-split jitter over the page, 50-2000 ms
fn shake(strength: i64) -> void1-10
fn flash() -> voida bright accent flash
fn sparks(slug: string) -> voida burst from a project card, "" for the hero
fn scan() -> voida scan line sweeps down the screen
fn decode() -> voidheadings decode from noise again
fn typeout(text: string) -> voidtype a line into the hero, under the intro

Examples#

Effects from an action
import site from "site"
import fx from "site/fx"

site.action(site.Action {
    name: "celebrate",
    title: "Celebrate",
    description: "Several one-shot effects at once",
    category: "Docs",
    keywords: ["party"],
    run: () => {
        fx.glitch(400)
        fx.shake(4)
        fx.flash()
        fx.sparks("")
        fx.scan()
        fx.decode()
        fx.typeout("well done")
    },
})

Limits#

  • glitch is clamped to 50-2000 ms and shake to 1-10. typeout text is cut to 120 characters.
  • Flashes share a budget with look flips (theme.invert, theme.flicker): at most 2 per second across the whole page, extras are dropped. With prefers-reduced-motion set, fx.flash does nothing.
  • A single run or callback plays at most 24 one-shot effects (effects, toasts, sounds and navigation together).
  • With prefers-reduced-motion set, every effect becomes one soft outline flash.

Declaration file#

This page is generated from the file below, served as /eitri/sdk/site/fx.eith. Types and signatures are exactly what the compiler checks scripts against. Back to all modules.

site/fx.eith
// site/fx: one-shot effects. They play once and leave no state behind.

pub fn glitch(ms: i64) -> void              // RGB-split jitter over the page, 50-2000 ms
pub fn shake(strength: i64) -> void         // 1-10
pub fn flash() -> void                      // a bright accent flash
pub fn sparks(slug: string) -> void         // a burst from a project card, "" for the hero
pub fn scan() -> void                       // a scan line sweeps down the screen
pub fn decode() -> void                     // headings decode from noise again
pub fn typeout(text: string) -> void        // type a line into the hero, under the intro