stnd.build

@stnd/client

Circle 3 — Specialized Satellite & Plumbing · Active · Utility

Role: Zero-dependency client-side behavior modules (code copy buttons, Medium-style image zoom, keyboard navigation, scroll wrappers).

When to use: Loaded automatically by @stnd/core to progressively enhance static prose without shipping a JS framework.

Quick Start (TL;DR)

// Automatically mounted via @stnd/core client hooks

Client-side utilities and enhancements for Standard applications.

ELI5

The stuff that only makes sense once you’re in a browser: keyboard shortcuts (Cmd+K), swipe gestures, “copy to clipboard”, detecting a Kindle/e-ink screen. Each piece is its own file you import directly by path — there’s no single @stnd/client bundle to pull in, just @stnd/client/keyboard, @stnd/client/gestures, etc.

Use it:

import { initKeyboard, registerShortcut } from "@stnd/client/keyboard";
initKeyboard({});
registerShortcut({ key: "k", meta: true, action: () => openLauncher(), id: "toggle-launcher" });

Overview

@stnd/client is a collection of browser-specific modules designed to improve interactivity, gestures, keyboard shortcuts, e-ink rendering, and application state. These modules are lightweight and framework-agnostic, though they integrate perfectly with Astro and Svelte views.


Usage

Key modules

Keyboard Shortcuts (/keyboard)

Unified keyboard shortcut management. Handles keybindings, prevents collisions, and offers automatic Type-to-Search.

import { initKeyboard, registerShortcut } from "@stnd/client/keyboard";

// 1. Initialize
initKeyboard({
  onTypeSearch: (char) => {
    console.log("User typed alphanumeric character outside inputs:", char);
  }
});

// 2. Register a shortcut
const cleanup = registerShortcut({
  key: "k",
  meta: true, // Cmd+K on Mac, Ctrl+K on Windows
  action: (e) => {
    e.preventDefault();
    console.log("Toggle command palette!");
  },
  id: "toggle-launcher" // Raises a console error on duplicate registration
});

// 3. Remove when views unmount
cleanup();

Touch Gestures (/gestures)

Enables fluid touch interactions on mobile browsers.

import { initGestures } from "@stnd/client/gestures";

const cleanup = initGestures({
  onSwipeBack: () => {
    console.log("User swiped from left to right; navigating back.");
    history.back();
  },
  onDoubleClick: (e) => {
    console.log("Double clicked/tapped screen coordinates:", e.clientX, e.clientY);
  }
});

Clipboard Copy (/copy-to-clipboard)

Safe browser copying handling fallback options for older mobile platforms.

import { copyToClipboard } from "@stnd/client/copy-to-clipboard";

copyToClipboard("Link copied to garden!")
  .then(() => console.log("Copied!"))
  .catch((err) => console.error("Clipboard write blocked", err));

E-Ink Display Adaptation (/eink)

Detects slow-refresh or monochrome E-Ink screens (Kindle, Kobo, BOOX, or slow media updates) and toggles specific high-contrast CSS rules.

import { initEInk } from "@stnd/client/eink";

// Run on page load
initEInk();

State — moved out of this package

State management no longer lives in @stnd/client. Toasts are a Gold Standard module, and shared reactive state goes through the runtime store:

// Toast notifications (Gold Standard module, loaded automatically)
import { toast } from "@stnd/modules/toast/toast.js";
toast("Note published successfully!", "success");

// Shared state — provide/inject via @stnd/store
import { provide, inject } from "@stnd/store";