sidebar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sidebar renders the markets pane: one row per watched symbol (symbol + 24h %change), windowed by a scroll offset. The active row is reverse- highlighted; every other row is tinted by its 24h direction so the list reads as a heat map. While quick search targets this pane the list is FILTERED to substring matches on the symbol, windowed by a separate search scroll, with the search candidate highlighted instead. It is a pure view component — Model.View is a function of its explicit Key and Data, owns no shared state, and caches its render via uikit.Memo keyed on Key. The parent supplies the data and a Key whose ticker revision stands in for "did the tickers change", so an unrelated frame reuses the cached render.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Rows []Row
}

Data is what the component renders on a cache miss: one Row per watched symbol, in list order. A ticker change bumps TickerRev in the Key, so the Key still decides the hit.

type Key

type Key struct {
	TickerRev    uint64
	Active       string
	Scroll       int
	Searching    bool
	Query        string
	SearchCursor int
	SearchScroll int
	Focused      bool
	W, H         int
	Style        uikit.StyleID
}

Key is the comparable cache key: equal Keys render identically. TickerRev is the store's ticker section revision (any ticker change ⇒ rev change ⇒ re-render). Active is the selected symbol (reverse-highlighted in the normal list). Scroll is the wheel offset of the normal list; Searching/Query/ SearchCursor/SearchScroll drive the filtered list while quick search targets this pane. Focused selects the border color and footer label color. W and H are the OUTER panel size; Style is the palette identity.

type Model

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

Model is the markets pane component. The zero value is ready to use.

func New

func New() *Model

New returns a markets pane component.

func (*Model) View

func (m *Model) View(k Key, d Data) string

View renders the full bordered pane (with the position indicator and live search query spliced into the bottom border) for k/d, reusing the cached render when k is unchanged.

type Row

type Row struct {
	Symbol             string
	PriceChangePercent string
	PriceChange        string
	Ready              bool
}

Row is one watched symbol's render input: the symbol, its 24h change fields, and whether a current ticker has arrived. PriceChangePercent is shown (with a "%" suffix); PriceChange supplies the sign for the heat-map tint. Ready false means no current ticker yet — the change is replaced by a loading marker and the row dims rather than showing a stale tint.

Jump to

Keyboard shortcuts

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