Skip to content

module

actions

Declarative page actions, handled by one delegated click listener:

  • data-copy="text" — copy the text to the clipboard (or, with data-copy-target="<selector>", the target's text). The button gets data-copied for a moment as feedback.
  • data-motion-replay="<selector>" — replay the declarative animations in the matching elements (crate::motion::replay).
  • data-theme-toggle — switch between the light and dark schemes (toggle_scheme).

Functions

copy_text

pub fn copy_text(text: &str)

Write text to the clipboard (best effort).

install

pub fn install()

Install the listener (once).

native_scheme

pub fn native_scheme() -> String

The page's own scheme (data-native-scheme on <html>).

scheme

pub fn scheme() -> String

The scheme being shown: "light" or "dark".

set_scheme

pub fn set_scheme(scheme: &str)

Show scheme ("light" or "dark"), flipping the palette when it isn't the page's own, and remember the choice.

sync_scheme

pub fn sync_scheme()

Reflect the scheme on <html> (data-scheme, color-scheme) and on every toggle (aria-pressed = dark, and its label).

toggle_scheme

pub fn toggle_scheme()

Switch between light and dark.

Constants

SCHEME_KEY

pub const SCHEME_KEY: &str = "weft-scheme";

The localStorage key holding the chosen scheme.