modals

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package modals demonstrates the three weights of feedback a screen can give, on one list of operations, so the difference between them is visible side by side rather than across two demos:

app.Info       passive. A successful op puts one line in the statusbar
               and the next keypress wipes it (rule 20).
pkg/confirm    a gate. A destructive op asks first, and the cancel side
               starts highlighted (rule 22).
pkg/alert      an acknowledgement. A failure the user must see and
               dismiss before continuing (rule 23).

Enter runs the highlighted op. "Force push main" goes through both modals in sequence — confirm the destructive thing, then acknowledge that it was rejected — which is the shape real tooling ends up in.

Both modals resolve by message (confirm.ConfirmedMsg / CancelledMsg, alert.DismissedMsg) posted as tea.Cmds; this screen owns show/hide state, gates IsCapturingKeys while either is up, and overlays them in a ZStack. Note the two hosting shapes: the confirm modal is a fixed size inside layout.Center, while the autosizing alert centers itself and needs no Center wrapper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t theme.Theme) screen.Screen

New returns the modals demo's root screen.

Types

type Screen

type Screen struct {
	// contains filtered or unexported fields
}

func (*Screen) Help

func (s *Screen) Help() []key.Binding

func (*Screen) HelpSections

func (s *Screen) HelpSections() []help.Section

HelpSections reflects the active context: while a modal is up its keys are the only ones that do anything, so they are the only ones listed.

func (*Screen) Init

func (s *Screen) Init() tea.Cmd

func (*Screen) IsCapturingKeys

func (s *Screen) IsCapturingKeys() bool

func (*Screen) Layout

func (s *Screen) Layout() layout.Node

func (*Screen) OnEnter

func (s *Screen) OnEnter(any) tea.Cmd

func (*Screen) SetTheme

func (s *Screen) SetTheme(t theme.Theme)

func (*Screen) Title

func (s *Screen) Title() string

func (*Screen) Update

func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)

Jump to

Keyboard shortcuts

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