timer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package timer provides countdown and elapsed time components with GCP styling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode int

Mode determines the timer behavior

const (
	// Countdown counts down from a duration to zero
	Countdown Mode = iota
	// Stopwatch counts up from zero (uses elapsed time tracking)
	Stopwatch
)

type Model

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

Model wraps bubbles/timer with GCP styling and additional features

func New

func New(duration time.Duration, mode Mode) Model

New creates a new timer model with the specified duration

func NewCountdown

func NewCountdown(duration time.Duration) Model

NewCountdown creates a countdown timer

func NewStopwatch

func NewStopwatch() Model

NewStopwatch creates a stopwatch (counts up)

func (Model) Cmd

func (m Model) Cmd() tea.Cmd

Cmd returns the tick command for the timer

func (Model) Elapsed

func (m Model) Elapsed() time.Duration

Elapsed returns the elapsed duration

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the timer (does not start it)

func (Model) Remaining

func (m Model) Remaining() time.Duration

Remaining returns the remaining duration (for countdown mode)

func (*Model) Reset

func (m *Model) Reset()

Reset resets the timer to initial state

func (Model) Running

func (m Model) Running() bool

Running returns true if the timer is active

func (*Model) Start

func (m *Model) Start() tea.Cmd

Start begins the timer

func (*Model) Stop

func (m *Model) Stop()

Stop pauses the timer

func (Model) TimedOut

func (m Model) TimedOut() bool

TimedOut returns true if the countdown reached zero

func (*Model) Toggle

func (m *Model) Toggle() tea.Cmd

Toggle starts or stops the timer

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update handles timer messages

func (Model) View

func (m Model) View() string

View renders the timer

func (Model) WithLabel

func (m Model) WithLabel(label string) Model

WithLabel sets a label to display before the timer

type TimerResetMsg

type TimerResetMsg struct{}

TimerResetMsg is sent when the timer should reset

type TimerStartMsg

type TimerStartMsg struct{}

TimerStartMsg is sent when the timer should start

type TimerStopMsg

type TimerStopMsg struct{}

TimerStopMsg is sent when the timer should stop

Jump to

Keyboard shortcuts

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