You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte-kit-vice/src/uix/sema/durations.ts

51 lines
1.7 KiB

/**
* Sema — perceptual duration scale.
*
* Single canonical scale used by:
* - the `VisualChannel`'s family fallback table (`chans/visual.ts`)
* - the morfo `events[].hold` declarative override (`MorfoEvent.hold`)
*
* Anchored to human perception (Bloch's law + UX research bands), not to
* frame-rate. Each label answers the question "what does this duration
* communicate to the user?":
*
* subliminal 50ms below conscious perception threshold
* glimpse 120ms minimum perceptible without effort
* brief 240ms comfortable acknowledgement / micro-feedback
* noticed 600ms sustained signal / announce
* insistent 1200ms warnings / errors
* persistent 3000ms until acknowledged
*
* Per-component override lives in the morfo (`events[].hold`). Per-call
* imperative override lives in `signal.hold`. Family fallback (when no
* override) is `FAMILY_DEFAULT_HOLD` consumed by VisualChannel.
*/
export const SEMA_DURATIONS = {
subliminal: 50,
glimpse: 120,
brief: 240,
noticed: 600,
insistent: 1200,
persistent: 3000
} as const
export type SemaDurationLabel = keyof typeof SEMA_DURATIONS
/**
* What a morfo event or signal can declare for `hold`. Either a label
* from the perceptual scale, or a raw millisecond value when the
* component needs a duration the scale doesn't cover.
*/
export type SemaDurationSpec = SemaDurationLabel | number
/**
* Resolve a duration spec to its millisecond value. Returns `undefined`
* when no spec is provided so callers can chain to a fallback.
*/
export function resolveSemaDuration(spec: SemaDurationSpec | undefined): number | undefined {
if (spec === undefined) return undefined
if (typeof spec === 'number') return spec
return SEMA_DURATIONS[spec]
}

Powered by TurnKey Linux.