stories

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 7 Imported by: 0

README

stories

Package stories is an interface for registering and viewing stories. Stories are predefined configurations of cy's UI components that may also describe a sequence of user inputs that are "played" into the story after it is loaded. This is similar to Storybook.

Documentation

Index

Constants

View Source
const (
	ABit = 300 * time.Millisecond
	Some = time.Second
	More = 3 * time.Second
	ALot = 5 * time.Second
)
View Source
const TYPE_DELAY = 100 * time.Millisecond

Variables

View Source
var Stories = make(map[string]Story)

Functions

func Register

func Register(name string, init InitFunc, config Config)

func Send

func Send(s mux.Screen, msgs ...interface{})

func Type added in v0.1.10

func Type(msgs ...string) (result []any)

Simulate typing.

Types

type Config

type Config struct {
	// If zero, the story will resize
	Size geom.Size
	// If true, the viewer captures the screen immediately and uses that
	// instead of a live view.
	IsSnapshot bool
	// A list of inputs that will be executed in order when the story
	// begins.
	Input []interface{}
}

func (*Config) HasInputs added in v0.1.10

func (c *Config) HasInputs() bool

type InitFunc

type InitFunc func(context.Context) (mux.Screen, error)

type MouseClickEvent added in v1.12.0

type MouseClickEvent struct {
	Button keys.MouseButton
}

MouseClickEvent clicks at the current mouse position.

func Click added in v1.12.0

func Click() MouseClickEvent

func RightClick added in v1.12.0

func RightClick() MouseClickEvent

type MouseDragEvent added in v1.12.0

type MouseDragEvent struct {
	geom.Vec2
}

MouseDragEvent moves the cursor to (R, C) while holding the left mouse button, triggering drag/selection behavior.

func Drag added in v1.12.0

func Drag(r, c int) MouseDragEvent

type MouseMoveEvent added in v1.12.0

type MouseMoveEvent struct {
	geom.Vec2
}

MouseMoveEvent tells the story runner to smoothly interpolate the cursor from its current position to (R, C).

func MouseMove added in v1.12.0

func MouseMove(r, c int) MouseMoveEvent

type MouseScrollEvent added in v1.12.0

type MouseScrollEvent struct {
	Up bool
}

MouseScrollEvent scrolls at the current mouse position.

func Scroll added in v1.12.0

func Scroll(up bool) MouseScrollEvent

type Story

type Story struct {
	Name   string
	Init   InitFunc
	Config Config
}

type WaitEvent added in v0.1.10

type WaitEvent struct {
	Duration time.Duration
}

func Wait added in v0.1.10

func Wait(duration time.Duration) WaitEvent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL